Example usage for android.transition TransitionSet addTransition

List of usage examples for android.transition TransitionSet addTransition

Introduction

In this page you can find the example usage for android.transition TransitionSet addTransition.

Prototype

public TransitionSet addTransition(Transition transition) 

Source Link

Document

Adds child transition to this set.

Usage

From source file:com.kogitune.activitytransition.ActivityTransition.java

public ExitActivityTransition start(Bundle savedInstanceState) {
    if (interpolator == null) {
        interpolator = new DecelerateInterpolator();
    }/*w w  w .  j  a  v a2s  .c o  m*/

    final Bundle bundle = fromIntent.getExtras();
    if (Build.VERSION.SDK_INT >= 21) {
        final TransitionData transitionData = new TransitionData(toView.getContext(), bundle);
        if (transitionData.imageFilePath != null) {
            TransitionAnimation.setImageToView(toView, transitionData.imageFilePath);
        }

        ViewCompat.setTransitionName(toView, toViewName);
        final Window window = ((Activity) context).getWindow();
        TransitionSet set = new TransitionSet();
        set.addTransition(new ChangeBounds());
        set.addTransition(new ChangeImageTransform());
        set.setInterpolator(interpolator);

        window.setSharedElementEnterTransition(set);
        window.setSharedElementReturnTransition(set);

        return new ExitActivityTransition(null);
    }
    final Context context = toView.getContext();
    final MoveData moveData = TransitionAnimation.startAnimation(context, toView, bundle, savedInstanceState,
            duration, interpolator);

    return new ExitActivityTransition(moveData);
}

From source file:net.mm2d.dmsexplorer.ServerDetailFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View rootView = inflater.inflate(R.layout.frg_server_detail, container, false);
    final String udn = getArguments().getString(Const.EXTRA_UDN);
    final DataHolder dataHolder = DataHolder.getInstance();
    final MediaServer server = dataHolder.getMsControlPoint().getMediaServer(udn);
    if (server == null) {
        getActivity().finish();//from   ww  w  .j  a v  a2  s  .  c  om
        return rootView;
    }
    final TextView titleView = (TextView) rootView.findViewById(R.id.title);
    if (titleView != null) {
        titleView.setText(server.getFriendlyName());
        titleView.setBackgroundColor(ThemeUtils.getAccentColor(server.getFriendlyName()));
    }
    final RecyclerView recyclerView = (RecyclerView) rootView.findViewById(R.id.server_detail);
    final PropertyAdapter adapter = new PropertyAdapter(getContext());
    setupPropertyAdapter(adapter, server);
    adapter.setOnItemLinkClickListener(this);
    recyclerView.setAdapter(adapter);

    FloatingActionButton fab = (FloatingActionButton) rootView.findViewById(R.id.fab);
    if (fab == null) {
        fab = (FloatingActionButton) getActivity().findViewById(R.id.fab);
    }
    if (fab != null) {
        fab.setOnClickListener(view -> {
            final Intent intent = CdsListActivity.makeIntent(getContext(), udn);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                final TransitionSet ts = new TransitionSet();
                ts.addTransition(new Slide(Gravity.START));
                ts.addTransition(new Fade());
                getActivity().getWindow().setExitTransition(ts);
                startActivity(intent,
                        ActivityOptions.makeSceneTransitionAnimation(getActivity(), view, "share").toBundle());
            } else {
                startActivity(intent);
            }
        });
    }
    return rootView;
}

From source file:syncthing.android.ui.login.ManagePresenter.java

@TargetApi(21)
private void applyFragmentTransitions(Fragment f) {
    if (VersionUtils.hasLollipop()) {
        TransitionSet set = new TransitionSet();
        set.addTransition(new Slide(Gravity.BOTTOM));
        set.addTransition(new Fade(Fade.IN));
        f.setEnterTransition(set);/*from www  .  j  ava  2s .  c  o  m*/
    }
}

From source file:com.melkir.ourstreets.fragment.GalleryFragment.java

public GalleryFragment() {

    final Fade fade = new Fade();
    fade.addTarget(R.id.appbar);//from   w w w  . j  a  v  a2s  . co  m

    Explode explode = new Explode();
    explode.excludeTarget(R.id.appbar, true);

    Elevation elevation = new Elevation();
    elevation.addTarget(R.id.gallery_card);
    elevation.setStartDelay(250); // arbitrarily chosen delay

    TransitionSet exit = new TransitionSet();
    exit.addTransition(fade);
    exit.addTransition(explode);
    exit.addTransition(elevation);

    setExitTransition(exit);
}

