List of usage examples for android.animation ObjectAnimator ofInt
public static <T> ObjectAnimator ofInt(T target, Property<T, Integer> property, int... values)
From source file:de.dmxcontrol.fragment.ActionSelectorFragment.java
public void updateStateSelected(final int state) { boolean jump = false; if (state != Integer.MIN_VALUE) { jump = Math.abs(mState - state) > 1; mState = state;/*from w w w .j av a 2 s. c o m*/ } if (crrActionButton != null) { crrActionButton.setSelected(false); } switch (mState) { case STATE_DEVICE_PANEL: crrActionButton = bDeviceAction; break; case STATE_INTENSITY_PANEL: crrActionButton = bIntensityAction; break; case STATE_COLOR_PANEL: crrActionButton = bColorAction; break; case STATE_PANTILT_PANEL: crrActionButton = bPanTiltAction; break; case STATE_GOBO_PANEL: crrActionButton = bGoboAction; break; case STATE_OPTIC_PANEL: crrActionButton = bOpticAction; break; case STATE_PRISM_PANEL: crrActionButton = bPrismAction; break; case STATE_RAW_PANEL: crrActionButton = bRawAction; break; case STATE_EFFECT_PANEL: crrActionButton = bEffectAction; break; case STATE_PRESET_PANEL: crrActionButton = bPresetAction; break; case STATE_PROGRAMMER_PANEL: crrActionButton = bProgrammerAction; break; default: crrActionButton = bDeviceAction; } crrActionButton.setSelected(true); final boolean fJump = jump; if (state != Integer.MIN_VALUE) { if (scrollView.getClass() == HorizontalScrollView.class) { final HorizontalScrollView scroll = ((HorizontalScrollView) scrollView); new Handler().post(new Runnable() { @Override public void run() { final float destination = ((crrActionButton.getLeft() - (scrollView.getWidth() / 2))) + (crrActionButton.getWidth() / 2); ObjectAnimator animator = ObjectAnimator.ofInt(scroll, "scrollX", (int) destination); if (!fJump) { animator.setDuration(600); } else { animator.setDuration(1200); } animator.start(); } }); } else if (scrollView.getClass() == ScrollView.class) { final ScrollView scroll = ((ScrollView) scrollView); new Handler().post(new Runnable() { @Override public void run() { final float destination = ((crrActionButton.getBottom() - (scrollView.getHeight() / 2))) - (crrActionButton.getHeight() / 2) + (getStatusBarHeight() / 2); ObjectAnimator animator = ObjectAnimator.ofInt(scroll, "scrollY", (int) destination); if (!fJump) { animator.setDuration(600); } else { animator.setDuration(1200); } animator.start(); } }); } } }
From source file:com.google.android.apps.muzei.settings.SettingsChooseSourceFragment.java
private void updateSelectedItem(boolean allowAnimate) { ComponentName previousSelectedSource = mSelectedSource; mSelectedSource = mSourceManager.getSelectedSource(); if (previousSelectedSource != null && previousSelectedSource.equals(mSelectedSource)) { // Only update status for (final Source source : mSources) { if (!source.componentName.equals(mSelectedSource) || source.rootView == null) { continue; }// w ww .j a v a 2s .co m updateSourceStatusUi(source); } return; } // This is a newly selected source. boolean selected; int index = -1; for (final Source source : mSources) { ++index; if (source.componentName.equals(previousSelectedSource)) { selected = false; } else if (source.componentName.equals(mSelectedSource)) { mSelectedSourceIndex = index; selected = true; } else { continue; } if (source.rootView == null) { continue; } View sourceImageButton = source.rootView.findViewById(R.id.source_image); Drawable drawable = selected ? mSelectedSourceImage : source.icon; drawable.setColorFilter(source.color, PorterDuff.Mode.SRC_ATOP); sourceImageButton.setBackground(drawable); float alpha = selected ? 1f : ALPHA_UNSELECTED; source.rootView.animate().alpha(alpha).setDuration(mAnimationDuration); if (selected) { updateSourceStatusUi(source); } animateSettingsButton(source.settingsButton, selected && source.settingsActivity != null, allowAnimate); } if (mSelectedSourceIndex >= 0 && allowAnimate) { if (mCurrentScroller != null) { mCurrentScroller.cancel(); } // For some reason smoothScrollTo isn't very smooth.. mCurrentScroller = ObjectAnimator.ofInt(mSourceScrollerView, "scrollX", mItemWidth * mSelectedSourceIndex); mCurrentScroller.setDuration(mAnimationDuration); mCurrentScroller.start(); } }
From source file:com.ltf.mytoolslibrary.viewbase.viewPagerGuidanceActivityMyLib.SpringIndicator.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private void createIndicatorColorAnim() { indicatorColorAnim = ObjectAnimator.ofInt(springView, "indicatorColor", indicatorColorArray); indicatorColorAnim.setEvaluator(new ArgbEvaluator()); indicatorColorAnim.setDuration(INDICATOR_ANIM_DURATION); }
From source file:com.money.manager.ex.home.HomeFragment.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { switch (loader.getId()) { case LOADER_ACCOUNT_BILLS: try {/*from w ww.j av a 2 s . co m*/ renderAccountsList(data); } catch (Exception e) { Timber.e(e, "rendering account list"); } // set total for accounts in the main Drawer. EventBus.getDefault().post(new AccountsTotalLoadedEvent(txtTotalAccounts.getText().toString())); break; case LOADER_INCOME_EXPENSES: double income = 0, expenses = 0; if (data != null) { while (data.moveToNext()) { expenses = data.getDouble(data.getColumnIndex(IncomeVsExpenseReportEntity.Expenses)); income = data.getDouble(data.getColumnIndex(IncomeVsExpenseReportEntity.Income)); } } TextView txtIncome = (TextView) getActivity().findViewById(R.id.textViewIncome); TextView txtExpenses = (TextView) getActivity().findViewById(R.id.textViewExpenses); TextView txtDifference = (TextView) getActivity().findViewById(R.id.textViewDifference); // set value if (txtIncome != null) txtIncome.setText(mCurrencyService.getCurrencyFormatted(mCurrencyService.getBaseCurrencyId(), MoneyFactory.fromDouble(income))); if (txtExpenses != null) txtExpenses.setText(mCurrencyService.getCurrencyFormatted(mCurrencyService.getBaseCurrencyId(), MoneyFactory.fromDouble(Math.abs(expenses)))); if (txtDifference != null) txtDifference.setText(mCurrencyService.getCurrencyFormatted(mCurrencyService.getBaseCurrencyId(), MoneyFactory.fromDouble(income - Math.abs(expenses)))); // manage progressbar final ProgressBar barIncome = (ProgressBar) getActivity().findViewById(R.id.progressBarIncome); final ProgressBar barExpenses = (ProgressBar) getActivity().findViewById(R.id.progressBarExpenses); if (barIncome != null && barExpenses != null) { barIncome.setMax((int) (Math.abs(income) + Math.abs(expenses))); barExpenses.setMax((int) (Math.abs(income) + Math.abs(expenses))); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) { ObjectAnimator animationIncome = ObjectAnimator.ofInt(barIncome, "progress", (int) Math.abs(income)); animationIncome.setDuration(1000); // 0.5 second animationIncome.setInterpolator(new DecelerateInterpolator()); animationIncome.start(); ObjectAnimator animationExpenses = ObjectAnimator.ofInt(barExpenses, "progress", (int) Math.abs(expenses)); animationExpenses.setDuration(1000); // 0.5 second animationExpenses.setInterpolator(new DecelerateInterpolator()); animationExpenses.start(); } else { barIncome.setProgress((int) Math.abs(income)); barExpenses.setProgress((int) Math.abs(expenses)); } } break; } // Close the cursor. MmxDatabaseUtils.closeCursor(data); }
From source file:org.michaelbel.bottomsheet.BottomSheet.java
@Override public void dismiss() { if (dismissed) { return;/*from w ww . j a va 2 s . c o m*/ } dismissed = true; cancelSheetAnimation(); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether( ObjectAnimator.ofFloat(containerView, "translationY", containerView.getMeasuredHeight() + Utils.dp(getContext(), 10)), ObjectAnimator.ofInt(backDrawable, "alpha", 0)); if (useFastDismiss) { int height = containerView.getMeasuredHeight(); animatorSet.setDuration( Math.max(60, (int) (180 * (height - containerView.getTranslationY()) / (float) height))); useFastDismiss = false; } else { animatorSet.setDuration(180); } animatorSet.setInterpolator(new AccelerateInterpolator()); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); if (currentSheetAnimation != null && currentSheetAnimation.equals(animation)) { currentSheetAnimation = null; handler.post(new Runnable() { @Override public void run() { try { dismissInternal(); } catch (Exception e) { Log.e(TAG, e.getMessage()); } } }); } } @Override public void onAnimationCancel(Animator animation) { super.onAnimationCancel(animation); if (currentSheetAnimation != null && currentSheetAnimation.equals(animation)) { currentSheetAnimation = null; } } }); animatorSet.start(); currentSheetAnimation = animatorSet; if (bottomSheetCallBack != null) { bottomSheetCallBack.onClose(); } }
From source file:com.google.android.apps.muzei.settings.ChooseSourceFragment.java
private void updateSelectedItem(com.google.android.apps.muzei.room.Source selectedSource, boolean allowAnimate) { ComponentName previousSelectedSource = mSelectedSource; if (selectedSource != null) { mSelectedSource = selectedSource.componentName; }//w w w . ja va 2s.c o m if (previousSelectedSource != null && previousSelectedSource.equals(mSelectedSource)) { // Only update status for (final Source source : mSources) { if (!source.componentName.equals(mSelectedSource) || source.rootView == null) { continue; } updateSourceStatusUi(source); } return; } // This is a newly selected source. boolean selected; int index = -1; for (final Source source : mSources) { ++index; if (source.componentName.equals(previousSelectedSource)) { selected = false; } else if (source.componentName.equals(mSelectedSource)) { mSelectedSourceIndex = index; selected = true; } else { continue; } if (source.rootView == null) { continue; } View sourceImageButton = source.rootView.findViewById(R.id.source_image); Drawable drawable = selected ? mSelectedSourceImage : source.icon; drawable.setColorFilter(source.color, PorterDuff.Mode.SRC_ATOP); sourceImageButton.setBackground(drawable); float alpha = selected ? 1f : Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && source.targetSdkVersion >= Build.VERSION_CODES.O ? ALPHA_DISABLED : ALPHA_UNSELECTED; source.rootView.animate().alpha(alpha).setDuration(mAnimationDuration); if (selected) { updateSourceStatusUi(source); } animateSettingsButton(source.settingsButton, selected && source.settingsActivity != null, allowAnimate); } if (mSelectedSourceIndex >= 0 && allowAnimate) { if (mCurrentScroller != null) { mCurrentScroller.cancel(); } // For some reason smoothScrollTo isn't very smooth.. mCurrentScroller = ObjectAnimator.ofInt(mSourceScrollerView, "scrollX", mItemWidth * mSelectedSourceIndex); mCurrentScroller.setDuration(mAnimationDuration); mCurrentScroller.start(); } }
From source file:com.nononsenseapps.feeder.ui.BaseActivity.java
protected void onActionBarAutoShowOrHide(boolean shown) { if (mStatusBarColorAnimator != null) { mStatusBarColorAnimator.cancel(); }/* w w w. j ava2s .co m*/ mStatusBarColorAnimator = ObjectAnimator .ofInt(mLPreviewUtils, "statusBarColor", shown ? mThemedStatusBarColor : Color.BLACK) .setDuration(250); mStatusBarColorAnimator.setEvaluator(ARGB_EVALUATOR); mStatusBarColorAnimator.start(); for (View view : mHideableHeaderViews) { if (shown) { view.animate().translationY(0).alpha(1).setDuration(HEADER_HIDE_ANIM_DURATION) .setInterpolator(new DecelerateInterpolator()); } else { view.animate().translationY(-view.getBottom()).alpha(0).setDuration(HEADER_HIDE_ANIM_DURATION) .setInterpolator(new DecelerateInterpolator()); } } for (View view : mHideableFooterViews) { if (shown) { view.animate().translationY(0).alpha(1).setDuration(HEADER_HIDE_ANIM_DURATION) .setInterpolator(new DecelerateInterpolator()); } else { view.animate().translationY(view.getHeight()).alpha(0).setDuration(HEADER_HIDE_ANIM_DURATION) .setInterpolator(new DecelerateInterpolator()); } } }
From source file:com.money.manager.ex.fragment.HomeFragment.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { MainActivity mainActivity = null;/* ww w .j av a 2 s .co m*/ if (getActivity() != null && getActivity() instanceof MainActivity) mainActivity = (MainActivity) getActivity(); switch (loader.getId()) { case ID_LOADER_USER_NAME: if (data != null && data.moveToFirst()) { while (data.isAfterLast() == false) { String infoValue = data.getString(data.getColumnIndex(infoTable.INFONAME)); // save into preferences username and basecurrency id if (Constants.INFOTABLE_USERNAME.equalsIgnoreCase(infoValue)) { application.setUserName(data.getString(data.getColumnIndex(infoTable.INFOVALUE))); } else if (Constants.INFOTABLE_BASECURRENCYID.equalsIgnoreCase(infoValue)) { //application.setBaseCurrencyId(data.getInt(data.getColumnIndex(infoTable.INFOVALUE))); } data.moveToNext(); } } // show username if (!TextUtils.isEmpty(application.getUserName())) ((SherlockFragmentActivity) getActivity()).getSupportActionBar() .setSubtitle(application.getUserName()); // set user name on drawer if (mainActivity != null) mainActivity.setDrawableUserName(application.getUserName()); break; case ID_LOADER_ACCOUNT_BILLS: double curTotal = 0, curReconciled = 0; AccountBillsAdapter adapter = null; linearHome.setVisibility(data != null && data.getCount() > 0 ? View.VISIBLE : View.GONE); linearWelcome.setVisibility(linearHome.getVisibility() == View.GONE ? View.VISIBLE : View.GONE); // cycle cursor if (data != null && data.moveToFirst()) { while (data.isAfterLast() == false) { curTotal += data.getDouble(data.getColumnIndex(QueryAccountBills.TOTALBASECONVRATE)); curReconciled += data.getDouble(data.getColumnIndex(QueryAccountBills.RECONCILEDBASECONVRATE)); data.moveToNext(); } // create adapter adapter = new AccountBillsAdapter(getActivity(), data); } // write accounts total txtTotalAccounts.setText(currencyUtils.getBaseCurrencyFormatted(curTotal)); // manage footer listview if (linearFooter == null) { linearFooter = (LinearLayout) getActivity().getLayoutInflater().inflate(R.layout.item_account_bills, null); // textview into layout txtFooterSummary = (TextView) linearFooter.findViewById(R.id.textVievItemAccountTotal); txtFooterSummaryReconciled = (TextView) linearFooter .findViewById(R.id.textVievItemAccountTotalReconciled); // set text TextView txtTextSummary = (TextView) linearFooter.findViewById(R.id.textVievItemAccountName); txtTextSummary.setText(R.string.summary); // invisibile image ImageView imgSummary = (ImageView) linearFooter.findViewById(R.id.imageViewAccountType); imgSummary.setVisibility(View.INVISIBLE); // set color textview txtTextSummary.setTextColor(Color.GRAY); txtFooterSummary.setTextColor(Color.GRAY); txtFooterSummaryReconciled.setTextColor(Color.GRAY); } // remove footer lstAccountBills.removeFooterView(linearFooter); // set text txtFooterSummary.setText(txtTotalAccounts.getText()); txtFooterSummaryReconciled.setText(currencyUtils.getBaseCurrencyFormatted(curReconciled)); // add footer lstAccountBills.addFooterView(linearFooter, null, false); // set adapter and shown lstAccountBills.setAdapter(adapter); setListViewAccountBillsVisible(true); // set total accounts in drawer if (mainActivity != null) { mainActivity.setDrawableTotalAccounts(txtTotalAccounts.getText().toString()); } break; case ID_LOADER_BILL_DEPOSITS: mainActivity.setDrawableRepeatingTransactions(data != null ? data.getCount() : 0); break; case ID_LOADER_INCOME_EXPENSES: double income = 0, expenses = 0; if (data != null && data.moveToFirst()) { while (!data.isAfterLast()) { expenses = data.getDouble(data.getColumnIndex(QueryReportIncomeVsExpenses.Expenses)); income = data.getDouble(data.getColumnIndex(QueryReportIncomeVsExpenses.Income)); //move to next record data.moveToNext(); } } TextView txtIncome = (TextView) getActivity().findViewById(R.id.textViewIncome); TextView txtExpenses = (TextView) getActivity().findViewById(R.id.textViewExpenses); TextView txtDifference = (TextView) getActivity().findViewById(R.id.textViewDifference); // set value if (txtIncome != null) txtIncome.setText(currencyUtils.getCurrencyFormatted(currencyUtils.getBaseCurrencyId(), income)); if (txtExpenses != null) txtExpenses.setText( currencyUtils.getCurrencyFormatted(currencyUtils.getBaseCurrencyId(), Math.abs(expenses))); if (txtDifference != null) txtDifference.setText(currencyUtils.getCurrencyFormatted(currencyUtils.getBaseCurrencyId(), income - Math.abs(expenses))); // manage progressbar final ProgressBar barIncome = (ProgressBar) getActivity().findViewById(R.id.progressBarIncome); final ProgressBar barExpenses = (ProgressBar) getActivity().findViewById(R.id.progressBarExpenses); if (barIncome != null && barExpenses != null) { barIncome.setMax((int) (Math.abs(income) + Math.abs(expenses))); barExpenses.setMax((int) (Math.abs(income) + Math.abs(expenses))); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) { ObjectAnimator animationIncome = ObjectAnimator.ofInt(barIncome, "progress", (int) Math.abs(income)); animationIncome.setDuration(1000); // 0.5 second animationIncome.setInterpolator(new DecelerateInterpolator()); animationIncome.start(); ObjectAnimator animationExpenses = ObjectAnimator.ofInt(barExpenses, "progress", (int) Math.abs(expenses)); animationExpenses.setDuration(1000); // 0.5 second animationExpenses.setInterpolator(new DecelerateInterpolator()); animationExpenses.start(); } else { barIncome.setProgress((int) Math.abs(income)); barExpenses.setProgress((int) Math.abs(expenses)); } } } }
From source file:com.justplay1.shoppist.features.search.widget.FloatingSearchView.java
private void fadeIn(boolean enter) { ValueAnimator backgroundAnim;/*from ww w. j a v a 2 s. com*/ if (Build.VERSION.SDK_INT >= 19) { backgroundAnim = ObjectAnimator.ofInt(backgroundDrawable, "alpha", enter ? 255 : 0); } else { backgroundAnim = ValueAnimator.ofInt(enter ? 0 : 255, enter ? 255 : 0); backgroundAnim.addUpdateListener(animation -> { int value = (Integer) animation.getAnimatedValue(); backgroundDrawable.setAlpha(value); }); } backgroundAnim.setDuration(enter ? DEFAULT_DURATION_ENTER : DEFAULT_DURATION_EXIT); backgroundAnim.setInterpolator(enter ? DECELERATE : ACCELERATE); backgroundAnim.start(); Drawable icon = unwrap(getIcon()); if (icon != null) { ObjectAnimator iconAnim = ObjectAnimator.ofFloat(icon, "progress", enter ? 1 : 0); iconAnim.setDuration(backgroundAnim.getDuration()); iconAnim.setInterpolator(backgroundAnim.getInterpolator()); iconAnim.start(); } }
From source file:com.owen.view.views.PieChart.java
/** * Initialize the control. This code is in a separate method so that it can be * called from both constructors.//from www.j a v a 2 s. com */ private void init() { // Force the background to software rendering because otherwise the Blur // filter won't work. setLayerToSW(this); // Set up the paint for the label text mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mTextPaint.setColor(mTextColor); if (mTextHeight == 0) { mTextHeight = mTextPaint.getTextSize(); } else { mTextPaint.setTextSize(mTextHeight); } // Set up the paint for the pie slices mPiePaint = new Paint(Paint.ANTI_ALIAS_FLAG); mPiePaint.setStyle(Paint.Style.FILL); mPiePaint.setTextSize(mTextHeight); // Set up the paint for the shadow mShadowPaint = new Paint(0); mShadowPaint.setColor(0xff101010); mShadowPaint.setMaskFilter(new BlurMaskFilter(8, BlurMaskFilter.Blur.NORMAL)); // Add a child view to draw the pie. Putting this in a child view // makes it possible to draw it on a separate hardware layer that rotates // independently mPieView = new PieView(getContext()); addView(mPieView); mPieView.rotateTo(mPieRotation); // The pointer doesn't need hardware acceleration, but in order to show up // in front of the pie it also needs to be on a separate view. mPointerView = new PointerView(getContext()); addView(mPointerView); // Set up an animator to animate the PieRotation property. This is used to // correct the pie's orientation after the user lets go of it. if (Build.VERSION.SDK_INT >= 11) { mAutoCenterAnimator = ObjectAnimator.ofInt(PieChart.this, "PieRotation", 0); // Add a listener to hook the onAnimationEnd event so that we can do // some cleanup when the pie stops moving. mAutoCenterAnimator.addListener(new Animator.AnimatorListener() { public void onAnimationStart(Animator animator) { } public void onAnimationEnd(Animator animator) { mPieView.decelerate(); } public void onAnimationCancel(Animator animator) { } public void onAnimationRepeat(Animator animator) { } }); } // Create a Scroller to handle the fling gesture. if (Build.VERSION.SDK_INT < 11) { mScroller = new Scroller(getContext()); } else { mScroller = new Scroller(getContext(), null, true); } // The scroller doesn't have any built-in animation functions--it just supplies // values when we ask it to. So we have to have a way to call it every frame // until the fling ends. This code (ab)uses a ValueAnimator object to generate // a callback on every animation frame. We don't use the animated value at all. if (Build.VERSION.SDK_INT >= 11) { mScrollAnimator = ValueAnimator.ofFloat(0, 1); mScrollAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { public void onAnimationUpdate(ValueAnimator valueAnimator) { tickScrollAnimation(); } }); } // Create a gesture detector to handle onTouch messages mDetector = new GestureDetector(PieChart.this.getContext(), new GestureListener()); // Turn off long press--this control doesn't use it, and if long press is enabled, // you can't scroll for a bit, pause, then scroll some more (the pause is interpreted // as a long press, apparently) mDetector.setIsLongpressEnabled(false); // In edit mode it's nice to have some demo data, so add that here. if (this.isInEditMode()) { Resources res = getResources(); addItem("Annabelle", 3, ContextCompat.getColor(getContext(), R.color.bluegrass)); addItem("Brunhilde", 4, ContextCompat.getColor(getContext(), R.color.chartreuse)); addItem("Carolina", 2, ContextCompat.getColor(getContext(), R.color.emerald)); addItem("Dahlia", 3, ContextCompat.getColor(getContext(), R.color.seafoam)); addItem("Ekaterina", 1, ContextCompat.getColor(getContext(), R.color.slate)); } }