mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-24 09:00:31 +00:00
Removing by long pressing no longer removes a random tab, but the pressed one.
This commit is contained in:
parent
614bdb33b4
commit
f29fa939ab
@ -161,12 +161,12 @@ public class ContentSettingsMain extends Fragment {
|
|||||||
itemTouchHelper = mItemTouchHelper;
|
itemTouchHelper = mItemTouchHelper;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean swapItems(int fromPosition, int toPosition) {
|
public void swapItems(int fromPosition, int toPosition) {
|
||||||
String temp = usedTabs.get(fromPosition);
|
String temp = usedTabs.get(fromPosition);
|
||||||
usedTabs.set(fromPosition, usedTabs.get(toPosition));
|
usedTabs.set(fromPosition, usedTabs.get(toPosition));
|
||||||
usedTabs.set(toPosition, temp);
|
usedTabs.set(toPosition, temp);
|
||||||
notifyItemMoved(fromPosition, toPosition);
|
notifyItemMoved(fromPosition, toPosition);
|
||||||
return true;
|
saveChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -208,6 +208,8 @@ public class ContentSettingsMain extends Fragment {
|
|||||||
handle.setImageResource(ThemeHelper.getIconByAttr(R.attr.drag_handle, getContext()));
|
handle.setImageResource(ThemeHelper.getIconByAttr(R.attr.drag_handle, getContext()));
|
||||||
handle.setOnTouchListener(getOnTouchListener(holder));
|
handle.setOnTouchListener(getOnTouchListener(holder));
|
||||||
|
|
||||||
|
view.setOnLongClickListener(getOnLongClickListener(holder));
|
||||||
|
|
||||||
if(usedTabs.get(position).startsWith("6\t")) {
|
if(usedTabs.get(position).startsWith("6\t")) {
|
||||||
String channelInfo[] = usedTabs.get(position).split("\t");
|
String channelInfo[] = usedTabs.get(position).split("\t");
|
||||||
String channelName = "";
|
String channelName = "";
|
||||||
@ -228,6 +230,16 @@ public class ContentSettingsMain extends Fragment {
|
|||||||
return false;
|
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 sourceIndex = source.getAdapterPosition();
|
||||||
final int targetIndex = target.getAdapterPosition();
|
final int targetIndex = target.getAdapterPosition();
|
||||||
final boolean isSwapped = usedAdapter.swapItems(sourceIndex, targetIndex);
|
usedAdapter.swapItems(sourceIndex, targetIndex);
|
||||||
if (isSwapped) saveChanges();
|
return true;
|
||||||
return isSwapped;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user