Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Allsimon committed Aug 22, 2016
1 parent 7f197ab commit b283f27
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -388,10 +388,12 @@ protected Void doInBackground(Void... params) {
} catch (InterruptedException ignored) {
}
Realm instance = Realm.getInstance(getRealmConfig());
RealmResults<QuoteModel> ids = instance.where(QuoteModel.class).findAllSorted("id", Sort.DESCENDING);
long offset = ids.size() == 0 ? 100 : ids.first().getId() + 1;
instance.beginTransaction();
for (int i = 0; i < 60; i++) {
QuoteModel quoteModel = instance.createObject(QuoteModel.class);
quoteModel.setId(i + 100); // That is to offset for primary key
quoteModel.setId(i + offset); // That is to offset for primary key
quoteModel.setQuote(quotes.get((int) (quoteModel.getId() % quotes.size())));
}
instance.commitTransaction();
Expand All @@ -402,7 +404,6 @@ protected Void doInBackground(Void... params) {
@Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
realmRecyclerView.disableShowLoadMore();
}
};
remoteItem.execute();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public RealmRecyclerView(Context context, AttributeSet attrs, int defStyleAttr)
super(context, attrs, defStyleAttr);
init(context, attrs);
}

public RealmRecyclerView(Context context, AttributeSet attrs, int defStyleAttr, int bufferItems) {
super(context, attrs, defStyleAttr);
if (bufferItems <= 0) bufferItems = 0;
Expand Down Expand Up @@ -333,6 +333,9 @@ public void onChanged() {

private void update() {
updateEmptyContentContainerVisibility(adapter);
if (hasLoadMoreFired) {
resetHasLoadMoreFired();
}
}
}
);
Expand All @@ -351,8 +354,8 @@ private void updateEmptyContentContainerVisibility(RecyclerView.Adapter adapter)
//
// Expose public RecyclerView methods to the RealmRecyclerView
//


public void setItemViewCacheSize(int size) {
recyclerView.setItemViewCacheSize(size);
}
Expand All @@ -364,10 +367,10 @@ public void smoothScrollToPosition(int position) {
public void scrollToPosition(int position) {
recyclerView.scrollToPosition(position);
}

//
// Expose public RecycleView

public RecyclerView getRecycleView(){
return recyclerView;
}
Expand All @@ -387,7 +390,7 @@ public void setRefreshing(boolean refreshing) {
isRefreshing = refreshing;
swipeRefreshLayout.setRefreshing(refreshing);
}

public void resetHasLoadMoreFired() {
hasLoadMoreFired = false;
}
Expand Down

0 comments on commit b283f27

Please sign in to comment.