Keep scene after Activity restart
This commit is contained in:
1 parent
588b255788
commit
5a2a5b4289
8 files changed
+75
-161
No files matched your search
@@ -33,14 +33,13 @@ import android.widget.FrameLayout;
|
||||
import com.hippo.util.AssertUtils;
|
||||
import com.hippo.util.ViewUtils;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* {@link com.hippo.scene.Scene} is a {@code Activity} of {@link android.app.Activity}.
|
||||
* <p>
|
||||
* When start a new {@code Scene}, previous {@code Scene} can stay at screen for
|
||||
* a while. Or retain for a while before destroy.
|
||||
*/
|
||||
// TODO Improve state
|
||||
public abstract class Scene {
|
||||
|
||||
public static final int LAUNCH_MODE_STANDARD = 0;
|
||||
@@ -168,8 +167,8 @@ public abstract class Scene {
|
||||
}
|
||||
|
||||
// TODO Tell destory is it need close
|
||||
void destroy(boolean willSave) {
|
||||
onDestroy(willSave);
|
||||
void destroy() {
|
||||
onDestroy();
|
||||
|
||||
SceneApplication.getRefWatcher(getStageActivity()).watch(this);
|
||||
}
|
||||
@@ -190,12 +189,8 @@ public abstract class Scene {
|
||||
onResume();
|
||||
}
|
||||
|
||||
void save(Map<String, Object> transferStop) {
|
||||
onSave(transferStop);
|
||||
}
|
||||
|
||||
void restore(Map<String, Object> transferStop) {
|
||||
onRestore(transferStop);
|
||||
void rebirth(@Nullable Bundle savedInstanceState) {
|
||||
onRebirth(savedInstanceState);
|
||||
}
|
||||
|
||||
void setFitPaddingBottom(int b) {
|
||||
@@ -249,10 +244,12 @@ public abstract class Scene {
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
protected void onDestroy(boolean willSave) {
|
||||
protected void onDestroy() {
|
||||
// Make sure soft key broad is hidden
|
||||
InputMethodManager imm = (InputMethodManager) getStageActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.hideSoftInputFromWindow(mSceneView.getWindowToken(), 0);
|
||||
if (mSceneView != null) {
|
||||
InputMethodManager imm = (InputMethodManager) getStageActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.hideSoftInputFromWindow(mSceneView.getWindowToken(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
protected void onOpen() {
|
||||
@@ -269,18 +266,9 @@ public abstract class Scene {
|
||||
getSceneView().setEnableTouch(true);
|
||||
}
|
||||
|
||||
protected void onSave(Map<String, Object> transferStop) {
|
||||
transferStop.put("scene_id", mId);
|
||||
transferStop.put("scene_announcer", mAnnouncer);
|
||||
transferStop.put("scene_curtain", mCurtain);
|
||||
}
|
||||
|
||||
protected void onRestore(Map<String, Object> transferStop) {
|
||||
mId = (Integer) transferStop.get("scene_id");
|
||||
mAnnouncer = (Announcer) transferStop.get("scene_announcer");
|
||||
mCurtain = (Curtain) transferStop.get("scene_curtain");
|
||||
protected void onRebirth(@Nullable Bundle savedInstanceState) {
|
||||
if (mCurtain != null) {
|
||||
mCurtain.onReplace();
|
||||
mCurtain.onRebirth();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user