Java Code Examples for android.transition.TransitionManager#go()

The following examples show how to use android.transition.TransitionManager#go() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CustomTransitionFragment.java    From animation-samples with Apache License 2.0 6 votes vote down vote up
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    Context context = getActivity();
    FrameLayout container = (FrameLayout) view.findViewById(R.id.container);
    view.findViewById(R.id.show_next_scene).setOnClickListener(this);
    if (null != savedInstanceState) {
        mCurrentScene = savedInstanceState.getInt(STATE_CURRENT_SCENE);
    }
    // We set up the Scenes here.
    mScenes = new Scene[] {
            Scene.getSceneForLayout(container, R.layout.scene1, context),
            Scene.getSceneForLayout(container, R.layout.scene2, context),
            Scene.getSceneForLayout(container, R.layout.scene3, context),
    };
    // This is the custom Transition.
    mTransition = new ChangeColor();
    // Show the initial Scene.
    TransitionManager.go(mScenes[mCurrentScene % mScenes.length]);
}
 
Example 2
Source File: MainActivity.java    From auid2 with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 3
Source File: BasicTransitionFragment.java    From animation-samples with Apache License 2.0 5 votes vote down vote up
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
    switch (checkedId) {
        case R.id.select_scene_1: {
            // BEGIN_INCLUDE(transition_simple)
            // You can start an automatic transition with TransitionManager.go().
            TransitionManager.go(mScene1);
            // END_INCLUDE(transition_simple)
            break;
        }
        case R.id.select_scene_2: {
            TransitionManager.go(mScene2);
            break;
        }
        case R.id.select_scene_3: {
            // BEGIN_INCLUDE(transition_custom)
            // You can also start a transition with a custom TransitionManager.
            mTransitionManagerForScene3.transitionTo(mScene3);
            // END_INCLUDE(transition_custom)
            break;
        }
        case R.id.select_scene_4: {
            // BEGIN_INCLUDE(transition_dynamic)
            // Alternatively, transition can be invoked dynamically without a Scene.
            // For this, we first call TransitionManager.beginDelayedTransition().
            TransitionManager.beginDelayedTransition(mSceneRoot);
            // Then, we can just change view properties as usual.
            View square = mSceneRoot.findViewById(R.id.transition_square);
            ViewGroup.LayoutParams params = square.getLayoutParams();
            int newSize = getResources().getDimensionPixelSize(R.dimen.square_size_expanded);
            params.width = newSize;
            params.height = newSize;
            square.setLayoutParams(params);
            // END_INCLUDE(transition_dynamic)
            break;
        }
    }
}
 
Example 4
Source File: CustomTransitionFragment.java    From animation-samples with Apache License 2.0 5 votes vote down vote up
@Override
public void onClick(View v) {
    switch (v.getId()) {
        case R.id.show_next_scene: {
            mCurrentScene = (mCurrentScene + 1) % mScenes.length;
            Log.i(TAG, "Transitioning to scene #" + mCurrentScene);
            // Pass the custom Transition as second argument for TransitionManager.go
            TransitionManager.go(mScenes[mCurrentScene], mTransition);
            break;
        }
    }
}
 
Example 5
Source File: MainActivity.java    From Android-9-Development-Cookbook with MIT License 5 votes vote down vote up
public void goAnimate(View view) {
        //Resource file solution
        ViewGroup root = findViewById(R.id.layout);
        Scene scene = Scene.getSceneForLayout(root, R.layout.activity_main_end, this);
        Transition transition = TransitionInflater.from(this)
                .inflateTransition(R.transition.transition_move);
        TransitionManager.go(scene, transition);

        //Code only solution
//        ViewGroup root = findViewById(R.id.layout);
//        Scene scene = new Scene(root);
//
//        Transition transition = new ChangeBounds();
//        TransitionManager.beginDelayedTransition(root,transition);
//
//        TextView textViewTop = findViewById(R.id.textViewTop);
//        RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)textViewTop.getLayoutParams();
//        params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM,1);
//        params.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0);
//        textViewTop.setLayoutParams(params);
//
//        TextView textViewBottom = findViewById(R.id.textViewBottom);
//        params = (RelativeLayout.LayoutParams) textViewBottom.getLayoutParams();
//        params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM,0);
//        params.addRule(RelativeLayout.ALIGN_PARENT_TOP, 1);
//        textViewBottom.setLayoutParams(params);
//
//        TransitionManager.go(scene);
    }
 
