Created
July 6, 2017 02:59
-
-
Save eddieberklee/fe3e753c3a0d7818408d917c020cb8e7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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