Java 类android.transition.TransitionManager 实例源码

项目:AnimatedListAdapter    文件:BaseAnimatedListAdapter.java   
public void setClickListener(final T holder) {
    holder.itemView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            final int position = holder.getAdapterPosition();
            if (position == RecyclerView.NO_POSITION) return;

            TransitionManager.beginDelayedTransition(mRecyclerView, expandCollapse);
            itemAnimator.setAnimateMoves(false);

            if (RecyclerView.NO_POSITION != mExpandedPosition) {
                notifyItemChanged(mExpandedPosition, COLLAPSE);
            }

            if (mExpandedPosition != position) {
                mExpandedPosition = position;
                notifyItemChanged(position, EXPAND);
                holder.itemView.requestFocus();
            } else {
                mExpandedPosition = RecyclerView.NO_POSITION;
            }

        }
    });
}
项目:mapbox-navigation-android    文件:InstructionView.java   
/**
 * Hide the instruction list and show the sound button.
 * <p>
 * This is based on orientation so the different layouts (for portrait vs. landscape)
 * can be animated appropriately.
 */
public void hideInstructionList() {
  int orientation = getContext().getResources().getConfiguration().orientation;
  if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
    ConstraintSet collapsed = new ConstraintSet();
    collapsed.clone(getContext(), R.layout.instruction_layout);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
      TransitionManager.beginDelayedTransition(InstructionView.this);
    }
    collapsed.applyTo(instructionLayout);
    instructionListLayout.setVisibility(INVISIBLE);
  } else {
    Animation slideUp = AnimationUtils.loadAnimation(getContext(), R.anim.slide_up_top);
    slideUp.setInterpolator(new AccelerateInterpolator());
    instructionListLayout.startAnimation(slideUp);
    instructionListLayout.setVisibility(INVISIBLE);
  }
}
项目:mapbox-navigation-android    文件:InstructionView.java   
/**
 * Show the instruction list and hide the sound button.
 * <p>
 * This is based on orientation so the different layouts (for portrait vs. landscape)
 * can be animated appropriately.
 */
public void showInstructionList() {
  int orientation = getContext().getResources().getConfiguration().orientation;
  if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
    ConstraintSet expanded = new ConstraintSet();
    expanded.clone(getContext(), R.layout.instruction_layout_alt);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
      TransitionManager.beginDelayedTransition(InstructionView.this);
    }
    expanded.applyTo(instructionLayout);
    instructionListLayout.setVisibility(VISIBLE);
  } else {
    Animation slideDown = AnimationUtils.loadAnimation(getContext(), R.anim.slide_down_top);
    slideDown.setInterpolator(new DecelerateInterpolator());
    instructionListLayout.setVisibility(VISIBLE);
    instructionListLayout.startAnimation(slideDown);
  }
}
项目:ConstraintDemo    文件:ConstraintSetActivity.java   
public void onApplyClick() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        TransitionManager.beginDelayedTransition(constraintLayout);
    }

    applyConstraintSet.setMargin(R.id.btn_1, ConstraintSet.START, 0);
    applyConstraintSet.setMargin(R.id.btn_1, ConstraintSet.END, 0);
    applyConstraintSet.setMargin(R.id.btn_2, ConstraintSet.START, 0);
    applyConstraintSet.setMargin(R.id.btn_2, ConstraintSet.END, 0);
    applyConstraintSet.setMargin(R.id.btn_3, ConstraintSet.START, 0);
    applyConstraintSet.setMargin(R.id.btn_3, ConstraintSet.END, 0);


    applyConstraintSet.centerHorizontally(R.id.btn_1, R.id.activity_constraint_set);
    applyConstraintSet.centerHorizontally(R.id.btn_2, R.id.activity_constraint_set);
    applyConstraintSet.centerHorizontally(R.id.btn_3, R.id.activity_constraint_set);
    applyConstraintSet.applyTo(constraintLayout);
}
项目:From-design-to-Android-part1    文件:OrderDialogFragment.java   
private void startCloneAnimation(View clonedView, View targetView) {
    clonedView.post(() -> {
            TransitionManager.beginDelayedTransition(
                (ViewGroup) binding.getRoot(), selectedViewTransition);

            // Fires the transition
            clonedView.setLayoutParams(SelectedParamsFactory
                .endParams(clonedView, targetView));
    });
}
项目:SDCardCleaner    文件:SDCardPercent.java   
/**
 * 刷新数据
 */
