Added swiping to remove, which is enabled by long-pressing
This commit is contained in:
parent
c730426be0
commit
523477fc2b
1 changed files with 9 additions and 8 deletions
|
@ -1,7 +1,6 @@
|
||||||
package org.schabi.newpipe.settings;
|
package org.schabi.newpipe.settings;
|
||||||
|
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.ColorStateList;
|
import android.content.res.ColorStateList;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
@ -23,7 +22,6 @@ import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
import org.schabi.newpipe.info_list.InfoItemDialog;
|
|
||||||
import org.schabi.newpipe.util.ThemeHelper;
|
import org.schabi.newpipe.util.ThemeHelper;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -235,19 +233,17 @@ public class ChoseTabsFragment extends Fragment {
|
||||||
|
|
||||||
private View.OnLongClickListener getOnLongClickListener(TabViewHolder holder) {
|
private View.OnLongClickListener getOnLongClickListener(TabViewHolder holder) {
|
||||||
return (view) -> {
|
return (view) -> {
|
||||||
int position = holder.getAdapterPosition();
|
if(itemTouchHelper != null) itemTouchHelper.startSwipe(holder);
|
||||||
selectedTabs.remove(position);
|
|
||||||
notifyItemRemoved(position);
|
|
||||||
saveChanges();
|
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ItemTouchHelper.SimpleCallback getItemTouchCallback() {
|
private ItemTouchHelper.SimpleCallback getItemTouchCallback() {
|
||||||
return new ItemTouchHelper.SimpleCallback(ItemTouchHelper.UP | ItemTouchHelper.DOWN,
|
return new ItemTouchHelper.SimpleCallback(ItemTouchHelper.UP | ItemTouchHelper.DOWN,
|
||||||
ItemTouchHelper.ACTION_STATE_IDLE) {
|
ItemTouchHelper.START | ItemTouchHelper.END) {
|
||||||
@Override
|
@Override
|
||||||
public int interpolateOutOfBoundsScroll(RecyclerView recyclerView, int viewSize,
|
public int interpolateOutOfBoundsScroll(RecyclerView recyclerView, int viewSize,
|
||||||
int viewSizeOutOfBounds, int totalSize,
|
int viewSizeOutOfBounds, int totalSize,
|
||||||
|
@ -284,7 +280,12 @@ public class ChoseTabsFragment extends Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSwiped(RecyclerView.ViewHolder viewHolder, int swipeDir) {}
|
public void onSwiped(RecyclerView.ViewHolder viewHolder, int swipeDir) {
|
||||||
|
int position = viewHolder.getAdapterPosition();
|
||||||
|
selectedTabs.remove(position);
|
||||||
|
selectedTabsAdapter.notifyItemRemoved(position);
|
||||||
|
saveChanges();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue