Project

General

Profile

« Previous | Next » 

Revision 5305fdc8

Added by Leszek Koltunski almost 2 years ago

Very important bugfix for an issue which probably has been the reason for many mysterious behaviours in the past: the JsonReader class cannot be a singleton! Convert it into a normal 'instanced' class.
With it being a singleton there's a major issue: when we create a new TwistyObject from a JSON file (by, for example, going to PurchaseActivity) and then we come back to the old object (by, for example, going back to the main RubikActivity) - then the JsonReader inside the old object has read the new JSON file and thus many of the 'abstract' methods in the old TwistyObject (for example getShortName()) all of the sudden start returning new values!

View differences:

src/main/java/org/distorted/config/ConfigScreenPane.java
77 77
      InputStream stream = object.getObjectStream(act);
78 78

  
79 79
      mObjectOrdinal = objectOrdinal;
80
      JsonReader reader = JsonReader.getInstance();
80
      JsonReader reader = new JsonReader();
81 81
      String name,author;
82 82
      int year, difficulty;
83 83

  
src/main/java/org/distorted/dialogs/RubikDialogTutorialView.java
69 69
      {
70 70
      try
71 71
        {
72
        JsonReader reader = JsonReader.getInstance();
72
        JsonReader reader = new JsonReader();
73 73
        reader.parseJsonTutorial(jsonStream);
74 74
        tutorials = reader.getTutorials();
75 75
        }
src/main/java/org/distorted/dialogs/RubikDialogUpdateView.java
193 193

  
194 194
        try
195 195
          {
196
          JsonReader reader = JsonReader.getInstance();
196
          JsonReader reader = new JsonReader();
197 197
          reader.readNumScramblesAndPrice(act,objectName);
198 198
          mInfo.mNumScrambles = reader.getNumScrambles();
199 199
          mInfo.mPrice        = reader.getPrice();
src/main/java/org/distorted/helpers/MovesController.java
202 202
      if( objects.length()>0 )
203 203
        {
204 204
        String[] tokens = objects.split(" ");
205
        int length = tokens.length;
205
        int length = tokens.length/3;
206 206

  
207
        for(int m=0; m<length/3; m++)
207
        for(int m=0; m<length; m++)
208 208
          {
209 209
          String axis  = tokens[3*m  ];
210 210
          String row   = tokens[3*m+1];
src/main/java/org/distorted/main/RubikActivity.java
83 83
    public static final float DIALOG_BUTTON_SIZE  = 0.06f;
84 84
    public static final float MENU_BIG_TEXT_SIZE  = 0.05f;
85 85
    public static final float MENU_MAIN_TEXT_SIZE = 0.047f;
86
    public static final float MENU_MED_TEXT_SIZE  = 0.04f;
87 86
    public static final float MENU_SMALL_TEXT_SIZE= 0.035f;
88 87
    public static final float TAB_WIDTH           = 0.100f;
89 88
    public static final float TAB_HEIGHT          = 0.100f;
src/main/java/org/distorted/purchase/PurchaseObjectLibInterface.java
11 11

  
12 12
import com.google.firebase.crashlytics.FirebaseCrashlytics;
13 13

  
14
import org.distorted.library.message.EffectMessageSender;
15 14
import org.distorted.objectlib.BuildConfig;
16
import org.distorted.objectlib.helpers.BlockController;
17 15
import org.distorted.objectlib.helpers.ObjectLibInterface;
18 16

  
19 17
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/purchase/PurchaseScreenPane.java
187 187
    if( mObject!=null )
188 188
      {
189 189
      InputStream stream = mObject.getObjectStream(act);
190
      JsonReader reader = JsonReader.getInstance();
190
      JsonReader reader = new JsonReader();
191 191
      String author, name;
192 192
      int year, difficulty;
193 193

  
src/main/java/org/distorted/purchase/PurchaseSurfaceView.java
27 27
{
28 28
    private ObjectControl mObjectController;
29 29
    private PurchaseRenderer mRenderer;
30
    private int mScreenWidth, mScreenHeight;
31 30
    private boolean mCreated;
32 31

  
33 32
///////////////////////////////////////////////////////////////////////////////////////////////////
34 33

  
35 34
    void setScreenSize(int width, int height)
36 35
      {
37
      mScreenWidth = width;
38
      mScreenHeight= height;
39 36
      mObjectController.setScreenSize(width,height);
40 37
      mObjectController.setObjectScale(1.00f);
41 38

  
src/main/java/org/distorted/screens/RubikScreenPlay.java
656 656

  
657 657
  public void errorUpdate()
658 658
    {
659
    android.util.Log.e("D", "Screen: Error receiving update");
659
    android.util.Log.e("D", "RubikScreenPlay: Error receiving downloaded objects update");
660 660
    }
661 661
  }

Also available in: Unified diff