android.transition.ArcMotion Java Examples

The following examples show how to use android.transition.ArcMotion. 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: AnswerDetailActivity.java    From AndroidPlusJava with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void init() {
    super.init();
    String serialised = getIntent().getStringExtra(Constant.EXTRA_ANSWER);
    try {
        mAnswer = (Answer) AVObject.parseAVObject(serialised);
    } catch (Exception e) {
        e.printStackTrace();
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        mQuestionTitle.setTransitionName(getString(R.string.question_title_transition));
        mAnswerText.setTransitionName(getString(R.string.answer_transition));
        ChangeBounds changeBounds = new ChangeBounds();
        changeBounds.setPathMotion(new ArcMotion());
        getWindow().setSharedElementEnterTransition(changeBounds);
    }

    initActionBar();
    initViews();
}
 
Example #2
Source File: ComicDetailsActivity.java    From HHComicViewer with Apache License 2.0 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void setMotion() {
    // Activity设置自定义 Shared Element切换动画
    //定义ArcMotion
    ArcMotion arcMotion = new ArcMotion();
    arcMotion.setMinimumHorizontalAngle(50f);
    arcMotion.setMinimumVerticalAngle(50f);
    //插值器,控制速度
    Interpolator interpolator = AnimationUtils
            .loadInterpolator(this, android.R.interpolator.fast_out_slow_in);
    //实例化自定义的ChangeBounds
    CustomChangeBounds changeBounds = new CustomChangeBounds();
    changeBounds.setPathMotion(arcMotion);
    changeBounds.setInterpolator(interpolator);
    changeBounds.addTarget(mBinding.comicThumbnailComicDetails);
    //将切换动画应用到当前的Activity的进入和返回
    getWindow().setSharedElementEnterTransition(changeBounds);
    getWindow().setSharedElementReturnTransition(changeBounds);
}
 
Example #3
Source File: BaseHeaderActivity.java    From CloudReader with Apache License 2.0 6 votes vote down vote up
/**
 * 设置自定义 Shared Element切换动画
 * 默认不开启曲线路径切换动画,
 * 开启需要重写setHeaderPicView(),和调用此方法并将isShow值设为true
 *
 * @param imageView 共享的图片
 * @param isShow    是否显示曲线动画
 */
protected void setMotion(ImageView imageView, boolean isShow) {
    if (!isShow) {
        return;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        // 定义ArcMotion
        ArcMotion arcMotion = new ArcMotion();
        // 设置曲线幅度
        arcMotion.setMinimumHorizontalAngle(10f);
        arcMotion.setMinimumVerticalAngle(10f);
        //插值器,控制速度
        Interpolator interpolator = AnimationUtils.loadInterpolator(this, android.R.interpolator.fast_out_slow_in);

        // 实例化自定义的ChangeBounds
        changeBounds = new CustomChangeBounds();
        changeBounds.setPathMotion(arcMotion);
        changeBounds.setInterpolator(interpolator);
        changeBounds.addTarget(imageView);
        // 将切换动画应用到当前的Activity的进入和返回
        getWindow().setSharedElementEnterTransition(changeBounds);
        getWindow().setSharedElementReturnTransition(changeBounds);
    }
}
 
Example #4
Source File: MaterialContainerTransform.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
private ProgressThresholdsGroup buildThresholdsGroup(boolean entering) {
  PathMotion pathMotion = getPathMotion();
  if (pathMotion instanceof ArcMotion || pathMotion instanceof MaterialArcMotion) {
    return getThresholdsOrDefault(
        entering, DEFAULT_ENTER_THRESHOLDS_ARC, DEFAULT_RETURN_THRESHOLDS_ARC);
  } else {
    return getThresholdsOrDefault(entering, DEFAULT_ENTER_THRESHOLDS, DEFAULT_RETURN_THRESHOLDS);
  }
}
 
Example #5
Source File: QuestionDetailActivity.java    From AndroidPlusJava with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void init() {
    super.init();
    String serialized = getIntent().getStringExtra(Constant.EXTRA_QUESTION);
    try {
        //反序列化
        mQuestion = (Question) Question.parseAVObject(serialized);
    } catch (Exception e) {
        e.printStackTrace();
    }

    mQuestionTitle.setText(mQuestion.getTitle());
    if (mQuestion.getDescription() == null || mQuestion.getDescription().length() == 0) {
        mQuestionDescription.setVisibility(View.GONE);
    } else {
        mQuestionDescription.setVisibility(View.VISIBLE);
        mQuestionDescription.setText(mQuestion.getDescription());
    }

    User currentUser = AVUser.getCurrentUser(User.class);
    isFavorite = currentUser.isFavouredQuestion(mQuestion.getObjectId());
    mFavourQuestion.setSelected(isFavorite);

    //配置转场动画
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        mQuestionTitle.setTransitionName(getString(R.string.question_title_transition));
        mQuestionDescription.setTransitionName(getString(R.string.question_des_transition));
        ChangeBounds changeBounds = new ChangeBounds();
        changeBounds.setPathMotion(new ArcMotion());
        getWindow().setSharedElementEnterTransition(changeBounds);
    }

    setSupportActionBar(mToolBar);
    ActionBar supportActionBar = getSupportActionBar();
    supportActionBar.setDisplayHomeAsUpEnabled(true);
    mCollapsingToolBar.setTitle(" ");

    String[] titles = getResources().getStringArray(R.array.answer_category);
    mViewPager.setAdapter(new QuestionDetailPagerAdapter(getSupportFragmentManager(), titles, mQuestion.getObjectId()));
    mTabLayout.setupWithViewPager(mViewPager);
}