Java Code Examples for android.transition.TransitionManager#beginDelayedTransition()

The following examples show how to use android.transition.TransitionManager#beginDelayedTransition() . 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: 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 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: MainActivity.java    From VehicleInfoOCR with GNU General Public License v3.0 6 votes vote down vote up
@TargetApi(19)
public void onDrawerButtonClicked(View v) {
    // drawer fade
    if(canDoTransitions)
        TransitionManager.beginDelayedTransition(superContainer,mFade);
    if(drawerView.getVisibility()== VISIBLE){
        vehicleNumber.setText("");
        drawerView.setVisibility(INVISIBLE);
        drawerBtn.animate().scaleX(1.1f).scaleY(1.1f).start();
    }
    else{
        checkInternetConnection();
        drawerView.setVisibility(VISIBLE);
        drawerBtn.animate().scaleX(1/1.1f).scaleY(1/1.1f).start();
    }
    // camBtn.performClick();
}
 
Example 4
Source File: SearchActivity.java    From android-proguards with Apache License 2.0 5 votes vote down vote up
void clearResults() {
    TransitionManager.beginDelayedTransition(container, getTransition(R.transition.auto));
    adapter.clear();
    dataManager.clear();
    results.setVisibility(View.GONE);
    progress.setVisibility(View.GONE);
    fab.setVisibility(View.GONE);
    confirmSaveContainer.setVisibility(View.GONE);
    resultsScrim.setVisibility(View.GONE);
    setNoResultsVisibility(View.GONE);
}
 
Example 5
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 6
Source File: GaugePanel.java    From trekarta with GNU General Public License v3.0 5 votes vote down vote up
public boolean setNavigationMode(boolean mode) {
    if (mNavigationMode == mode)
        return false;
    mNavigationMode = mode;
    int visibility = mode ? View.VISIBLE : View.GONE;
    TransitionManager.beginDelayedTransition(this);
    for (Gauge gauge : mGauges) {
        if (isNavigationGauge(gauge.getType()))
            gauge.setVisibility(visibility);
    }
    return true;
}
 
Example 7
Source File: MainActivity.java    From journaldev with MIT License 5 votes vote down vote up
private void revertAnimation() {
    show = false;

    ConstraintSet constraintSet = new ConstraintSet();
    constraintSet.clone(this, R.layout.activity_main);

    ChangeBounds transition = new ChangeBounds();
    transition.setInterpolator(new AnticipateInterpolator(1.0f));
    transition.setDuration(1200);

    TransitionManager.beginDelayedTransition(cc1, transition);
    constraintSet.applyTo(cc1);

}
 
Example 8
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 9
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 10
Source File: CacheControlActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private void updateStorageUsageRow() {
    View view = layoutManager.findViewByPosition(storageUsageRow);
    if (view instanceof StroageUsageView) {
        StroageUsageView stroageUsageView = ((StroageUsageView) view);
        long currentTime =  System.currentTimeMillis();
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && currentTime - fragmentCreateTime > 250) {
            TransitionSet transition = new TransitionSet();
            ChangeBounds changeBounds = new ChangeBounds();
            changeBounds.setDuration(250);
            changeBounds.excludeTarget(stroageUsageView.legendLayout,true);
            Fade in = new Fade(Fade.IN);
            in.setDuration(290);
            transition
                    .addTransition(new Fade(Fade.OUT).setDuration(250))
                    .addTransition(changeBounds)
                    .addTransition(in);
            transition.setOrdering(TransitionSet.ORDERING_TOGETHER);
            transition.setInterpolator(CubicBezierInterpolator.EASE_OUT);
            TransitionManager.beginDelayedTransition(listView, transition);
        }
        stroageUsageView.setStorageUsage(calculating, databaseSize, totalSize, totalDeviceFreeSize, totalDeviceSize);
        RecyclerView.ViewHolder holder = listView.findViewHolderForAdapterPosition(storageUsageRow);
        if (holder != null) {
            stroageUsageView.setEnabled(listAdapter.isEnabled(holder));
        }
    } else {
        listAdapter.notifyDataSetChanged();
    }
}
 
