Merge "QS Edit: fix some move logic" into nyc-dev
This commit is contained in:
@@ -331,23 +331,32 @@ public class TileAdapter extends RecyclerView.Adapter<Holder> implements TileSta
|
|||||||
|
|
||||||
private boolean move(int from, int to, View v) {
|
private boolean move(int from, int to, View v) {
|
||||||
if (to >= mEditIndex) {
|
if (to >= mEditIndex) {
|
||||||
if (from >= mEditIndex) {
|
if (from < mEditIndex) {
|
||||||
return false;
|
// Removing a tile.
|
||||||
}
|
// Sort tiles into system/non-system groups.
|
||||||
// Sort tiles into system/non-system groups.
|
TileInfo tile = mTiles.get(from);
|
||||||
TileInfo tile = mTiles.get(from);
|
if (tile.isSystem) {
|
||||||
if (tile.isSystem) {
|
if (to > mTileDividerIndex) {
|
||||||
if (to > mTileDividerIndex) {
|
to = mTileDividerIndex;
|
||||||
to = mTileDividerIndex;
|
}
|
||||||
|
} else {
|
||||||
|
if (mTileDividerIndex == mTiles.size()) {
|
||||||
|
notifyItemInserted(mTiles.size());
|
||||||
|
mTiles.add(null);
|
||||||
|
}
|
||||||
|
if (to <= mTileDividerIndex) {
|
||||||
|
to = mTileDividerIndex;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (mTileDividerIndex == mTiles.size()) {
|
if (to > mEditIndex) {
|
||||||
notifyItemInserted(mTiles.size());
|
// Don't allow tiles to be dragged around when they aren't added.
|
||||||
mTiles.add(null);
|
return false;
|
||||||
}
|
|
||||||
if (to <= mTileDividerIndex) {
|
|
||||||
to = mTileDividerIndex;
|
|
||||||
}
|
}
|
||||||
|
// Allow the case where to == mEditIndex to fall through and swap which
|
||||||
|
// side the tile is currently on.
|
||||||
|
// This lets the the cases where all tiles are on one side of the line
|
||||||
|
// work.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CharSequence fromLabel = mTiles.get(from).state.label;
|
CharSequence fromLabel = mTiles.get(from).state.label;
|
||||||
|
|||||||
Reference in New Issue
Block a user