diff --git a/app/src/main/java/com/justwayward/reader/ui/activity/MainActivity.java b/app/src/main/java/com/justwayward/reader/ui/activity/MainActivity.java index 3c09a605..9d2d1f43 100644 --- a/app/src/main/java/com/justwayward/reader/ui/activity/MainActivity.java +++ b/app/src/main/java/com/justwayward/reader/ui/activity/MainActivity.java @@ -121,6 +121,9 @@ public void initToolBar() { mCommonToolbar.setLogo(R.mipmap.logo); setTitle(""); } + public void pullSyncBookShelf(){ + mPresenter.syncBookShelf(); + } @Override public void initDatas() { diff --git a/app/src/main/java/com/justwayward/reader/ui/fragment/RecommendFragment.java b/app/src/main/java/com/justwayward/reader/ui/fragment/RecommendFragment.java index 29737d9c..f90be52c 100644 --- a/app/src/main/java/com/justwayward/reader/ui/fragment/RecommendFragment.java +++ b/app/src/main/java/com/justwayward/reader/ui/fragment/RecommendFragment.java @@ -360,6 +360,27 @@ public void delete() { @Override public void onRefresh() { super.onRefresh(); + StackTraceElement stack[] = (new Throwable()).getStackTrace(); + + + boolean hasRefBookShelfInCallStack = false; + boolean isMRefresh = false; + for (int i = 0; i < stack.length; i++) { + StackTraceElement ste = stack[i]; + if (ste.getMethodName().equals("pullSyncBookShelf")) { + hasRefBookShelfInCallStack = true; + } + if (ste.getMethodName().equals("onAnimationEnd") && ste.getFileName().equals("SwipeRefreshLayout.java")) { + isMRefresh = true; + } + } + + if (!hasRefBookShelfInCallStack && isMRefresh) { + ((MainActivity) activity).pullSyncBookShelf(); + return; + } + + gone(llBatchManagement); List data = CollectionsManager.getInstance().getCollectionListBySort(); mAdapter.clear();