summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2022-05-07 17:44:56 +0200
committerMichael Weghorn <m.weghorn@posteo.de>2022-05-08 08:22:26 +0200
commit5c452ad4c31bcaa3f0a94c50b5eeb7cbca27da2e (patch)
tree414c07ac3bebbdfbc26b4b8da4f986297c6a3b00 /android
parentfd50cbbc410ebf949e00881de848bf90cb2f72aa (diff)
android: Don't store selected pos in ColorPickerAdapter
The position is already set and used in `ColorPaletteAdapter` as its `upperSelectedBox` member, so stop doing the double bookkeeping in both classes and retrieve it from there instead. Change-Id: I59896b85f5d5a0285076f61599be64638fa71121 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133987 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'android')
-rw-r--r--android/source/src/java/org/libreoffice/ColorPaletteAdapter.java4
-rw-r--r--android/source/src/java/org/libreoffice/ColorPickerAdapter.java8
2 files changed, 6 insertions, 6 deletions
diff --git a/android/source/src/java/org/libreoffice/ColorPaletteAdapter.java b/android/source/src/java/org/libreoffice/ColorPaletteAdapter.java
index e26dcc1c30a9..16d8a977864f 100644
--- a/android/source/src/java/org/libreoffice/ColorPaletteAdapter.java
+++ b/android/source/src/java/org/libreoffice/ColorPaletteAdapter.java
@@ -36,6 +36,10 @@ public class ColorPaletteAdapter extends RecyclerView.Adapter<ColorPaletteAdapte
return selectedBox;
}
+ public int getUpperSelectedBox() {
+ return upperSelectedBox;
+ }
+
@Override
public void onBindViewHolder(final ColorPaletteViewHolder holder, int position) {
diff --git a/android/source/src/java/org/libreoffice/ColorPickerAdapter.java b/android/source/src/java/org/libreoffice/ColorPickerAdapter.java
index b88087da3bf0..ed8fe0e59933 100644
--- a/android/source/src/java/org/libreoffice/ColorPickerAdapter.java
+++ b/android/source/src/java/org/libreoffice/ColorPickerAdapter.java
@@ -17,7 +17,6 @@ public class ColorPickerAdapter extends RecyclerView.Adapter<ColorPickerAdapter.
private final ColorPaletteListener colorPaletteListener;
private final int[] colorList;
private final int[][] colorPalette = new int[11][8];
- private int selectedBox = 0;
public ColorPickerAdapter(Context mContext, final ColorPaletteAdapter colorPaletteAdapter, ColorPaletteListener colorPaletteListener) {
this.mContext = mContext;
@@ -41,7 +40,7 @@ public class ColorPickerAdapter extends RecyclerView.Adapter<ColorPickerAdapter.
public void onBindViewHolder(final ColorPickerViewHolder holder, int position) {
holder.colorBox.setBackgroundColor(colorList[position]);
- if (selectedBox != position)
+ if (colorPaletteAdapter.getUpperSelectedBox() != position)
holder.colorBox.setImageDrawable(null);
else {
holder.colorBox.setImageResource(R.drawable.ic_done_white_12dp);
@@ -64,7 +63,6 @@ public class ColorPickerAdapter extends RecyclerView.Adapter<ColorPickerAdapter.
private void setPosition(int position) {
- this.selectedBox = position;
selectSubColor(position, position==0?0:3);
colorPaletteListener.applyColor(colorList[position]);
updateAdapter();
@@ -122,19 +120,17 @@ public class ColorPickerAdapter extends RecyclerView.Adapter<ColorPickerAdapter.
*/
if (color == -1) {
colorPaletteAdapter.changePosition(0, 0);
- selectedBox = 0;
updateAdapter();
return;
}
/*
Find the color if the palette points another color
*/
- if (colorPalette[selectedBox][colorPaletteAdapter.getSelectedBox()] != color) {
+ if (colorPalette[colorPaletteAdapter.getUpperSelectedBox()][colorPaletteAdapter.getSelectedBox()] != color) {
for (int i = 0; i < 11; i++) {
for (int k = 0; k < 8; k++) {
if (colorPalette[i][k] == color) {
colorPaletteAdapter.changePosition(i, k);
- selectedBox = i;
updateAdapter();
return;
}