commit a675474f85e2a99d39ced8956e62080c1244fbfa
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Tue Feb 11 01:10:51 2020 +0000

    Downloading High Scores: actually downloading scores!

diff --git a/src/main/java/org/distorted/magic/RubikScoresDownloader.java b/src/main/java/org/distorted/magic/RubikScoresDownloader.java
index 618e8cd6..c43cd58f 100644
--- a/src/main/java/org/distorted/magic/RubikScoresDownloader.java
+++ b/src/main/java/org/distorted/magic/RubikScoresDownloader.java
@@ -19,7 +19,6 @@
 
 package org.distorted.magic;
 
-import java.io.IOException;
 import java.io.InputStream;
 import java.net.HttpURLConnection;
 import java.net.URL;
@@ -31,6 +30,7 @@ class RubikScoresDownloader implements Runnable
   interface Receiver
     {
     void receive(String[][][][] scores);
+    void exception(String exception);
     }
 
   static final int MAX_PLACES = 12;
@@ -128,20 +128,8 @@ class RubikScoresDownloader implements Runnable
           mValues[size][level][place][1] = name;
           mValues[size][level][place][2] = realTime;
           }
-        else
-          {
-          android.util.Log.e("fillRow", "row invalid: level or place invalid: "+row);
-          }
-        }
-      else
-        {
-        android.util.Log.e("fillRow", "row invalid: size invalid: "+row);
         }
       }
-    else
-      {
-      android.util.Log.e("fillRow", "row invalid: "+row);
-      }
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -183,7 +171,7 @@ class RubikScoresDownloader implements Runnable
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  private void doDownload()
+  private boolean doDownload()
     {
     String veri = "distored";
     String name = URLencode(veri);
@@ -203,11 +191,8 @@ class RubikScoresDownloader implements Runnable
       conn.connect();
       conn.getOutputStream().flush();
 
-      InputStream is = null;
-
-      try
+      try( InputStream is = conn.getInputStream() )
         {
-        is = conn.getInputStream();
         int ch;
         StringBuilder sb = new StringBuilder();
         while( ( ch = is.read() ) != -1 )
@@ -218,112 +203,17 @@ class RubikScoresDownloader implements Runnable
         }
       catch(Exception e)
         {
-        android.util.Log.e("downloader", "biffed it getting HTTPResponse");
-        }
-      finally
-        {
-        try
-          {
-          if (is != null)
-            is.close();
-          }
-        catch (Exception e) {}
+        mReceiver.exception("biffed it getting HTTPResponse");
+        return false;
         }
       }
-    catch( IOException ioe )
-      {
-      android.util.Log.e("downloader", "IOException: "+ioe.getMessage());
-      }
-    catch( SecurityException se )
+    catch( Exception e )
       {
-      android.util.Log.e("downloader", "SecurityException: "+se.getMessage());
+      mReceiver.exception(e.getMessage());
+      return false;
       }
 
