Fixed swipe refresh on fast scroll

This commit is contained in:
M66B
2019-07-18 14:04:14 +02:00
parent 456756efd3
commit ec59befb82
3 changed files with 15 additions and 15 deletions

View File

@@ -192,7 +192,6 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
private boolean date;
private boolean threading;
private boolean pull;
private boolean swipenav;
private boolean autoscroll;
private boolean actionbar;
@@ -309,11 +308,6 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
if (viewType == AdapterMessage.ViewType.UNIFIED || viewType == AdapterMessage.ViewType.FOLDER)
pull = prefs.getBoolean("pull", true);
else
pull = false;
swipenav = prefs.getBoolean("swipenav", true);
autoscroll = (prefs.getBoolean("autoscroll", false) || viewType == AdapterMessage.ViewType.THREAD);
date = prefs.getBoolean("date", true);
@@ -900,12 +894,24 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
fabMore.show();
else
fabMore.hide();
updateSwipeRefresh();
}
});
}
updateSwipeRefresh();
swipeRefresh.setOnChildScrollUpCallback(new SwipeRefreshLayout.OnChildScrollUpCallback() {
@Override
public boolean canChildScrollUp(@NonNull SwipeRefreshLayout parent, @Nullable View child) {
if (viewType != AdapterMessage.ViewType.UNIFIED && viewType != AdapterMessage.ViewType.FOLDER)
return true;
if (!prefs.getBoolean("pull", true))
return true;
if (swiping)
return true;
if (selectionTracker != null && selectionTracker.hasSelection())
return true;
return rvMessage.canScrollVertically(-1);
}
});
pgpService = new OpenPgpServiceConnection(getContext(), "org.sufficientlysecure.keychain");
pgpService.bindToService();
@@ -946,10 +952,6 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
super.onDestroy();
}
private void updateSwipeRefresh() {
swipeRefresh.setEnabled(pull && !swiping && (selectionTracker == null || !selectionTracker.hasSelection()));
}
private void scrollToVisibleItem(LinearLayoutManager llm, boolean bottom) {
int pos = llm.findLastVisibleItemPosition();
if (pos == RecyclerView.NO_POSITION)
@@ -1294,7 +1296,6 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
public void onSelectedChanged(@Nullable RecyclerView.ViewHolder viewHolder, int actionState) {
super.onSelectedChanged(viewHolder, actionState);
swiping = (actionState == ItemTouchHelper.ACTION_STATE_SWIPE);
updateSwipeRefresh();
}
@Override

View File

@@ -40,7 +40,7 @@ public class FragmentOptions extends FragmentBase {
static String[] OPTIONS_RESTART = new String[]{
"startup", "date", "threading", "avatars", "identicons", "circular", "name_email", "subject_italic", "flags", "preview",
"addresses", "attachments_alt", "contrast", "monospaced", "autohtml", "autoimages", "actionbar",
"pull", "autoscroll", "swipenav", "autoexpand", "autoclose", "autonext",
"autoscroll", "swipenav", "autoexpand", "autoclose", "autonext",
"subscriptions", "debug",
"biometrics"
};