public void refresh() {
    long _space_free = Environment.getExternalStorageDirectory().getFreeSpace();
    long _fileCount_all = Global.get_fileCount_all();
    long _fileSize_all = Global.get_fileSize_all();
    long _fileCount_rubbish = Global.get_fileCount_rubbish();
    long _fileSize_rubbish = Global.get_fileSize_rubbish();

    TransitionManager.beginDelayedTransition(_line);
    _set_line.setGuidelinePercent(R.id.guideLine_rubbish, (float) NumberUtil.div(_fileSize_rubbish, _space_total, 3));
    _set_line.setGuidelinePercent(R.id.guideLine_file, (float) NumberUtil.div(_fileSize_all, _space_total, 3));
    _set_line.setGuidelinePercent(R.id.guideLine_system, (float) (1 - NumberUtil.div(_space_free, _space_total, 3)));
    _set_line.applyTo(_line);

    _text_system.setText(getContext().getString(R.string.state_fileCount_system, Formatter.formatFileSize(getContext(), _space_total - _space_free - _fileSize_all)));
    _text_blank.setText(getContext().getString(R.string.state_fileCount_blank, Formatter.formatFileSize(getContext(), _space_free)));
    _text_file.setText(getContext().getString(R.string.state_fileCount_file, Formatter.formatFileSize(getContext(), _fileSize_all), _fileCount_all));
    _text_rubbish.setText(getContext().getString(R.string.state_fileCount_rubbish, Formatter.formatFileSize(getContext(), _fileSize_rubbish), _fileCount_rubbish));
}
项目: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);
}
项目:android_packages_apps_tv    文件:TvTransitionManager.java   
public void goToEmptyScene(boolean withAnimation) {
    if (mCurrentScene == mEmptyScene) {
        return;
    }
    initIfNeeded();
    if (withAnimation) {
        mEmptyView.setAlpha(1.0f);
        transitionTo(mEmptyScene);
    } else {
        TransitionManager.go(mEmptyScene, null);
        // When transition is null, transition got stuck without calling endTransitions.
        TransitionManager.endTransitions(mEmptyScene.getSceneRoot());
        // Since Fade.OUT transition doesn't run, we need to set alpha manually.
        mEmptyView.setAlpha(0);
    }
}
项目:librus-client    文件:ProgressItem.java   
@Override
    public void bindViewHolder(final FlexibleAdapter adapter, ViewHolder holder, int position, List payloads) {
        TransitionManager.beginDelayedTransition((ViewGroup) holder.itemView);
        if (this.status == IDLE) {
            holder.button.setVisibility(View.VISIBLE);
            holder.button.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    ((TimetableAdapter) adapter).onLoadMoreListener.onLoadMore();
                }
            });
            holder.progressBar.setVisibility(View.GONE);
        } else if (status == LOADING) {
            holder.progressBar.setVisibility(View.VISIBLE);
            holder.button.setVisibility(View.GONE);
        }


//        LibrusUtils.logError("Progress item .bindViewHolder()");
    }