-/*
-mScores =
-
-"0 0 0 INEED7X7X7 1 rus" + "\n" +
-"0 0 1 Tilly 1 uk" + "\n" +
-"0 0 2 ARNOLD 1 rus" + "\n" +
-"0 0 3 ALBERTO 1 mex" + "\n" +
-"0 0 4 TO 1 ger" + "\n" +
-"0 1 0 INEED7X7X7 1 rus" + "\n" +
-"0 1 1 Tilly 1 uk" + "\n" +
-"0 1 2 ALBERTO 1 mex" + "\n" +
-"0 1 3 RINAT 1 rus" + "\n" +
-"0 1 4 BOOW 1 tha" + "\n" +
-"0 2 0 Neriel 3 bra" + "\n" +
-"0 2 1 NPPN 3 vie" + "\n" +
-"0 2 2 FREDRIK 4 den" + "\n" +
-"0 2 3 OHIOCUBER 4 usa" + "\n" +
-"0 2 4 S13 4 usa" + "\n" +
-"0 3 0 NIKITOS 8 rus" + "\n" +
-"0 3 1 THISNAVIS 8 usa" + "\n" +
-"0 3 2 MDR04 9 ita" + "\n" +
-"0 3 3 ROBERT04 9 unk" + "\n" +
-"0 3 4 DULCE 10 mex" + "\n" +
-"1 0 0 INEED7X7X7 1 rus" + "\n" +
-"1 0 1 Tilly 1 uk" + "\n" +
-"1 0 2 REBECCA 1 fra" + "\n" +
-"1 0 3 PRAKOBKRIT 1 tha" + "\n" +
-"1 0 4 E 1 mex" + "\n" +
-"1 1 0 BAYLEY 3 usa" + "\n" +
-"1 1 1 DEMONAIRE 3 uk" + "\n" +
-"1 1 2 UMMWT 3 ina" + "\n" +
-"1 1 3 MDR04 4 ita" + "\n" +
-"1 1 4 FREDRIK 4 den" + "\n" +
-"1 2 0 HAGER 5 egy" + "\n" +
-"1 2 1 S13 7 usa" + "\n" +
-"1 2 2 UTEK 7 ina" + "\n" +
-"1 2 3 UMMWT 7 ina" + "\n" +
-"1 2 4 210JITQU 7 ukr" + "\n" +
-"1 3 0 UTEK 16 ina" + "\n" +
-"1 3 1 LOLO766 21 fra" + "\n" +
-"1 3 2 NIKITOS 21 rus" + "\n" +
-"1 3 3 PYCUK1707 21 rus" + "\n" +
-"1 3 4 KEDAR 22 ind" + "\n" +
-"2 0 0 INEED7X7X7 1 rus" + "\n" +
-"2 0 1 HOMER0815 1 ger" + "\n" +
-"2 0 2 EIP 1 usa" + "\n" +
-"2 0 3 THEBIGBOSS 1 fra" + "\n" +
-"2 0 4 PHONG 1 vie" + "\n" +
-"2 1 0 SATERNSPY9 3 unk" + "\n" +
-"2 1 1 S13 4 usa" + "\n" +
-"2 1 2 ALSOELAN 4 usa" + "\n" +
-"2 1 3 NIKITOS 4 rus" + "\n" +
-"2 1 4 SEPIA6MIRA 4 unk" + "\n" +
-"2 2 0 STEVE123 9 irl" + "\n" +
-"2 2 1 NIKITOS 9 rus" + "\n" +
-"2 2 2 SEPIA6MIRA 9 unk" + "\n" +
-"2 2 3 INEED7X7X7 10 rus" + "\n" +
-"2 2 4 S13 10 usa" + "\n" +
-"2 3 0 NIKITOS 22 rus" + "\n" +
-"2 3 1 RUBIK123 24 lit" + "\n" +
-"2 3 2 NONAME 24 fin" + "\n" +
-"2 3 3 ABB0 26 ind" + "\n" +
-"2 3 4 NOYS 27 mex" + "\n" +
-"3 0 0 JARO 1 ger" + "\n" +
-"3 0 1 INEED7X7X7 1 rus" + "\n" +
-"3 0 2 MDR04 1 ita" + "\n" +
-"3 0 3 SAMW 1 uk" + "\n" +
-"3 0 4 MOKAI88 1 den" + "\n" +
-"3 1 0 MDR04G 3 ita" + "\n" +
-"3 1 1 INEED7X7X7 4 rus" + "\n" +
-"3 1 2 S13 4 usa" + "\n" +
-"3 1 3 KARAVAN 4 rus" + "\n" +
-"3 1 4 AWSOME897 4 usa" + "\n" +
-"3 2 0 INEED7X7X7 8 rus" + "\n" +
-"3 2 1 KARAVAN 8 rus" + "\n" +
-"3 2 2 S13 9 usa" + "\n" +
-"3 2 3 ALSOELAN 9 usa" + "\n" +
-"3 2 4 ROBERT04 9 unk" + "\n" +
-"3 3 0 NIKITOS 23 rus" + "\n" +
-"3 3 1 THISNAVIS 23 usa" + "\n" +
-"3 3 2 INEED7X7X7 24 rus" + "\n" +
-"3 3 3 RUBIK123 30 lit" + "\n" +
-"3 3 4 SKY16 31 usa";
-
- */
+    return true;
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -355,12 +245,14 @@ mScores =
 
   public void run()
     {
+    boolean success=true;
+
     try
       {
       if( gottaDownload() )
         {
         mRunning = true;
-        doDownload();
+        success = doDownload();
         fillValues();
         }
       }
@@ -370,6 +262,10 @@ mScores =
       }
 
     mRunning = false;
-    mReceiver.receive(mValues);
+
+    if( success )
+      {
+      mReceiver.receive(mValues);
+      }
     }
 }
\ No newline at end of file
diff --git a/src/main/java/org/distorted/magic/RubikScoresView.java b/src/main/java/org/distorted/magic/RubikScoresView.java
index 457ed70c..c2d9c0c5 100644
--- a/src/main/java/org/distorted/magic/RubikScoresView.java
+++ b/src/main/java/org/distorted/magic/RubikScoresView.java
@@ -65,6 +65,14 @@ public class RubikScoresView extends FrameLayout
     addView(view);
     }
 
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  void exception(final String exce)
+    {
+    TextView text = findViewById(R.id.downloading_text);
+    text.setText(exce);
+    }
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   void prepareView(FragmentActivity act, final String[][][] values)
diff --git a/src/main/java/org/distorted/magic/RubikScoresViewPager.java b/src/main/java/org/distorted/magic/RubikScoresViewPager.java
index 66d5adaa..cb22d11e 100644
--- a/src/main/java/org/distorted/magic/RubikScoresViewPager.java
+++ b/src/main/java/org/distorted/magic/RubikScoresViewPager.java
@@ -60,6 +60,23 @@ class RubikScoresViewPager extends PagerAdapter implements RubikScoresDownloader
       });
     }
 
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public void exception(final String exce)
+    {
+    mAct.runOnUiThread(new Runnable()
+      {
+      @Override
+      public void run()
+        {
+        for(int i=0; i<RubikSize.LENGTH; i++)
+          {
+          mViews[i].exception(exce);
+          }
+        }
+      });
+    }
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   @Override
