1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-12-23 16:40:32 +00:00

Removing by long pressing no longer removes a random tab, but the pressed one.

This commit is contained in:
Somethingweirdhere 2018-06-19 15:13:38 +02:00 committed by Christian Schabesberger
parent 614bdb33b4
commit f29fa939ab

View File

@ -161,12 +161,12 @@ public class ContentSettingsMain extends Fragment {
itemTouchHelper = mItemTouchHelper;
}
public boolean swapItems(int fromPosition, int toPosition) {
public void swapItems(int fromPosition, int toPosition) {
String temp = usedTabs.get(fromPosition);
usedTabs.set(fromPosition, usedTabs.get(toPosition));
usedTabs.set(toPosition, temp);
notifyItemMoved(fromPosition, toPosition);
return true;
saveChanges();
}
@Override
@ -208,6 +208,8 @@ public class ContentSettingsMain extends Fragment {
handle.setImageResource(ThemeHelper.getIconByAttr(R.attr.drag_handle, getContext()));
handle.setOnTouchListener(getOnTouchListener(holder));
view.setOnLongClickListener(getOnLongClickListener(holder));
if(usedTabs.get(position).startsWith("6\t")) {
String channelInfo[] = usedTabs.get(position).split("\t");
String channelName = "";
@ -228,6 +230,16 @@ public class ContentSettingsMain extends Fragment {
return false;
};
}
private View.OnLongClickListener getOnLongClickListener(TabViewHolder holder) {
return (view) -> {
int position = holder.getAdapterPosition();
usedTabs.remove(position);
notifyItemRemoved(position);
saveChanges();
return false;
};
}
}
}
@ -255,9 +267,8 @@ public class ContentSettingsMain extends Fragment {
final int sourceIndex = source.getAdapterPosition();
final int targetIndex = target.getAdapterPosition();
final boolean isSwapped = usedAdapter.swapItems(sourceIndex, targetIndex);
if (isSwapped) saveChanges();
return isSwapped;
usedAdapter.swapItems(sourceIndex, targetIndex);
return true;
}
@Override