Project

General

Profile

« Previous | Next » 

Revision 329c0aeb

Added by Leszek Koltunski about 4 years ago

Many small improvements.

View differences:

src/main/java/org/distorted/network/RubikScoresDownloader.java
24 24
import java.net.URL;
25 25
import java.net.UnknownHostException;
26 26

  
27
import org.distorted.magic.R;
28

  
29 27
import static org.distorted.object.RubikObject.LENGTH;
30 28
import static org.distorted.uistate.RubikStatePlay.MAX_SCRAMBLE;
31 29

  
......
85 83
  private static boolean mRunning = false;
86 84
  private static int mMode = IDLE;
87 85
  private static Receiver mReceiver;
88
  private static String mUserName;
86
  private static String mUserName, mVersion;
89 87
  private static int mNumRuns;
90 88

  
91 89
  private static String mScores = "";
......
93 91
  private static String[][][] mName    = new String[LENGTH][MAX_SCRAMBLE][MAX_PLACES];
94 92
  private static String[][][] mTime    = new String[LENGTH][MAX_SCRAMBLE][MAX_PLACES];
95 93

  
94
  private static int[][] mPlaces = new int[LENGTH][MAX_SCRAMBLE];
95

  
96 96
///////////////////////////////////////////////////////////////////////////////////////////////////
97 97

  
98 98
  private void fillValues()
99 99
    {
100 100
    int begin=-1 ,end, len = mScores.length();
101 101

  
102
    for(int i=0; i<LENGTH; i++)
103
      for(int j=0; j<MAX_SCRAMBLE; j++)
104
        {
105
        mPlaces[i][j] = 0;
106
        }
107

  
102 108
    while( begin<len )
103 109
      {
104 110
      end = mScores.indexOf('\n', begin+1);
......
134 140

  
135 141
        if(level>=0 && level<MAX_SCRAMBLE && place>=0 && place<MAX_PLACES)
136 142
          {
143
          int p = mPlaces[size][level];
144
          mPlaces[size][level]++;
145

  
146
          if( p!=place ) android.util.Log.e("downloader", "size="+size+" level="+level+" p="+p+" place="+place);
147

  
137 148
          mCountry[size][level][place] = country;
138 149
          mName   [size][level][place] = name;
139 150
          mTime   [size][level][place] = realTime;
......
183 194

  
184 195
  private boolean doDownload()
185 196
    {
186
    String version = R.string.app_version+"d";
187
    String message=URL+"/download.cgi?n="+URLencode(mUserName)+"&r="+mNumRuns+"&e="+version;
197
    String message=URL+"/download.cgi?n="+URLencode(mUserName)+"&r="+mNumRuns+"&e="+mVersion+"d";
188 198

  
189 199
    try
190 200
      {
......
230 240
      return false;
231 241
      }
232 242

  
243
    if( mScores.length()==0 )
244
      {
245
      mReceiver.exception("Failed to download scores");
246
      return false;
247
      }
248

  
233 249
    return true;
234 250
    }
235 251

  
......
280 296

  
281 297
///////////////////////////////////////////////////////////////////////////////////////////////////
282 298

  
283
  public void download(Receiver receiver, String userName, int numRuns)
299
  public void download(Receiver receiver, String userName, String version, int numRuns)
284 300
    {
285 301
    mReceiver = receiver;
286 302
    mMode     = DOWNLOAD;
287 303
    mUserName = userName;
304
    mVersion  = version;
288 305
    mNumRuns  = numRuns;
289 306

  
290 307
    Thread networkThrd = new Thread(this);

Also available in: Unified diff