Loading packages/SystemUI/src/com/android/systemui/qs/customize/TileAdapter.java +13 −13 Original line number Original line Diff line number Diff line Loading @@ -142,11 +142,9 @@ public class TileAdapter extends RecyclerView.Adapter<Holder> implements TileSta } } } } mTileDividerIndex = mTiles.size(); mTileDividerIndex = mTiles.size(); if (mOtherTiles.size() != 0) { mTiles.add(null); mTiles.add(null); } mTiles.addAll(mOtherTiles); mTiles.addAll(mOtherTiles); mEditIndex = mTiles.indexOf(null); updateDividerLocations(); notifyDataSetChanged(); notifyDataSetChanged(); } } Loading Loading @@ -203,6 +201,8 @@ public class TileAdapter extends RecyclerView.Adapter<Holder> implements TileSta @Override @Override public void onBindViewHolder(final Holder holder, int position) { public void onBindViewHolder(final Holder holder, int position) { if (holder.getItemViewType() == TYPE_DIVIDER) { if (holder.getItemViewType() == TYPE_DIVIDER) { holder.itemView.setVisibility(mTileDividerIndex < mTiles.size() - 1 ? View.VISIBLE : View.INVISIBLE); return; return; } } if (holder.getItemViewType() == TYPE_EDIT) { if (holder.getItemViewType() == TYPE_EDIT) { Loading Loading @@ -340,9 +340,8 @@ public class TileAdapter extends RecyclerView.Adapter<Holder> implements TileSta to = mTileDividerIndex; to = mTileDividerIndex; } } } else { } else { if (mTileDividerIndex == mTiles.size()) { if (mTileDividerIndex == mTiles.size() - 1) { notifyItemInserted(mTiles.size()); notifyItemChanged(mTileDividerIndex); mTiles.add(null); } } if (to <= mTileDividerIndex) { if (to <= mTileDividerIndex) { to = mTileDividerIndex; to = mTileDividerIndex; Loading @@ -351,7 +350,7 @@ public class TileAdapter extends RecyclerView.Adapter<Holder> implements TileSta } else { } else { if (to > mEditIndex) { if (to > mEditIndex) { // Don't allow tiles to be dragged around when they aren't added. // Don't allow tiles to be dragged around when they aren't added. return false; to = from; } } // Allow the case where to == mEditIndex to fall through and swap which // Allow the case where to == mEditIndex to fall through and swap which // side the tile is currently on. // side the tile is currently on. Loading @@ -362,6 +361,9 @@ public class TileAdapter extends RecyclerView.Adapter<Holder> implements TileSta CharSequence fromLabel = mTiles.get(from).state.label; CharSequence fromLabel = mTiles.get(from).state.label; move(from, to, mTiles); move(from, to, mTiles); updateDividerLocations(); updateDividerLocations(); if (to == from) { return true; } CharSequence announcement; CharSequence announcement; if (to >= mEditIndex) { if (to >= mEditIndex) { MetricsLogger.action(mContext, MetricsProto.MetricsEvent.ACTION_QS_EDIT_REMOVE_SPEC, MetricsLogger.action(mContext, MetricsProto.MetricsEvent.ACTION_QS_EDIT_REMOVE_SPEC, Loading Loading @@ -405,12 +407,11 @@ public class TileAdapter extends RecyclerView.Adapter<Holder> implements TileSta } } } } if (mTiles.size() - 1 == mTileDividerIndex) { if (mTiles.size() - 1 == mTileDividerIndex) { mTiles.remove(mTiles.size() - 1); notifyItemChanged(mTileDividerIndex); notifyItemRemoved(mTiles.size()); } } } } private String strip(TileInfo tileInfo) { private static String strip(TileInfo tileInfo) { String spec = tileInfo.spec; String spec = tileInfo.spec; if (spec.startsWith(CustomTile.PREFIX)) { if (spec.startsWith(CustomTile.PREFIX)) { ComponentName component = CustomTile.getComponentFromSpec(spec); ComponentName component = CustomTile.getComponentFromSpec(spec); Loading @@ -420,8 +421,7 @@ public class TileAdapter extends RecyclerView.Adapter<Holder> implements TileSta } } private <T> void move(int from, int to, List<T> list) { private <T> void move(int from, int to, List<T> list) { list.add(from > to ? to : to + 1, list.get(from)); list.add(to, list.remove(from)); list.remove(from > to ? from + 1 : from); notifyItemMoved(from, to); notifyItemMoved(from, to); notifyItemChanged(to); notifyItemChanged(to); } } Loading Loading
packages/SystemUI/src/com/android/systemui/qs/customize/TileAdapter.java +13 −13 Original line number Original line Diff line number Diff line Loading @@ -142,11 +142,9 @@ public class TileAdapter extends RecyclerView.Adapter<Holder> implements TileSta } } } } mTileDividerIndex = mTiles.size(); mTileDividerIndex = mTiles.size(); if (mOtherTiles.size() != 0) { mTiles.add(null); mTiles.add(null); } mTiles.addAll(mOtherTiles); mTiles.addAll(mOtherTiles); mEditIndex = mTiles.indexOf(null); updateDividerLocations(); notifyDataSetChanged(); notifyDataSetChanged(); } } Loading Loading @@ -203,6 +201,8 @@ public class TileAdapter extends RecyclerView.Adapter<Holder> implements TileSta @Override @Override public void onBindViewHolder(final Holder holder, int position) { public void onBindViewHolder(final Holder holder, int position) { if (holder.getItemViewType() == TYPE_DIVIDER) { if (holder.getItemViewType() == TYPE_DIVIDER) { holder.itemView.setVisibility(mTileDividerIndex < mTiles.size() - 1 ? View.VISIBLE : View.INVISIBLE); return; return; } } if (holder.getItemViewType() == TYPE_EDIT) { if (holder.getItemViewType() == TYPE_EDIT) { Loading Loading @@ -340,9 +340,8 @@ public class TileAdapter extends RecyclerView.Adapter<Holder> implements TileSta to = mTileDividerIndex; to = mTileDividerIndex; } } } else { } else { if (mTileDividerIndex == mTiles.size()) { if (mTileDividerIndex == mTiles.size() - 1) { notifyItemInserted(mTiles.size()); notifyItemChanged(mTileDividerIndex); mTiles.add(null); } } if (to <= mTileDividerIndex) { if (to <= mTileDividerIndex) { to = mTileDividerIndex; to = mTileDividerIndex; Loading @@ -351,7 +350,7 @@ public class TileAdapter extends RecyclerView.Adapter<Holder> implements TileSta } else { } else { if (to > mEditIndex) { if (to > mEditIndex) { // Don't allow tiles to be dragged around when they aren't added. // Don't allow tiles to be dragged around when they aren't added. return false; to = from; } } // Allow the case where to == mEditIndex to fall through and swap which // Allow the case where to == mEditIndex to fall through and swap which // side the tile is currently on. // side the tile is currently on. Loading @@ -362,6 +361,9 @@ public class TileAdapter extends RecyclerView.Adapter<Holder> implements TileSta CharSequence fromLabel = mTiles.get(from).state.label; CharSequence fromLabel = mTiles.get(from).state.label; move(from, to, mTiles); move(from, to, mTiles); updateDividerLocations(); updateDividerLocations(); if (to == from) { return true; } CharSequence announcement; CharSequence announcement; if (to >= mEditIndex) { if (to >= mEditIndex) { MetricsLogger.action(mContext, MetricsProto.MetricsEvent.ACTION_QS_EDIT_REMOVE_SPEC, MetricsLogger.action(mContext, MetricsProto.MetricsEvent.ACTION_QS_EDIT_REMOVE_SPEC, Loading Loading @@ -405,12 +407,11 @@ public class TileAdapter extends RecyclerView.Adapter<Holder> implements TileSta } } } } if (mTiles.size() - 1 == mTileDividerIndex) { if (mTiles.size() - 1 == mTileDividerIndex) { mTiles.remove(mTiles.size() - 1); notifyItemChanged(mTileDividerIndex); notifyItemRemoved(mTiles.size()); } } } } private String strip(TileInfo tileInfo) { private static String strip(TileInfo tileInfo) { String spec = tileInfo.spec; String spec = tileInfo.spec; if (spec.startsWith(CustomTile.PREFIX)) { if (spec.startsWith(CustomTile.PREFIX)) { ComponentName component = CustomTile.getComponentFromSpec(spec); ComponentName component = CustomTile.getComponentFromSpec(spec); Loading @@ -420,8 +421,7 @@ public class TileAdapter extends RecyclerView.Adapter<Holder> implements TileSta } } private <T> void move(int from, int to, List<T> list) { private <T> void move(int from, int to, List<T> list) { list.add(from > to ? to : to + 1, list.get(from)); list.add(to, list.remove(from)); list.remove(from > to ? from + 1 : from); notifyItemMoved(from, to); notifyItemMoved(from, to); notifyItemChanged(to); notifyItemChanged(to); } } Loading