Skip to content

Instantly share code, notes, and snippets.

@eddieberklee
Created July 6, 2017 02:59
Show Gist options
  • Save eddieberklee/fe3e753c3a0d7818408d917c020cb8e7 to your computer and use it in GitHub Desktop.
Save eddieberklee/fe3e753c3a0d7818408d917c020cb8e7 to your computer and use it in GitHub Desktop.
private void init() {
mAllEntriesAdapter = new AllEntriesRecyclerAdapter(AllEntriesActivity.this, mEntries, mAllEntriesRecyclerView);
mAllEntriesLayoutManager = new StaggeredGridLayoutManager(mNumColumns, StaggeredGridLayoutManager.VERTICAL);
mAllEntriesRecyclerView.setLayoutManager(mAllEntriesLayoutManager);
mAllEntriesRecyclerView.setAdapter(mAllEntriesAdapter);
RealmQuery<Entry> entriesQuery = mRealm.where(Entry.class);
RealmResults<Entry> entriesResults = entriesQuery.findAll();
if (entriesResults.size() == 0) {
Util.showCustomToast(AllEntriesActivity.this, R.string.no_entries_to_show_toast);
}
List<Entry> entries = new ArrayList<>(entriesResults);
Entry.sortEntries(entries);
for (Entry e : entries) {
mEntries.add(0, e);
}
if (entries.size() > 0) {
mAllEntriesAdapter.notifyDataSetChanged();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment