commit 15e5214c4b3183536fd213f48ed3accbcd4f27c3
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Mon Oct 4 14:17:41 2021 +0200

    Simplifications

diff --git a/src/main/java/org/distorted/objectlib/helpers/ObjectSurfaceView.java b/src/main/java/org/distorted/objectlib/helpers/ObjectSurfaceView.java
index b6ae78f3..00af2ccb 100644
--- a/src/main/java/org/distorted/objectlib/helpers/ObjectSurfaceView.java
+++ b/src/main/java/org/distorted/objectlib/helpers/ObjectSurfaceView.java
@@ -19,17 +19,9 @@
 
 package org.distorted.objectlib.helpers;
 
-import org.distorted.library.main.DistortedScreen;
-import org.distorted.library.type.Static4D;
-import org.distorted.objectlib.main.Movement;
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
 public interface ObjectSurfaceView
   {
-  TwistyActivity getActivity();
-  void setMovement(Movement move);
-  Static4D getQuat();
-  void setQuat();
-  DistortedScreen getScreen();
+
   }
diff --git a/src/main/java/org/distorted/objectlib/helpers/TwistyActivity.java b/src/main/java/org/distorted/objectlib/helpers/TwistyActivity.java
index 6b0b54cb..db20bda1 100644
--- a/src/main/java/org/distorted/objectlib/helpers/TwistyActivity.java
+++ b/src/main/java/org/distorted/objectlib/helpers/TwistyActivity.java
@@ -21,6 +21,7 @@ package org.distorted.objectlib.helpers;
 
 import androidx.appcompat.app.AppCompatActivity;
 
+import org.distorted.library.main.DistortedScreen;
 import org.distorted.objectlib.main.ObjectPreRender;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -33,6 +34,7 @@ abstract public class TwistyActivity extends AppCompatActivity
 
   public abstract ObjectPreRender getPreRender();
   public abstract boolean isLocked();
+  public abstract DistortedScreen getScreen();
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
diff --git a/src/main/java/org/distorted/objectlib/main/ObjectControl.java b/src/main/java/org/distorted/objectlib/main/ObjectControl.java
index ad846199..b82f5f2c 100644
--- a/src/main/java/org/distorted/objectlib/main/ObjectControl.java
+++ b/src/main/java/org/distorted/objectlib/main/ObjectControl.java
@@ -509,7 +509,7 @@ public class ObjectControl
 
       mDensity = dm.densityDpi;
 
-      mPreRender = new ObjectPreRender(view,actioner);
+      mPreRender = new ObjectPreRender(act,this,actioner);
       mAct = new WeakReference<>(act);
       mActioner = actioner;
       }
@@ -560,41 +560,6 @@ public class ObjectControl
       return mPreRender;
       }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-    public void prepareDown()
-      {
-      mIsAutomatic = true;
-      mPointer1 = 0;
-      mPointer2 = INVALID_POINTER_ID;
-      }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-    public void prepareDown2()
-      {
-      mPointer2 = 0;
-      }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-    public void prepareUp()
-      {
-      mIsAutomatic = false;
-      mPointer1 = INVALID_POINTER_ID;
-      mPointer2 = INVALID_POINTER_ID;
-      }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-    public void prepareMove(float x1, float y1, float x2, float y2)
-      {
-      mX1 = x1;
-      mY1 = y1;
-      mX2 = x2;
-      mY2 = y2;
-      }
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
     public boolean onTouchEvent(MotionEvent event, int mode)
diff --git a/src/main/java/org/distorted/objectlib/main/ObjectPreRender.java b/src/main/java/org/distorted/objectlib/main/ObjectPreRender.java
index cbb02107..24c741a1 100644
--- a/src/main/java/org/distorted/objectlib/main/ObjectPreRender.java
+++ b/src/main/java/org/distorted/objectlib/main/ObjectPreRender.java
@@ -23,18 +23,21 @@ import android.content.SharedPreferences;
 import android.content.res.Resources;
 
 import org.distorted.objectlib.helpers.ObjectStateActioner;
-import org.distorted.objectlib.helpers.ObjectSurfaceView;
 import org.distorted.objectlib.effects.BaseEffect;
 import org.distorted.objectlib.effects.EffectController;
 import org.distorted.objectlib.effects.scramble.ScrambleEffect;
 import org.distorted.objectlib.helpers.BlockController;
 import org.distorted.objectlib.helpers.MovesFinished;
