Example usage for android.transition Slide Slide

List of usage examples for android.transition Slide Slide

Introduction

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

Prototype

public Slide(int slideEdge) 

Source Link

Document

Constructor using the provided slide edge direction.

Usage

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

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

    postponeEnterTransition();//from   ww w . j a  v a 2s.  co  m

    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:com.josecalles.porridge.home.HomeActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_home);
    ButterKnife.bind(this);
    injectPresenter();/*from ww w  .ja va  2  s  .  c om*/
    setActionBar(mToolbar);
    setupDrawerLayout();
    setupNavigationView();
    getWindow().setEnterTransition(new Slide(Gravity.END));
    checkIfCameFromEvents();
}

From source file:org.opensilk.common.ui.mortarfragment.FragmentManagerOwner.java

@SuppressLint("RtlHardcoded")
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Deprecated/*  w w  w  .j  a  v  a2s  . co  m*/
public int replaceMainContent(Fragment frag, String tag, boolean addToBackstack) {
    if (!hasView())
        return -1;
    FragmentTransaction ft = getView().getSupportFragmentManager().beginTransaction();
    if (VersionUtils.hasLollipop()) {
        frag.setEnterTransition(new Slide(Gravity.RIGHT));
        frag.setExitTransition(new Slide(Gravity.LEFT));
    } else {
        ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
    }
    ft.replace(getView().getContainerViewId(), frag, tag);
    if (addToBackstack)
        ft.addToBackStack(tag);
    return ft.commit();
}

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();/*ww w . j  a  va 2s  .com*/
        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:com.jlt.unsplashd.DetailActivity.java

@Override
// begin onCreate
protected void onCreate(Bundle savedInstanceState) {

    // 0. super things
    // 1. use the detail layout
    // 2. bind things
    // 3. show the image
    // 3a. using the uri from the intent
    // 3b. using the place holder color
    // 3c. into the correct view
    // 4. set author text from intent
    // 5. when the back toolbar button is tapped
    // 5a. close activity after transition is done
    // 6. for lollipop devices
    // 6a. slide description from bottom

    // 0. super things

    super.onCreate(savedInstanceState);

    // 1. use the detail layout

    setContentView(R.layout.activity_detail);

    // 2. bind things

    ButterKnife.bind(this);

    // 3. show the image

    Picasso.with(this)

            // 3a. using the uri from the intent

            .load(getIntent().getData())

            // 3b. using the place holder color

            .placeholder(R.color.colorPlaceholder)

            // 3c. into the correct view

            .into(threeTwoImageView);/*  ww  w .ja va 2 s  .  co m*/

    // 4. set author text from intent

    authorTextView.setText(getString(R.string.author_name, getIntent().getStringArrayExtra(EXTRA_AUTHOR_NAME)));

    // 5. when the back toolbar button is tapped

    // begin toolbar.setNavigationOnClickListener
    toolbar.setNavigationOnClickListener(

            // begin new View.OnClickListener
            new View.OnClickListener() {

                @Override
                // begin onClick
                public void onClick(View view) {

                    // 5a. close activity after transition is done

                    finishAfterTransition();

                } // end onClick

            } // end new View.OnClickListener

    ); // end toolbar.setNavigationOnClickListener

    // 6. for lollipop devices

    // begin if lollipop and above
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

        // 6a. slide description from bottom

        Slide slide = new Slide(Gravity.BOTTOM);

        slide.addTarget(R.id.ad_ll_description);

        slide.setInterpolator(new FastOutSlowInInterpolator());

        slide.setDuration(slideDuration);

        getWindow().setEnterTransition(slide);

    } // end if lollipop and above

}

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

private void onCdsItemClick(final View v, final View accent, int position, CdsObject object) {
    if (object.isContainer()) {
        browse(position, object.getObjectId(), object.getTitle(), true);
        return;// w  w  w. j ava 2  s  .c o  m
    }
    if (mTwoPane) {
        if (mSelectedObject != null && mSelectedObject.equals(object)) {
            return;
        }
        mCdsDetailFragment = CdsDetailFragment.newInstance(mServer.getUdn(), object);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            mCdsDetailFragment.setEnterTransition(new Slide(Gravity.START));
        }
        getSupportFragmentManager().beginTransaction().replace(R.id.cds_detail_container, mCdsDetailFragment)
                .commit();
    } else {
        final Intent intent = CdsDetailActivity.makeIntent(v.getContext(), mServer.getUdn(), object);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            startActivity(intent, ActivityOptions
                    .makeSceneTransitionAnimation(CdsListActivity.this, accent, "share").toBundle());
        } else {
            startActivity(intent);
        }
    }
    mSelectedObject = object;
    mCdsListAdapter.setSelection(position);
}

From source file:org.anoopam.main.anoopamaudio.AudioListActivity.java

@Override
public void setAnimations() {
    super.setAnimations();
    getWindow().setEnterTransition(new Slide(Gravity.RIGHT));
    getWindow().setReturnTransition(new Slide(Gravity.BOTTOM));
}

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   w w  w  .ja  v  a2s .  c o m*/
    }
}

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 av  a  2s.c om
    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:spit.matrix2017.Activities.EventDetails.java

@Override
protected void onStart() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Slide slide = new Slide(Gravity.BOTTOM);

        if (isFirstLaunch) {
            fab.hide();//  w w w .j a va 2  s.  c  o  m
            isFirstLaunch = false;
        }

        slide.addTarget(R.id.description_card);
        slide.addTarget(R.id.venue_time_card);
        slide.addTarget(R.id.registration_card);
        slide.addTarget(R.id.prizes_card);
        slide.addTarget(R.id.organizers_card);
        slide.setInterpolator(new LinearOutSlowInInterpolator());
        getWindow().setEnterTransition(slide);
        getWindow().setExitTransition(slide);
        getWindow().setReenterTransition(slide);

        setupEnterAnimation();
    }
    super.onStart();
}