From source file:com.example.android.unsplash.DetailActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    setContentView(R.layout.activity_detail);

    postponeEnterTransition();//from   w w  w .  j ava 2s. c om

    TransitionSet transitions = new TransitionSet();
    Slide slide = new Slide(Gravity.BOTTOM);
    slide.setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.linear_out_slow_in));
    slide.setDuration(getResources().getInteger(android.R.integer.config_shortAnimTime));
    transitions.addTransition(slide);
    transitions.addTransition(new Fade());
    getWindow().setEnterTransition(transitions);

    Intent intent = getIntent();
    sharedElementCallback = new DetailSharedElementEnterCallback(intent);
    setEnterSharedElementCallback(sharedElementCallback);
    try {
        initialItem = Integer.parseInt(intent.getData().getLastPathSegment());
    } catch (NumberFormatException e) {
        initialItem = 0;
    }
    PhotoService.getInstance().getPhotosAsync(new PhotoService.PhotoCallback() {
        @Override
        public void success(ArrayList<Photo> photos) {
            setUpViewPager(photos);
            findViewById(android.R.id.empty).setVisibility(View.GONE);
        }

        @Override
        public void error() {
            finishAfterTransition();
        }
    });

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setNavigationOnClickListener(navigationOnClickListener);

    super.onCreate(savedInstanceState);
}

From source file:net.mm2d.dmsexplorer.CdsListActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
        final TransitionSet ts = new TransitionSet();
        ts.addTransition(new Slide(Gravity.END));
        ts.addTransition(new Fade());
        getWindow().setEnterTransition(ts);
    }/*from  w  w  w .j  a v  a 2  s. co  m*/
    mHandler = new Handler();
    final String udn = getIntent().getStringExtra(Const.EXTRA_UDN);
    mServer = mDataHolder.getMsControlPoint().getMediaServer(udn);
    if (mServer == null) {
        finish();
        return;
    }
    final String name = mServer.getFriendlyName();
    if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
        getWindow().setStatusBarColor(ThemeUtils.getAccentDarkColor(name));
    }
    setContentView(R.layout.act_cds_list);
    final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    toolbar.setBackgroundColor(ThemeUtils.getAccentColor(name));
    final ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setTitle(name);

    mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeRefresh);
    mSwipeRefreshLayout.setColorSchemeResources(R.color.progress1, R.color.progress2, R.color.progress3,
            R.color.progress4);
    mSwipeRefreshLayout.setOnRefreshListener(() -> {
        mDataHolder.popCache();
        reload();
    });
    mCdsListAdapter = new CdsListAdapter(this);
    mCdsListAdapter.setOnItemClickListener(this::onCdsItemClick);
    mRecyclerView = (RecyclerView) findViewById(R.id.cds_list);
    mRecyclerView.setAdapter(mCdsListAdapter);
    mRecyclerView.addItemDecoration(new DividerItemDecoration(this));

    if (findViewById(R.id.cds_detail_container) != null) {
        mTwoPane = true;
    }
    if (savedInstanceState == null) {
        browse(0, "0", "", true);
    }
}

From source file:com.sociablue.nanodegree_p1.MovieListFragment.java

public void setupTransitions(final MovieDetailPagerFragment newFragment, ImageView posterImageView) {
    //TODO: Shared Element Return Transition

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        // Inflate transitions to apply
        TransitionSet changeTransitionSet = new TransitionSet();
        Transition changeTransform = new ChangeTransform();
        changeTransitionSet.addTransition(changeTransform);
        changeTransitionSet.addTransition(new ChangeBounds());
        changeTransitionSet.setDuration(200);
        changeTransitionSet.setInterpolator(new AccelerateDecelerateInterpolator());
        this.setAllowEnterTransitionOverlap(true);
        this.setAllowReturnTransitionOverlap(true);

        // Setup enter transition on second fragment
        newFragment.setSharedElementEnterTransition(changeTransitionSet);
        newFragment.setAllowEnterTransitionOverlap(true);

        // Find the shared element (in Fragment A)
        moviePoster = posterImageView;//  ww  w.ja  v  a2s. co m
        moviePoster.setTransitionName("movie_poster");

        // Add and hide details view pager fragment. Adding fragment, creates view and downloads images.
        getFragmentManager().beginTransaction().add(R.id.movie_list_fragment, newFragment, "detail")
                .addToBackStack("transaction2").hide(newFragment).commit();

    } else {
        // Code to run on older devices
        //TODO: Handle older devices
    }
}