android.transition.TransitionManager Java Examples

The following examples show how to use android.transition.TransitionManager. 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: ProgramEventDetailActivity.java    From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License 7 votes vote down vote up
@Override
public void showHideFilter() {
    Transition transition = new ChangeBounds();
    transition.setDuration(200);
    TransitionManager.beginDelayedTransition(binding.backdropLayout, transition);
    backDropActive = !backDropActive;
    ConstraintSet initSet = new ConstraintSet();
    initSet.clone(binding.backdropLayout);
    binding.filterOpen.setVisibility(backDropActive ? View.VISIBLE : View.GONE);

    if (backDropActive) {
        initSet.connect(R.id.eventsLayout, ConstraintSet.TOP, R.id.filterLayout, ConstraintSet.BOTTOM, 50);
    } else {
        initSet.connect(R.id.eventsLayout, ConstraintSet.TOP, R.id.backdropGuideTop, ConstraintSet.BOTTOM, 0);
    }

    initSet.applyTo(binding.backdropLayout);
}
 
Example #2
Source File: DesignerNewsLogin.java    From android-proguards with Apache License 2.0 6 votes vote down vote up
@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);
            }
        }
    }
}
 
Example #3
Source File: PopupWindow.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Displays the content view in a popup window anchored to the corner of
 * another view. The window is positioned according to the specified
 * gravity and offset by the specified x and y coordinates.
 * <p>
 * If there is not enough room on screen to show the popup in its entirety,
 * this method tries to find a parent scroll view to scroll. If no parent
 * view can be scrolled, the specified vertical gravity will be ignored and
 * the popup will anchor itself such that it is visible.
 * <p>
 * If the view later scrolls to move <code>anchor</code> to a different
 * location, the popup will be moved correspondingly.
 *
 * @param anchor the view on which to pin the popup window
 * @param xoff A horizontal offset from the anchor in pixels
 * @param yoff A vertical offset from the anchor in pixels
 * @param gravity Alignment of the popup relative to the anchor
 *
 * @see #dismiss()
 */
public void showAsDropDown(View anchor, int xoff, int yoff, int gravity) {
    if (isShowing() || !hasContentView()) {
        return;
    }

    TransitionManager.endTransitions(mDecorView);

    attachToAnchor(anchor, xoff, yoff, gravity);

    mIsShowing = true;
    mIsDropdown = true;

    final WindowManager.LayoutParams p =
            createPopupLayoutParams(anchor.getApplicationWindowToken());
    preparePopup(p);

    final boolean aboveAnchor = findDropDownPosition(anchor, p, xoff, yoff,
            p.width, p.height, gravity, mAllowScrollingAnchorParent);
    updateAboveAnchor(aboveAnchor);
    p.accessibilityIdOfAnchor = (anchor != null) ? anchor.getAccessibilityViewId() : -1;

    invokePopup(p);
}
 
Example #4
Source File: CoverActivity.java    From GyroscopeImageDemo with Apache License 2.0 6 votes vote down vote up
/**
 * 模拟入场动画
 */
private void runEnterAnim() {
  getScreenSize();
  mIvCover.post(new Runnable() {
    @Override public void run() {
      FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(mScreenWidth, mScreenHeight);
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        ChangeImageTransform changeImageTransform = new ChangeImageTransform();
        AutoTransition autoTransition = new AutoTransition();
        changeImageTransform.setDuration(TRANSITIONS_DURATION);
        autoTransition.setDuration(TRANSITIONS_DURATION);
        TransitionSet transitionSet = new TransitionSet();
        transitionSet.addTransition(autoTransition);
        transitionSet.addTransition(changeImageTransform);
        TransitionManager.beginDelayedTransition(mTransitionsContainer, transitionSet);
        mIvCover.setLayoutParams(params);
        mIvCover.setScaleType(ImageView.ScaleType.CENTER_CROP);
      } else {
        mIvCover.setLayoutParams(params);
        mIvCover.setScaleType(ImageView.ScaleType.CENTER_CROP);
      }
    }
  });
}
 
