commit 41748f19f39f05da0372b03f5050822575b84bae
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Mon Apr 6 14:29:05 2020 +0100

    Progress making the Solver state more abstract.

diff --git a/src/main/java/org/distorted/states/RubikStateSolver.java b/src/main/java/org/distorted/states/RubikStateSolver.java
index 2b9a743b..6bce5147 100644
--- a/src/main/java/org/distorted/states/RubikStateSolver.java
+++ b/src/main/java/org/distorted/states/RubikStateSolver.java
@@ -45,21 +45,18 @@ import org.distorted.solvers.Solver;
 
 public class RubikStateSolver extends RubikStateAbstract
   {
-  private static final int NUM_FACES   =  6;
   private static final int BITMAP_SIZE = 35;
 
-  private static final int[] FACE_COLORS = new int[]
-         {
-           0xffffff00, 0xffffffff,
-           0xff0000ff, 0xff00ff00,
-           0xffff0000, 0xffb5651d
-         };
+  private static final RubikObjectList OBJECT = RubikObjectList.CUBE;
+  private static final int             SIZE   = 3;
 
   private static Bitmap[] mBitmap;
   private ImageButton[] mColorButton;
   private Button mBackButton, mSolveButton;
   private boolean mSolving;
   private int mCurrentColor;
+  private int[] mFaceColors;
+  private int mNumFaces;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
@@ -74,22 +71,12 @@ public class RubikStateSolver extends RubikStateAbstract
     {
     mSolving = false;
 
-    act.changeObject(RubikObjectList.CUBE,3,null);
+    act.changeObject(OBJECT,SIZE,null);
     RubikStatePlay play = (RubikStatePlay)RubikState.PLAY.getStateClass();
-    play.setObjectAndSize(RubikObjectList.CUBE,3);
+    play.setObjectAndSize(OBJECT,SIZE);
 
-int[] colors = RubikObjectList.retFaceColors(RubikObjectList.CUBE);
-
-if( colors != null )
-  {
-  int len = colors.length;
-
-  android.util.Log.e("solver", "retColors len="+len+" first: "+colors[0]);
-  }
-else
-  {
-  android.util.Log.e("solver", "retColors null");
-  }
+    mFaceColors = RubikObjectList.retFaceColors(OBJECT);
+    mNumFaces   = mFaceColors!=null ? mFaceColors.length : 0;
 
     DisplayMetrics metrics = act.getResources().getDisplayMetrics();
     final float scale = metrics.density;
@@ -98,10 +85,13 @@ else
     LinearLayout layoutTop = act.findViewById(R.id.upperBar);
     layoutTop.removeAllViews();
 
-    if( mBitmap     ==null ) setupBitmaps(scale);
-    if( mColorButton==null ) setupColorButtons(act,scale);
+    if( mNumFaces>0 )
+      {
+      if( mBitmap     ==null ) setupBitmaps(scale);
+      if( mColorButton==null ) setupColorButtons(act,scale);
 
-    markButton(act);
+      markButton(act);
+      }
 
     for(ImageButton button: mColorButton) layoutTop.addView(button);
 
@@ -127,7 +117,7 @@ else
     final float R = SIZE*0.10f;
     final float M = SIZE*0.05f;
 
-    mBitmap = new Bitmap[NUM_FACES];
+    mBitmap = new Bitmap[mNumFaces];
 
     Paint paint = new Paint();
     paint.setColor(0xff008800);
@@ -137,7 +127,7 @@ else
     paint.setTextAlign(Paint.Align.CENTER);
     paint.setStyle(Paint.Style.FILL);
 
-    for(int i=0; i<NUM_FACES; i++)
+    for(int i=0; i<mNumFaces; i++)
       {
       mBitmap[i] = Bitmap.createBitmap(SIZE, SIZE, Bitmap.Config.ARGB_8888);
       Canvas canvas = new Canvas(mBitmap[i]);
@@ -145,7 +135,7 @@ else
       paint.setColor(0xff000000);
       canvas.drawRect(0, 0, SIZE, SIZE, paint);
 
-      paint.setColor(FACE_COLORS[i]);
+      paint.setColor(mFaceColors[i]);
       canvas.drawRoundRect( M, M, SIZE-M, SIZE-M, R, R, paint);
       }
     }
@@ -154,9 +144,9 @@ else
 
   private void setupColorButtons(final RubikActivity act, final float scale)
     {
-    mColorButton = new ImageButton[NUM_FACES];
+    mColorButton = new ImageButton[mNumFaces];
 
-    for(int i=0; i<NUM_FACES; i++)
+    for(int i=0; i<mNumFaces; i++)
       {
       final int ii = i;
       int padding = (int)(3*scale + 0.5f);
@@ -233,7 +223,7 @@ else
 
   private void markButton(RubikActivity act)
     {
-    for(int b=0; b<NUM_FACES; b++)
+    for(int b=0; b<mNumFaces; b++)
       {
       Drawable d = mColorButton[b].getBackground();
 
