Revision 5bfc1b49
Added by Leszek Koltunski almost 5 years ago
src/main/java/org/distorted/magic/RubikRenderer.java | ||
---|---|---|
58 | 58 |
private RubikCube mOldCube, mNewCube; |
59 | 59 |
private int mScreenWidth, mScreenHeight; |
60 | 60 |
private MeshFlat mMesh; |
61 |
private SharedPreferences mPreferences; |
|
61 | 62 |
|
62 | 63 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
63 | 64 |
|
... | ... | |
97 | 98 |
|
98 | 99 |
private void createCubeNow(int newSize) |
99 | 100 |
{ |
101 |
boolean firstTime = (mOldCube==null && mNewCube==null); |
|
102 |
|
|
100 | 103 |
if( mOldCube!=null ) mOldCube.releaseResources(); |
101 | 104 |
mOldCube = mNewCube; |
102 | 105 |
|
... | ... | |
105 | 108 |
|
106 | 109 |
mNewCube = new RubikCube(newSize, mView.getQuatCurrent(), mView.getQuatAccumulated(), texture, mMesh, effects); |
107 | 110 |
mNewCube.createTexture(); |
111 |
if( firstTime ) mNewCube.restorePreferences(mPreferences); |
|
108 | 112 |
|
109 | 113 |
if( mScreenWidth!=0 ) |
110 | 114 |
{ |
... | ... | |
139 | 143 |
|
140 | 144 |
void savePreferences(SharedPreferences.Editor editor) |
141 | 145 |
{ |
142 |
android.util.Log.e("renderer", "saving prefs"); |
|
143 |
|
|
144 |
//editor.putInt("state", mCurrentState.ordinal() ); |
|
146 |
mNewCube.savePreferences(editor); |
|
145 | 147 |
} |
146 | 148 |
|
147 | 149 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
148 | 150 |
|
149 | 151 |
void restorePreferences(SharedPreferences preferences) |
150 | 152 |
{ |
151 |
android.util.Log.e("renderer", "restoring prefs"); |
|
152 |
|
|
153 |
//int stateOrdinal = preferences.getInt("state", RubikState.MAIN.ordinal() ); |
|
153 |
mPreferences = preferences; |
|
154 | 154 |
} |
155 | 155 |
|
156 | 156 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/object/RubikCube.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.object; |
21 | 21 |
|
22 |
import android.content.SharedPreferences; |
|
22 | 23 |
import android.graphics.Bitmap; |
23 | 24 |
import android.graphics.Canvas; |
24 | 25 |
import android.graphics.Paint; |
... | ... | |
371 | 372 |
return mQuatAccumulated; |
372 | 373 |
} |
373 | 374 |
|
375 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
376 |
|
|
377 |
public void savePreferences(SharedPreferences.Editor editor) |
|
378 |
{ |
|
379 |
android.util.Log.e("cube", "saving Preferences"); |
|
380 |
} |
|
381 |
|
|
382 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
383 |
|
|
384 |
public void restorePreferences(SharedPreferences preferences) |
|
385 |
{ |
|
386 |
android.util.Log.e("cube", "restoring Preferences"); |
|
387 |
} |
|
388 |
|
|
374 | 389 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
375 | 390 |
|
376 | 391 |
public long finishRotationNow(EffectListener listener) |
Also available in: Unified diff
Progress with saving Cube state