Example #5
Source File: SettingsActivity.java    From HeadsUp with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #6
Source File: ExitTransitionCoordinator.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private void beginTransitions() {
    Transition sharedElementTransition = getSharedElementExitTransition();
    Transition viewsTransition = getExitTransition();

    Transition transition = mergeTransitions(sharedElementTransition, viewsTransition);
    ViewGroup decorView = getDecor();
    if (transition != null && decorView != null) {
        setGhostVisibility(View.INVISIBLE);
        scheduleGhostVisibilityChange(View.INVISIBLE);
        if (viewsTransition != null) {
            setTransitioningViewsVisiblity(View.VISIBLE, false);
        }
        TransitionManager.beginDelayedTransition(decorView, transition);
        scheduleGhostVisibilityChange(View.VISIBLE);
        setGhostVisibility(View.VISIBLE);
        if (viewsTransition != null) {
            setTransitioningViewsVisiblity(View.INVISIBLE, false);
        }
        decorView.invalidate();
    } else {
        transitionStarted();
    }
}
 
Example #7
Source File: DataSetDetailActivity.java    From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void showHideFilter() {
    Transition transition = new ChangeBounds();
    transition.setDuration(200);
    TransitionManager.beginDelayedTransition(binding.backdropLayout, transition);
    backDropActive = !backDropActive;
    ConstraintSet initSet = new ConstraintSet();
    initSet.clone(binding.backdropLayout);
    if (backDropActive) {
        initSet.connect(R.id.eventsLayout, ConstraintSet.TOP, R.id.filterLayout, ConstraintSet.BOTTOM, 50);
    }
    else {
        initSet.connect(R.id.eventsLayout, ConstraintSet.TOP, R.id.backdropGuideTop, ConstraintSet.BOTTOM, 0);
    }
    initSet.applyTo(binding.backdropLayout);

    binding.filterOpen.setVisibility(backDropActive ? View.VISIBLE : View.GONE);
}
 
Example #8
Source File: ExitTransitionCoordinator.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
public void resetViews() {
    ViewGroup decorView = getDecor();
    if (decorView != null) {
        TransitionManager.endTransitions(decorView);
    }
    if (mTransitioningViews != null) {
        showViews(mTransitioningViews, true);
        setTransitioningViewsVisiblity(View.VISIBLE, true);
    }
    showViews(mSharedElements, true);
    mIsHidden = true;
    if (!mIsReturning && decorView != null) {
        decorView.suppressLayout(false);
    }
    moveSharedElementsFromOverlay();
    clearState();
}
 
Example #9
Source File: ActivityOptions.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * This method should be called when the {@link #startSharedElementAnimation(Window, Pair[])}
 * animation must be stopped and the Views reset. This can happen if there was an error
 * from startActivity or a springboard activity and the animation should stop and reset.
 *
 * @hide
 */
public static void stopSharedElementAnimation(Window window) {
    final View decorView = window.getDecorView();
    if (decorView == null) {
        return;
    }
    final ExitTransitionCoordinator exit = (ExitTransitionCoordinator)
            decorView.getTag(com.android.internal.R.id.cross_task_transition);
    if (exit != null) {
        exit.cancelPendingTransitions();
        decorView.setTagInternal(com.android.internal.R.id.cross_task_transition, null);
        TransitionManager.endTransitions((ViewGroup) decorView);
        exit.resetViews();
        exit.clearState();
        decorView.setVisibility(View.VISIBLE);
    }
}
 
Example #10
Source File: SearchTEActivity.java    From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void swipeFilters(boolean general) {
    Transition transition = new ChangeBounds();
    transition.setDuration(200);
    TransitionManager.beginDelayedTransition(binding.backdropLayout, transition);
    if (backDropActive && !general && switchOpenClose == 0)
        switchOpenClose = 1;
    else if (backDropActive && general && switchOpenClose == 1)
        switchOpenClose = 0;
    else {
        switchOpenClose = general ? 0 : 1;
        backDropActive = !backDropActive;
    }
    binding.filterOpen.setVisibility(backDropActive ? View.VISIBLE : View.GONE);

    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT)
        activeFilter(general);
}
 
Example #11
Source File: ImageSpanTarget.java    From android-proguards with Apache License 2.0 6 votes vote down vote up
@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);
    }
}
 
