Scroll up after manual refresh

pull/152/head
M66B 7 years ago
parent c0983d24f5
commit fdf4988865

@ -1133,7 +1133,7 @@ for example one listed [here](https://github.com/offa/android-foss#-document--pd
<a name="faq69"></a> <a name="faq69"></a>
**(69) Can you add auto scroll up on new message?** **(69) Can you add auto scroll up on new message?**
The message list is automatically scrolled up when navigating from a new message notification. The message list is automatically scrolled up when navigating from a new message notification or after a manual refresh.
Always automatically scrolling up on arrival of new messages would interfere with your own navigation and scrolling. Always automatically scrolling up on arrival of new messages would interfere with your own navigation and scrolling.
<br /> <br />

@ -134,6 +134,7 @@ public class FragmentMessages extends FragmentBase {
private boolean outbox = false; private boolean outbox = false;
private boolean connected; private boolean connected;
private boolean searching = false; private boolean searching = false;
private boolean manual = false;
private AdapterMessage adapter; private AdapterMessage adapter;
private AdapterMessage.ViewType viewType; private AdapterMessage.ViewType viewType;
@ -488,6 +489,11 @@ public class FragmentMessages extends FragmentBase {
args.putLong("folder", folder); args.putLong("folder", folder);
new SimpleTask<Boolean>() { new SimpleTask<Boolean>() {
@Override
protected void onPreExecute(Bundle args) {
manual = true;
}
@Override @Override
protected Boolean onExecute(Context context, Bundle args) { protected Boolean onExecute(Context context, Bundle args) {
long fid = args.getLong("folder"); long fid = args.getLong("folder");
@ -519,6 +525,7 @@ public class FragmentMessages extends FragmentBase {
@Override @Override
protected void onException(Bundle args, Throwable ex) { protected void onException(Bundle args, Throwable ex) {
manual = false;
swipeRefresh.setRefreshing(false); swipeRefresh.setRefreshing(false);
if (ex instanceof IllegalArgumentException) if (ex instanceof IllegalArgumentException)
Snackbar.make(view, ex.getMessage(), Snackbar.LENGTH_LONG).show(); Snackbar.make(view, ex.getMessage(), Snackbar.LENGTH_LONG).show();
@ -1525,6 +1532,11 @@ public class FragmentMessages extends FragmentBase {
break; break;
} }
if (!refreshing && manual) {
manual = false;
rvMessage.scrollToPosition(0);
}
swipeRefresh.setRefreshing(refreshing); swipeRefresh.setRefreshing(refreshing);
} }
}); });
@ -1550,7 +1562,14 @@ public class FragmentMessages extends FragmentBase {
} }
} }
swipeRefresh.setRefreshing(folder != null && folder.isSynchronizing()); boolean refreshing = (folder != null && folder.isSynchronizing());
if (!refreshing && manual) {
manual = false;
rvMessage.scrollToPosition(0);
}
swipeRefresh.setRefreshing(refreshing);
} }
}); });
break; break;

Loading…
Cancel
Save