项目: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
    }
}
项目:Amumu    文件:DesignerNewsLogin.java   
@Override
public void onRequestPermissionsResult(int requestCode,
                                       String[] permissions,
                                       int[] grantResults) {
    if (requestCode == PERMISSIONS_REQUEST_GET_ACCOUNTS) {
        TransitionManager.beginDelayedTransition(container);
        if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
            setupAccountAutocomplete();
            username.requestFocus();
            username.showDropDown();
        } else {
            // if permission was denied check if we should ask again in the future (i.e. they
            // did not check 'never ask again')
            if (shouldShowRequestPermissionRationale(Manifest.permission.GET_ACCOUNTS)) {
                setupPermissionPrimer();
            } else {
                // denied & shouldn't ask again. deal with it (•_•) ( •_•)>⌐■-■ (⌐■_■)
                TransitionManager.beginDelayedTransition(container);
                permissionPrimer.setVisibility(View.GONE);
            }
        }
    }
}
项目:Amumu    文件:ImageSpanTarget.java   
@Override
public void onResourceReady(Bitmap bitmap, GlideAnimation<? super Bitmap> glideAnimation) {
    TextView tv = textView.get();
    if (tv != null) {
        BitmapDrawable bitmapDrawable = new BitmapDrawable(tv.getResources(), bitmap);
        // image span doesn't handle scaling so we manually set bounds
        if (bitmap.getWidth() > tv.getWidth()) {
            float aspectRatio = (float) bitmap.getHeight() / (float) bitmap.getWidth();
            bitmapDrawable.setBounds(0, 0, tv.getWidth(), (int) (aspectRatio * tv.getWidth()));
        } else {
            bitmapDrawable.setBounds(0, 0, bitmap.getWidth(), bitmap.getHeight());
        }
        ImageSpan span = new ImageSpan(bitmapDrawable);
        // add the image span and remove our marker
        SpannableStringBuilder ssb = new SpannableStringBuilder(tv.getText());
        int start = ssb.getSpanStart(loadingSpan);
        int end = ssb.getSpanEnd(loadingSpan);
        if (start >= 0 && end >= 0) {
            ssb.setSpan(span, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        }
        ssb.removeSpan(loadingSpan);
        // animate the change
        TransitionManager.beginDelayedTransition((ViewGroup) tv.getParent());
        tv.setText(ssb);
    }
}
项目:android-material-stepper    文件:StepTab.java   
private void updateSubtitle(@Nullable CharSequence newSubtitle) {
    if (ObjectsCompat.equals(newSubtitle, mStepSubtitleTextView.getText())) {
        return;
    }

    //Do not hide the subtitle if error message is empty
    if (!TextUtils.isEmpty(mSubtitle) && TextUtils.isEmpty(newSubtitle)) {
        newSubtitle = mSubtitle;
    }

    mStepSubtitleTextView.setText(newSubtitle);
    mStepSubtitleTextView.setVisibility(!TextUtils.isEmpty(newSubtitle) ? VISIBLE : GONE);
    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
        TransitionManager.beginDelayedTransition(this);
    }
}
项目:android-proguards    文件:DesignerNewsLogin.java   
@Override @TargetApi(Build.VERSION_CODES.M)
public void onRequestPermissionsResult(int requestCode,
                                       @NonNull String[] permissions,
                                       @NonNull int[] grantResults) {
    if (requestCode == PERMISSIONS_REQUEST_GET_ACCOUNTS) {
        TransitionManager.beginDelayedTransition(container);
        if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
            setupAccountAutocomplete();
            username.requestFocus();
            username.showDropDown();
        } else {
            // if permission was denied check if we should ask again in the future (i.e. they
            // did not check 'never ask again')
            if (shouldShowRequestPermissionRationale(Manifest.permission.GET_ACCOUNTS)) {
                setupPermissionPrimer();
            } else {
                // denied & shouldn't ask again. deal with it (•_•) ( •_•)>⌐■-■ (⌐■_■)
                TransitionManager.beginDelayedTransition(container);
                permissionPrimer.setVisibility(View.GONE);
            }
        }
    }
}
项目:android-proguards    文件:ImageSpanTarget.java   
@Override
public void onResourceReady(Bitmap bitmap, GlideAnimation<? super Bitmap> glideAnimation) {
    TextView tv = textView.get();
    if (tv != null) {
        BitmapDrawable bitmapDrawable = new BitmapDrawable(tv.getResources(), bitmap);
        // image span doesn't handle scaling so we manually set bounds
        if (bitmap.getWidth() > tv.getWidth()) {
            float aspectRatio = (float) bitmap.getHeight() / (float) bitmap.getWidth();
            bitmapDrawable.setBounds(0, 0, tv.getWidth(), (int) (aspectRatio * tv.getWidth()));
        } else {
            bitmapDrawable.setBounds(0, 0, bitmap.getWidth(), bitmap.getHeight());
        }
        ImageSpan span = new ImageSpan(bitmapDrawable);
        // add the image span and remove our marker
        SpannableStringBuilder ssb = new SpannableStringBuilder(tv.getText());
        int start = ssb.getSpanStart(loadingSpan);
        int end = ssb.getSpanEnd(loadingSpan);
        if (start >= 0 && end >= 0) {
            ssb.setSpan(span, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        }
        ssb.removeSpan(loadingSpan);
        // animate the change
        TransitionManager.beginDelayedTransition((ViewGroup) tv.getParent());
        tv.setText(ssb);
    }
}
项目:OldDriver-master    文件:DesignerNewsLogin.java   
@Override
public void onRequestPermissionsResult(int requestCode,
                                       String[] permissions,
                                       int[] grantResults) {
    if (requestCode == PERMISSIONS_REQUEST_GET_ACCOUNTS) {
        TransitionManager.beginDelayedTransition(container);
        if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
            setupAccountAutocomplete();
            username.requestFocus();
            username.showDropDown();
        } else {
            // if permission was denied check if we should ask again in the future (i.e. they
            // did not check 'never ask again')
            if (shouldShowRequestPermissionRationale(Manifest.permission.GET_ACCOUNTS)) {
                setupPermissionPrimer();
            } else {
                // denied & shouldn't ask again. deal with it (•_•) ( •_•)>⌐■-■ (⌐■_■)
                TransitionManager.beginDelayedTransition(container);
                permissionPrimer.setVisibility(View.GONE);
            }
        }
    }
}
项目:OldDriver-master    文件:ImageSpanTarget.java   
@Override
public void onResourceReady(Bitmap bitmap, GlideAnimation<? super Bitmap> glideAnimation) {
    TextView tv = textView.get();
    if (tv != null) {
        BitmapDrawable bitmapDrawable = new BitmapDrawable(tv.getResources(), bitmap);
        // image span doesn't handle scaling so we manually set bounds
        if (bitmap.getWidth() > tv.getWidth()) {
            float aspectRatio = (float) bitmap.getHeight() / (float) bitmap.getWidth();
            bitmapDrawable.setBounds(0, 0, tv.getWidth(), (int) (aspectRatio * tv.getWidth()));
        } else {
            bitmapDrawable.setBounds(0, 0, bitmap.getWidth(), bitmap.getHeight());
        }
        ImageSpan span = new ImageSpan(bitmapDrawable);
        // add the image span and remove our marker
        SpannableStringBuilder ssb = new SpannableStringBuilder(tv.getText());
        int start = ssb.getSpanStart(loadingSpan);
        int end = ssb.getSpanEnd(loadingSpan);
        if (start >= 0 && end >= 0) {
            ssb.setSpan(span, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        }
        ssb.removeSpan(loadingSpan);
        // animate the change
        TransitionManager.beginDelayedTransition((ViewGroup) tv.getParent());
        tv.setText(ssb);
    }
}
项目:CompositeAndroid    文件:ActivityDelegate.java   
public TransitionManager getContentTransitionManager() {
    if (mPlugins.isEmpty()) {
        return getOriginal().super_getContentTransitionManager();
    }

    final ListIterator<ActivityPlugin> iterator = mPlugins.listIterator(mPlugins.size());

    final CallFun0<TransitionManager> superCall = new CallFun0<TransitionManager>(
            "getContentTransitionManager()") {

        @Override
        public TransitionManager call() {
            if (iterator.hasPrevious()) {
                return iterator.previous().getContentTransitionManager(this);
            } else {
                return getOriginal().super_getContentTransitionManager();
            }
        }
    };
    return superCall.call();
}
项目:FabTransformingSample    文件:MainActivity.java   
private void changeFabMode(boolean transformed, boolean animate) {
    if (animate) {
        final TransitionSet transition = new FabTransformation(transformed, fab.getHeight() / 2f);
        TransitionManager.beginDelayedTransition(sceneRoot, transition);
    }

    final float baseMargin = getResources().getDimension(R.dimen.fab_margin);
    final FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) fab.getLayoutParams();
    params.bottomMargin = (int) (baseMargin - (transformed ? diff : 0));
    params.setMarginEnd((int) (baseMargin + (transformed ? diff * HORIZONTAL_FACTOR : 0)));
    fab.setLayoutParams(params);

    toolsContainer.setVisibility(transformed ? View.VISIBLE : View.INVISIBLE);
    tools.setVisibility(transformed ? View.VISIBLE : View.INVISIBLE);
    tools.setScaleX(transformed ? 1f : 0.8f);
    fab.setVisibility(transformed ? View.INVISIBLE : View.VISIBLE);
}
项目:auid2    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    mSceneRoot = (ViewGroup) findViewById(R.id.scene_root);

    mScene1 = Scene.getSceneForLayout(mSceneRoot, R.layout.scene1, this);
    mScene2 = Scene.getSceneForLayout(mSceneRoot, R.layout.scene2, this);

    mTransition = new ChangeBounds();
    mTransition.setDuration(DateUtils.SECOND_IN_MILLIS);
    mTransition.setInterpolator(new AccelerateDecelerateInterpolator());
    TransitionManager.go(mScene1);
    mCurrentScene = mScene1;

    findViewById(R.id.button).setOnClickListener(this);
}
项目:chanobol    文件:PostsDialog.java   
@TargetApi(Build.VERSION_CODES.LOLLIPOP) private void animatePostsArrival() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        postsView.setVisibility(View.INVISIBLE);
        postsView.postDelayed(new Runnable() {
            @Override public void run() {
                revealBackground();
                postsView.setVisibility(View.GONE);
                Transition t = TransitionInflater.from(getActivity()).inflateTransition(R.transition.postsdialog);
                TransitionManager.beginDelayedTransition(postsView, t);
                postsView.setVisibility(View.VISIBLE);
            }
        }, 10);
    } else {
        background.setVisibility(View.VISIBLE);
    }
}
项目: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);
}
项目:sprockets-android    文件:Transitions.java   
/**
 * {@link TransitionManager#beginDelayedTransition(ViewGroup) Begin a delayed transition} if
 * one is not already running.
 */
