Fix fav page load after jump
This commit is contained in:
1 parent
a37c676d96
commit
47c5629f7d
2 files changed
+41
-21
No files matched your search
@@ -837,8 +837,20 @@ public class FavoritesScene extends BaseScene implements
|
||||
else
|
||||
pages = Integer.MAX_VALUE;
|
||||
|
||||
mHelper.prevPg = result.prevPage;
|
||||
mHelper.nextPg = result.nextPage;
|
||||
String prev = result.prevPage, next = result.nextPage;
|
||||
switch (mHelper.operation) {
|
||||
case -1:
|
||||
if (prev != null) mHelper.upperPage = prev;
|
||||
break;
|
||||
case 1:
|
||||
if (next != null) mHelper.lowerPage = next;
|
||||
break;
|
||||
default:
|
||||
mHelper.upperPage = prev;
|
||||
mHelper.lowerPage = next;
|
||||
break;
|
||||
}
|
||||
|
||||
mHelper.onGetPageData(taskId, pages, mHelper.pgCounter + 1, result.galleryInfoList);
|
||||
|
||||
if (mDrawerAdapter != null) {
|
||||
@@ -1158,9 +1170,10 @@ public class FavoritesScene extends BaseScene implements
|
||||
}
|
||||
|
||||
private class FavoritesHelper extends GalleryInfoContentHelper {
|
||||
public String upperPage = null;
|
||||
public String lowerPage = null;
|
||||
public int operation = 0;
|
||||
public int pgCounter = 0;
|
||||
public String prevPg = null;
|
||||
public String nextPg = null;
|
||||
|
||||
@Override
|
||||
protected void getPageData(final int taskId, int type, int page) {
|
||||
@@ -1208,7 +1221,7 @@ public class FavoritesScene extends BaseScene implements
|
||||
url = mUrlBuilder.build();
|
||||
}
|
||||
|
||||
mUrlBuilder.setNext(nextPg);
|
||||
mUrlBuilder.setNext(lowerPage);
|
||||
EhRequest request = new EhRequest();
|
||||
request.setMethod(EhClient.METHOD_MODIFY_FAVORITES);
|
||||
request.setCallback(new GetFavoritesListener(getContext(),
|
||||
@@ -1221,15 +1234,21 @@ public class FavoritesScene extends BaseScene implements
|
||||
final String keyword = mUrlBuilder.getKeyword();
|
||||
SimpleHandler.getInstance().post(() -> onGetFavoritesLocal(keyword, taskId));
|
||||
} else {
|
||||
String prevPage = null, nextPage = null;
|
||||
if (page != 0) {
|
||||
if (page >= mHelper.getPageForTop())
|
||||
nextPage = nextPg;
|
||||
else
|
||||
prevPage = prevPg;
|
||||
String prev = null, next = null;
|
||||
if (jumpTo != null) {
|
||||
next = Integer.toString(minGid);
|
||||
operation = 0;
|
||||
} else if (page != 0) {
|
||||
if (page >= mHelper.getPageForTop()) {
|
||||
next = lowerPage;
|
||||
operation = 1;
|
||||
} else {
|
||||
prev = upperPage;
|
||||
operation = -1;
|
||||
}
|
||||
}
|
||||
mUrlBuilder.setPrev(prevPage);
|
||||
mUrlBuilder.setNext(jumpTo == null ? nextPage : Integer.toString(minGid));
|
||||
mUrlBuilder.setPrev(prev);
|
||||
mUrlBuilder.setNext(next);
|
||||
|
||||
mUrlBuilder.setJumpTo(jumpTo);
|
||||
jumpTo = null;
|
||||
@@ -1305,23 +1324,24 @@ public class FavoritesScene extends BaseScene implements
|
||||
@Override
|
||||
protected void beforeRefresh() {
|
||||
super.beforeRefresh();
|
||||
prevPg = null;
|
||||
nextPg = null;
|
||||
upperPage = null;
|
||||
lowerPage = null;
|
||||
operation = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Parcelable saveInstanceState(Parcelable superState) {
|
||||
Bundle bundle = (Bundle) super.saveInstanceState(superState);
|
||||
bundle.putString(KEY_PREV_PAGE, prevPg);
|
||||
bundle.putString(KEY_NEXT_PAGE, nextPg);
|
||||
bundle.putString(KEY_UPPER_PAGE, upperPage);
|
||||
bundle.putString(KEY_LOWER_PAGE, lowerPage);
|
||||
return bundle;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Parcelable restoreInstanceState(Parcelable state) {
|
||||
Bundle bundle = (Bundle) state;
|
||||
prevPg = bundle.getString(KEY_PREV_PAGE);
|
||||
nextPg = bundle.getString(KEY_NEXT_PAGE);
|
||||
upperPage = bundle.getString(KEY_UPPER_PAGE);
|
||||
lowerPage = bundle.getString(KEY_LOWER_PAGE);
|
||||
return super.restoreInstanceState(state);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ abstract class GalleryInfoContentHelper : ContentHelper<GalleryInfo?>() {
|
||||
private const val KEY_DATA_MAP = "data_map"
|
||||
private const val KEY_MAX_GID = "max_gid"
|
||||
private const val KEY_MIN_GID = "min_gid"
|
||||
const val KEY_PREV_PAGE = "prev_page"
|
||||
const val KEY_NEXT_PAGE = "next_page"
|
||||
const val KEY_UPPER_PAGE = "upper_page"
|
||||
const val KEY_LOWER_PAGE = "lower_page"
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user