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

View File

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

View File

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