@UiThread
public static void tryDelayed(ViewGroup sceneRoot) {
    if (!sceneRoot.isLaidOut()) { // transition won't run
        return;
    }
    if (sDelayedTransition == null) {
        sDelayedTransition = new AutoTransition().addListener(new SimpleTransitionListener() {
            @Override
            public void onTransitionEnd(Transition transition) {
                super.onTransitionEnd(transition);
                sDelayedTransitionRunning = false;
            }
        });
    }
    if (!sDelayedTransitionRunning) {
        sDelayedTransitionRunning = true;
        TransitionManager.beginDelayedTransition(sceneRoot, sDelayedTransition);
    }
}
项目:plaid    文件:DesignerNewsLogin.java   
@Override @TargetApi(Build.VERSION_CODES.M)
public void onRequestPermissionsResult(int requestCode,
                                       @NonNull String[] permissions,
                                       @NonNull int[] grantResults) {
    if (requestCode == PERMISSIONS_REQUEST_GET_ACCOUNTS) {
        TransitionManager.beginDelayedTransition(container);
        if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
            setupAccountAutocomplete();
            username.requestFocus();
            username.showDropDown();
        } else {
            // if permission was denied check if we should ask again in the future (i.e. they
            // did not check 'never ask again')
            if (shouldShowRequestPermissionRationale(Manifest.permission.GET_ACCOUNTS)) {
                setupPermissionPrimer();
            } else {
                // denied & shouldn't ask again. deal with it (•_•) ( •_•)>⌐■-■ (⌐■_■)
                TransitionManager.beginDelayedTransition(container);
                permissionPrimer.setVisibility(View.GONE);
            }
        }
    }
}
项目:ApkLauncher    文件:Transitions.java   
public void selectScene(View view) {
    switch (view.getId()) {
        case R.id.scene1:
            mTransitionManager.transitionTo(mScene1);
            break;
        case R.id.scene2:
            mTransitionManager.transitionTo(mScene2);
            break;
        case R.id.scene3:
            mTransitionManager.transitionTo(mScene3);
            break;
        case R.id.scene4:
            // scene4 is not an actual 'Scene', but rather a dynamic change in the UI,
            // transitioned to using beginDelayedTransition() to tell the TransitionManager
            // to get ready to run a transition at the next frame
            TransitionManager.beginDelayedTransition(mSceneRoot);
            setNewSize(R.id.view1, 150, 25);
            setNewSize(R.id.view2, 150, 25);
            setNewSize(R.id.view3, 150, 25);
            setNewSize(R.id.view4, 150, 25);
            break;
    }
}
项目: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;
        }
    }
}
项目:binea_project_for_android    文件:AutoTransitionSample.java   
@Nullable @Override public View onCreateView(
        LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_autotransition, container, false);

    final TextView textView = (TextView) view.findViewById(R.id.text);
    final ViewGroup transitionGroup = (ViewGroup) view.findViewById(R.id.transitions_container);
    //transitionGroup.findViewById(R.id.button).setOnClickListener(visible -> {
    //    TransitionManager.beginDelayedTransition(transitionGroup);
    //
    //    textView.setVisibility(visible ? View.VISIBLE : View.GONE);
    //});
    transitionGroup.findViewById(R.id.button).setOnClickListener(new VisibleToggleClickListener() {
         @Override protected void changeVisibility(boolean visible) {
             TransitionManager.beginDelayedTransition(transitionGroup);
             textView.setVisibility(visible ? View.VISIBLE : View.GONE);
        }
    });
    return view;
}
项目:ApiDemos    文件:Transitions.java   
public void selectScene(View view) {
    switch (view.getId()) {
        case R.id.scene1:
            mTransitionManager.transitionTo(mScene1);
            break;
        case R.id.scene2:
            mTransitionManager.transitionTo(mScene2);
            break;
        case R.id.scene3:
            mTransitionManager.transitionTo(mScene3);
            break;
        case R.id.scene4:
            // scene4 is not an actual 'Scene', but rather a dynamic change in the UI,
            // transitioned to using beginDelayedTransition() to tell the TransitionManager
            // to get ready to run a transition at the next frame
            TransitionManager.beginDelayedTransition(mSceneRoot);
            setNewSize(R.id.view1, 150, 25);
            setNewSize(R.id.view2, 150, 25);
            setNewSize(R.id.view3, 150, 25);
            setNewSize(R.id.view4, 150, 25);
            break;
    }
}
项目:AcDisplay    文件:SettingsActivity.java   
/**
 * Switch to a specific Fragment with taking care of validation, Title and BackStack
 */
