Java 类android.transition.Slide 实例源码

项目:SunmiUI    文件:ImageSharedTransitionActivity.java   
@Override
    protected void onCreate(Bundle savedInstanceState) {
//        getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
        super.onCreate(savedInstanceState);
        Slide slideIn = new Slide();
        slideIn.setDuration(500);
        //设置为进入
        slideIn.setMode(Visibility.MODE_IN);
        //设置从右边进入
        slideIn.setSlideEdge(Gravity.RIGHT);
        getWindow().setEnterTransition(new ChangeImageTransform().setDuration(3000));
//        getWindow().setEnterTransition(new Explode().setDuration(2000));
//        getWindow().setExitTransition(new Explode().setDuration(2000));
        Slide slideReturn =new Slide();
        slideReturn.setDuration(500);
        slideReturn.setSlideEdge(Gravity.LEFT);
        slideReturn.setMode(Visibility.MODE_OUT);
        getWindow().setReturnTransition (slideReturn );
        setContentView(R.layout.activity_img_transition);
        mImageView = (ImageView) findViewById(R.id.img);

//        Transition sharedElementEnterTransition = getWindow().getSharedElementEnterTransition();

    }
项目:chaosflix    文件:BrowseActivity.java   
@Override
public void onConferenceSelected(Conference con) {
    mDisposables.add(mViewModel.getConference(con.getApiID())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(conference -> {
                EventsFragment eventsFragment = EventsFragment.newInstance(conference.getApiID(),getNumColumns());
                FragmentManager fm = getSupportFragmentManager();
                Fragment oldFragment = fm.findFragmentById(R.id.fragment_container);

                TransitionInflater transitionInflater = TransitionInflater.from(this);
                oldFragment.setExitTransition(
                        transitionInflater.inflateTransition(android.R.transition.fade));
                eventsFragment.setEnterTransition(
                        transitionInflater.inflateTransition(android.R.transition.slide_right));

                Slide slideTransition = new Slide(Gravity.RIGHT);
                eventsFragment.setEnterTransition(slideTransition);

                FragmentTransaction ft = fm.beginTransaction();
                ft.replace(R.id.fragment_container, eventsFragment);
                ft.setReorderingAllowed(true);
                ft.addToBackStack(null);
                ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
                ft.commit();
            }));
}
项目:aos-Video    文件:VideoDetailsActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Lollipop only :-(
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        getWindow().requestFeature(Window.FEATURE_ACTIVITY_TRANSITIONS);

        // Always set the exit transition because the "Next Episode" transition may be needed (we don't know yet)
        getWindow().setExitTransition(new Slide(Gravity.LEFT));

        // Set the enter animation only when asked (i.e. it is a "Next Episode" transition)
        if (getIntent().getBooleanExtra(SLIDE_TRANSITION_EXTRA, false)) {
            getWindow().setEnterTransition(new Slide(Gravity.RIGHT));
        }
    }

    setContentView(R.layout.androidtv_details_activity);
}
项目:DailyStudy    文件:ViewerActivity.java   
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_viewer);
        ButterKnife.bind(this);

        Slide slide = new Slide(Gravity.LEFT);
        slide.addTarget(R.id.tv_text);

        getWindow().setEnterTransition(slide);
//        Explode explode = new Explode();
//        explode.addTarget(R.id.tv_text);
//        getWindow().setEnterTransition(explode);
        ImageView imageView = (ImageView) findViewById(R.id.image);
        imageView.setImageResource(getIntent().getIntExtra("resId", R.mipmap.pic_1));

//        ViewCompat.setTransitionName(imageView, "image");
    }
