Enabling swiping actions on locked queue list

This commit is contained in:
olivoto 2020-07-22 12:45:44 -03:00 committed by GitHub
parent 93d6ccb6fe
commit 8c0c5b972e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 11 deletions

View File

@ -20,16 +20,17 @@ public class QueueRecyclerAdapter extends EpisodeItemListAdapter {
private static final String TAG = "QueueRecyclerAdapter";
private final ItemTouchHelper itemTouchHelper;
private boolean locked;
private boolean dragDropEnabled;
public QueueRecyclerAdapter(MainActivity mainActivity, ItemTouchHelper itemTouchHelper) {
super(mainActivity);
this.itemTouchHelper = itemTouchHelper;
locked = UserPreferences.isQueueLocked();
dragDropEnabled = ! (UserPreferences.isQueueKeepSorted() || UserPreferences.isQueueLocked());
}
public void setLocked(boolean locked) {
this.locked = locked;
public void updateDragDropEnabled() {
dragDropEnabled = ! (UserPreferences.isQueueKeepSorted() || UserPreferences.isQueueLocked());
notifyDataSetChanged();
}
@ -44,7 +45,7 @@ public class QueueRecyclerAdapter extends EpisodeItemListAdapter {
return false;
};
if (locked) {
if (!dragDropEnabled) {
holder.dragHandle.setVisibility(View.GONE);
holder.dragHandle.setOnTouchListener(null);
holder.coverHolder.setOnTouchListener(null);

View File

@ -16,7 +16,6 @@ import android.widget.ProgressBar;
import android.widget.TextView;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.view.ViewCompat;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.RecyclerView;
@ -337,10 +336,10 @@ public class QueueFragment extends Fragment {
SortOrder sortOrder = UserPreferences.getQueueKeepSortedOrder();
DBWriter.reorderQueue(sortOrder, true);
if (recyclerAdapter != null) {
recyclerAdapter.setLocked(true);
recyclerAdapter.updateDragDropEnabled();
}
} else if (recyclerAdapter != null) {
recyclerAdapter.setLocked(UserPreferences.isQueueLocked());
recyclerAdapter.updateDragDropEnabled();
}
getActivity().invalidateOptionsMenu();
return true;
@ -383,7 +382,7 @@ public class QueueFragment extends Fragment {
UserPreferences.setQueueLocked(locked);
getActivity().invalidateOptionsMenu();
if (recyclerAdapter != null) {
recyclerAdapter.setLocked(locked);
recyclerAdapter.updateDragDropEnabled();
}
if (locked) {
((MainActivity) getActivity()).showSnackbarAbovePlayer(R.string.queue_locked, Snackbar.LENGTH_SHORT);

View File

@ -632,8 +632,7 @@ public class UserPreferences {
}
public static boolean isQueueLocked() {
return prefs.getBoolean(PREF_QUEUE_LOCKED, false)
|| isQueueKeepSorted();
return prefs.getBoolean(PREF_QUEUE_LOCKED, false);
}
public static void setFastForwardSecs(int secs) {