commit 028f3e0dc58ae1df3a057a3d13590163dbbbddd9
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Tue Feb 11 21:49:49 2020 +0000

    Downloading High Scores: even better way of displaying scores

diff --git a/src/main/java/org/distorted/magic/RubikScoresPagerAdapter.java b/src/main/java/org/distorted/magic/RubikScoresPagerAdapter.java
index 94305a0c..74ed1b31 100644
--- a/src/main/java/org/distorted/magic/RubikScoresPagerAdapter.java
+++ b/src/main/java/org/distorted/magic/RubikScoresPagerAdapter.java
@@ -32,10 +32,29 @@ class RubikScoresPagerAdapter extends PagerAdapter implements RubikScoresDownloa
   {
   private FragmentActivity mAct;
   private RubikScoresView[] mViews;
+  private ViewPager mViewPager;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   public void receive(final int[][][] country, final String[][][] name, final String[][][] time)
+    {
+    prepareView();
+
+    int c = mViewPager.getCurrentItem();
+
+    addPage(c,country[c],name[c],time[c]);
+
+    for(int i=0; i<RubikSize.LENGTH; i++)
+      {
+      if( i==c ) continue;
+
+      addPage(i,country[i],name[i],time[i]);
+      }
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  private void prepareView()
     {
     mAct.runOnUiThread(new Runnable()
       {
@@ -56,35 +75,35 @@ class RubikScoresPagerAdapter extends PagerAdapter implements RubikScoresDownloa
       {
 
       }
+    }
 
-    for(int i=0; i<RubikSize.LENGTH; i++)
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  private void addPage(final int page, final int[][] country, final String[][] name, final String[][] time)
+    {
+    for(int section=0; section<RubikActivity.MAX_SCRAMBLE; section++)
       {
-      final RubikScoresView view = mViews[i];
+      final int sec = section;
+      final int[] c = country[section];
+      final String[] n = name[section];
+      final String[] t = time[section];
 
-      for(int j=0; j<RubikActivity.MAX_SCRAMBLE; j++)
+      mAct.runOnUiThread(new Runnable()
         {
-        final int scramble = j;
-        final int[] c = country[i][j];
-        final String[] n = name[i][j];
-        final String[] t = time[i][j];
-
-        mAct.runOnUiThread(new Runnable()
-          {
-          @Override
-          public void run()
-            {
-            view.addScramble(mAct, scramble, c, n, t);
-            }
-          });
-
-        try
+        @Override
+        public void run()
           {
-          Thread.sleep(50);
+          mViews[page].addSection(mAct, sec, c, n, t);
           }
-        catch( InterruptedException ie)
-          {
+        });
+
+      try
+        {
+        Thread.sleep(50);
+        }
+      catch( InterruptedException ie)
+        {
 
-          }
         }
       }
     }
@@ -112,6 +131,7 @@ class RubikScoresPagerAdapter extends PagerAdapter implements RubikScoresDownloa
     {
     mAct = act;
     mViews = new RubikScoresView[RubikSize.LENGTH];
+    mViewPager = viewPager;
 
     viewPager.setAdapter(this);
     viewPager.setOffscreenPageLimit( RubikSize.LENGTH-1 );
diff --git a/src/main/java/org/distorted/magic/RubikScoresView.java b/src/main/java/org/distorted/magic/RubikScoresView.java
index e6da84df..e7453473 100644
--- a/src/main/java/org/distorted/magic/RubikScoresView.java
+++ b/src/main/java/org/distorted/magic/RubikScoresView.java
@@ -79,7 +79,7 @@ public class RubikScoresView extends FrameLayout
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  void addScramble(FragmentActivity act, int scramble, final int[] country, final String[] name, final String[] time)
+  void addSection(FragmentActivity act, int scramble, final int[] country, final String[] name, final String[] time)
     {
     LinearLayout level = (LinearLayout)inflate(act, R.layout.level_records, null);
     TextView text = level.findViewById(R.id.levelTitle);
