getSceneView return NonNull
This commit is contained in:
1 parent
416d5ed588
commit
8c13d08360
4 files changed
+7
-24
No files matched your search
@@ -105,11 +105,10 @@ public abstract class Scene {
|
||||
}
|
||||
|
||||
/**
|
||||
* You will get null before onCreate and after onDestroy mostly
|
||||
*
|
||||
* @return Null or nonull
|
||||
* Must call it after onCreate and before onDestroy
|
||||
*/
|
||||
public @Nullable SceneView getSceneView() {
|
||||
public @NonNull SceneView getSceneView() {
|
||||
AssertUtils.assertNotNull("Must call it after onCreate and before onDestroy", mSceneView);
|
||||
return mSceneView;
|
||||
}
|
||||
|
||||
@@ -203,7 +202,7 @@ public abstract class Scene {
|
||||
public void setBackgroundColor(int bgColor) {
|
||||
if (mBackgroundColor != bgColor) {
|
||||
mBackgroundColor = bgColor;
|
||||
View sceneView = getSceneView();
|
||||
View sceneView = mSceneView;
|
||||
if (sceneView != null) {
|
||||
sceneView.setBackgroundColor(bgColor);
|
||||
}
|
||||
@@ -284,7 +283,7 @@ public abstract class Scene {
|
||||
* @return The view if found or null otherwise.
|
||||
*/
|
||||
public View findViewById(int resId) {
|
||||
View sceneView = getSceneView();
|
||||
View sceneView = mSceneView;
|
||||
if (sceneView != null) {
|
||||
return sceneView.findViewById(resId);
|
||||
} else {
|
||||
|
||||
@@ -24,7 +24,6 @@ import android.view.ViewTreeObserver;
|
||||
|
||||
import com.hippo.animation.SimpleAnimatorListener;
|
||||
import com.hippo.util.AnimationUtils;
|
||||
import com.hippo.util.AssertUtils;
|
||||
import com.hippo.util.ViewUtils;
|
||||
|
||||
public class SimpleCurtain extends Curtain {
|
||||
@@ -47,8 +46,6 @@ public class SimpleCurtain extends Curtain {
|
||||
@Override
|
||||
public void open(@NonNull final Scene enter, @NonNull final Scene exit) {
|
||||
final View enterSceneView = enter.getSceneView();
|
||||
AssertUtils.assertNotNull("Enter scene view must not be null.", enterSceneView);
|
||||
|
||||
ViewUtils.setVisibility(enterSceneView, View.INVISIBLE);
|
||||
|
||||
enterSceneView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@@ -109,8 +106,6 @@ public class SimpleCurtain extends Curtain {
|
||||
showSceneOnClose(enter);
|
||||
|
||||
final View exitSceneView = exit.getSceneView();
|
||||
AssertUtils.assertNotNull("Exit scene view must not be null.", exitSceneView);
|
||||
|
||||
int width = exitSceneView.getWidth();
|
||||
int height = exitSceneView.getHeight();
|
||||
float translationX = 0f;
|
||||
|
||||
@@ -70,16 +70,12 @@ public abstract class StageActivity extends StatsActivity {
|
||||
|
||||
void attachSceneToStage(Scene scene) {
|
||||
View sceneView = scene.getSceneView();
|
||||
if (sceneView != null) {
|
||||
getStageLayout().addView(sceneView);
|
||||
}
|
||||
getStageLayout().addView(sceneView);
|
||||
}
|
||||
|
||||
void detachSceneFromStage(Scene scene) {
|
||||
View sceneView = scene.getSceneView();
|
||||
if (sceneView != null) {
|
||||
getStageLayout().removeView(sceneView);
|
||||
}
|
||||
getStageLayout().removeView(sceneView);
|
||||
}
|
||||
|
||||
public void startScene(@NonNull Class sceneClass) {
|
||||
|
||||
@@ -29,7 +29,6 @@ import android.widget.AbsoluteLayout;
|
||||
|
||||
import com.hippo.animation.ArgbEvaluator;
|
||||
import com.hippo.animation.SimpleAnimatorListener;
|
||||
import com.hippo.util.AssertUtils;
|
||||
import com.hippo.util.Log;
|
||||
import com.hippo.util.ViewUtils;
|
||||
import com.hippo.widget.GlobalLayoutSet;
|
||||
@@ -122,8 +121,6 @@ public class TransitionCurtain extends Curtain {
|
||||
Set<TransitionItem> transitionItemSet = mTransitionItemSet;
|
||||
|
||||
ViewGroup enterSceneView = mEnterScene.getSceneView();
|
||||
AssertUtils.assertNotNull("Enter scene view must not be null.", enterSceneView);
|
||||
|
||||
GlobalLayoutSet globalLayoutSet = new GlobalLayoutSet();
|
||||
|
||||
for (TransitionItem item : transitionItemSet) {
|
||||
@@ -214,7 +211,6 @@ public class TransitionCurtain extends Curtain {
|
||||
ViewUtils.setVisibility(item.exitView, View.VISIBLE);
|
||||
|
||||
ViewGroup enterSceneView = mEnterScene.getSceneView();
|
||||
AssertUtils.assertNotNull("Enter scene view must not be null.", enterSceneView);
|
||||
enterSceneView.removeView(item.bmpView);
|
||||
|
||||
item.bmp.recycle();
|
||||
@@ -294,8 +290,6 @@ public class TransitionCurtain extends Curtain {
|
||||
Set<TransitionItem> transitionItemSet = mTransitionItemSet;
|
||||
|
||||
ViewGroup exitSceneView = mExitScene.getSceneView();
|
||||
AssertUtils.assertNotNull("Exit scene view must not be null.", exitSceneView);
|
||||
|
||||
GlobalLayoutSet globalLayoutSet = new GlobalLayoutSet();
|
||||
|
||||
for (TransitionItem item : transitionItemSet) {
|
||||
@@ -385,7 +379,6 @@ public class TransitionCurtain extends Curtain {
|
||||
ViewUtils.setVisibility(item.exitView, View.VISIBLE);
|
||||
|
||||
ViewGroup exitSceneView = mExitScene.getSceneView();
|
||||
AssertUtils.assertNotNull("Exit scene view must not be null.", exitSceneView);
|
||||
exitSceneView.removeView(item.bmpView);
|
||||
|
||||
item.bmp.recycle();
|
||||
|
||||
Reference in new issue
Block a user