public static Bundle read( byte[] bytes ) { try { JSONObject json = (JSONObject)new JSONTokener( new String( bytes ) ).nextValue(); return new Bundle( json ); } catch (JSONException e) { return null; } }
public Collection<Bundlable> getCollection( String key ) { ArrayList<Bundlable> list = new ArrayList<Bundlable>(); try { JSONArray array = data.getJSONArray( key ); for (int i=0; i < array.length(); i++) { list.add( new Bundle( array.getJSONObject( i ) ).get() ); } } catch (JSONException e) { } return list; }
public static Bundle read( byte[] bytes ) { try { JSONObject json = (JSONObject)new JSONTokener( new String( bytes ) ).nextValue(); return new Bundle( json ); } catch (JSONException e) { return null; } }
public void put( String key, Bundlable object ) { if (object != null) { try { Bundle bundle = new Bundle(); bundle.put( CLASS_NAME, object.getClass().getName() ); object.storeInBundle( bundle ); data.put( key, bundle.data ); } catch (JSONException e) { } } }
public void put( String key, Bundlable object ) { if (object != null) { try { Bundle bundle = new Bundle(); bundle.put( CLASS_NAME, object.getClass().getName() ); object.storeInBundle( bundle ); data.put( key, bundle.data ); } catch (JSONException e) { Game.reportException(e); } } }
public void put( String key, Bundlable object ) { if (object != null) { try { Bundle bundle = new Bundle(); bundle.put( CLASS_NAME, object.getClass().getName() ); object.storeInBundle( bundle ); data.put( key, bundle.data ); } catch (JSONException e) { Game.reportException(e); } } }
public static void saveLevel( int save ) throws IOException { Bundle bundle = new Bundle(); bundle.put( LEVEL, level ); FileUtils.bundleToFile(GamesInProgress.depthFile( save, depth), bundle); }
public static void saveLevel( int save ) throws IOException { Bundle bundle = new Bundle(); bundle.put( LEVEL, level ); FileUtils.bundleToFile(GamesInProgress.depthFile( save, depth), bundle); }
public static void saveGlobal() { if (saveNeeded) { Bundle bundle = new Bundle(); store( bundle, global ); try { FileUtils.bundleToFile(BADGES_FILE, bundle); saveNeeded = false; } catch (IOException e) { ShatteredPixelDungeon.reportException(e); } } }
public static void saveGlobal() { if (saveNeeded) { Bundle bundle = new Bundle(); store( bundle, global ); try { FileUtils.bundleToFile(BADGES_FILE, bundle); saveNeeded = false; } catch (IOException e) { ShatteredPixelDungeon.reportException(e); } } }
public static void saveLevel() throws IOException { Bundle bundle = new Bundle(); bundle.put( LEVEL, level ); OutputStream output = Game.instance.openFileOutput( Utils.format( depthFile( hero.heroClass ), depth ), Game.MODE_PRIVATE ); Bundle.write( bundle, output ); output.close(); }
public void save() { Bundle bundle = new Bundle(); bundle.put( RECORDS, records ); bundle.put( LATEST, lastRecord ); bundle.put( TOTAL, totalNumber ); bundle.put( WON, wonNumber ); try { FileUtils.bundleToFile( RANKINGS_FILE, bundle); } catch (IOException e) { ShatteredPixelDungeon.reportException(e); } }
public static void storeInBundle( Bundle bundle ) { Bundle node = new Bundle(); node.put( SPAWNED, spawned ); if (spawned) { node.put( ALTERNATIVE, alternative ); node.put( GIVEN, given ); node.put( COMPLETED, completed ); node.put( REFORGED, reforged ); } bundle.put( NODE, node ); }
public static void storeInBundle( Bundle bundle ) { Bundle node = new Bundle(); node.put( SPAWNED, spawned ); if (spawned) { node.put( ALTERNATIVE, alternative ); node.put( GIVEN, given ); node.put( COMPLETED, completed ); node.put( REWARD, reward ); } bundle.put( NODE, node ); }
public void save() { Bundle bundle = new Bundle(); bundle.put( RECORDS, records ); bundle.put( LATEST, lastRecord ); bundle.put( TOTAL, totalNumber ); bundle.put( WON, wonNumber ); try { FileUtils.bundleToFile( RANKINGS_FILE, bundle); } catch (IOException e) { ShatteredPixelDungeon.reportException(e); } }
public static void storeInBundle( Bundle bundle ) { Bundle node = new Bundle(); node.put( SPAWNED, spawned ); if (spawned) { node.put( ALTERNATIVE, alternative ); node.put( GIVEN, given ); node.put( COMPLETED, completed ); node.put( REWARD, reward ); } bundle.put( NODE, node ); }
public static void storeInBundle( Bundle bundle ) { Bundle node = new Bundle(); node.put( SPAWNED, spawned ); if (spawned) { node.put( ALTERNATIVE, alternative ); node.put( GIVEN, given ); node.put( COMPLETED, completed ); node.put( REWARD, reward ); } bundle.put( NODE, node ); }
public static void storeInBundle( Bundle bundle ) { Bundle node = new Bundle(); node.put( SPAWNED, spawned ); if (spawned) { node.put( ALTERNATIVE, alternative ); node.put( GIVEN, given ); node.put( COMPLETED, completed ); node.put( REFORGED, reforged ); } bundle.put( NODE, node ); }
public static void storeInBundle( Bundle bundle ) { Bundle node = new Bundle(); node.put( SPAWNED, spawned ); if (spawned) { node.put( ALTERNATIVE, alternative ); node.put( GIVEN, given ); node.put( COMPLETED, completed ); node.put( REFORGED, reforged ); } bundle.put( NODE, node ); }
public static void storeInBundle( Bundle bundle ) { Bundle node = new Bundle(); node.put( SPAWNED, spawned ); if (spawned) { node.put( ALTERNATIVE, alternative ); node.put( COMPLETED, completed ); node.put(GIVEN, given ); node.put( WAND1, wand1 ); node.put( WAND2, wand2 ); } bundle.put( NODE, node ); }