191 |
191 |
{
|
192 |
192 |
makeProgress(50,R.string.installing);
|
193 |
193 |
RubikFiles files = RubikFiles.getInstance();
|
194 |
|
boolean oSuccess=false, eSuccess=false;
|
|
194 |
boolean oSuccess, eSuccess=false;
|
195 |
195 |
|
196 |
196 |
if( mInfo.mObjectStream!=null )
|
197 |
197 |
{
|
198 |
|
String name = mInfo.mObjectShortName + "_object.json";
|
|
198 |
String objectName = mInfo.mObjectShortName + "_object.json";
|
199 |
199 |
Activity act = mAct.get();
|
200 |
|
oSuccess = files.saveFile(act,mInfo.mObjectStream, name);
|
|
200 |
oSuccess = files.saveFile(act,mInfo.mObjectStream, objectName);
|
201 |
201 |
|
202 |
|
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "Saving JSON "+name+" to a file "+oSuccess);
|
|
202 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "Saving JSON "+objectName+" to a file "+oSuccess);
|
203 |
203 |
|
204 |
204 |
try
|
205 |
205 |
{
|
206 |
206 |
JsonReader reader = JsonReader.getInstance();
|
207 |
|
mInfo.mNumScrambles = reader.readNumScrambles(act,name);
|
|
207 |
mInfo.mNumScrambles = reader.readNumScrambles(act,objectName);
|
208 |
208 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "Read from JSON numScrambles="+mInfo.mNumScrambles);
|
209 |
|
}
|
210 |
|
catch(Exception ex)
|
211 |
|
{
|
212 |
|
mInfo.mNumScrambles = 25;
|
213 |
|
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "Error reading numScrambles");
|
214 |
|
}
|
215 |
|
}
|
216 |
209 |
|
217 |
|
if( mInfo.mExtrasStream!=null )
|
218 |
|
{
|
219 |
|
String name = mInfo.mObjectShortName + "_extras.json";
|
220 |
|
Activity act = mAct.get();
|
221 |
|
eSuccess = files.saveFile(act,mInfo.mExtrasStream, name);
|
|
210 |
if( mInfo.mExtrasStream!=null )
|
|
211 |
{
|
|
212 |
String name = mInfo.mObjectShortName + "_extras.json";
|
|
213 |
eSuccess = files.saveFile(act,mInfo.mExtrasStream, name);
|
222 |
214 |
|
223 |
|
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "Saving Extras "+name+" to a file "+eSuccess);
|
224 |
|
}
|
|
215 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "Saving Extras "+name+" to a file "+eSuccess);
|
|
216 |
}
|
225 |
217 |
|
226 |
|
if( mIconSaved || oSuccess || eSuccess )
|
227 |
|
{
|
228 |
|
makeProgress(75,R.string.configuring);
|
|
218 |
if( mIconSaved || oSuccess || eSuccess )
|
|
219 |
{
|
|
220 |
makeProgress(75,R.string.configuring);
|
229 |
221 |
|
230 |
|
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "1");
|
|
222 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "1");
|
231 |
223 |
|
232 |
|
Activity act = mAct.get();
|
233 |
|
RubikObjectList.addDownloadedObject(act, mInfo.mObjectShortName,mInfo.mNumScrambles, mInfo.mObjectMinorVersion,
|
234 |
|
mInfo.mExtrasMinorVersion, mIconSaved, oSuccess, eSuccess);
|
|
224 |
RubikObjectList.addDownloadedObject(act, mInfo.mObjectShortName,mInfo.mNumScrambles, mInfo.mObjectMinorVersion,
|
|
225 |
mInfo.mExtrasMinorVersion, mIconSaved, oSuccess, eSuccess);
|
235 |
226 |
|
236 |
|
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "2");
|
|
227 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "2");
|
237 |
228 |
|
238 |
|
RubikNetwork network = RubikNetwork.getInstance();
|
239 |
|
network.updateDone(mInfo.mObjectShortName);
|
|
229 |
RubikNetwork network = RubikNetwork.getInstance();
|
|
230 |
network.updateDone(mInfo.mObjectShortName);
|
240 |
231 |
|
241 |
|
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "3");
|
|
232 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "3");
|
242 |
233 |
|
243 |
|
RubikScreenPlay play = (RubikScreenPlay)ScreenList.PLAY.getScreenClass();
|
244 |
|
play.recreatePopup();
|
|
234 |
RubikScreenPlay play = (RubikScreenPlay)ScreenList.PLAY.getScreenClass();
|
|
235 |
play.recreatePopup();
|
245 |
236 |
|
246 |
|
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "4");
|
|
237 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "4");
|
247 |
238 |
|
248 |
|
makeProgress(100,R.string.success);
|
|
239 |
makeProgress(100,R.string.success);
|
249 |
240 |
|
250 |
|
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "5");
|
251 |
|
}
|
252 |
|
else
|
253 |
|
{
|
254 |
|
displayError(R.string.saveError);
|
|
241 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "5");
|
|
242 |
}
|
|
243 |
else
|
|
244 |
{
|
|
245 |
displayError(R.string.saveError);
|
|
246 |
}
|
|
247 |
}
|
|
248 |
catch(Exception ex)
|
|
249 |
{
|
|
250 |
displayError(R.string.saveError);
|
|
251 |
files.deleteJsonObject(act,objectName);
|
|
252 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "Error reading numScrambles");
|
|
253 |
}
|
255 |
254 |
}
|
256 |
255 |
}
|
257 |
256 |
}
|
- we need to export the main activity
- we need to detect if the downloaded JSON is corrupt and if yes, do not save it.