throwrocks / android-inventory-app Goto Github PK
View Code? Open in Web Editor NEWAndroid app to manage an inventory
Android app to manage an inventory
the app has crashed
at rocks.athrow.android_inventory_app.ItemListActivity.setupRecyclerView(ItemListActivity.java:62)
at rocks.athrow.android_inventory_app.ItemListActivity.onStart(ItemListActivity.java:51).
package rocks.athrow.android_inventory_app;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.support.design.widget.FloatingActionButton;
import android.util.Log;
import android.view.View;
import io.realm.Realm;
import io.realm.RealmConfiguration;
import io.realm.RealmResults;
public class ItemListActivity extends AppCompatActivity {
private static final String LOG_TAG = ItemListActivity.class.getSimpleName();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_item_list);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
if (toolbar != null) {
toolbar.setTitle(getTitle());
}
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
if (fab != null) {
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(getApplicationContext(), ItemDetailDataEntry.class);
startActivity(intent);
}
});
}
}
@Override
protected void onStart() {
super.onStart();
View recyclerView = findViewById(R.id.item_list);
assert recyclerView != null;
setupRecyclerView((RecyclerView) recyclerView);
}
private void setupRecyclerView(@NonNull RecyclerView recyclerView) {
recyclerView.setLayoutManager(new LinearLayoutManager(this));
RealmConfiguration realmConfig = new RealmConfiguration.Builder(this).build();
Realm.setDefaultConfiguration(realmConfig);
Realm realm = Realm.getDefaultInstance();
realm.beginTransaction();
final RealmResults<Item> items = realm.where(Item.class).findAll();
realm.commitTransaction();
int size = items.size();
Log.e(LOG_TAG, "size " + size);
if (size > 0) {
recyclerView.setAdapter(new ItemListAdapter(this, realm.where(Item.class).findAllAsync()));
recyclerView.setHasFixedSize(true);
}
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.