Example 6
Source File: MainActivity.java    From auid2 with Apache License 2.0 5 votes vote down vote up
@Override
public void onClick(View v) {
    if (mCurrentScene == mScene1) {
        TransitionManager.go(mScene2, mTransition);
        mCurrentScene = mScene2;
    } else {
        TransitionManager.go(mScene1, mTransition);
        mCurrentScene = mScene1;
    }
}
 
Example 7
Source File: TransitionHelperKitkat.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
static void runTransition(Object scene, Object transition) {
    TransitionManager.go((Scene) scene, (Transition) transition);
}
 
Example 8
Source File: AcDisplayFragment.java    From AcDisplay with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Changes current scene to given one.
 *
 * @see #showWidget(com.achep.acdisplay.ui.components.Widget)
 */
@SuppressLint("NewApi")
protected synchronized final void goScene(@NonNull SceneCompat sceneCompat, boolean animate) {
    if (mCurrentScene == sceneCompat) return;
    mCurrentScene = sceneCompat;
    if (DEBUG) Log.d(TAG, "Going to " + sceneCompat);

    if (Device.hasKitKatApi()) animate &= mSceneContainer.isLaidOut();
    if (!animate) {
        sceneCompat.enter();
        return;
    }

    if (Device.hasKitKatApi()) {
        final Scene scene = sceneCompat.getScene();
        try {
            // This must be a synchronization problem with Android's Scene or TransitionManager,
            // but those were declared as final classes, so I have no idea how to fix it.
            TransitionManager.go(scene, mTransitionSwitchScene);
        } catch (IllegalStateException e) {
            Log.w(TAG, "TransitionManager has failed switching scenes!");

            ViewGroup viewGroup = (ViewGroup) getSceneView().getParent();
            viewGroup.removeView(getSceneView());

            try {
                // Reset internal scene's tag to make it work again.
                int id = Resources.getSystem().getIdentifier("current_scene", "id", "android");
                Method method = View.class.getMethod("setTagInternal", int.class, Object.class);
                method.setAccessible(true);
                method.invoke(viewGroup, id, null);
            } catch (NoSuchMethodException
                    | IllegalAccessException
                    | InvocationTargetException e2) {
                throw new RuntimeException("An attempt to fix the TransitionManager has failed.");
            }

            TransitionManager.go(scene, mTransitionSwitchScene);
        }
    } else {
        sceneCompat.enter();

        if (getActivity() != null) {
            // TODO: Better animation for Jelly Bean users.
            float density = getResources().getDisplayMetrics().density;
            getSceneView().setAlpha(0.6f);
            getSceneView().setRotationX(6f);
            getSceneView().setTranslationY(6f * density);
            getSceneView().animate().alpha(1).rotationX(0).translationY(0);
        }
    }
}
 
Example 9
Source File: MainActivity.java    From cogitolearning-examples with MIT License 4 votes vote down vote up
public void showWebSiteForm(View view)
{
  TransitionManager.go(webSiteForm);
}
 
Example 10
Source File: MainActivity.java    From cogitolearning-examples with MIT License 4 votes vote down vote up
public void showPictureForm(View view)
{
  TransitionManager.go(pictureForm);
}
 
Example 11
Source File: MainActivity.java    From cogitolearning-examples with MIT License 4 votes vote down vote up
public void showContactForm(View view)
{
  TransitionManager.go(contactForm);
}
 
Example 12
Source File: MainActivity.java    From cogitolearning-examples with MIT License 4 votes vote down vote up
public void showEventForm(View view)
{
  TransitionManager.go(eventForm);
}
 
Example 13
Source File: OrderDialogFragment.java    From From-design-to-Android-part1 with Apache License 2.0 3 votes vote down vote up
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);
}