List of usage examples for android.animation ObjectAnimator ofObject
@NonNull @SafeVarargs public static <T, V, P> ObjectAnimator ofObject(T target, Property<T, P> property, TypeConverter<V, P> converter, TypeEvaluator<V> evaluator, V... values)
From source file:com.waz.zclient.pages.main.conversation.SingleImageFragment.java
private void backToConversation(boolean afterFling) { if (isClosing) { return;//from ww w . j ava2 s.c o m } isClosing = true; loadClickedImageSizeAndPosition(); initAnimatingImageView(afterFling); restoreRotation(); getControllerFactory().getSingleImageController().hideSingleImage(); fadeControls(false); PointF currentFocusPoint = messageTouchImageView.getScrollPosition(); if (currentFocusPoint == null) { getControllerFactory().getSingleImageController().clearReferences(); getFragmentManager().popBackStack(); return; } TouchImageView.FocusAndScale startFocusAndScale = new TouchImageView.FocusAndScale(currentFocusPoint.x, currentFocusPoint.y, messageTouchImageView.getCurrentZoom()); TouchImageView.FocusAndScale finishFocusAndScale = new TouchImageView.FocusAndScale(0.5f, 0.5f, 1f); if ((MathUtils.floatEqual(currentFocusPoint.x, 0.5f) || MathUtils.floatEqual(currentFocusPoint.y, 0.5f)) && MathUtils.floatEqual(messageTouchImageView.getCurrentZoom(), 1f)) { zoomOutAndRotateBackOnCloseDuration = 1; } ObjectAnimator .ofObject(messageTouchImageView, "focusAndScale", new TouchImageView.FocusAndScaleEvaluator(), startFocusAndScale, finishFocusAndScale) .setDuration(zoomOutAndRotateBackOnCloseDuration).start(); final boolean imageOffScreenInList = getControllerFactory().getSingleImageController() .isContainerOutOfScreen(); ViewPropertyAnimator exitAnimation = animatingImageView.animate(); if (imageOffScreenInList) { exitAnimation.alpha(0); } else { exitAnimation.x(clickedImageLocation.x).y(clickedImageLocation.y).rotation(0f).scaleX(1f).scaleY(1f); } exitAnimation.setDuration(openAnimationDuration).setStartDelay(zoomOutAndRotateBackOnCloseDuration) .setInterpolator(new Expo.EaseOut()).withStartAction(new Runnable() { @Override public void run() { animatingImageView.setVisibility(View.VISIBLE); messageTouchImageView.setVisibility(View.GONE); if (imageOffScreenInList) { getControllerFactory().getSingleImageController().getImageContainer() .setVisibility(View.VISIBLE); } else { getControllerFactory().getSingleImageController().getImageContainer() .setVisibility(View.INVISIBLE); } ViewUtils.fadeInView( getControllerFactory().getSingleImageController().getLoadingIndicator(), getResources().getInteger(R.integer.framework_animation_duration_short)); } }).withEndAction(new Runnable() { @Override public void run() { getControllerFactory().getSingleImageController().getImageContainer() .setVisibility(View.VISIBLE); getControllerFactory().getSingleImageController().clearReferences(); getFragmentManager().popBackStack(); } }); exitAnimation.start(); background.animate().alpha(0f) .setStartDelay(zoomOutAndRotateBackOnCloseDuration + closeAnimationBackgroundDelay) .setDuration(openAnimationBackgroundDuration).setInterpolator(new Quart.EaseOut()).start(); }
From source file:com.justplay1.shoppist.features.search.widget.FloatingSearchView.java
private ValueAnimator getValueAnimator(int colorTo, int colorFrom) { final ValueAnimator colorAnimation; if (Build.VERSION.SDK_INT >= 19) colorAnimation = ObjectAnimator.ofObject(this, "setBackgroundColor", new ArgbEvaluator(), colorFrom, colorTo);// w w w . j a v a 2 s . com else { colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo); } return colorAnimation; }
From source file:android.improving.utils.views.PagerSlidingTabStrip.java
/** * text animation// w ww . j ava2 s. c o m * @param view * @param color1 * @param color2 */ private void animTextColor(TextView view, int color1, int color2) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { view.setTextColor(color2); } else { if (color1 == color2) { view.setTextColor(color2); } else { ObjectAnimator backgroundColorAnimator = ObjectAnimator.ofObject(view, CHANGECOLORSTRING, new ArgbEvaluator(), color1, color2); backgroundColorAnimator.setDuration(100); backgroundColorAnimator.start(); } } }
From source file:zemin.notification.NotificationView.java
private void updateContentBackground() { Drawable background = mBackground;//from ww w. j a va 2s. c o m if (hasState(CONTENT_BACKGROUND_CHANGED)) { if (mContentBackground != null) { if (mShadowEnabled) { final Drawable[] layers = new Drawable[] { getResources().getDrawable(android.R.drawable.dialog_holo_light_frame), mContentBackground, }; background = new LayerDrawable(layers); int l, t, r, b; l = t = r = b = 0; for (int i = 0, size = layers.length; i < size; i++) { Rect rect = new Rect(); layers[i].getPadding(rect); l += rect.left; t += rect.top; r += rect.right; b += rect.bottom; } setContentPadding(l, t, r, b); } else { background = mContentBackground; Rect rect = new Rect(); background.getPadding(rect); setContentPadding(rect.left, rect.top, rect.right, rect.bottom); } if (mContentBackground instanceof GradientDrawable) { GradientDrawable b = (GradientDrawable) mContentBackground; b.setCornerRadius(mCornerRadius); b.setStroke(mStrokeWidth, mStrokeColor); if (mBackgroundColorAnimator != null) { mBackgroundColorAnimator.cancel(); mBackgroundColorAnimator = null; } ColorProperty colorProperty = new ColorProperty(); mBackgroundColorAnimator = ObjectAnimator.ofObject(b, colorProperty, new ArgbEvaluator(), 0, 0); mBackgroundColorAnimator.setDuration(mBackgroundTransitionTime); if (mBackgroundAlphaAnimator != null) { mBackgroundAlphaAnimator.cancel(); mBackgroundAlphaAnimator = null; } AlphaProperty alphaProperty = new AlphaProperty(); mBackgroundAlphaAnimator = ObjectAnimator.ofObject(b, alphaProperty, new IntEvaluator(), 0, 0); mBackgroundAlphaAnimator.setDuration(mBackgroundTransitionTime); } } clearState(CONTENT_BACKGROUND_CHANGED); clearState(CONTENT_BACKGROUND_CHANGED_MINOR); } else if (hasState(CONTENT_BACKGROUND_CHANGED_MINOR)) { if (mContentBackground instanceof GradientDrawable) { GradientDrawable b = (GradientDrawable) mContentBackground; b.setStroke(mStrokeWidth, mStrokeColor); mBackgroundColorAnimator.setDuration(mBackgroundTransitionTime); mBackgroundAlphaAnimator.setDuration(mBackgroundTransitionTime); } clearState(CONTENT_BACKGROUND_CHANGED_MINOR); } mBackground = background; mContentView.setBackground(background); }
From source file:org.sufficientlysecure.keychain.ui.keyview.ViewKeyActivity.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { /* TODO better error handling? May cause problems when a key is deleted, * because the notification triggers faster than the activity closes. *///from ww w. j a v a2 s . com // Swap the new cursor in. (The framework will take care of closing the // old cursor once we return.) switch (loader.getId()) { case LOADER_ID_UNIFIED: { // Avoid NullPointerExceptions... if (data.getCount() == 0) { return; } if (data.moveToFirst()) { // get name, email, and comment from USER_ID String name = data.getString(INDEX_NAME); mCollapsingToolbarLayout.setTitle(name != null ? name : getString(R.string.user_id_no_name)); mMasterKeyId = data.getLong(INDEX_MASTER_KEY_ID); mFingerprint = data.getBlob(INDEX_FINGERPRINT); mIsSecret = data.getInt(INDEX_HAS_ANY_SECRET) != 0; mHasEncrypt = data.getInt(INDEX_HAS_ENCRYPT) != 0; mIsRevoked = data.getInt(INDEX_IS_REVOKED) > 0; mIsExpired = data.getInt(INDEX_IS_EXPIRED) != 0; mIsSecure = data.getInt(INDEX_IS_SECURE) == 1; mIsVerified = data.getInt(INDEX_VERIFIED) > 0; // queue showing of the main fragment showMainFragment(); // if the refresh animation isn't playing if (!mRotate.hasStarted() && !mRotateSpin.hasStarted()) { // re-create options menu based on mIsSecret, mIsVerified supportInvalidateOptionsMenu(); // this is done at the end of the animation otherwise } AsyncTask<Long, Void, Bitmap> photoTask = new AsyncTask<Long, Void, Bitmap>() { protected Bitmap doInBackground(Long... mMasterKeyId) { return new ContactHelper(ViewKeyActivity.this).loadPhotoByMasterKeyId(mMasterKeyId[0], true); } protected void onPostExecute(Bitmap photo) { if (photo == null) { return; } mPhoto.setImageBitmap(photo); mPhoto.setColorFilter(getResources().getColor(R.color.toolbar_photo_tint), PorterDuff.Mode.SRC_ATOP); mPhotoLayout.setVisibility(View.VISIBLE); } }; boolean showStatusText = mIsSecure && !mIsExpired && !mIsRevoked; if (showStatusText) { mStatusText.setVisibility(View.VISIBLE); if (mIsSecret) { mStatusText.setText(R.string.view_key_my_key); } else if (mIsVerified) { mStatusText.setText(R.string.view_key_verified); } else { mStatusText.setText(R.string.view_key_unverified); } } else { mStatusText.setVisibility(View.GONE); } // Note: order is important int color; if (mIsRevoked) { mStatusImage.setVisibility(View.VISIBLE); KeyFormattingUtils.setStatusImage(this, mStatusImage, mStatusText, State.REVOKED, R.color.icons, true); // noinspection deprecation, fix requires api level 23 color = getResources().getColor(R.color.key_flag_red); mActionEncryptFile.setVisibility(View.INVISIBLE); mActionEncryptText.setVisibility(View.INVISIBLE); hideFab(); mQrCodeLayout.setVisibility(View.GONE); } else if (!mIsSecure) { mStatusImage.setVisibility(View.VISIBLE); KeyFormattingUtils.setStatusImage(this, mStatusImage, mStatusText, State.INSECURE, R.color.icons, true); // noinspection deprecation, fix requires api level 23 color = getResources().getColor(R.color.key_flag_red); mActionEncryptFile.setVisibility(View.INVISIBLE); mActionEncryptText.setVisibility(View.INVISIBLE); hideFab(); mQrCodeLayout.setVisibility(View.GONE); } else if (mIsExpired) { mStatusImage.setVisibility(View.VISIBLE); KeyFormattingUtils.setStatusImage(this, mStatusImage, mStatusText, State.EXPIRED, R.color.icons, true); // noinspection deprecation, fix requires api level 23 color = getResources().getColor(R.color.key_flag_red); mActionEncryptFile.setVisibility(View.INVISIBLE); mActionEncryptText.setVisibility(View.INVISIBLE); hideFab(); mQrCodeLayout.setVisibility(View.GONE); } else if (mIsSecret) { mStatusImage.setVisibility(View.GONE); // noinspection deprecation, fix requires api level 23 color = getResources().getColor(R.color.key_flag_green); // reload qr code only if the fingerprint changed if (!Arrays.equals(mFingerprint, mQrCodeLoaded)) { loadQrCode(mFingerprint); } photoTask.execute(mMasterKeyId); mQrCodeLayout.setVisibility(View.VISIBLE); // and place leftOf qr code // RelativeLayout.LayoutParams nameParams = (RelativeLayout.LayoutParams) // mName.getLayoutParams(); // // remove right margin // nameParams.setMargins(FormattingUtils.dpToPx(this, 48), 0, 0, 0); // if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { // nameParams.setMarginEnd(0); // } // nameParams.addRule(RelativeLayout.LEFT_OF, R.id.view_key_qr_code_layout); // mName.setLayoutParams(nameParams); RelativeLayout.LayoutParams statusParams = (RelativeLayout.LayoutParams) mStatusText .getLayoutParams(); statusParams.setMargins(FormattingUtils.dpToPx(this, 48), 0, 0, 0); if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { statusParams.setMarginEnd(0); } statusParams.addRule(RelativeLayout.LEFT_OF, R.id.view_key_qr_code_layout); mStatusText.setLayoutParams(statusParams); mActionEncryptFile.setVisibility(View.VISIBLE); mActionEncryptText.setVisibility(View.VISIBLE); showFab(); // noinspection deprecation (no getDrawable with theme at current minApi level 15!) mFab.setImageDrawable(getResources().getDrawable(R.drawable.ic_repeat_white_24dp)); } else { mActionEncryptFile.setVisibility(View.VISIBLE); mActionEncryptText.setVisibility(View.VISIBLE); mQrCodeLayout.setVisibility(View.GONE); if (mIsVerified) { mStatusText.setText(R.string.view_key_verified); mStatusImage.setVisibility(View.VISIBLE); KeyFormattingUtils.setStatusImage(this, mStatusImage, mStatusText, State.VERIFIED, R.color.icons, true); // noinspection deprecation, fix requires api level 23 color = getResources().getColor(R.color.key_flag_green); photoTask.execute(mMasterKeyId); hideFab(); } else { mStatusText.setText(R.string.view_key_unverified); mStatusImage.setVisibility(View.VISIBLE); KeyFormattingUtils.setStatusImage(this, mStatusImage, mStatusText, State.UNVERIFIED, R.color.icons, true); // noinspection deprecation, fix requires api level 23 color = getResources().getColor(R.color.key_flag_orange); showFab(); } } if (mPreviousColor == 0 || mPreviousColor == color) { mAppBarLayout.setBackgroundColor(color); mCollapsingToolbarLayout.setContentScrimColor(color); mCollapsingToolbarLayout.setStatusBarScrimColor(getStatusBarBackgroundColor(color)); mPreviousColor = color; } else { ObjectAnimator colorFade = ObjectAnimator.ofObject(mAppBarLayout, "backgroundColor", new ArgbEvaluator(), mPreviousColor, color); mCollapsingToolbarLayout.setContentScrimColor(color); mCollapsingToolbarLayout.setStatusBarScrimColor(getStatusBarBackgroundColor(color)); colorFade.setDuration(1200); colorFade.start(); mPreviousColor = color; } //noinspection deprecation mStatusImage.setAlpha(80); break; } } } }