Project

General

Profile

« Previous | Next » 

Revision a15078bb

Added by Leszek Koltunski about 4 years ago

Report to Crashlytics if we fail to restore preferencees (2)

View differences:

src/main/java/org/distorted/objects/Cubit.java
188 188
      return mQuatIndex;
189 189
      }
190 190

  
191
    return -1;
192
    }
193

  
194
///////////////////////////////////////////////////////////////////////////////////////////////////
195

  
196
  int returnPreferences(SharedPreferences preferences)
197
    {
198
    String number = mOrigPosition.get0()+"_"+mOrigPosition.get1()+"_"+mOrigPosition.get2();
199
    return preferences.getInt("q_"+number, 0);
191
    return -mQuatIndex;
200 192
    }
201 193

  
202 194
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistyObject.java
109 109
  private Dynamic1D mRotationAngle;
110 110
  private Static3D mRotationAxis;
111 111
  private Static3D mObjectScale;
112
  private int[] mQuatDebug;
112 113

  
113 114
  float[] mRowChances;
114 115
  Static1D mRotationAngleStatic, mRotationAngleMiddle, mRotationAngleFinal;
......
143 144
    CUTS = getCuts(mNumLayers);
144 145
    NUM_CUTS = CUTS.length;
145 146

  
147
    mQuatDebug = new int[NUM_CUBITS];
148

  
146 149
    if( mObjectScreenRatio>MAX_SIZE_CHANGE) mObjectScreenRatio = MAX_SIZE_CHANGE;
147 150
    if( mObjectScreenRatio<MIN_SIZE_CHANGE) mObjectScreenRatio = MIN_SIZE_CHANGE;
148 151

  
......
440 443
    {
441 444
    for(int i=0; i<NUM_CUBITS; i++)
442 445
      {
443
      int index = CUBITS[i].restorePreferences(preferences);
446
      mQuatDebug[i] = CUBITS[i].restorePreferences(preferences);
444 447

  
445
      if( index<0 )
448
      if( mQuatDebug[i]<0 )
446 449
        {
447
        String debug = mList.name();
448

  
449 450
        for(int j=0; j<NUM_CUBITS; j++)
450 451
          {
451
          debug += (CUBITS[i].returnPreferences(preferences)+" ");
452 452
          CUBITS[j].modifyCurrentPosition(QUATS[0]);
453 453
          mMesh.setEffectAssociation(j, CUBITS[j].computeAssociation(),0);
454 454
          }
455

  
456
        FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
457
        crashlytics.log("failed to restore preferences: "+debug);
455
        recordQuatsState("Failed to restorePreferences");
458 456

  
459 457
        break;
460 458
        }
461 459

  
462
      mMesh.setEffectAssociation(i, CUBITS[i].computeAssociation(),index);
460
      mMesh.setEffectAssociation(i, CUBITS[i].computeAssociation(),mQuatDebug[i]);
461
      }
462
    }
463

  
464
///////////////////////////////////////////////////////////////////////////////////////////////////
465

  
466
  public void recordQuatsState(String message)
467
    {
468
    StringBuilder quats = new StringBuilder();
469

  
470
    for(int j=0; j<NUM_CUBITS; j++)
471
      {
472
      quats.append(mQuatDebug[j]);
473
      quats.append(" ");
463 474
      }
475

  
476
    Exception ex = new Exception(message);
477
    FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
478
    crashlytics.setCustomKey("quats" , quats.toString());
479
    crashlytics.setCustomKey("object", mList.name()+"_"+mNumLayers );
480
    crashlytics.recordException(ex);
464 481
    }
465 482

  
466 483
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff