Java Code Examples for android.transition.Slide#setDuration()

The following examples show how to use android.transition.Slide#setDuration() . 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: MainActivity.java    From trekarta with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onRouteDetails(Route route) {
    Fragment fragment = mFragmentManager.findFragmentByTag("routeInformation");
    if (fragment == null) {
        fragment = Fragment.instantiate(this, RouteInformation.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, "routeInformation");
        ft.addToBackStack("routeInformation");
        ft.commit();
        updateMapViewArea();
    }
    ((RouteInformation) fragment).setRoute(route);
    mViews.extendPanel.setForeground(getDrawable(R.drawable.dim));
    mViews.extendPanel.getForeground().setAlpha(0);
    ObjectAnimator anim = ObjectAnimator.ofInt(mViews.extendPanel.getForeground(), "alpha", 0, 255);
    anim.setDuration(500);
    anim.start();
}
 
Example 2
Source File: FragmentSelect.java    From imageres_resolution with MIT License 6 votes vote down vote up
private void switchToPreview(Uri uri) {
    Fragment fragment = FragmentPreview.instance(uri);

    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
        int duration = getResources().getInteger(android.R.integer.config_mediumAnimTime);

        Slide slideTransition = new Slide(Gravity.LEFT);
        slideTransition.setDuration(duration);
        setExitTransition(slideTransition);

        Slide slideTransition2 = new Slide(Gravity.RIGHT);
        slideTransition2.setDuration(duration);
        fragment.setEnterTransition(slideTransition2);

        TransitionInflater inflater = TransitionInflater.from(getContext());
        Transition transition = inflater.inflateTransition(R.transition.transition_default);
        fragment.setSharedElementEnterTransition(transition);
    }

    getFragmentManager()
            .beginTransaction()
            .replace(R.id.frg_docker, fragment)
            .addSharedElement(mBtnFindWrapper, ViewCompat.getTransitionName(mBtnFindWrapper))
            .addToBackStack("select")
            .commitAllowingStateLoss();
}
 
Example 3
Source File: DetailActivity.java    From animation-samples with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 4
Source File: MainActivity.java    From trekarta with GNU General Public License v3.0 6 votes vote down vote up
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);
    mViews.extendPanel.setForeground(getDrawable(R.drawable.dim));
    mViews.extendPanel.getForeground().setAlpha(0);
    ObjectAnimator anim = ObjectAnimator.ofInt(mViews.extendPanel.getForeground(), "alpha", 0, 255);
    anim.setDuration(500);
    anim.start();
}
 
Example 5
Source File: MainActivity.java    From Android-Animation-Set with Apache License 2.0 5 votes vote down vote up
private void setupWindowAnimations() {
    Slide slide = new Slide();
    slide.setSlideEdge(Gravity.LEFT);
    slide.setDuration(1000);
    getWindow().setReenterTransition(slide);
    getWindow().setExitTransition(slide);
}
 
Example 6
Source File: FragmentPreview.java    From imageres_resolution with MIT License 5 votes vote down vote up
@OnClick(R.id.btn_start_process)
void onClick(View view) {
    String type = getType();
    String rate = getRate();
    String noise = getNoise();

    Fragment fragment = FragmentProcess.instance(mUri, type, rate, noise);
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
        int duration = getResources().getInteger(android.R.integer.config_mediumAnimTime);

        Slide slideTransition = new Slide(Gravity.LEFT);
        slideTransition.setDuration(duration);
        setExitTransition(slideTransition);

        Slide slideTransition2 = new Slide(Gravity.RIGHT);
        slideTransition2.setDuration(duration);
        fragment.setEnterTransition(slideTransition2);

        TransitionInflater inflater = TransitionInflater.from(getContext());
        Transition transition = inflater.inflateTransition(R.transition.transition_default);
        fragment.setSharedElementEnterTransition(transition);
    }

    getFragmentManager()
            .beginTransaction()
            .replace(R.id.frg_docker, fragment)
            .addToBackStack("preview")
            .addSharedElement(mIvPreview, ViewCompat.getTransitionName(mIvPreview))
            .commitAllowingStateLoss();
}
 
Example 7
Source File: FragmentProcess.java    From imageres_resolution with MIT License 5 votes vote down vote up
@Override
public void onResponse(Call<Bitmap> call, Response<Bitmap> response) {
    Bitmap image = response.body();
    if (null == image) {
        Toast.makeText(getActivity(), "缩放图片失败", Toast.LENGTH_LONG).show();
        getFragmentManager().popBackStack();
        return;
    }

    Fragment fragment = FragmentResult.instance(mUri);
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
        int duration = getResources().getInteger(android.R.integer.config_mediumAnimTime);

        Slide slideTransition = new Slide(Gravity.LEFT);
        slideTransition.setDuration(duration);
        setExitTransition(slideTransition);

        Slide slideTransition2 = new Slide(Gravity.RIGHT);
        slideTransition2.setDuration(duration);
        fragment.setEnterTransition(slideTransition2);

        TransitionInflater inflater = TransitionInflater.from(getContext());
        Transition transition = inflater.inflateTransition(R.transition.transition_default);
        fragment.setSharedElementEnterTransition(transition);
    }

    IActivity activity = (IActivity) getActivity();
    activity.setImage(image);
    getFragmentManager()
            .beginTransaction()
            .replace(R.id.frg_docker, fragment)
            .addSharedElement(mIvProcess, ViewCompat.getTransitionName(mIvProcess))
            .commitAllowingStateLoss();
}
 
Example 8
Source File: VideoDetailActivity.java    From Aurora with Apache License 2.0 5 votes vote down vote up
@Override
public void initData(Bundle savedInstanceState) {
    initMedia();
    if (videoInfo.getData().getConsumption() !=null ){
        initRecyclerView();
        mPresenter.getRelaRelateVideoInfo(videoInfo.getData().getId());
        mPresenter.getShareInfo(videoInfo.getData().getId());
    }else {
        mPresenter.getVideoData(videoInfo.getData().getId());
    }
    dragBottomView.setDismissedListener(this);
    replyDragBottomView.setDismissedListener(this);
    if (supportsTransitions()){
        Slide slide = new Slide(Gravity.BOTTOM);
        slide.setDuration(500L);
        slide.excludeTarget(android.R.id.statusBarBackground, true);
        slide.excludeTarget(android.R.id.navigationBarBackground, true);
        slide.excludeTarget(R.id.rl_screen, true);
        slide.excludeTarget(R.id.detail_player, true);
        getWindow().setEnterTransition(slide);
        getWindow().getEnterTransition().excludeTarget(R.id.frameLayout,true);
        getWindow().getEnterTransition().excludeTarget(R.id.fl_loading,true);
        Fade fade = new Fade();
        fade.setDuration(500L);
        getWindow().setReturnTransition(fade);
    }

}
 
Example 9
Source File: FlutterVideoDetailActivity.java    From Aurora with Apache License 2.0 5 votes vote down vote up
@Override
public void initData(Bundle savedInstanceState) {
    initMedia();
    if (videoInfo.getData().getConsumption() !=null ){
        initRecyclerView();
        mPresenter.getRelaRelateVideoInfo(videoInfo.getData().getId());
        mPresenter.getShareInfo(videoInfo.getData().getId());
    }else {
        mPresenter.getVideoData(videoInfo.getData().getId());
    }
    dragBottomView.setDismissedListener(this);
    replyDragBottomView.setDismissedListener(this);
    if (supportsTransitions()){
        Slide slide = new Slide(Gravity.BOTTOM);
        slide.setDuration(500L);
        slide.excludeTarget(android.R.id.statusBarBackground, true);
        slide.excludeTarget(android.R.id.navigationBarBackground, true);
        slide.excludeTarget(R.id.rl_screen, true);
        slide.excludeTarget(R.id.detail_player, true);
        getWindow().setEnterTransition(slide);
        getWindow().getEnterTransition().excludeTarget(R.id.frameLayout,true);
        getWindow().getEnterTransition().excludeTarget(R.id.fl_loading,true);
        Fade fade = new Fade();
        fade.setDuration(500L);
        getWindow().setReturnTransition(fade);
    }

}
 
Example 10
Source File: ReadActivity.java    From Jreader with GNU General Public License v2.0 5 votes vote down vote up
/**
*   设置转换动画  在5.0系统自身已经带有这种效果
*/
@TargetApi(21)
private void setupWindowAnimations() {

        Fade fade = new Fade();
        fade.setDuration(500);
        getWindow().setEnterTransition(fade);

        Slide slide = new Slide();
        slide.setDuration(500);
        getWindow().setReturnTransition(fade);

}
 
Example 11
Source File: MainActivity.java    From Study_Android_Demo with Apache License 2.0 5 votes vote down vote up
private void setupWindowAnimations() {
    Slide slide = new Slide();
    slide.setSlideEdge(Gravity.LEFT);
    slide.setDuration(1000);
    getWindow().setReenterTransition(slide);
    getWindow().setExitTransition(slide);
}
 
Example 12
Source File: OfflineDownloadBaseActivity.java    From HHComicViewer with Apache License 2.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
protected Visibility buildEnterTransition() {
    Slide enterTransition = new Slide();
    enterTransition.setDuration(getResources().getInteger(R.integer.anim_duration_medium));
    enterTransition.setSlideEdge(Gravity.RIGHT); //从右边滑动进入
    return enterTransition;
}
 
Example 13
Source File: MainActivity.java    From trekarta with GNU General Public License v3.0 5 votes vote down vote up
@SuppressLint("ClickableViewAccessibility")
@Override
public void onWaypointDetails(Waypoint waypoint, boolean fromList) {
    Bundle args = new Bundle(3);
    args.putBoolean(WaypointInformation.ARG_DETAILS, fromList);
    if (fromList || mLocationState != LocationState.DISABLED) {
        if (mLocationState != LocationState.DISABLED && mLocationService != null) {
            Location location = mLocationService.getLocation();
            args.putDouble(WaypointInformation.ARG_LATITUDE, location.getLatitude());
            args.putDouble(WaypointInformation.ARG_LONGITUDE, location.getLongitude());
        } else {
            MapPosition position = mMap.getMapPosition();
            args.putDouble(WaypointInformation.ARG_LATITUDE, position.getLatitude());
            args.putDouble(WaypointInformation.ARG_LONGITUDE, position.getLongitude());
        }
    }

    Fragment fragment = mFragmentManager.findFragmentByTag("amenityInformation");
    if (fragment != null) {
        mFragmentManager.popBackStack("amenityInformation", FragmentManager.POP_BACK_STACK_INCLUSIVE);
    }
    fragment = mFragmentManager.findFragmentByTag("waypointInformation");
    if (fragment == null) {
        fragment = Fragment.instantiate(this, WaypointInformation.class.getName(), args);
        Slide slide = new Slide(Gravity.BOTTOM);
        slide.setDuration(getResources().getInteger(android.R.integer.config_shortAnimTime));
        fragment.setEnterTransition(slide);
        FragmentTransaction ft = mFragmentManager.beginTransaction();
        ft.replace(R.id.bottomSheetPanel, fragment, "waypointInformation");
        ft.addToBackStack("waypointInformation");
        ft.commit();
    }
    ((WaypointInformation) fragment).setWaypoint(waypoint);
    mViews.extendPanel.setForeground(getDrawable(R.drawable.dim));
    mViews.extendPanel.getForeground().setAlpha(0);
    ObjectAnimator anim = ObjectAnimator.ofInt(mViews.extendPanel.getForeground(), "alpha", 0, 255);
    anim.setDuration(500);
    anim.start();
}
 
Example 14
Source File: DetailActivity.java    From android-instant-apps with Apache License 2.0 4 votes vote down vote up
@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);
    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);
}
 
Example 15
Source File: MainActivity.java    From trekarta with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onFeatureDetails(long id, boolean fromList) {
    Bundle args = new Bundle(3);
    //args.putBoolean(AmenityInformation.ARG_DETAILS, fromList);

    if (fromList || mLocationState != LocationState.DISABLED) {
        if (mLocationState != LocationState.DISABLED && mLocationService != null) {
            Location location = mLocationService.getLocation();
            args.putDouble(AmenityInformation.ARG_LATITUDE, location.getLatitude());
            args.putDouble(AmenityInformation.ARG_LONGITUDE, location.getLongitude());
        } else {
            MapPosition position = mMap.getMapPosition();
            args.putDouble(AmenityInformation.ARG_LATITUDE, position.getLatitude());
            args.putDouble(AmenityInformation.ARG_LONGITUDE, position.getLongitude());
        }
    }

    Fragment fragment = mFragmentManager.findFragmentByTag("waypointInformation");
    if (fragment != null) {
        mFragmentManager.popBackStack("waypointInformation", FragmentManager.POP_BACK_STACK_INCLUSIVE);
    }
    fragment = mFragmentManager.findFragmentByTag("amenityInformation");
    if (fragment == null) {
        fragment = Fragment.instantiate(this, AmenityInformation.class.getName(), args);
        Slide slide = new Slide(Gravity.BOTTOM);
        // 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.bottomSheetPanel, fragment, "amenityInformation");
        ft.addToBackStack("amenityInformation");
        ft.commit();
        updateMapViewArea();
    }
    ((AmenityInformation) fragment).setPreferredLanguage(Configuration.getLanguage());
    ((AmenityInformation) fragment).setAmenity(id);
    mViews.extendPanel.setForeground(getDrawable(R.drawable.dim));
    mViews.extendPanel.getForeground().setAlpha(0);
    ObjectAnimator anim = ObjectAnimator.ofInt(mViews.extendPanel.getForeground(), "alpha", 0, 255);
    anim.setDuration(500);
    anim.start();
}
 
Example 16
Source File: TransitionAnimationBySlideActivity.java    From Study_Android_Demo with Apache License 2.0 4 votes vote down vote up
private Transition buildEnterTransitionByCode() {
    Slide enterTransition = new Slide();
    enterTransition.setDuration(500);
    enterTransition.setSlideEdge(Gravity.RIGHT);
    return enterTransition;
}
 
Example 17
Source File: DetailActivity.java    From atlas with Apache License 2.0 4 votes vote down vote up
@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);
    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);
}
 
Example 18
Source File: TransitionAnimationBySlideActivity.java    From Android-Animation-Set with Apache License 2.0 4 votes vote down vote up
private Transition buildEnterTransitionByCode() {
    Slide enterTransition = new Slide();
    enterTransition.setDuration(500);
    enterTransition.setSlideEdge(Gravity.RIGHT);
    return enterTransition;
}