android/source/src/java/org/libreoffice/ColorPickerAdapter.java |   24 
+++++-----
 1 file changed, 12 insertions(+), 12 deletions(-)

New commits:
commit 9a249103de13f2a00fc17bf138d3e656f9a311b8
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Sat May 7 17:54:57 2022 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Sun May 8 08:23:29 2022 +0200

    android: Switch order of these if/else statements
    
    I find
    
        if (a == b) {
            // statement 1
        } else {
            // statement 2
        }
    
    more straightforward than
    
        if ( a != b) {
            // statement 2
        } else {
            // statement 1
        }
    
    since it doesn't require logically negating twice
    (else block is for `!(a != b)`) in the second form), and this
    also prepares for a follow-up commit where one of the conditions
    will be extended further.
    
    Change-Id: I1d2177bdcf662994e757b626983a9f9626c66aa1
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133988
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/android/source/src/java/org/libreoffice/ColorPickerAdapter.java 
b/android/source/src/java/org/libreoffice/ColorPickerAdapter.java
index ed8fe0e59933..bae9c3ed7768 100644
--- a/android/source/src/java/org/libreoffice/ColorPickerAdapter.java
+++ b/android/source/src/java/org/libreoffice/ColorPickerAdapter.java
@@ -40,10 +40,10 @@ public class ColorPickerAdapter extends 
RecyclerView.Adapter<ColorPickerAdapter.
     public void onBindViewHolder(final ColorPickerViewHolder holder, int 
position) {
         holder.colorBox.setBackgroundColor(colorList[position]);
 
-        if (colorPaletteAdapter.getUpperSelectedBox() != position)
-            holder.colorBox.setImageDrawable(null);
-        else {
+        if (colorPaletteAdapter.getUpperSelectedBox() == position) {
             holder.colorBox.setImageResource(R.drawable.ic_done_white_12dp);
+        } else {
+            holder.colorBox.setImageDrawable(null);
         }
 
         holder.colorBox.setOnClickListener(new View.OnClickListener() {
@@ -86,7 +86,15 @@ public class ColorPickerAdapter extends 
RecyclerView.Adapter<ColorPickerAdapter.
             int red_shade = red;
             int green_shade = green;
             int blue_shade = blue;
-            if (i != 0) {
+            if (i == 0) {
+                colorPalette[0][0] = colorList[i];
+                for (int k = 1; k < 7; k++) {
+                    red_tint = (int) (red_tint + (255 - red_tint) * 0.25);
+                    green_tint = (int) (green_tint + (255 - green_tint) * 
0.25);
+                    blue_tint = (int) (blue_tint + (255 - blue_tint) * 0.25);
+                    colorPalette[i][k] = (Color.rgb(red_tint, green_tint, 
blue_tint));
+                }
+            } else {
                 colorPalette[i][3] = colorList[i];
                 for (int k = 2; k >= 0; k--) {
                     red_shade = (int) (red_shade * 0.75);
@@ -100,14 +108,6 @@ public class ColorPickerAdapter extends 
RecyclerView.Adapter<ColorPickerAdapter.
                     blue_tint = (int) (blue_tint + (255 - blue_tint) * 0.45);
                     colorPalette[i][k] = (Color.rgb(red_tint, green_tint, 
blue_tint));
                 }
-            } else {
-                colorPalette[0][0] = colorList[i];
-                for (int k = 1; k < 7; k++) {
-                    red_tint = (int) (red_tint + (255 - red_tint) * 0.25);
-                    green_tint = (int) (green_tint + (255 - green_tint) * 
0.25);
-                    blue_tint = (int) (blue_tint + (255 - blue_tint) * 0.25);
-                    colorPalette[i][k] = (Color.rgb(red_tint, green_tint, 
blue_tint));
-                }
             }
             colorPalette[i][7] = Color.WHITE; // last one is always white
         }

Reply via email to