Project

General

Profile

« Previous | Next » 

Revision b39f8e39

Added by Leszek Koltunski over 2 years ago

Progress with ConfigScreen.

View differences:

src/main/java/org/distorted/objectlib/json/JsonReader.java
476 476
    parseColors(colors);
477 477
    }
478 478

  
479
///////////////////////////////////////////////////////////////////////////////////////////////////
480

  
481
  private void parseVersion1Metadata(JSONObject object) throws JSONException
482
    {
483
    JSONObject metadata = object.getJSONObject("metadata");
484
    parseMetadata(metadata);
485
    }
486

  
479 487
///////////////////////////////////////////////////////////////////////////////////////////////////
480 488

  
481 489
  public void parseJsonFile(InputStream jsonStream)
......
512 520
      }
513 521
    }
514 522

  
523
///////////////////////////////////////////////////////////////////////////////////////////////////
524

  
525
  public void parseJsonFileMetadata(InputStream jsonStream)
526
    {
527
    BufferedReader br = new BufferedReader(new InputStreamReader(jsonStream, StandardCharsets.UTF_8));
528

  
529
    try
530
      {
531
      StringBuilder contents = new StringBuilder();
532
      String tmp;
533
      while( (tmp = br.readLine()) != null) contents.append(tmp);
534
      br.close();
535
      jsonStream.close();
536

  
537
      JSONObject object = new JSONObject(contents.toString());
538
      int major = object.getInt("major");
539

  
540
      if( major==1 )
541
        {
542
        parseVersion1Metadata(object);
543
        }
544
      else
545
        {
546
        android.util.Log.e("readJsonFileQuick", "Unknown version "+major);
547
        }
548
      }
549
    catch(IOException e)
550
      {
551
      android.util.Log.e("readJsonFileQuick", "Error reading JSON file: "+e.toString());
552
      }
553
    catch( JSONException e )
554
      {
555
      android.util.Log.e("parseJsonFileQuick", "Error parsing JSON file: "+e.toString());
556
      }
557
    }
558

  
515 559
///////////////////////////////////////////////////////////////////////////////////////////////////
516 560

  
517 561
  public ScrambleState[] getScrambleStates()

Also available in: Unified diff