Example 11
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 12
Source File: SelectionModesActivity.java    From material-calendarview with MIT License 5 votes vote down vote up
@OnCheckedChanged(R.id.calendar_mode)
void onCalendarModeChanged(boolean checked) {
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
    TransitionManager.beginDelayedTransition(parent);
  }
  final CalendarMode mode = checked ? CalendarMode.WEEKS : CalendarMode.MONTHS;
  single.state().edit().setCalendarDisplayMode(mode).commit();
  multi.state().edit().setCalendarDisplayMode(mode).commit();
  range.state().edit().setCalendarDisplayMode(mode).commit();
  none.state().edit().setCalendarDisplayMode(mode).commit();
}
 
Example 13
Source File: MovieView.java    From media-samples with Apache License 2.0 5 votes vote down vote up
/** Hides all the controls. */
public void hideControls() {
    TransitionManager.beginDelayedTransition(this);
    mShade.setVisibility(View.INVISIBLE);
    mToggle.setVisibility(View.INVISIBLE);
    mFastForward.setVisibility(View.INVISIBLE);
    mFastRewind.setVisibility(View.INVISIBLE);
    mMinimize.setVisibility(View.INVISIBLE);
}
 
Example 14
Source File: NeuralModelActivity.java    From Synapse with Apache License 2.0 4 votes vote down vote up
private void prepareAnimation() {
    TransitionManager.beginDelayedTransition(mContainer);
}
 
Example 15
Source File: FragmentTransition.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
/**
 * Configures a transition for a single fragment container for which the transaction was
 * ordered. That means that the transaction has not been executed yet, so incoming
 * Views are not yet known.
 *
 * @param fragmentManager The executing FragmentManagerImpl
 * @param containerId The container ID that is executing the transition.
 * @param fragments A structure holding the transitioning fragments in this container.
 * @param nonExistentView A View that does not exist in the hierarchy. This is used to
 *                        prevent transitions from acting on other Views when there is no
 *                        other target.
 * @param nameOverrides A map of the shared element names from the starting fragment to
 *                      the final fragment's Views as given in
 *                      {@link FragmentTransaction#addSharedElement(View, String)}.
 */
private static void configureTransitionsOrdered(FragmentManagerImpl fragmentManager,
        int containerId, FragmentContainerTransition fragments,
        View nonExistentView, ArrayMap<String, String> nameOverrides) {
    ViewGroup sceneRoot = null;
    if (fragmentManager.mContainer.onHasView()) {
        sceneRoot = fragmentManager.mContainer.onFindViewById(containerId);
    }
    if (sceneRoot == null) {
        return;
    }
    final Fragment inFragment = fragments.lastIn;
    final Fragment outFragment = fragments.firstOut;
    final boolean inIsPop = fragments.lastInIsPop;
    final boolean outIsPop = fragments.firstOutIsPop;

    Transition enterTransition = getEnterTransition(inFragment, inIsPop);
    Transition exitTransition = getExitTransition(outFragment, outIsPop);

    ArrayList<View> sharedElementsOut = new ArrayList<>();
    ArrayList<View> sharedElementsIn = new ArrayList<>();

    TransitionSet sharedElementTransition = configureSharedElementsOrdered(sceneRoot,
            nonExistentView, nameOverrides, fragments, sharedElementsOut, sharedElementsIn,
            enterTransition, exitTransition);

    if (enterTransition == null && sharedElementTransition == null &&
            exitTransition == null) {
        return; // no transitions!
    }

    ArrayList<View> exitingViews = configureEnteringExitingViews(exitTransition,
            outFragment, sharedElementsOut, nonExistentView);

    if (exitingViews == null || exitingViews.isEmpty()) {
        exitTransition = null;
    }

    if (enterTransition != null) {
        // Ensure the entering transition doesn't target anything until the views are made
        // visible
        enterTransition.addTarget(nonExistentView);
    }

    Transition transition = mergeTransitions(enterTransition, exitTransition,
            sharedElementTransition, inFragment, fragments.lastInIsPop);

    if (transition != null) {
        transition.setNameOverrides(nameOverrides);
        final ArrayList<View> enteringViews = new ArrayList<>();
        scheduleRemoveTargets(transition,
                enterTransition, enteringViews, exitTransition, exitingViews,
                sharedElementTransition, sharedElementsIn);
        scheduleTargetChange(sceneRoot, inFragment, nonExistentView, sharedElementsIn,
                enterTransition, enteringViews, exitTransition, exitingViews);

        TransitionManager.beginDelayedTransition(sceneRoot, transition);
    }
}
 