private Fragment switchToFragment(String fragmentName, Bundle args, boolean validate,
                                  boolean addToBackStack, int titleResId, CharSequence title,
                                  boolean withTransition) {
    if (validate && !isValidFragment(fragmentName)) {
        String message = "Invalid fragment for this activity: " + fragmentName;
        throw new IllegalArgumentException(message);
    }

    Fragment f = Fragment.instantiate(this, fragmentName, args);
    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    transaction.replace(android.R.id.content, f);

    if (withTransition && Device.hasKitKatApi())
        TransitionManager.beginDelayedTransition(mContent);
    if (addToBackStack) transaction.addToBackStack(SettingsActivity.BACK_STACK_PREFS);
    if (titleResId > 0) {
        transaction.setBreadCrumbTitle(titleResId);
    } else if (title != null) {
        transaction.setBreadCrumbTitle(title);
    }

    transaction.commitAllowingStateLoss();
    getFragmentManager().executePendingTransactions();
    return f;
}
项目:AcDisplay    文件:MediaWidget.java   
/**
 * Updates the content of the view to latest metadata
 * provided by {@link com.achep.acdisplay.services.media.MediaController2#getMetadata()}.
 */
private void populateMetadata() {
    if (mIdle) {
        ViewGroup vg = getView();
        if (Device.hasKitKatApi() && vg.isLaidOut() && getFragment().isAnimatable()) {
            TransitionManager.beginDelayedTransition(vg);
        }
    }

    Metadata metadata = mMediaController.getMetadata();
    ViewUtils.safelySetText(mTitleView, metadata.title);
    ViewUtils.safelySetText(mSubtitleView, metadata.subtitle);
    mDurationText.setText(formatTime(metadata.duration));
    mSeekUiAtomic.stop();
    mSeekBar.setMax(Math.min(100, (int) (metadata.duration / 1000L)));

    if (mArtworkView != null) {
        mArtworkView.setImageBitmap(metadata.bitmap);
    }
}
项目:chanobol    文件:PostsDialog.java   
@TargetApi(Build.VERSION_CODES.LOLLIPOP) private void animatePostsArrival() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        postsView.setVisibility(View.INVISIBLE);
        postsView.postDelayed(new Runnable() {
            @Override public void run() {
                revealBackground();
                postsView.setVisibility(View.GONE);
                Transition t = TransitionInflater.from(getActivity()).inflateTransition(R.transition.postsdialog);
                TransitionManager.beginDelayedTransition(postsView, t);
                postsView.setVisibility(View.VISIBLE);
            }
        }, 10);
    } else {
        background.setVisibility(View.VISIBLE);
    }
}
项目: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);
}
项目:GlassTune    文件:TuneGuitarActivity.java   
private void setPitchBarPosition(double frequency) {
    View pitchBar = (View)findViewById(R.id.tune_view_current_pitch);
    int margin = 20;
    double leftDP = NoteCalculator.getPitchBarPosition(frequency, 560);

    Transition moveTransition = new ChangeBounds();
    moveTransition.setDuration(300);
    moveTransition.setInterpolator(new LinearInterpolator());

    TransitionManager.beginDelayedTransition((ViewGroup) pitchBar.getRootView(), moveTransition);

    ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams)(pitchBar.getLayoutParams());
    Log.d(TAG, String.format("Current: %d New: %f", params.leftMargin, leftDP));
    params.setMargins((int)leftDP,0,0,0);
    pitchBar.setLayoutParams(params);
}
项目:HeadsUp    文件:SettingsActivity.java   
/**
 * Switch to a specific Fragment with taking care of validation, Title and BackStack
 */