项目:Pocket-Plays-for-Twitch    文件:LiveStreamActivity.java   
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private TransitionSet constructTransitions() {
    int[] slideTargets = {R.id.ChatRecyclerView, R.id.chat_input, R.id.chat_input_divider};

    Transition slideTransition = new Slide(Gravity.BOTTOM);
    Transition fadeTransition = new Fade();

    for (int slideTarget : slideTargets) {
        slideTransition.addTarget(slideTarget);
        fadeTransition.excludeTarget(slideTarget, true);
    }

    TransitionSet set = new TransitionSet();
    set.addTransition(slideTransition);
    set.addTransition(fadeTransition);
    return set;
}
项目:Alligator    文件:SampleTransitionAnimationProvider.java   
@SuppressLint("RtlHardcoded")
private TransitionAnimation createSlideAnimation(boolean forward, AnimationData animationData) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Transition enterTransition = forward ? new Slide(Gravity.RIGHT) : new Slide(Gravity.LEFT);
        Transition exitTransition = forward ? new Slide(Gravity.LEFT) : new Slide(Gravity.RIGHT);
        LollipopTransitionAnimation animation = new LollipopTransitionAnimation(enterTransition, exitTransition);
        animation.setAllowEnterTransitionOverlap(false);

        Fragment currentFragment = mActivity.getSupportFragmentManager().findFragmentById(R.id.fragment_container);
        if (currentFragment instanceof SharedElementProvider) {
            SharedElementProvider sharedElementProvider = (SharedElementProvider) currentFragment;
            View sharedElement = sharedElementProvider.getSharedElement(animationData);
            String shareElementName = sharedElementProvider.getSharedElementName(animationData);
            animation.addSharedElement(sharedElement, shareElementName);
            Transition moveTransition = TransitionInflater.from(mActivity).inflateTransition(android.R.transition.move);
            moveTransition.setDuration(600);
            animation.setSharedElementTransition(moveTransition);
        }
        return animation;
    } else {
        int enterAnimRes = forward ? R.anim.slide_in_right : R.anim.slide_in_left;
        int exitAnimRes = forward ? R.anim.slide_out_left : R.anim.slide_out_right;
        return new SimpleTransitionAnimation(enterAnimRes, exitAnimRes);
    }
}
项目:AndroidOpen    文件:SharedElementFragment1.java   
private void addNextFragment(Sample sample, ImageView squareBlue, boolean overlap) {
    SharedElementFragment2 sharedElementFragment2 = SharedElementFragment2.newInstance(sample);

    Slide slideTransition = new Slide(Gravity.RIGHT);
    slideTransition.setDuration(getResources().getInteger(R.integer.anim_duration_medium));

    ChangeBounds changeBoundsTransition = new ChangeBounds();
    changeBoundsTransition.setDuration(getResources().getInteger(R.integer.anim_duration_medium));

    sharedElementFragment2.setEnterTransition(slideTransition);
    sharedElementFragment2.setAllowEnterTransitionOverlap(overlap);
    sharedElementFragment2.setAllowReturnTransitionOverlap(overlap);
    sharedElementFragment2.setSharedElementEnterTransition(changeBoundsTransition);

    getFragmentManager().beginTransaction()
            .replace(R.id.sample2_content, sharedElementFragment2)
            .addToBackStack(null)
            .addSharedElement(squareBlue, getString(R.string.square_blue_name))
            .commit();
}
项目:malp    文件:MainActivity.java   
@Override
public void openPlaylist(String name) {
    // Create fragment and give it an argument for the selected article
    PlaylistTracksFragment newFragment = new PlaylistTracksFragment();
    Bundle args = new Bundle();
    args.putString(PlaylistTracksFragment.EXTRA_PLAYLIST_NAME, name);


    newFragment.setArguments(args);

    android.support.v4.app.FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    newFragment.setEnterTransition(new Slide(GravityCompat.getAbsoluteGravity(GravityCompat.START, getResources().getConfiguration().getLayoutDirection())));
    newFragment.setExitTransition(new Slide(GravityCompat.getAbsoluteGravity(GravityCompat.END, getResources().getConfiguration().getLayoutDirection())));
    // Replace whatever is in the fragment_container view with this
    // fragment,
    // and add the transaction to the back stack so the user can navigate
    // back
    transaction.replace(R.id.fragment_container, newFragment);
    transaction.addToBackStack("PlaylistTracksFragment");

    // Commit the transaction
    transaction.commit();

}
项目:malp    文件:MainActivity.java   
@Override
public void openPath(String path) {
    // Create fragment and give it an argument for the selected directory
    FilesFragment newFragment = new FilesFragment();
    Bundle args = new Bundle();
    args.putString(FilesFragment.EXTRA_FILENAME, path);

    newFragment.setArguments(args);

    FragmentManager fragmentManager = getSupportFragmentManager();

    android.support.v4.app.FragmentTransaction transaction = fragmentManager.beginTransaction();

    newFragment.setEnterTransition(new Slide(GravityCompat.getAbsoluteGravity(GravityCompat.START, getResources().getConfiguration().getLayoutDirection())));
    newFragment.setExitTransition(new Slide(GravityCompat.getAbsoluteGravity(GravityCompat.END, getResources().getConfiguration().getLayoutDirection())));

    transaction.addToBackStack("FilesFragment" + path);
    transaction.replace(R.id.fragment_container, newFragment);

    // Commit the transaction
    transaction.commit();

}
项目:android-unsplash    文件:DetailActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    setContentView(R.layout.activity_detail);

    postponeEnterTransition();

    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);
    initialItem = intent.getIntExtra(IntentUtil.SELECTED_ITEM_POSITION, 0);
    setUpViewPager(intent.<Photo>getParcelableArrayListExtra(IntentUtil.PHOTO));

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

    super.onCreate(savedInstanceState);
}
项目:Matrix2017    文件: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();
            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();
}
项目:AndroidFlipCardTransition    文件:BigCardActivity.java   
private void setupSlideTransition() {
    Slide slideEnter = new Slide();
    slideEnter.setSlideEdge(Gravity.LEFT);
    slideEnter.setDuration(500);
    slideEnter.setStartDelay(250);
    slideEnter.excludeTarget(android.R.id.navigationBarBackground, true);
    slideEnter.excludeTarget(android.R.id.statusBarBackground, true);

    getWindow().setEnterTransition(slideEnter);

    Slide slideOut = new Slide();
    slideOut.setSlideEdge(Gravity.RIGHT);
    slideOut.setDuration(500);
    slideOut.setStartDelay(0);
    slideOut.excludeTarget(android.R.id.navigationBarBackground, true);
    slideOut.excludeTarget(android.R.id.statusBarBackground, true);

    getWindow().setExitTransition(slideOut);
}
项目:AndroidFlipCardTransition    文件:FlipCardTransitionActivity.java   
private void setupSlideTransition() {
    Slide slideEnter = new Slide();
    slideEnter.addTarget(R.id.text_card);
    slideEnter.setDuration(1000);
    slideEnter.setStartDelay(500);
    slideEnter.setSlideEdge(Gravity.RIGHT);
    slideEnter.excludeTarget(android.R.id.navigationBarBackground, true);
    slideEnter.excludeTarget(android.R.id.statusBarBackground, true);

    getWindow().setEnterTransition(slideEnter);
    // Tips: Cann't set same Transition object to more than one Transition callbacks.
    // getWindow().setReenterTransition(slideEnter);

    Slide slideOut = new Slide();
    slideOut.addTarget(R.id.text_card);
    slideOut.setDuration(500);
    slideOut.setSlideEdge(Gravity.RIGHT);
    slideOut.excludeTarget(android.R.id.navigationBarBackground, true);
    slideOut.excludeTarget(android.R.id.statusBarBackground, true);
    getWindow().setExitTransition(slideOut);
}
项目:SunmiUI    文件:ImageSharedTransitionActivity.java   
@Override
    protected void onCreate(Bundle savedInstanceState) {
//        getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
        super.onCreate(savedInstanceState);
        Slide slideIn = new Slide();
        slideIn.setDuration(500);
        //设置为进入
        slideIn.setMode(Visibility.MODE_IN);
        //设置从右边进入
        slideIn.setSlideEdge(Gravity.RIGHT);
        getWindow().setEnterTransition(new ChangeImageTransform().setDuration(3000));
//        getWindow().setEnterTransition(new Explode().setDuration(2000));
//        getWindow().setExitTransition(new Explode().setDuration(2000));
        Slide slideReturn =new Slide();
        slideReturn.setDuration(500);
        slideReturn.setSlideEdge(Gravity.LEFT);
        slideReturn.setMode(Visibility.MODE_OUT);
        getWindow().setReturnTransition (slideReturn );
        setContentView(R.layout.activity_img_transition);
        mImageView = (ImageView) findViewById(R.id.img);

//        Transition sharedElementEnterTransition = getWindow().getSharedElementEnterTransition();

    }