Example 16
Source File: ConstraintSetHelper.java    From opentok-android-sdk-samples with MIT License 4 votes vote down vote up
public void applyToLayout(ConstraintLayout layout, boolean animated) {
    if (animated) {
        TransitionManager.beginDelayedTransition(layout);
    }
    set.applyTo(layout);
}
 
Example 17
Source File: LocationInformation.java    From trekarta with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onLocationStateChanged(LocationState locationState) {
    int visibility = (locationState == LocationState.DISABLED) ? View.GONE : View.VISIBLE;
    TransitionManager.beginDelayedTransition(mRootView, new Fade());
    mSwitchOffButton.setVisibility(visibility);
}
 
Example 18
Source File: LegendSignatureView.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public void setData(int index, long date, ArrayList<LineViewData> lines, boolean animateChanges) {
    int n = holdes.length;
    if (animateChanges) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            TransitionSet transition = new TransitionSet();
            transition.
                    addTransition(new Fade(Fade.OUT).setDuration(100)).
                    addTransition(new ChangeBounds().setDuration(150)).
                    addTransition(new Fade(Fade.IN).setDuration(100));
            transition.setOrdering(TransitionSet.ORDERING_SEQUENTIAL);
            TransitionManager.beginDelayedTransition(this, transition);
        }
    }

    if (isTopHourChart) {
        time.setText(String.format(Locale.ENGLISH, "%02d:00", date));
    } else {
        time.setText(formatData(new Date(date)));
        if (useHour) hourTime.setText(hourFormat.format(date));
    }

    int sum = 0;

    for (int i = 0; i < n; i++) {
        if (lines.get(i).enabled) sum += lines.get(i).line.y[index];
    }

    for (int i = 0; i < n; i++) {
        Holder h = holdes[i];

        if (!lines.get(i).enabled) {
            h.root.setVisibility(View.GONE);
        } else {
            ChartData.Line l = lines.get(i).line;
            if (h.root.getMeasuredHeight() == 0) {
                h.root.requestLayout();
            }
            h.root.setVisibility(View.VISIBLE);
            h.value.setText(formatWholeNumber(l.y[index]));
            h.signature.setText(l.name);
            if (l.colorKey != null && Theme.hasThemeKey(l.colorKey)) {
                h.value.setTextColor(Theme.getColor(l.colorKey));
            } else {
                h.value.setTextColor(Theme.getCurrentTheme().isDark() ? l.colorDark : l.color);
            }
            h.signature.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));

            if (showPercentage && h.percentage != null) {
                h.percentage.setVisibility(VISIBLE);
                h.percentage.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
                float v = lines.get(i).line.y[index] / (float) sum;
                if (v < 0.1f && v != 0f) {
                    h.percentage.setText(String.format(Locale.ENGLISH, "%.1f%s", (100f * v), "%"));
                } else {
                    h.percentage.setText(String.format(Locale.ENGLISH, "%d%s", Math.round(100 * v), "%"));
                }
            }
        }
    }

    if (zoomEnabled) {
        canGoZoom = sum > 0;
        chevron.setVisibility(sum > 0 ? View.VISIBLE : View.GONE);
    } else {
        canGoZoom = false;
        chevron.setVisibility(View.GONE);
    }
}
 
Example 19
Source File: ListBindingAdapters.java    From views-widgets-samples with Apache License 2.0 4 votes vote down vote up
/**
 * Starts a transition only if on KITKAT or higher.
 *
 * @param root The scene root
 */
private static void startTransition(ViewGroup root) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        TransitionManager.beginDelayedTransition(root);
    }
}
 
Example 20
Source File: DropDownView.java    From DropDownView with Apache License 2.0 4 votes vote down vote up
@TargetApi(Build.VERSION_CODES.KITKAT)
private void beginDelayedExpandTransition() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        TransitionManager.beginDelayedTransition(this, expandTransitionSet);
    }
}