Improve preference, use leakcanary, start GalleryDetailScene
This commit is contained in:
1 parent
9b6815c60c
commit
2130e7a8dd
42 files changed
+1289
-386
No files matched your search
@@ -23,7 +23,9 @@ import com.hippo.util.IntIdGenerator;
|
||||
import com.hippo.util.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Stack;
|
||||
|
||||
public class SceneManager {
|
||||
@@ -39,6 +41,8 @@ public class SceneManager {
|
||||
|
||||
private List<SceneStateListener> mSceneStateListenerList = new ArrayList<>();
|
||||
|
||||
private Map<String, Object> mTransferStop = new HashMap<>();
|
||||
|
||||
private static SceneManager sSceneManger;
|
||||
|
||||
public static SceneManager getInstance() {
|
||||
@@ -100,12 +104,6 @@ public class SceneManager {
|
||||
}
|
||||
}
|
||||
|
||||
private void notifyReplace(Class clazz) {
|
||||
for (SceneStateListener l : mSceneStateListenerList) {
|
||||
l.onReplace(clazz);
|
||||
}
|
||||
}
|
||||
|
||||
Scene createSceneByClass(@NonNull Class sceneClass) {
|
||||
try {
|
||||
return (Scene) sceneClass.newInstance();
|
||||
@@ -210,7 +208,7 @@ public class SceneManager {
|
||||
// It is the last scene, just finish the activity
|
||||
mSceneStack.remove(index);
|
||||
|
||||
scene.destroy();
|
||||
scene.destroy(false);
|
||||
scene.setState(Scene.SCENE_STATE_DESTROY);
|
||||
notifyDestroy(scene.getClass());
|
||||
|
||||
@@ -229,7 +227,7 @@ public class SceneManager {
|
||||
notifyResume(previousState.getClass());
|
||||
}
|
||||
|
||||
scene.destroy();
|
||||
scene.destroy(false);
|
||||
scene.setState(Scene.SCENE_STATE_DESTROY);
|
||||
notifyDestroy(scene.getClass());
|
||||
|
||||
@@ -298,15 +296,18 @@ public class SceneManager {
|
||||
tempStack.addAll(mSceneStack);
|
||||
mSceneStack.clear();
|
||||
|
||||
Map<String, Object> transferStop = mTransferStop;
|
||||
for (Scene oldScene : tempStack) {
|
||||
Scene newScene = createSceneByClass(oldScene.getClass());
|
||||
newScene.replace(oldScene);
|
||||
notifyReplace(newScene.getClass());
|
||||
|
||||
oldScene.destroy();
|
||||
oldScene.destroy(true);
|
||||
oldScene.setState(Scene.SCENE_STATE_DESTROY);
|
||||
notifyDestroy(oldScene.getClass());
|
||||
|
||||
oldScene.save(transferStop);
|
||||
|
||||
Scene newScene = createSceneByClass(oldScene.getClass());
|
||||
|
||||
newScene.restore(transferStop);
|
||||
|
||||
newScene.create(savedInstanceState);
|
||||
newScene.setState(Scene.SCENE_STATE_CREATE);
|
||||
notifyCreate(newScene.getClass());
|
||||
@@ -315,6 +316,8 @@ public class SceneManager {
|
||||
|
||||
newScene.setState(Scene.SCENE_STATE_RUN);
|
||||
mSceneStack.push(newScene);
|
||||
|
||||
transferStop.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -323,6 +326,5 @@ public class SceneManager {
|
||||
void onDestroy(Class clazz);
|
||||
void onPause(Class clazz);
|
||||
void onResume(Class clazz);
|
||||
void onReplace(Class clazz);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user