Update Scene
This commit is contained in:
1 parent
e2d16df66a
commit
29f003724b
2 files changed
+28
-13
No files matched your search
@@ -260,15 +260,24 @@ public abstract class Scene {
|
||||
}
|
||||
|
||||
public void onBackPressed() {
|
||||
// TODO First click to show finish animation, click again to finish the animation at once and it is finished
|
||||
|
||||
if (mCurtain != null && mCurtain.isInAnimation()) {
|
||||
mCurtain.endAnimation();
|
||||
} else if (!sSceneManager.endLegacyScene()) {
|
||||
if (!endCurtainAnimation() && !sSceneManager.endLegacyScene()) {
|
||||
sSceneManager.finishScene(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* End curtainAnimation if it is running
|
||||
*
|
||||
* @return True if curtain animation is running
|
||||
*/
|
||||
boolean endCurtainAnimation() {
|
||||
if (mCurtain != null && mCurtain.isInAnimation()) {
|
||||
mCurtain.endAnimation();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void openFinished() {
|
||||
open();
|
||||
setState(Scene.SCENE_STATE_RUN);
|
||||
@@ -276,6 +285,8 @@ public abstract class Scene {
|
||||
|
||||
void closeFinished() {
|
||||
sSceneManager.removeLegacyScene(this);
|
||||
|
||||
close();
|
||||
setState(Scene.SCENE_STATE_DESTROY);
|
||||
detachFromeStage();
|
||||
}
|
||||
|
||||
@@ -84,16 +84,17 @@ class SceneManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* End legacy scene close animation at once
|
||||
*
|
||||
* @return True if legacy scene exist and its curtain animation is running
|
||||
*/
|
||||
boolean endLegacyScene() {
|
||||
if (mLegacyScene != null) {
|
||||
Curtain curtain = mLegacyScene.getCurtain();
|
||||
if (curtain != null && curtain.isInAnimation()) {
|
||||
curtain.endAnimation();
|
||||
mLegacyScene = null;
|
||||
return true;
|
||||
}
|
||||
boolean result = mLegacyScene.endCurtainAnimation();
|
||||
mLegacyScene = null;
|
||||
return result;
|
||||
}
|
||||
mLegacyScene = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -103,6 +104,7 @@ class SceneManager {
|
||||
|
||||
endLegacyScene();
|
||||
|
||||
// Scene state might be SCENE_STATE_RUN, SCENE_STATE_OPEN, SCENE_STATE_PAUSE
|
||||
if (index == 0) {
|
||||
// It is the last scene, just finish the activity
|
||||
mSceneStack.remove(index);
|
||||
@@ -111,9 +113,12 @@ class SceneManager {
|
||||
getStageActivity().finish();
|
||||
} else {
|
||||
// TODO check scene state
|
||||
|
||||
mSceneStack.remove(index);
|
||||
Scene previousState = getTopState();
|
||||
|
||||
// If Scene is CLOSE
|
||||
|
||||
if (previousState != null) {
|
||||
previousState.resume();
|
||||
scene.setState(Scene.SCENE_STATE_RUN);
|
||||
@@ -153,7 +158,6 @@ class SceneManager {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// TODO What if this scene is closing
|
||||
boolean onBackPressed() {
|
||||
Scene scene = getTopState();
|
||||
if (scene != null) {
|
||||
|
||||
Reference in new issue
Block a user