Scroll up after manual refresh

This commit is contained in:
M66B 2019-03-01 20:03:39 +00:00
parent c0983d24f5
commit fdf4988865
2 changed files with 21 additions and 2 deletions

2
FAQ.md
View File

@ -1133,7 +1133,7 @@ for example one listed [here](https://github.com/offa/android-foss#-document--pd
<a name="faq69"></a>
**(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.
<br />

View File

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