项目:FunWithAndroid    文件:WelcomeFragmentStep1.java   
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@OnClick(R.id.next)
public void onClickBegin(View view) {

    //set behavior for this fragment
    setExitTransition(new Slide(Gravity.START));
    setReenterTransition(new Slide(Gravity.TOP));

    WelcomeFragmentStep2 fragment = new WelcomeFragmentStep2();
    //set behavior for new fragment transitions
    fragment.setEnterTransition(new Fade());
    fragment.setSharedElementEnterTransition(getNextButtonTransition());

    getActivity().getFragmentManager().beginTransaction()
            .replace(R.id.root, fragment)
            .addSharedElement(next, "next")
            .addToBackStack(null)
            .commit();
}
项目:MaterialDesign-Udacity    文件:MainActivity.java   
public void click(View view) {
    /*
     * Slide: this transition tracks changes to the visibility of target views
     *        in the start and end scenes and moves views in or out
     *        from one of the edges of the scene.
     */
    Slide slide = new Slide();
    // Change the edge that Views appear and disappear from.
    slide.setSlideEdge(Gravity.TOP);

    ViewGroup root = (ViewGroup) findViewById(android.R.id.content);
    /*
     * beginDelayedTransition: Convenience method to animate to a new scene
     *                         defined by all changes within the given scene root
     *                         between calling this method and the next rendering frame.
     */
    TransitionManager.beginDelayedTransition(root, slide);
    imageView.setVisibility(View.INVISIBLE);
}
项目:PlutusAndroid    文件:BaseActivity.java   
@Override
protected void onCreate( Bundle savedInstanceState ){
    super.onCreate( savedInstanceState );
    setRequestedOrientation( ActivityInfo.SCREEN_ORIENTATION_PORTRAIT );
    app = (PlutusAndroid)getApplicationContext();
    imm = (InputMethodManager)getSystemService( Context.INPUT_METHOD_SERVICE );

    Language language = app.getLanguage();
    Locale locale = language == Language.DEFAULT ? app.getDefaultLocale() : language.getLocale();

    Locale.setDefault( locale );
    Configuration config = new Configuration();
    config.locale = locale;
    this.getBaseContext().getResources().updateConfiguration( config, null );

    //if( app.getAndroidApiVersion() >= android.os.Build.VERSION_CODES.LOLLIPOP ){
        Transition slide = new Slide();
        slide.excludeTarget( android.R.id.statusBarBackground, true );
        slide.excludeTarget( R.id.toolbar, true );
        slide.excludeTarget( android.R.id.navigationBarBackground, true );
        getWindow().setEnterTransition( slide );
    //}
}
项目:apkupdater    文件:AnimationUtil.java   
public static void startToolbarAnimation(
    Context context,
    ViewGroup v
) {
    if (new UpdaterOptions(context).disableAnimations()) {
        return;
    }

    if (Build.VERSION.SDK_INT >= 21) {
        TransitionManager.beginDelayedTransition(v, new TransitionSet()
            .addTransition(new Fade(Fade.IN))
            .addTransition(new Slide(Gravity.LEFT))
            .addTransition(new ChangeBounds())
        );

    } else if (Build.VERSION.SDK_INT >= 14){
        android.support.transition.TransitionManager.beginDelayedTransition(v, new AutoTransition().setDuration(250));
    } {
        // No animation
    }
}
项目:-Material-Design    文件:LearnTransitionActivityB.java   
public void setAnimation() {
    type = getIntent().getStringExtra("type");

    switch (type) {
        case "1":
            getWindow().setEnterTransition(new Explode());
            getWindow().setExitTransition(new Explode());
            break;
        case "2":
            getWindow().setEnterTransition(new Slide());
            getWindow().setExitTransition(new Slide());
            break;
        case "3":
            getWindow().setEnterTransition(new Fade());
            getWindow().setExitTransition(new Fade());
            break;
    }
}
项目:NavigationFragment    文件:SmallImageFragment.java   
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    final ImageView smallImageView = (ImageView)getView().findViewById(R.id.iv_small_image);
    smallImageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            NavigationFragment fragment = LargeImageFragment.newInstance();
            PresentationTransaction transaction = beginPresentation();

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                setExitTransition(new Slide(Gravity.START));
                setEnterTransition(new Slide(Gravity.START));

                fragment.setSharedElementEnterTransition(new DetailTransition());
                fragment.setSharedElementReturnTransition(new DetailTransition());

                fragment.setEnterTransition(new Slide(Gravity.END));

                transaction.addSharedElement(smallImageView, "trans_largeImageView");
            }
            transaction.presentFragment(fragment);
        }
    });
}
项目:odyssey    文件:OdysseyMainActivity.java   
@Override
public void onPlaylistSelected(String playlistTitle, long playlistID) {
    // Create fragment and give it an argument for the selected playlist
    PlaylistTracksFragment newFragment = new PlaylistTracksFragment();
    Bundle args = new Bundle();
    args.putString(PlaylistTracksFragment.ARG_PLAYLISTTITLE, playlistTitle);
    args.putLong(PlaylistTracksFragment.ARG_PLAYLISTID, playlistID);

    newFragment.setArguments(args);

    android.support.v4.app.FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();

    // set enter / exit animation
    newFragment.setEnterTransition(new Slide(GravityCompat.getAbsoluteGravity(GravityCompat.START, getResources().getConfiguration().getLayoutDirection())));
    newFragment.setExitTransition(new Slide(GravityCompat.getAbsoluteGravity(GravityCompat.END, getResources().getConfiguration().getLayoutDirection())));

    // Replace whatever is in the fragment_container view with this
    // fragment,
    // and add the transaction to the back stack so the user can navigate
    // back
    transaction.replace(R.id.fragment_container, newFragment);
    transaction.addToBackStack("PlaylistTracksFragment");

    // Commit the transaction
    transaction.commit();
}
项目:odyssey    文件:OdysseyMainActivity.java   
@Override
public void onRecentAlbumsSelected() {
    // Create fragment
    RecentAlbumsFragment newFragment = new RecentAlbumsFragment();

    android.support.v4.app.FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();

    // set enter / exit animation
    newFragment.setEnterTransition(new Slide(Gravity.BOTTOM));
    newFragment.setExitTransition(new Slide(Gravity.TOP));

    // Replace whatever is in the fragment_container view with this
    // fragment,
    // and add the transaction to the back stack so the user can navigate
    // back
    transaction.replace(R.id.fragment_container, newFragment);
    transaction.addToBackStack("RecentAlbumsFragment");

    // Commit the transaction
    transaction.commit();
}
项目:odyssey    文件:OdysseyMainActivity.java   
@Override
public void onPlaylistFileSelected(String name, String path) {
    // Create fragment and give it an argument for the selected playlist
    PlaylistTracksFragment newFragment = new PlaylistTracksFragment();
    Bundle args = new Bundle();
    args.putString(PlaylistTracksFragment.ARG_PLAYLISTTITLE, name);
    args.putString(PlaylistTracksFragment.ARG_PLAYLISTPATH, path);

    newFragment.setArguments(args);

    android.support.v4.app.FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();

    // set enter / exit animation
    newFragment.setEnterTransition(new Slide(GravityCompat.getAbsoluteGravity(GravityCompat.START, getResources().getConfiguration().getLayoutDirection())));
    newFragment.setExitTransition(new Slide(GravityCompat.getAbsoluteGravity(GravityCompat.END, getResources().getConfiguration().getLayoutDirection())));

    // Replace whatever is in the fragment_container view with this
    // fragment,
    // and add the transaction to the back stack so the user can navigate
    // back
    transaction.replace(R.id.fragment_container, newFragment);
    transaction.addToBackStack("PlaylistTracksFragment");

    // Commit the transaction
    transaction.commit();
}
项目:Material-Animations    文件:SharedElementFragment1.java   
private void addNextFragment(Sample sample, ImageView squareBlue, boolean overlap) {
    SharedElementFragment2 sharedElementFragment2 = SharedElementFragment2.newInstance(sample);

    Slide slideTransition = new Slide(Gravity.RIGHT);
    slideTransition.setDuration(getResources().getInteger(R.integer.anim_duration_medium));

    ChangeBounds changeBoundsTransition = new ChangeBounds();
    changeBoundsTransition.setDuration(getResources().getInteger(R.integer.anim_duration_medium));

    sharedElementFragment2.setEnterTransition(slideTransition);
    sharedElementFragment2.setAllowEnterTransitionOverlap(overlap);
    sharedElementFragment2.setAllowReturnTransitionOverlap(overlap);
    sharedElementFragment2.setSharedElementEnterTransition(changeBoundsTransition);

    getFragmentManager().beginTransaction()
            .replace(R.id.sample2_content, sharedElementFragment2)
            .addToBackStack(null)
            .addSharedElement(squareBlue, getString(R.string.square_blue_name))
            .commit();
}
项目:NSIT-Connect    文件:ContestDetailActivity.java   
@Override
public void onCreate(Bundle savedInstanceState) {

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        // inside your activity (if you did not enable transitions in your theme)
        getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);

        // set an exit transition
        getWindow().setEnterTransition(new Slide());
        getWindow().setExitTransition(new Slide());
    }

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_contest_detail);


    if (savedInstanceState == null) {
        Uri contestUri = getIntent().getData();
        Fragment fragment = ContestDetailFragment.newInstance(contestUri);
        getSupportFragmentManager().beginTransaction()
                .add(R.id.contest_detail_container,fragment)
                .commit();
    }
}
项目:trainee-om-shop    文件:OFragmentUtils.java   
private void loadFragment(Fragment fragment, Boolean addToBackState) {
    String tag = fragment.getClass().getCanonicalName();
    if (fragmentManager.findFragmentByTag(tag) != null && savedInstance != null) {
        fragmentManager.popBackStack(tag, FragmentManager.POP_BACK_STACK_INCLUSIVE);
        fragmentManager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
    }
    if (savedInstance == null) {
        Log.i(TAG, "Fragment Loaded (" + tag + ")");
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            Slide slideIn = new Slide();
            slideIn.setSlideEdge(Gravity.RIGHT);
            fragment.setEnterTransition(slideIn);
            Slide slideOut = new Slide();
            slideOut.setSlideEdge(Gravity.LEFT);
            fragment.setExitTransition(slideOut);
        }
        FragmentTransaction tran = fragmentManager.beginTransaction()
                .replace(R.id.fragment_container, fragment, tag);

        if (addToBackState)
            tran.addToBackStack(tag);
        tran.commitAllowingStateLoss();
    }
}
项目:chanobol    文件:PostsActivity.java   
@TargetApi(Build.VERSION_CODES.LOLLIPOP) private void animatePostsArrival() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        postsAdapter.hide = true;
        postsAdapter.firstLoad = true;
        postsAdapter.notifyDataSetChanged();
        TransitionManager.beginDelayedTransition(postsView, new Slide(Gravity.BOTTOM));
        postsAdapter.hide = false;
        postsAdapter.firstLoad = false;
        postsAdapter.notifyDataSetChanged();
        // Unreliable, often leads to https://code.google.com/p/android/issues/detail?id=77846
        //postsAdapter.notifyItemChanged(0);
        //postsAdapter.notifyItemRangeInserted(1, posts.size()-1);
    } else {
        postsAdapter.notifyDataSetChanged();
    }
}
项目:chanobol    文件:ThreadsActivity.java   
@TargetApi(Build.VERSION_CODES.LOLLIPOP) private void animateThreadsArrival() {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        notifyDataSetChanged();
        return;
    }
    // Add slight delay because thumbnails must be retrieved, too,
    // and it looks bad when the thumbnails are loaded afterwards.
    threadsView.postDelayed(new Runnable() {
        @Override public void run() {
            threadsAdapter.hide = true;
            notifyDataSetChanged();
            TransitionManager.beginDelayedTransition(threadsView, new Slide(Gravity.BOTTOM));
            threadsAdapter.hide = false;
            notifyDataSetChanged();
        }
    }, 300);
}
项目:trekarta    文件:MainActivity.java   
@Override
public void showMarkerInformation(@NonNull GeoPoint point, @Nullable String name) {
    if (mFragmentManager.getBackStackEntryCount() > 0) {
        popAll();
    }
    Bundle args = new Bundle(3);
    args.putDouble(MarkerInformation.ARG_LATITUDE, point.getLatitude());
    args.putDouble(MarkerInformation.ARG_LONGITUDE, point.getLongitude());
    args.putString(MarkerInformation.ARG_NAME, name);
    Fragment fragment = Fragment.instantiate(this, MarkerInformation.class.getName(), args);
    fragment.setEnterTransition(new Slide());
    FragmentTransaction ft = mFragmentManager.beginTransaction();
    ft.replace(R.id.contentPanel, fragment, "markerInformation");
    ft.addToBackStack("markerInformation");
    ft.commit();
    updateMapViewArea();
}
项目:trekarta    文件:MainActivity.java   
private void onTrackDetails(Track track, boolean current) {
    Fragment fragment = mFragmentManager.findFragmentByTag("trackInformation");
    if (fragment == null) {
        fragment = Fragment.instantiate(this, TrackInformation.class.getName());
        Slide slide = new Slide(mSlideGravity);
        // Required to sync with FloatingActionButton
        slide.setDuration(getResources().getInteger(android.R.integer.config_shortAnimTime));
        fragment.setEnterTransition(slide);
        FragmentTransaction ft = mFragmentManager.beginTransaction();
        ft.replace(R.id.contentPanel, fragment, "trackInformation");
        ft.addToBackStack("trackInformation");
        ft.commit();
        updateMapViewArea();
    }
    ((TrackInformation) fragment).setTrack(track, current);
    mExtendPanel.setForeground(getDrawable(R.drawable.dim));
    mExtendPanel.getForeground().setAlpha(0);
    ObjectAnimator anim = ObjectAnimator.ofInt(mExtendPanel.getForeground(), "alpha", 0, 255);
    anim.setDuration(500);
    anim.start();
}
项目:trekarta    文件:MainActivity.java   
private void startMapSelection(boolean zoom) {
    if (mFragmentManager.getBackStackEntryCount() > 0) {
        popAll();
    }
    if (zoom) {
        MapPosition mapPosition = mMap.getMapPosition();
        mapPosition.setScale(MapCoverageLayer.TEXT_MIN_SCALE + 5f);
        mapPosition.setBearing(0f);
        mapPosition.setTilt(0f);
        mMap.animator().animateTo(MAP_POSITION_ANIMATION_DURATION, mapPosition);
    }
    MapSelection fragment = (MapSelection) Fragment.instantiate(this, MapSelection.class.getName());
    fragment.setMapIndex(mNativeMapIndex);
    fragment.setEnterTransition(new Slide());
    FragmentTransaction ft = mFragmentManager.beginTransaction();
    ft.replace(R.id.contentPanel, fragment, "mapSelection");
    ft.addToBackStack("mapSelection");
    ft.commit();
    updateMapViewArea();
}
项目:binea_project_for_android    文件:ScenesSample.java   
@Override public void onCheckedChanged(final RadioGroup group, int checkedId) {
    switch (checkedId) {
        case R.id.select_scene_1: {
            // You can start an automatic transition with TransitionManager.go().
            TransitionManager.go(mScene1);
            break;
        }
        case R.id.select_scene_2: {
            TransitionSet set = new TransitionSet();
            Slide slide = new Slide(Gravity.LEFT);
            slide.addTarget(R.id.transition_title);
            set.addTransition(slide);
            set.addTransition(new ChangeBounds());
            set.setOrdering(TransitionSet.ORDERING_TOGETHER);
            set.setDuration(350);
            TransitionManager.go(mScene2, set);
            break;
        }
        case R.id.select_scene_3: {
            // You can also start a transition with a custom TransitionManager.
            mTransitionManagerForScene3.transitionTo(mScene3);
            break;
        }
    }
}
项目:transitions-animate-demo    文件:DetailsActivity8.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_details_shared);
    ((Toolbar) findViewById(R.id.action_bar)).setTitle("Details - Stage 8");

    ImageView imageView = (ImageView) findViewById(R.id.image);
    String imageUrl = getIntent().getStringExtra("imageUrl");

    Picasso
            .with(this)
            .load(imageUrl)
            .into(imageView);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
        Transition transition = new Slide();
        transition.excludeTarget(android.R.id.statusBarBackground, true);
        transition.excludeTarget(android.R.id.navigationBarBackground, true);
        getWindow().setEnterTransition(transition);
    }
}
项目:chanobol    文件:PostsActivity.java   
@TargetApi(Build.VERSION_CODES.LOLLIPOP) private void animatePostsArrival() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        postsAdapter.hide = true;
        postsAdapter.firstLoad = true;
        postsAdapter.notifyDataSetChanged();
        TransitionManager.beginDelayedTransition(postsView, new Slide(Gravity.BOTTOM));
        postsAdapter.hide = false;
        postsAdapter.firstLoad = false;
        postsAdapter.notifyDataSetChanged();
        // Unreliable, often leads to https://code.google.com/p/android/issues/detail?id=77846
        //postsAdapter.notifyItemChanged(0);
        //postsAdapter.notifyItemRangeInserted(1, posts.size()-1);
    } else {
        postsAdapter.notifyDataSetChanged();
    }
}
项目:chanobol    文件:ThreadsActivity.java   
@TargetApi(Build.VERSION_CODES.LOLLIPOP) private void animateThreadsArrival() {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        notifyDataSetChanged();
        return;
    }
    // Add slight delay because thumbnails must be retrieved, too,
    // and it looks bad when the thumbnails are loaded afterwards.
    threadsView.postDelayed(new Runnable() {
        @Override public void run() {
            threadsAdapter.hide = true;
            notifyDataSetChanged();
            TransitionManager.beginDelayedTransition(threadsView, new Slide(Gravity.BOTTOM));
            threadsAdapter.hide = false;
            notifyDataSetChanged();
        }
    }, 300);
}
项目:SampleAndroidL    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    getWindow().requestFeature(android.view.Window.FEATURE_CONTENT_TRANSITIONS);
    Transition ts = /*new Explode();*/new Slide();
    //ts.setStartDelay(2000);
    ts.setDuration(500);

    /*
     * If you have set an enter transition for the second activity,
     * the transition is also activated when the activity starts.
     */
    getWindow().setEnterTransition(ts);
    getWindow().setExitTransition(ts);

    setContentView(R.layout.activity_main);

    mRecyclerView = (RecyclerView)findViewById(android.R.id.list);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(MainActivity.this));
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mAdapter = new ImageAdapter(ImageFactoryManager.getInstance().getAllImages(), R.layout.row, this);
    mRecyclerView.setAdapter(mAdapter);
}
项目:SOS-The-Healthcare-Companion    文件:ViewActivity.java   
public void setupTransitions() {
    // Add shared element transition animation if on Lollipop or later
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        // Enter transitions
        TransitionSet setEnter = new TransitionSet();

        Transition slideDown = new Explode();
        slideDown.addTarget(headerView);
        slideDown.excludeTarget(scrollView, true);
        slideDown.setDuration(500);
        setEnter.addTransition(slideDown);

        Transition fadeOut = new Slide(Gravity.BOTTOM);
        fadeOut.addTarget(scrollView);
        fadeOut.setDuration(500);
        setEnter.addTransition(fadeOut);

        // Exit transitions
        TransitionSet setExit = new TransitionSet();

        Transition slideDown2 = new Explode();
        slideDown2.addTarget(headerView);
        slideDown2.setDuration(570);
        setExit.addTransition(slideDown2);

        Transition fadeOut2 = new Slide(Gravity.BOTTOM);
        fadeOut2.addTarget(scrollView);
        fadeOut2.setDuration(280);
        setExit.addTransition(fadeOut2);

        getWindow().setEnterTransition(setEnter);
        getWindow().setReturnTransition(setExit);
    }
}
项目:Nird2    文件:BriarActivity.java   
public void setSceneTransitionAnimation() {
    if (Build.VERSION.SDK_INT < 21) return;
    Transition slide = new Slide(Gravity.RIGHT);
    slide.excludeTarget(android.R.id.statusBarBackground, true);
    slide.excludeTarget(android.R.id.navigationBarBackground, true);
    Window window = getWindow();
    window.requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
    window.setExitTransition(slide);
    window.setEnterTransition(slide);
    window.setTransitionBackgroundFadeDuration(getResources()
            .getInteger(android.R.integer.config_longAnimTime));
    window.setBackgroundDrawableResource(android.R.color.transparent);
}
项目:Nird2    文件:BriarActivity.java   
public void setSceneTransitionAnimation() {
    if (Build.VERSION.SDK_INT < 21) return;
    Transition slide = new Slide(Gravity.RIGHT);
    slide.excludeTarget(android.R.id.statusBarBackground, true);
    slide.excludeTarget(android.R.id.navigationBarBackground, true);
    Window window = getWindow();
    window.requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
    window.setExitTransition(slide);
    window.setEnterTransition(slide);
    window.setTransitionBackgroundFadeDuration(getResources()
            .getInteger(android.R.integer.config_longAnimTime));
    window.setBackgroundDrawableResource(android.R.color.transparent);
}
项目:TripleTap    文件:MainMenuFragment.java   
/**
 * Setup fragment transitions
 */
public void setupTransitions() {
    SidePropagation propagateBottom = new SidePropagation();
    propagateBottom.setSide(Gravity.BOTTOM);
    propagateBottom.setPropagationSpeed(2);

    SidePropagation propagateTop = new SidePropagation();
    propagateTop.setSide(Gravity.TOP);
    propagateTop.setPropagationSpeed(2);

    // Transition used for replacement fragments
    mNewEnterTransition = new Slide(Gravity.END);
    mNewEnterTransition.setPropagation(propagateBottom);
    mNewEnterTransition.setStartDelay(100);

    mNewExitTransition = new Slide(Gravity.END);
    mNewExitTransition.setPropagation(propagateBottom);
    mNewExitTransition.setStartDelay(0);

    // Transition used for main menu entering and exiting
    mMainExitTransition = new Slide(Gravity.START);
    mMainExitTransition.setPropagation(propagateTop);
    mMainExitTransition.setStartDelay(0);

    // Transition used for main menu reentering
    mMainReenterTransition = new Slide(Gravity.START);
    mMainReenterTransition.setPropagation(propagateTop);
    mMainReenterTransition.setStartDelay(200);

}