Project

General

Profile

« Previous | Next » 

Revision 4f36e418

Added by Leszek Koltunski over 4 years ago

Hopefully get rid of the most common crash in the field right now by changing the States to always create all their Views from scratch.

View differences:

src/main/java/org/distorted/states/RubikStatePattern.java
108 108
    DisplayMetrics metrics = act.getResources().getDisplayMetrics();
109 109
    final float scale = metrics.density;
110 110

  
111
    if( mPrevButton==null ) setupPrevButton(act,scale);
112
    if( mNextButton==null ) setupNextButton(act,scale);
113
    if( mMovesText ==null ) setupTextView(act,scale);
111
    setupPrevButton(act,scale);
112
    setupNextButton(act,scale);
113
    setupTextView(act,scale);
114 114

  
115 115
    setTrioState(false);
116 116

  
......
120 120
    layoutLeft.addView(mMovesText);
121 121
    layoutLeft.addView(mNextButton);
122 122

  
123
    if( mBackButton==null ) setupBackButton(act,scale);
123
    setupBackButton(act,scale);
124 124

  
125 125
    LinearLayout layoutRight = act.findViewById(R.id.mainBarRight);
126 126
    layoutRight.removeAllViews();
......
272 272

  
273 273
  public void savePreferences(SharedPreferences.Editor editor)
274 274
    {
275
    mBackButton= null;
276
    mPrevButton= null;
277
    mNextButton= null;
278
    mMovesText = null;
275

  
279 276
    }
280 277

  
281 278
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/states/RubikStatePlay.java
76 76
    LinearLayout layoutTop = act.findViewById(R.id.upperBar);
77 77
    layoutTop.removeAllViews();
78 78

  
79
    if( mObjButton   ==null ) setupObjectButton(act,scale);
79
    setupObjectButton(act,scale);
80 80
    layoutTop.addView(mObjButton);
81
    if( mLevelSpinner==null ) setupLevelSpinner(act,scale);
81
    setupLevelSpinner(act,scale);
82 82
    layoutTop.addView(mLevelSpinner);
83
    if( mPlayButton  ==null ) setupPlayButton(act,scale);
83
    setupPlayButton(act,scale);
84 84
    layoutTop.addView(mPlayButton);
85 85

  
86 86
    // BOT ////////////////////////////
87 87

  
88
    if( mSolveButton==null ) setupSolveButton(act,scale);
88
    setupSolveButton(act,scale);
89 89

  
90 90
    LinearLayout layoutLeft = act.findViewById(R.id.mainBarLeft);
91 91
    layoutLeft.removeAllViews();
92 92
    layoutLeft.addView(mSolveButton);
93 93

  
94
    if( mBackButton==null ) setupBackButton(act,scale);
94
    setupBackButton(act,scale);
95 95

  
96 96
    LinearLayout layoutRight = act.findViewById(R.id.mainBarRight);
97 97
    layoutRight.removeAllViews();
98 98
    layoutRight.addView(mBackButton);
99 99

  
100
    if( mPopup==null ) setupPopupWindow(act, scale);
100
    setupPopupWindow(act, scale);
101 101
    }
102 102

  
103 103
///////////////////////////////////////////////////////////////////////////////////////////////////
......
303 303
    editor.putInt("statePlay_object", mObject);
304 304
    editor.putInt("statePlay_size"  , mSize);
305 305

  
306
    mObjButton   = null;
307
    mBackButton  = null;
308
    mSolveButton = null;
309
    mPlayButton  = null;
310
    mLevelSpinner= null;
311

  
312 306
    if( mPopup!=null )
313 307
      {
314 308
      mPopup.dismiss();
src/main/java/org/distorted/states/RubikStateSolution.java
73 73
    layoutTop.addView(text);
74 74

  
75 75
    // BOT ////////////////////////////
76
    if( mPrevButton==null ) setupPrevButton(act,scale);
77
    if( mNextButton==null ) setupNextButton(act,scale);
78
    if( mMovesText ==null ) setupTextView(act,scale);
76
    setupPrevButton(act,scale);
77
    setupNextButton(act,scale);
78
    setupTextView(act,scale);
79 79

  
80 80
    LinearLayout layoutLeft = act.findViewById(R.id.mainBarLeft);
81 81
    layoutLeft.removeAllViews();
......
83 83
    layoutLeft.addView(mMovesText);
84 84
    layoutLeft.addView(mNextButton);
85 85

  
86
    if( mBackButton==null ) setupBackButton(act,scale);
86
    setupBackButton(act,scale);
87 87

  
88 88
    LinearLayout layoutRight = act.findViewById(R.id.mainBarRight);
89 89
    layoutRight.removeAllViews();
......
266 266

  
267 267
  public void savePreferences(SharedPreferences.Editor editor)
268 268
    {
269
    mBackButton= null;
270
    mPrevButton= null;
271
    mNextButton= null;
272
    mMovesText = null;
269

  
273 270
    }
274 271

  
275 272
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/states/RubikStateSolver.java
106 106
    for(ImageButton button: mColorButton) layoutTop.addView(button);
107 107

  
108 108
    // BOT ////////////////////////////
109
    if( mSolveButton==null ) setupSolveButton(act,scale);
109
    setupSolveButton(act,scale);
110 110

  
111 111
    LinearLayout layoutLeft = act.findViewById(R.id.mainBarLeft);
112 112
    layoutLeft.removeAllViews();
113 113
    layoutLeft.addView(mSolveButton);
114 114

  
115
    if( mBackButton==null ) setupBackButton(act,scale);
115
    setupBackButton(act,scale);
116 116

  
117 117
    LinearLayout layoutRight = act.findViewById(R.id.mainBarRight);
118 118
    layoutRight.removeAllViews();
......
252 252

  
253 253
  public void savePreferences(SharedPreferences.Editor editor)
254 254
    {
255
    mColorButton = null;
256
    mBackButton  = null;
257
    mSolveButton = null;
258

  
259 255
    editor.putInt("stateSolver_color", mCurrentColor);
260 256
    }
261 257

  
src/main/java/org/distorted/states/RubikStateSolving.java
108 108
    LinearLayout layoutLeft = act.findViewById(R.id.mainBarLeft);
109 109
    layoutLeft.removeAllViews();
110 110

  
111
    if( mPrevButton==null ) setupPrevMoveButtom(act,scale);
111
    setupPrevMoveButtom(act,scale);
112 112
    layoutLeft.addView(mPrevButton);
113 113

  
114 114
    LinearLayout layoutRight = act.findViewById(R.id.mainBarRight);
......
214 214

  
215 215
  public void savePreferences(SharedPreferences.Editor editor)
216 216
    {
217
    mPrevButton = null;
218

  
219 217
    mElapsed = System.currentTimeMillis()-mStartTime;
220 218
    editor.putLong("stateSolving_elapsed" , mElapsed);
221 219
    mScores.savePreferences(editor);

Also available in: Unified diff