Update list pos on navigate

pull/200/head
M66B 3 years ago
parent 2775af4837
commit ff96f08ec9

@ -337,6 +337,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
private Long prev = null; private Long prev = null;
private Long next = null; private Long next = null;
private Long closeId = null; private Long closeId = null;
private boolean closeForward;
private int autoCloseCount = 0; private int autoCloseCount = 0;
private boolean autoExpanded = true; private boolean autoExpanded = true;
@ -913,10 +914,10 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
onActionMove(EntityFolder.ARCHIVE); onActionMove(EntityFolder.ARCHIVE);
return true; return true;
} else if (itemId == R.id.action_prev) { } else if (itemId == R.id.action_prev) {
navigate(prev, true); navigate(prev, true, false);
return true; return true;
} else if (itemId == R.id.action_next) { } else if (itemId == R.id.action_next) {
navigate(next, false); navigate(next, false, true);
return true; return true;
} }
return false; return false;
@ -1296,7 +1297,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
Animation bounce = AnimationUtils.loadAnimation(getContext(), R.anim.bounce_right); Animation bounce = AnimationUtils.loadAnimation(getContext(), R.anim.bounce_right);
view.startAnimation(bounce); view.startAnimation(bounce);
} else } else
navigate(prev, true); navigate(prev, true, false);
return (prev != null); return (prev != null);
} }
@ -1307,7 +1308,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
Animation bounce = AnimationUtils.loadAnimation(getContext(), R.anim.bounce_left); Animation bounce = AnimationUtils.loadAnimation(getContext(), R.anim.bounce_left);
view.startAnimation(bounce); view.startAnimation(bounce);
} else } else
navigate(next, false); navigate(next, false, true);
return (next != null); return (next != null);
} }
@ -4957,6 +4958,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
if ((next ? "next" : "previous").equals(onclose)) if ((next ? "next" : "previous").equals(onclose))
if (!exists || id != null) { if (!exists || id != null) {
closeId = id; closeId = id;
closeForward = next;
if (!once) { if (!once) {
once = true; once = true;
loadMessagesNext(top); loadMessagesNext(top);
@ -5481,7 +5483,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean reversed = prefs.getBoolean("reversed", false); boolean reversed = prefs.getBoolean("reversed", false);
navigate(closeId, "previous".equals(onclose) ^ reversed); navigate(closeId, "previous".equals(onclose) ^ reversed, closeForward);
} }
} }
} }
@ -5525,13 +5527,16 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
} }
} }
private void navigate(long id, final boolean left) { private void navigate(long id, final boolean left, final boolean forward) {
if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
return; return;
if (navigating) if (navigating)
return; return;
navigating = true; navigating = true;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
final boolean reversed = prefs.getBoolean("reversed", false);
Bundle result = new Bundle(); Bundle result = new Bundle();
result.putLong("id", id); result.putLong("id", id);
getParentFragmentManager().setFragmentResult("message.selected", result); getParentFragmentManager().setFragmentResult("message.selected", result);
@ -5563,6 +5568,8 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
nargs.putLong("folder", message.folder); nargs.putLong("folder", message.folder);
nargs.putString("thread", message.thread); nargs.putString("thread", message.thread);
nargs.putLong("id", message.id); nargs.putLong("id", message.id);
if (lpos != NO_POSITION)
nargs.putInt("lpos", forward ^ reversed ? lpos - 1 : lpos + 1);
nargs.putBoolean("found", found); nargs.putBoolean("found", found);
nargs.putBoolean("pane", pane); nargs.putBoolean("pane", pane);
nargs.putLong("primary", primary); nargs.putLong("primary", primary);
@ -6117,7 +6124,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
Animation bounce = AnimationUtils.loadAnimation(context, R.anim.bounce_left); Animation bounce = AnimationUtils.loadAnimation(context, R.anim.bounce_left);
view.startAnimation(bounce); view.startAnimation(bounce);
} else } else
navigate(next, false); navigate(next, false, true);
return true; return true;
} }
@ -6126,7 +6133,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
Animation bounce = AnimationUtils.loadAnimation(context, R.anim.bounce_right); Animation bounce = AnimationUtils.loadAnimation(context, R.anim.bounce_right);
view.startAnimation(bounce); view.startAnimation(bounce);
} else } else
navigate(prev, true); navigate(prev, true, false);
return true; return true;
} }

Loading…
Cancel
Save