Revision fb8a0bcd
Added by Leszek Koltunski 10 months ago
src/main/java/org/distorted/solverui/SolverActivity.java | ||
---|---|---|
51 | 51 |
private static final int ACTIVITY_NUMBER = 4; |
52 | 52 |
private static final float RATIO_INSET= 0.09f; |
53 | 53 |
|
54 |
private boolean mJustStarted; |
|
55 | 54 |
private static int mScreenWidth, mScreenHeight; |
56 | 55 |
private int mCurrentApiVersion; |
57 | 56 |
private int mHeightUpperBar; |
... | ... | |
69 | 68 |
setContentView(R.layout.solver); |
70 | 69 |
hideNavigationBar(); |
71 | 70 |
|
72 |
mJustStarted = true; |
|
73 | 71 |
Bundle b = getIntent().getExtras(); |
74 | 72 |
mObjectOrdinal = b!=null ? b.getInt("obj") : 0; |
75 | 73 |
mSolverOrdinal = ImplementedSolversList.getSolverOrdinal(mObjectOrdinal); |
... | ... | |
197 | 195 |
createObject(); |
198 | 196 |
|
199 | 197 |
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); |
200 |
restorePreferences(preferences,mJustStarted);
|
|
198 |
restorePreferences(preferences); |
|
201 | 199 |
ScreenList.setScreen(this); |
202 | 200 |
} |
203 | 201 |
|
... | ... | |
222 | 220 |
ScreenList.getScreen(i).getScreenClass().savePreferences(editor); |
223 | 221 |
} |
224 | 222 |
|
225 |
RubikObjectList.savePreferences(editor); |
|
226 | 223 |
ScreenList.savePreferences(editor); |
227 |
SolverSurfaceView view = findViewById(R.id.solverSurfaceView); |
|
228 |
OSInterface os = view.getInterface(); |
|
229 |
os.setEditor(editor); |
|
230 |
view.getObjectControl().savePreferences(); |
|
231 | 224 |
|
232 | 225 |
boolean success = editor.commit(); |
233 | 226 |
if( !success ) android.util.Log.e("D", "Failed to save preferences"); |
... | ... | |
235 | 228 |
|
236 | 229 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
237 | 230 |
|
238 |
private void restorePreferences(SharedPreferences preferences, boolean justStarted)
|
|
231 |
private void restorePreferences(SharedPreferences preferences) |
|
239 | 232 |
{ |
240 |
RubikObjectList.restorePreferences(this,preferences,justStarted); |
|
241 |
|
|
242 |
for (int i=0; i<ScreenList.LENGTH; i++) |
|
233 |
for( int i=0; i<ScreenList.LENGTH; i++ ) |
|
243 | 234 |
{ |
244 | 235 |
ScreenList.getScreen(i).getScreenClass().restorePreferences(preferences); |
245 | 236 |
} |
246 | 237 |
|
247 | 238 |
ScreenList.restorePreferences(preferences); |
248 |
|
|
249 |
SolverSurfaceView view = findViewById(R.id.solverSurfaceView); |
|
250 |
OSInterface os = view.getInterface(); |
|
251 |
os.setPreferences(preferences); |
|
252 |
view.getObjectControl().restorePreferences(); |
|
253 | 239 |
} |
254 | 240 |
|
255 | 241 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
321 | 307 |
SolverSurfaceView view = findViewById(R.id.solverSurfaceView); |
322 | 308 |
ObjectControl control = view.getObjectControl(); |
323 | 309 |
RubikObject object = RubikObjectList.getObject(mObjectOrdinal); |
324 |
int iconMode = TwistyObject.MODE_NORM; |
|
325 | 310 |
InputStream jsonStream = object==null ? null : object.getObjectStream(this); |
326 | 311 |
InputStream meshStream = object==null ? null : object.getMeshStream(this); |
327 | 312 |
String name = object==null ? "NULL" : object.getUpperName(); |
328 | 313 |
OSInterface os = view.getInterface(); |
329 | 314 |
InitAssets asset = new InitAssets(jsonStream,meshStream,os); |
330 |
|
|
331 |
control.changeIfDifferent(mObjectOrdinal,name,iconMode,asset); |
|
315 |
control.changeIfDifferent(mObjectOrdinal,name,TwistyObject.MODE_NORM,asset); |
|
332 | 316 |
} |
333 | 317 |
|
334 | 318 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
bugfix in SolverActivity - do not restore scramble state of an object there!