Example #12
Source File: CustomTransitionFragment.java    From animation-samples with Apache License 2.0 6 votes vote down vote up
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    Context context = getActivity();
    FrameLayout container = (FrameLayout) view.findViewById(R.id.container);
    view.findViewById(R.id.show_next_scene).setOnClickListener(this);
    if (null != savedInstanceState) {
        mCurrentScene = savedInstanceState.getInt(STATE_CURRENT_SCENE);
    }
    // We set up the Scenes here.
    mScenes = new Scene[] {
            Scene.getSceneForLayout(container, R.layout.scene1, context),
            Scene.getSceneForLayout(container, R.layout.scene2, context),
            Scene.getSceneForLayout(container, R.layout.scene3, context),
    };
    // This is the custom Transition.
    mTransition = new ChangeColor();
    // Show the initial Scene.
    TransitionManager.go(mScenes[mCurrentScene % mScenes.length]);
}
 
Example #13
Source File: MediaWidget.java    From AcDisplay with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example #14
Source File: HomeActivity.java    From android-proguards with Apache License 2.0 5 votes vote down vote up
@Override
public void onAvailable(Network network) {
    connected = true;
    if (adapter.getDataItemCount() != 0) return;
    runOnUiThread(new Runnable() {
        @Override
        public void run() {
            TransitionManager.beginDelayedTransition(drawer);
            noConnection.setVisibility(View.GONE);
            loading.setVisibility(View.VISIBLE);
            dataManager.loadAllDataSources();
        }
    });
}
 
Example #15
Source File: MainActivity.java    From trekarta with GNU General Public License v3.0 5 votes vote down vote up
@SuppressLint("RestrictedApi")
@Override
public FloatingActionButton enableActionButton() {
    if (mViews.listActionButton.getVisibility() == View.VISIBLE)
        mViews.listActionButton.setVisibility(View.INVISIBLE);
    TransitionManager.beginDelayedTransition(mViews.coordinatorLayout, new Fade());
    mViews.actionButton.setVisibility(View.VISIBLE);
    return mViews.actionButton;
}
 
Example #16
Source File: DesignerNewsLogin.java    From android-proguards with Apache License 2.0 5 votes vote down vote up
private void showLoading() {
    TransitionManager.beginDelayedTransition(container);
    title.setVisibility(View.GONE);
    usernameLabel.setVisibility(View.GONE);
    permissionPrimer.setVisibility(View.GONE);
    passwordLabel.setVisibility(View.GONE);
    actionsContainer.setVisibility(View.GONE);
    loading.setVisibility(View.VISIBLE);
}
 
Example #17
Source File: DesignerNewsLogin.java    From android-proguards with Apache License 2.0 5 votes vote down vote up
private void showLogin() {
    TransitionManager.beginDelayedTransition(container);
    title.setVisibility(View.VISIBLE);
    usernameLabel.setVisibility(View.VISIBLE);
    passwordLabel.setVisibility(View.VISIBLE);
    actionsContainer.setVisibility(View.VISIBLE);
    loading.setVisibility(View.GONE);
}
 
Example #18
Source File: MainActivity.java    From trekarta with GNU General Public License v3.0 5 votes vote down vote up
@SuppressLint("RestrictedApi")
@Override
public FloatingActionButton enableListActionButton() {
    TransitionManager.beginDelayedTransition(mViews.coordinatorLayout, new Fade());
    mViews.listActionButton.setVisibility(View.VISIBLE);
    return mViews.listActionButton;
}
 
Example #19
Source File: DynamicSettersActivity.java    From material-calendarview with MIT License 5 votes vote down vote up
@OnClick(R.id.button_months)
public void onSetMonthMode() {
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && animateModeTransition.isChecked()) {
    TransitionManager.beginDelayedTransition(parent);
  }
  widget.state().edit().setCalendarDisplayMode(CalendarMode.MONTHS).commit();
}
 
Example #20
Source File: SearchActivity.java    From Melophile with Apache License 2.0 5 votes vote down vote up
private void gotResult() {
  progressBar.setVisibility(View.GONE);
  if (pager.getVisibility() != View.VISIBLE) {
    TransitionManager.beginDelayedTransition(root, getTransition(R.transition.search_show_result));
    tabs.setVisibility(View.VISIBLE);
    pager.setVisibility(View.VISIBLE);
  }
}
 
Example #21
Source File: MainActivity.java    From auid2 with Apache License 2.0 5 votes vote down vote up
@Override
public void onClick(View v) {
    if (mCurrentScene == mScene1) {
        TransitionManager.go(mScene2, mTransition);
        mCurrentScene = mScene2;
    } else {
        TransitionManager.go(mScene1, mTransition);
        mCurrentScene = mScene1;
    }
}
 
