commit 24679c47e284788d8c2a6bbd0e245444111c2524
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Wed Oct 12 00:18:46 2022 +0200

    Progress with marking objects as free.

diff --git a/src/main/java/org/distorted/external/RubikScores.java b/src/main/java/org/distorted/external/RubikScores.java
index cd4637d0..cb3e6b2a 100644
--- a/src/main/java/org/distorted/external/RubikScores.java
+++ b/src/main/java/org/distorted/external/RubikScores.java
@@ -30,6 +30,10 @@ import static org.distorted.objectlib.main.ObjectType.MAX_SCRAMBLES;
 
 public class RubikScores
   {
+  public static final int RECORD_FIRST   = 0;
+  public static final int RECORD_NEW     = 1;
+  public static final int RECORD_NOT_NEW = 2;
+
   public static final int MAX_RECORD = 10;
   public static final int MULT = 1000000;
   public static final long NO_RECORD = Long.MAX_VALUE;
@@ -238,7 +242,7 @@ public class RubikScores
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  public synchronized boolean setRecord(int object, int level, long record)
+  public synchronized int setRecord(int object, int level, long record)
     {
     int key = mapKey(object,level);
     MapValue oldValue = mMap.get(key);
@@ -247,7 +251,7 @@ public class RubikScores
       {
       MapValue value = new MapValue(record,0);
       mMap.put(key,value);
-      return true;
+      return RECORD_FIRST;
       }
 
     long oldRecord = oldValue.record;
@@ -256,11 +260,12 @@ public class RubikScores
       {
       MapValue value = new MapValue(record,0);
       mMap.put(key,value);
-      return true;
+      return RECORD_NEW;
       }
 
-    return false;
+    return RECORD_NOT_NEW;
     }
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   public synchronized long getRecord(int object, int level)
diff --git a/src/main/java/org/distorted/main/RubikObjectLibInterface.java b/src/main/java/org/distorted/main/RubikObjectLibInterface.java
index b0590023..a990768b 100644
--- a/src/main/java/org/distorted/main/RubikObjectLibInterface.java
+++ b/src/main/java/org/distorted/main/RubikObjectLibInterface.java
@@ -44,12 +44,15 @@ import org.distorted.solvers.SolverMain;
 
 import java.lang.ref.WeakReference;
 
+import static org.distorted.external.RubikScores.RECORD_FIRST;
+import static org.distorted.external.RubikScores.RECORD_NOT_NEW;
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
 public class RubikObjectLibInterface implements ObjectLibInterface
 {
   private final WeakReference<RubikActivity> mAct;
-  private boolean mIsNewRecord;
+  private int mIsNewRecord;
   private long mNewRecord;
   private int mLastCubitColor, mLastCubit, mLastCubitFace;
 
@@ -195,11 +198,18 @@ public class RubikObjectLibInterface implements ObjectLibInterface
       reportRecord(act,startTime,endTime,debug,scrambleNum);
       requestReview(act);
 
-      if( mIsNewRecord )
+      if( mIsNewRecord!=RECORD_NOT_NEW )
         {
-        RubikDialogNewRecord dialog = new RubikDialogNewRecord();
-        dialog.setArguments(bundle);
-        dialog.show( act.getSupportFragmentManager(), RubikDialogNewRecord.getDialogTag() );
+        if( mIsNewRecord==RECORD_FIRST && RubikObjectList.thereAreLockedObjects() )
+          {
+
+          }
+        else
+          {
+          RubikDialogNewRecord dialog = new RubikDialogNewRecord();
+          dialog.setArguments(bundle);
+          dialog.show( act.getSupportFragmentManager(), RubikDialogNewRecord.getDialogTag() );
+          }
         }
       else
         {
@@ -308,17 +318,8 @@ public class RubikObjectLibInterface implements ObjectLibInterface
     if( ScreenList.getCurrentScreen()== ScreenList.SOLV )
       {
       RubikScreenSolving solving = (RubikScreenSolving) ScreenList.SOLV.getScreenClass();
-      mNewRecord = solving.getRecord();
-
-      if( mNewRecord< 0 )
-        {
-        mNewRecord = -mNewRecord;
-        mIsNewRecord = false;
-        }
-      else
-        {
-        mIsNewRecord = true;
-        }
+      mNewRecord = solving.stopTimerAndGetRecord();
+      mIsNewRecord = solving.setRecord();
       }
     }
 
diff --git a/src/main/java/org/distorted/objects/RubikObjectList.java b/src/main/java/org/distorted/objects/RubikObjectList.java
index 24541168..66310769 100644
--- a/src/main/java/org/distorted/objects/RubikObjectList.java
+++ b/src/main/java/org/distorted/objects/RubikObjectList.java
@@ -358,6 +358,19 @@ public class RubikObjectList
     return mFreeBoughtObjects.equals("*");
     }
 
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public static boolean thereAreLockedObjects()
+    {
+    for(int i=0; i<mNumObjects; i++)
+      {
+      RubikObject o = mObjects.get(i);
+      if( !o.isFree() ) return true;
+      }
+
+    return false;
+    }
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   public static boolean objectAlreadyBought(String shortName)
diff --git a/src/main/java/org/distorted/screens/RubikScreenSolving.java b/src/main/java/org/distorted/screens/RubikScreenSolving.java
index ee8622c4..39bd7cf2 100644
--- a/src/main/java/org/distorted/screens/RubikScreenSolving.java
+++ b/src/main/java/org/distorted/screens/RubikScreenSolving.java
@@ -167,25 +167,28 @@ public class RubikScreenSolving extends RubikScreenBase
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  public long getRecord()
+  public long stopTimerAndGetRecord()
     {
     if( mRunning )
       {
       stopCounting();
-
       mElapsed = System.currentTimeMillis()-mStartTime;
-
-      RubikScreenPlay play = (RubikScreenPlay) ScreenList.PLAY.getScreenClass();
-      int object = RubikObjectList.getCurrObject();
-      int level = play.getLevel()-1;
-      boolean isNew = mScores.setRecord(object, level, mElapsed);
-
-      return isNew ? mElapsed : -mElapsed;
+      return mElapsed;
       }
 
     return 0;
     }
 
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public int setRecord()
+    {
+    RubikScreenPlay play = (RubikScreenPlay) ScreenList.PLAY.getScreenClass();
+    int object = RubikObjectList.getCurrObject();
+    int level = play.getLevel()-1;
+    return mScores.setRecord(object, level, mElapsed);
+    }
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   public void resetElapsed()