private Fragment switchToFragment(String fragmentName, Bundle args, boolean validate,
                                  boolean addToBackStack, int titleResId, CharSequence title,
                                  boolean withTransition) {
    if (validate && !isValidFragment(fragmentName)) {
        String message = "Invalid fragment for this activity: " + fragmentName;
        throw new IllegalArgumentException(message);
    }

    Fragment f = Fragment.instantiate(this, fragmentName, args);
    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    transaction.replace(R.id.main_content, f);

    if (withTransition && Device.hasKitKatApi())
        TransitionManager.beginDelayedTransition(mContent);
    if (addToBackStack) transaction.addToBackStack(SettingsActivity.BACK_STACK_PREFS);
    if (titleResId > 0) {
        transaction.setBreadCrumbTitle(titleResId);
    } else if (title != null) {
        transaction.setBreadCrumbTitle(title);
    }

    transaction.commitAllowingStateLoss();
    getFragmentManager().executePendingTransactions();
    return f;
}
项目:BreakMeOffKitKat    文件:TransitionsDelayedFragment.java   
@OnClick({ R.id.text1 })
public void onTextClick() {

    // Create a TransitionSet that will animated ChangeBounds and Fade
    TransitionSet transitionSet = new TransitionSet();
    transitionSet.addTransition(new ChangeBounds());
    transitionSet.addTransition(new Fade());

    TransitionManager.beginDelayedTransition(mLayout, transitionSet);

    // Remove text1 from the Layout
    mLayout.removeView(mText1);

    // Increase the height of Text1 and set a top margin
    LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) mText1.getLayoutParams();
    params.height *= 2;
    params.topMargin = 100;
    mText1.setLayoutParams(params);

    // Add text1 back to the layout
    // TransitionManager will automagically apply animations
    mLayout.addView(mText1, 1);


}
项目:felix-on-android    文件:Transitions.java   
public void selectScene(View view) {
    switch (view.getId()) {
        case R.id.scene1:
            mTransitionManager.transitionTo(mScene1);
            break;
        case R.id.scene2:
            mTransitionManager.transitionTo(mScene2);
            break;
        case R.id.scene3:
            mTransitionManager.transitionTo(mScene3);
            break;
        case R.id.scene4:
            // scene4 is not an actual 'Scene', but rather a dynamic change in the UI,
            // transitioned to using beginDelayedTransition() to tell the TransitionManager
            // to get ready to run a transition at the next frame
            TransitionManager.beginDelayedTransition(mSceneRoot);
            setNewSize(R.id.view1, 150, 25);
            setNewSize(R.id.view2, 150, 25);
            setNewSize(R.id.view3, 150, 25);
            setNewSize(R.id.view4, 150, 25);
            break;
    }
}
项目:wwmmo    文件:BuildLayout.java   
/** Show the "build" popup sheet for the given {@link Design}. */
public void showBuildSheet(Design design) {
  final Colony colony = checkNotNull(colonies.get(viewPager.getCurrentItem()));

  bottomPaneContentView = new BuildBottomPane(
      getContext(), star, colony, design, (designType, count) -> {
          StarManager.i.updateStar(star, new StarModification.Builder()
              .type(StarModification.MODIFICATION_TYPE.ADD_BUILD_REQUEST)
              .colony_id(colony.id)
              .design_type(designType)
              .count(count));
          hideBottomSheet();
        });

  TransitionManager.beginDelayedTransition(bottomPane);
  bottomPane.getLayoutParams().height = ViewGroup.LayoutParams.WRAP_CONTENT;
  bottomPane.removeAllViews();
  bottomPane.addView((View) bottomPaneContentView);
}
项目:android-PictureInPicture    文件:MovieView.java   
/** Shows all the controls. */
public void showControls() {
    TransitionManager.beginDelayedTransition(this);
    mShade.setVisibility(View.VISIBLE);
    mToggle.setVisibility(View.VISIBLE);
    mFastForward.setVisibility(View.VISIBLE);
    mFastRewind.setVisibility(View.VISIBLE);
    mMinimize.setVisibility(View.VISIBLE);
}