+import org.distorted.objectlib.helpers.TwistyActivity;
+
+import java.lang.ref.WeakReference;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
 public class ObjectPreRender implements EffectController
   {
-  private final ObjectSurfaceView mView;
+  private final WeakReference<TwistyActivity> mAct;
+  private final ObjectControl mController;
   private ObjectType mNextObject;
   private TwistyObject mOldObject, mNewObject;
   private SharedPreferences mPreferences;
@@ -61,10 +64,11 @@ public class ObjectPreRender implements EffectController
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  public ObjectPreRender(ObjectSurfaceView view, ObjectStateActioner actioner)
+  public ObjectPreRender(TwistyActivity act, ObjectControl controller, ObjectStateActioner actioner)
     {
-    mView = view;
+    mAct = new WeakReference<>(act);
     mActioner = actioner;
+    mController = controller;
 
     mFinishRotation       = false;
     mRemoveRotation       = false;
@@ -87,7 +91,7 @@ public class ObjectPreRender implements EffectController
 
     mEffectID = new long[BaseEffect.Type.LENGTH];
 
-    mBlockController = new BlockController(mView.getActivity());
+    mBlockController = new BlockController(act);
     unblockEverything();
     }
 
@@ -99,13 +103,16 @@ public class ObjectPreRender implements EffectController
 
     if( mOldObject!=null ) mOldObject.releaseResources();
     mOldObject = mNewObject;
-    Resources res = mView.getActivity().getResources();
 
-    mNewObject = object.create(mView.getQuat(), moves, res, mScreenWidth);
+    TwistyActivity tact = mAct.get();
+
+    Resources res = tact.getResources();
+
+    mNewObject = object.create( mController.getQuat(), moves, res, mScreenWidth);
 
     if( mNewObject!=null )
       {
-      mView.setMovement(mNewObject.getMovement());
+      mController.setMovement(mNewObject.getMovement());
       if( firstTime ) mNewObject.restorePreferences(mPreferences);
       mIsSolved = mNewObject.isSolved();
       }
@@ -119,7 +126,7 @@ public class ObjectPreRender implements EffectController
     try
       {
       int index = type.ordinal();
-      mEffectID[index] = type.startEffect(mView.getScreen(),this);
+      mEffectID[index] = type.startEffect(mAct.get().getScreen(),this);
       }
     catch( Exception ex )
       {
@@ -291,18 +298,68 @@ public class ObjectPreRender implements EffectController
   private void setQuatNow()
     {
     mSetQuat = false;
-    mView.setQuat();
+    mController.setQuat();
     }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// PUBLIC API
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  public void rememberMove(int axis, int row, int angle)
+  void rememberMove(int axis, int row, int angle)
     {
     mDebug += (" (m "+axis+" "+(1<<row)+" "+angle+" "+(System.currentTimeMillis()-mDebugStartTime)+")");
     }
 
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  void finishRotation(int nearestAngle)
+    {
+    mNearestAngle   = nearestAngle;
+    mFinishRotation = true;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  void setTextureMap(int cubit, int face, int newColor)
+    {
+    mSetTextureMap = true;
+
+    mCubit    = cubit;
+    mFace     = face;
+    mNewColor = newColor;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  void setQuatOnNextRender()
+    {
+    mSetQuat = true;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// INTERNAL API
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// this only sets the cubits state to solved
+
+  public void solve()
+    {
+    mSolve = true;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public int getNumScrambles()
+    {
+    return mScrambleObjectNum;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public TwistyObject getOldObject()
+    {
+    return mOldObject;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// PUBLIC API
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   public void setScreenSize(int width)
@@ -332,14 +389,6 @@ public class ObjectPreRender implements EffectController
     mPreferences = preferences;
     }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  public void finishRotation(int nearestAngle)
-    {
-    mNearestAngle   = nearestAngle;
-    mFinishRotation = true;
-    }
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   public void changeObject(ObjectType object)
@@ -357,17 +406,6 @@ public class ObjectPreRender implements EffectController
     mNextMoves  = moves;
     }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  public void setTextureMap(int cubit, int face, int newColor)
-    {
-    mSetTextureMap = true;
-
-    mCubit    = cubit;
-    mFace     = face;
-    mNewColor = newColor;
-    }
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   public boolean isTouchBlocked()
@@ -426,13 +464,6 @@ public class ObjectPreRender implements EffectController
     mBlockController.uiUnblocked();
     }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  public void setQuatOnNextRender()
-    {
-    mSetQuat = true;
-    }
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   public void preRender()
@@ -502,14 +533,6 @@ public class ObjectPreRender implements EffectController
       }
     }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// this only sets the cubits state to solved
-
-  public void solve()
-    {
-    mSolve = true;
-    }
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   public void resetAllTextureMaps()
@@ -524,20 +547,6 @@ public class ObjectPreRender implements EffectController
     return mNewObject;
     }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  public TwistyObject getOldObject()
-    {
-    return mOldObject;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  public int getNumScrambles()
-    {
-    return mScrambleObjectNum;
-    }
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   public void effectFinished(final long effectID)
@@ -560,8 +569,8 @@ public class ObjectPreRender implements EffectController
         if( effectID == mEffectID[i] )
           {
           if( i!=BaseEffect.Type.WIN.ordinal() ) unblockEverything();
-          if( i==BaseEffect.Type.SCRAMBLE.ordinal() ) mActioner.onScrambleEffectFinished(mView.getActivity());
-          if( i==BaseEffect.Type.WIN.ordinal()      ) mActioner.onWinEffectFinished(mView.getActivity(),mDebug,mScrambleObjectNum);
+          if( i==BaseEffect.Type.SCRAMBLE.ordinal() ) mActioner.onScrambleEffectFinished(mAct.get());
+          if( i==BaseEffect.Type.WIN.ordinal()      ) mActioner.onWinEffectFinished(mAct.get(),mDebug,mScrambleObjectNum);
           break;
           }
         }
