@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_customized_transition); ViewGroup container = (ViewGroup) findViewById(R.id.container); scenes = new Scene[]{ Scene.getSceneForLayout(container, R.layout.activity_customized_transition_scene1, this), Scene.getSceneForLayout(container, R.layout.activity_customized_transition_scene2, this), }; container.setOnClickListener(this); transition = new CircleViewTransition(); }
private Scene buildScene(ViewGroup sceneRoot, final TransitionLayout layout) { final Scene scene = new Scene(sceneRoot, (View) layout); scene.setEnterAction(new Runnable() { @Override public void run() { boolean wasEmptyScene = (mCurrentScene == mEmptyScene); setCurrentScene(scene, (ViewGroup) layout); layout.onEnterAction(wasEmptyScene); } }); scene.setExitAction(new Runnable() { @Override public void run() { removeAllViewsFromOverlay(); layout.onExitAction(); } }); return scene; }
public Scene getContentScene() { if (mPlugins.isEmpty()) { return getOriginal().super_getContentScene(); } final ListIterator<ActivityPlugin> iterator = mPlugins.listIterator(mPlugins.size()); final CallFun0<Scene> superCall = new CallFun0<Scene>("getContentScene()") { @Override public Scene call() { if (iterator.hasPrevious()) { return iterator.previous().getContentScene(this); } else { return getOriginal().super_getContentScene(); } } }; return superCall.call(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); mSceneRoot = (ViewGroup) findViewById(R.id.scene_root); mScene1 = Scene.getSceneForLayout(mSceneRoot, R.layout.scene1, this); mScene2 = Scene.getSceneForLayout(mSceneRoot, R.layout.scene2, this); mTransition = new ChangeBounds(); mTransition.setDuration(DateUtils.SECOND_IN_MILLIS); mTransition.setInterpolator(new AccelerateDecelerateInterpolator()); TransitionManager.go(mScene1); mCurrentScene = mScene1; findViewById(R.id.button).setOnClickListener(this); }
@Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_initialize, container, false); if (Is.greaterThanOrEqual(MARSHMALLOW)) { view.findViewById(R.id.tutorial_accept) .setOnClickListener(this); ViewGroup sceneRoot = (ViewGroup) view.findViewById(R.id.scene_root); sceneComplete = Scene.getSceneForLayout(sceneRoot, R.layout.scene_finished, getContext()); if (hasPermissions()) { sceneComplete.enter(); } } else { view.findViewById(R.id.tutorial_done) .setOnClickListener(this); } return view; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.transition); mSceneRoot = (ViewGroup) findViewById(R.id.sceneRoot); TransitionInflater inflater = TransitionInflater.from(this); // Note that this is not the only way to create a Scene object, but that // loading them from layout resources cooperates with the // TransitionManager that we are also loading from resources, and which // uses the same layout resource files to determine the scenes to transition // from/to. mScene1 = Scene.getSceneForLayout(mSceneRoot, R.layout.transition_scene1, this); mScene2 = Scene.getSceneForLayout(mSceneRoot, R.layout.transition_scene2, this); mScene3 = Scene.getSceneForLayout(mSceneRoot, R.layout.transition_scene3, this); mTransitionManager = inflater.inflateTransitionManager(R.transition.transitions_mgr, mSceneRoot); }
@Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_scenes, container, false); RadioGroup radioGroup = (RadioGroup) view.findViewById(R.id.select_scene); radioGroup.setOnCheckedChangeListener(this); mSceneRoot = (ViewGroup) view.findViewById(R.id.scene_root); // A Scene can be instantiated from a live view hierarchy. mScene1 = new Scene(mSceneRoot, mSceneRoot.findViewById(R.id.container)); // You can also inflate a generate a Scene from a layout resource file. mScene2 = Scene.getSceneForLayout(mSceneRoot, R.layout.scene2, getContext()); // Another scene from a layout resource file. mScene3 = Scene.getSceneForLayout(mSceneRoot, R.layout.scene3, getContext()); // We create a custom TransitionManager for Scene 3, in which ChangeBounds, Fade and // ChangeImageTransform take place at the same time. mTransitionManagerForScene3 = TransitionInflater.from(getContext()).inflateTransitionManager(R.anim.scene3_transition_manager, mSceneRoot); return view; }
/** * 共享元素 */ private void changeToConfirmScene() { final LayoutOrderConfirmationBinding confBinding = prepareConfirmationBinding(); final Scene scene = new Scene(binding.content, ((ViewGroup) confBinding.getRoot())); scene.setEnterAction(onEnterConfirmScene(confBinding)); final Transition transition = TransitionInflater.from(getContext()) .inflateTransition(R.transition.transition_confirmation_view); TransitionManager.go(scene, transition); }
private void setupViews() { stepButtons = new Button[4]; scenes = new Scene[4]; ViewGroup root = (ViewGroup) findViewById(R.id.scene_container); stepButtons[0] = (Button) findViewById(R.id.step1); stepButtons[1] = (Button) findViewById(R.id.step2); stepButtons[2] = (Button) findViewById(R.id.step3); stepButtons[3] = (Button) findViewById(R.id.step4); for (int i = 0; i < stepButtons.length; i++) { Button button = stepButtons[i]; final int sceneNumber = i; button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { transitionTo(sceneNumber); } }); } scenes[0] = Scene.getSceneForLayout(root, R.layout.activity_scene_scene1, this); scenes[1] = Scene.getSceneForLayout(root, R.layout.activity_scene_scene2, this); scenes[2] = Scene.getSceneForLayout(root, R.layout.activity_scene_scene3, this); scenes[3] = Scene.getSceneForLayout(root, R.layout.activity_scene_scene4, this); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_transition_manager); radioGroup = (RadioGroup) findViewById(R.id.select_scene); radioGroup.setOnCheckedChangeListener(this); scene1Button = (RadioButton) findViewById(R.id.select_scene_1); scene2Button = (RadioButton) findViewById(R.id.select_scene_2); scene3Button = (RadioButton) findViewById(R.id.select_scene_3); sceneRootView = (ViewGroup) findViewById(R.id.scene_root); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { scenes[0] = new Scene(sceneRootView, findViewById(R.id.container)); } else { scenes[0] = new Scene(sceneRootView, (ViewGroup) findViewById(R.id.container)); } scenes[1] = Scene.getSceneForLayout(sceneRootView, R.layout.activity_transition_manager_scene2, this); scenes[1].setExitAction(new Runnable() { @Override public void run() { setTitle("Leave scene 2"); } }); scenes[2] = Scene.getSceneForLayout(sceneRootView, R.layout.activity_transition_manager_scene3, this); scenes[2].setEnterAction(new Runnable() { @Override public void run() { setTitle("Now showing scene3"); } }); scene3TransitionManager = TransitionInflater.from(this).inflateTransitionManager(R.transition.transition_manager_scene3, sceneRootView); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_live_demo); ViewGroup container = (ViewGroup) findViewById(R.id.container); scenes = new Scene[] { Scene.getSceneForLayout(container, R.layout.activity_live_scene1, this), Scene.getSceneForLayout(container, R.layout.activity_live_scene2, this), }; setupViews(); }
/** * Returns the type of the given scene. */ @SceneType public int getSceneType(Scene scene) { if (scene == mChannelBannerScene) { return SCENE_TYPE_CHANNEL_BANNER; } else if (scene == mInputBannerScene) { return SCENE_TYPE_INPUT_BANNER; } else if (scene == mKeypadChannelSwitchScene) { return SCENE_TYPE_KEYPAD_CHANNEL_SWITCH; } else if (scene == mSelectInputScene) { return SCENE_TYPE_SELECT_INPUT; } return SCENE_TYPE_EMPTY; }
private void setCurrentScene(Scene scene, ViewGroup sceneView) { if (mListener != null) { mListener.onSceneChanged(getSceneType(mCurrentScene), getSceneType(scene)); } mCurrentScene = scene; mCurrentSceneView = sceneView; // TODO: Is this a still valid call? mMainActivity.updateKeyInputFocus(); }
@Nullable @Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.fragment_search, container, false); mSceneRoot = (ViewGroup) view.findViewById(R.id.sceneRoot); mSceneMessage = new Scene(mSceneRoot, mSceneRoot.findViewById(R.id.container)); mSceneResults = Scene.getSceneForLayout(mSceneRoot, R.layout.fragment_search_results, getActivity()); return view; }
private void goToScene(@NonNull final Scene scene) { if (mSceneCurrent != scene) { mSceneCurrent = scene; if (mListView != null) { mListView.clearOnScrollListeners(); } TransitionManager.go(scene, mDefaultTransition); } }
private void transitionTo(Scene scene) { if (scene != mCurrent) { boolean mustRebind = mCurrent != null; mCurrent = scene; mTransitionManager.transitionTo(scene); if (mustRebind) { unbind(); bindViews(); } } }
@TargetApi(19) @Override public void onAnimationEnd(Animation animation) { // This method is called at the end of the animation for the fragment transaction, // which is perfect time to start our Transition. Log.i(TAG, "Fragment animation ended. Starting a Transition."); final Scene scene = Scene.getSceneForLayout((ViewGroup) getView(), R.layout.fragment_detail_content, getActivity()); TransitionManager.go(scene); // Note that we need to bind views with data after we call TransitionManager.go(). bind(scene.getSceneRoot()); }
public SceneCompat(ViewGroup parent, ViewGroup view) { if (Device.hasKitKatApi()) { mScene = new Scene(parent, view); } mParent = parent; mView = view; }
@Override public void onAnimationEnd(Animation animation) { // This method is called at the end of the animation for the fragment transaction, // which is perfect time to start our Transition. Log.i(TAG, "Fragment animation ended. Starting a Transition."); final Scene scene = Scene.getSceneForLayout((ViewGroup) getView(), R.layout.fragment_detail_content, getActivity()); TransitionManager.go(scene); // Note that we need to bind views with data after we call TransitionManager.go(). bind(scene.getSceneRoot()); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_activity); container = (ViewGroup) findViewById(R.id.main_container); webSiteForm = Scene.getSceneForLayout(container, R.layout.scene_link, this); pictureForm = Scene.getSceneForLayout(container, R.layout.scene_picture, this); contactForm = Scene.getSceneForLayout(container, R.layout.scene_contact, this); eventForm = Scene.getSceneForLayout(container, R.layout.scene_event, this); }
@RequiresApi(api = Build.VERSION_CODES.KITKAT) @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_transition); radioGroup.setOnCheckedChangeListener(this); // A Scene can be instantiated from a live view hierarchy. mScene1 = new Scene(sceneRoot, (ViewGroup) sceneRoot.findViewById(R.id.container)); // You can also inflate a generate a Scene from a layout resource file. mScene2 = Scene.getSceneForLayout(sceneRoot, R.layout.scene2, this); // Another scene from a layout resource file. mScene3 = Scene.getSceneForLayout(sceneRoot, R.layout.scene3, this); // We create a custom TransitionManager for Scene 3, in which ChangeBounds and Fade // take place at the same time. mTransitionManagerForScene3 = TransitionInflater.from(this) .inflateTransitionManager(R.transition.scene3_transition_manager, sceneRoot); }
public TransitionLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (!isInEditMode()) { Resources res = getResources(); TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.TransitionLayout); if (res != null && ta != null) { int transitionManagerId = ta.getResourceId(R.styleable.TransitionLayout_transitionManager, 0); if (transitionManagerId > 0) { transitionManager = TransitionInflater.from(context).inflateTransitionManager(transitionManagerId, this); } int[] phases = null; Scene[] scenes = null; String scenesStr = ta.getString(R.styleable.TransitionLayout_scenes); if (scenesStr != null) { String[] layouts = scenesStr.split(","); scenes = new Scene[layouts.length]; for (int i = 0; i < layouts.length; i++) { String layout = layouts[i].trim(); int id = res.getIdentifier(layout, "layout", context.getPackageName()); scenes[i] = Scene.getSceneForLayout(this, id, context); } } String phaseStr = ta.getString(R.styleable.TransitionLayout_transitionPhases); if (phaseStr != null) { String[] phasesStr = phaseStr.split(","); phases = new int[phasesStr.length]; for (int i = 0; i < phasesStr.length; i++) { String phase = phasesStr[i].trim(); phases[i] = Integer.parseInt(phase); } } if (scenes != null && phases != null && scenes.length == phases.length + 1) { mScenes = new SparseArray<>(scenes.length); for (int i = 0; i < phases.length; i++) { mScenes.put(phases[i], scenes[i + 1]); } } else { throw new RuntimeException("Either scenes or phases aren't defined, or the counts do not match"); } ta.recycle(); if (transitionManager != null) { TransitionManager.go(scenes[0], TransitionInflater.from(context).inflateTransition(R.transition.none)); } } } }
public void initIfNeeded() { if (mInitialized) { return; } mEnterAnimator = AnimatorInflater.loadAnimator(mMainActivity, R.animator.channel_banner_enter); mExitAnimator = AnimatorInflater.loadAnimator(mMainActivity, R.animator.channel_banner_exit); mEmptyScene = new Scene(mSceneContainer, (View) mEmptyView); mEmptyScene.setEnterAction(new Runnable() { @Override public void run() { FrameLayout.LayoutParams emptySceneLayoutParams = (FrameLayout.LayoutParams) mEmptyView.getLayoutParams(); ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) mCurrentSceneView.getLayoutParams(); emptySceneLayoutParams.topMargin = mCurrentSceneView.getTop(); emptySceneLayoutParams.setMarginStart(lp.getMarginStart()); emptySceneLayoutParams.height = mCurrentSceneView.getHeight(); emptySceneLayoutParams.width = mCurrentSceneView.getWidth(); mEmptyView.setLayoutParams(emptySceneLayoutParams); setCurrentScene(mEmptyScene, mEmptyView); } }); mEmptyScene.setExitAction(new Runnable() { @Override public void run() { removeAllViewsFromOverlay(); } }); mChannelBannerScene = buildScene(mSceneContainer, mChannelBannerView); mInputBannerScene = buildScene(mSceneContainer, mInputBannerView); mKeypadChannelSwitchScene = buildScene(mSceneContainer, mKeypadChannelSwitchView); mSelectInputScene = buildScene(mSceneContainer, mSelectInputView); mCurrentScene = mEmptyScene; // Enter transitions TransitionSet enter = new TransitionSet() .addTransition(new SceneTransition(SceneTransition.ENTER)) .addTransition(new Fade(Fade.IN)); setTransition(mEmptyScene, mChannelBannerScene, enter); setTransition(mEmptyScene, mInputBannerScene, enter); setTransition(mEmptyScene, mKeypadChannelSwitchScene, enter); setTransition(mEmptyScene, mSelectInputScene, enter); // Exit transitions TransitionSet exit = new TransitionSet() .addTransition(new SceneTransition(SceneTransition.EXIT)) .addTransition(new Fade(Fade.OUT)); setTransition(mChannelBannerScene, mEmptyScene, exit); setTransition(mInputBannerScene, mEmptyScene, exit); setTransition(mKeypadChannelSwitchScene, mEmptyScene, exit); setTransition(mSelectInputScene, mEmptyScene, exit); // All other possible transitions between scenes TransitionInflater ti = TransitionInflater.from(mMainActivity); Transition transition = ti.inflateTransition(R.transition.transition_between_scenes); setTransition(mChannelBannerScene, mKeypadChannelSwitchScene, transition); setTransition(mChannelBannerScene, mSelectInputScene, transition); setTransition(mInputBannerScene, mSelectInputScene, transition); setTransition(mKeypadChannelSwitchScene, mChannelBannerScene, transition); setTransition(mKeypadChannelSwitchScene, mSelectInputScene, transition); setTransition(mSelectInputScene, mChannelBannerScene, transition); setTransition(mSelectInputScene, mInputBannerScene, transition); mInitialized = true; }
private void setupTransitions() { // Slide slide = new Slide(Gravity.BOTTOM); // slide.excludeTarget(android.R.id.statusBarBackground, true); // getWindow().setEnterTransition(slide); // getWindow().setSharedElementsUseOverlay(false); mTransitionManager = new TransitionManager(); ViewGroup transitionRoot = detailContainer; // Expanded scene mExpandedScene = Scene.getSceneForLayout(transitionRoot, R.layout.activity_album_detail_expanded, this); mExpandedScene.setEnterAction(new Runnable() { @Override public void run() { ButterKnife.bind(AlbumDetailActivity.this); populate(); mCurrentScene = mExpandedScene; } }); TransitionSet expandTransitionSet = new TransitionSet(); expandTransitionSet.setOrdering(TransitionSet.ORDERING_SEQUENTIAL); ChangeBounds changeBounds = new ChangeBounds(); changeBounds.setDuration(200); expandTransitionSet.addTransition(changeBounds); Fade fadeLyrics = new Fade(); fadeLyrics.addTarget(R.id.lyrics); fadeLyrics.setDuration(150); expandTransitionSet.addTransition(fadeLyrics); // Collapsed scene mCollapsedScene = Scene.getSceneForLayout(transitionRoot, R.layout.activity_album_detail, this); mCollapsedScene.setEnterAction(new Runnable() { @Override public void run() { ButterKnife.bind(AlbumDetailActivity.this); populate(); mCurrentScene = mCollapsedScene; } }); TransitionSet collapseTransitionSet = new TransitionSet(); collapseTransitionSet.setOrdering(TransitionSet.ORDERING_SEQUENTIAL); Fade fadeOutLyrics = new Fade(); fadeOutLyrics.addTarget(R.id.lyrics); fadeOutLyrics.setDuration(150); collapseTransitionSet.addTransition(fadeOutLyrics); ChangeBounds resetBounds = new ChangeBounds(); resetBounds.setDuration(200); collapseTransitionSet.addTransition(resetBounds); mTransitionManager.setTransition(mExpandedScene, mCollapsedScene, collapseTransitionSet); mTransitionManager.setTransition(mCollapsedScene, mExpandedScene, expandTransitionSet); mCollapsedScene.enter(); // postponeEnterTransition(); }
@Override public Scene getContentScene() { return super.getContentScene(); }
@Override public Scene getContentScene() { return delegate.getContentScene(); }
@Override public Scene super_getContentScene() { return super.getContentScene(); }
public Scene getContentScene() { verifyMethodCalledFromDelegate("getContentScene()"); return ((CallFun0<Scene>) mSuperListeners.pop()).call(); }
Scene getContentScene(final CallFun0<Scene> superCall) { synchronized (mSuperListeners) { mSuperListeners.push(superCall); return getContentScene(); } }
private void initializeScenes(ViewGroup contentView) { mNormalScene = Scene.getSceneForLayout(contentView, R.layout.activity_uiaction_normal, this); mFavoriteScene = Scene.getSceneForLayout(contentView, R.layout.activity_uiaction_favorite, this); }
@Override public void onUpdate(Boolean isFavorite) { //Do any UI action in response to a ViewModel's property change Scene scene = isFavorite ? mFavoriteScene : mNormalScene; transitionTo(scene); }
public Scene getContentScene() { return mHostActivity.getContentScene(); }