Example #22
Source File: MusicCoverView.java    From Music-Cover-View with Apache License 2.0 5 votes vote down vote up
private void morphToCircle() {
    if (mIsMorphing) {
        return;
    }
    TransitionManager.beginDelayedTransition((ViewGroup) getParent(), mRectToCircleTransition);
    setScaleType(ScaleType.CENTER_INSIDE);
}
 
Example #23
Source File: NiboOriginDestinationPickerFragment.java    From Nibo with MIT License 5 votes vote down vote up
private void addMargins() {
    mContentCardView.postDelayed(new Runnable() {
        @Override
        public void run() {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
                TransitionManager.beginDelayedTransition(mContentCardView);
            }
            setMargins(mContentCardView, dpToPx(16), 0, dpToPx(16), 0);
        }
    }, 200);
}
 
Example #24
Source File: NiboOriginDestinationPickerFragment.java    From Nibo with MIT License 5 votes vote down vote up
private void removeMargins() {
    mContentCardView.postDelayed(new Runnable() {
        @Override
        public void run() {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
                TransitionManager.beginDelayedTransition(mContentCardView);
            }
            setMargins(mContentCardView, 0, 0, 0, 0);
        }
    }, 200);
}
 
Example #25
Source File: NiboPickerFragment.java    From Nibo with MIT License 5 votes vote down vote up
void hideAddressWithTransition() {

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            TransitionManager.beginDelayedTransition(mRootLayout);
        }
        mLocationDetails.setVisibility(View.GONE);
        mMap.setPadding(0, 0, 0, 0);

    }
 
Example #26
Source File: NiboPickerFragment.java    From Nibo with MIT License 5 votes vote down vote up
void showAddressWithTransition() {

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            TransitionManager.beginDelayedTransition(mRootLayout);
        }
        mLocationDetails.setVisibility(View.VISIBLE);
        mMap.setPadding(0, 0, 0, mLocationDetails.getHeight());

    }
 
Example #27
Source File: TransitionKitKat.java    From Noyze with Apache License 2.0 5 votes vote down vote up
@Override public void beginDelayedTransition(ViewGroup sceneRoot, Object transition) {
    if (transition instanceof Transition) {
        Transition trans = (Transition) transition;
        trans.addListener(AcceleratedTransitionListener.get());
        TransitionManager.beginDelayedTransition(sceneRoot, trans);
    }
}
 
Example #28
Source File: BoardAdapter.java    From BoardView with Apache License 2.0 5 votes vote down vote up
public void addItem(int column,int index, Object item){
    BoardItem boardItem = (BoardItem)((ViewGroup)((ViewGroup)boardView.getChildAt(0)).getChildAt(0)).getChildAt(column);
    TransitionManager.beginDelayedTransition(boardItem, transition);
    ScrollView scrollView = (ScrollView)boardItem.getChildAt(1);
    LinearLayout llColumn = (LinearLayout)scrollView.getChildAt(0);
    columns.get(column).objects.add(index,item);
    View v = createItemView(context,columns.get(column).header_object,item,column,index);
    llColumn.addView(v,index);
    boardView.addBoardItem(v,column);
    llColumn.invalidate();
    columns.get(column).views.add(index,v);
}
 
Example #29
Source File: BoardAdapter.java    From BoardView with Apache License 2.0 5 votes vote down vote up
public void addColumn(int index, Column column){
    columns.add(index,column);
    for(int j = 0; j < getItemCount(index);j++){
        column.objects.add(createItemObject(index,j));
        column.views.add(createItemView(context,createHeaderObject(index),createItemObject(index,j),index,j));
    }
    column.items_locked = isItemLocked(index);
    column.column_locked = isColumnLocked(index);
    column.header_object = createHeaderObject(index);
    column.footer_object = createFooterObject(index);
    column.header = createHeaderView(context,column.header_object,index);
    column.footer = createFooterView(context,column.footer_object,index);
    TransitionManager.beginDelayedTransition(boardView, boardViewTransition);
    boardView.addColumnList(column.header,column.views,column.footer,index);
}
 
Example #30
Source File: GaugePanel.java    From trekarta with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onMenuItemClick(MenuItem item) {
    TransitionManager.beginDelayedTransition(this);
    int type = item.getItemId();
    if (mGaugeMap.indexOfKey(type) >= 0)
        removeGauge(type);
    else
        addGauge(type);
    if (mMapHolder != null)
        mMapHolder.updateMapViewArea();
    return true;
}