List of usage examples for android.view.animation AccelerateInterpolator AccelerateInterpolator
public AccelerateInterpolator()
From source file:arun.com.chromer.browsing.article.util.ArticleScrollListener.java
@Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); int minDistance = toolbar.getContext().getResources() .getDimensionPixelSize(R.dimen.article_minToolbarScroll); if (Math.abs(dy) < minDistance) { return;//from www .ja v a 2s .com } if (dy > 0 && toolbar.getTranslationY() == 0) { Interpolator interpolator = new AccelerateInterpolator(); if (!isUpdatingTranslation) { animateTranslation(-1 * toolbar.getHeight(), interpolator); } if (transparentBackground && !isUpdatingBackground) { animateBackgroundColor(transparentColor, primaryColor, interpolator); transparentBackground = false; } } else if (dy < 0 && toolbar.getTranslationY() != 0) { Interpolator interpolator = new DecelerateInterpolator(); if (!isUpdatingTranslation) { animateTranslation(0, interpolator); } LinearLayoutManager manager = (LinearLayoutManager) recyclerView.getLayoutManager(); int firstItem = manager.findFirstVisibleItemPosition(); if (!transparentBackground && firstItem == 0 && !isUpdatingBackground) { animateBackgroundColor(primaryColor, transparentColor, interpolator); transparentBackground = true; } } }
From source file:com.github.rubensousa.floatingtoolbar.FloatingAnimatorImpl.java
@Override public void hide() { super.hide(); // A snackbar might have appeared, so we need to update the fab position again if (getAppBar() != null) { getFab().setY(getFloatingToolbar().getY()); } else {/*from www. j a v a2s . co m*/ getFab().setTranslationY(getFloatingToolbar().getTranslationY()); } final int fabNewY = getFab().getTop(); ViewCompat.animate(getFab()).x(getFab().getLeft()).y(fabNewY) .translationY(getFloatingToolbar().getTranslationY()).scaleX(1f).scaleY(1f) .setStartDelay(FAB_UNMORPH_DELAY).setDuration(FAB_UNMORPH_DURATION) .setInterpolator(new AccelerateInterpolator()) .setListener(new ViewPropertyAnimatorListenerAdapter() { @Override public void onAnimationStart(View view) { getFab().setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(View view) { // Make sure the fab goes to the right place after the animation ends // when the Appbar is attached if (getAppBar() != null && getFab().getVisibility() == View.INVISIBLE) { getFab().show(); } getAnimationListener().onAnimationFinished(); } }); ViewCompat.animate(getFloatingToolbar()).scaleX(0f).setDuration(CIRCULAR_UNREVEAL_DURATION) .setStartDelay(CIRCULAR_UNREVEAL_DELAY).setInterpolator(new AccelerateDecelerateInterpolator()) .setListener(new ViewPropertyAnimatorListenerAdapter() { @Override public void onAnimationEnd(View view) { getFloatingToolbar().setVisibility(View.INVISIBLE); ViewCompat.animate(getFloatingToolbar()).setListener(null); } }); }
From source file:io.apptik.multiview.animators.Anims.java
public static ViewPropertyAnimatorCompat flipDownOut(final View view) { return ViewCompat.animate(view).rotationY(90).translationX(-(view.getMeasuredWidth() / 4)).scaleX(0.5F) .scaleY(0.5F).setInterpolator(new AccelerateInterpolator()); }
From source file:com.anyline.reactnative.Document4Activity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(getResources().getIdentifier("activity_scan_scanview", "layout", getPackageName())); // takes care of fading the error message out after some time with no error reported from the SDK errorMessageCleanup = new Runnable() { @Override//from w ww.j a va2 s . c o m public void run() { if (Document4Activity.this.isFinishing()) { return; } if (System.currentTimeMillis() > lastErrorRecieved + ERROR_MESSAGE_DELAY) { if (errorMessage == null || errorMessageAnimator == null) { return; } if (errorMessage.getAlpha() == 0f) { errorMessage.setText(""); } else if (!errorMessageAnimator.isRunning()) { errorMessageAnimator = ObjectAnimator.ofFloat(errorMessage, "alpha", errorMessage.getAlpha(), 0f); errorMessageAnimator.setDuration(ERROR_MESSAGE_DELAY); errorMessageAnimator.setInterpolator(new AccelerateInterpolator()); errorMessageAnimator.start(); } } handler.postDelayed(errorMessageCleanup, ERROR_MESSAGE_DELAY); } }; // Set the flag to keep the screen on (otherwise the screen may go dark during scanning) getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); imageViewResult = (ImageView) findViewById( getResources().getIdentifier("image_result", "id", getPackageName())); errorMessageLayout = (FrameLayout) findViewById( getResources().getIdentifier("error_message_layout", "id", getPackageName())); errorMessage = (TextView) findViewById( getResources().getIdentifier("error_message", "id", getPackageName())); documentScanView = (ScanView) findViewById( getResources().getIdentifier("document_scan_view", "id", getPackageName())); // add a camera open listener that will be called when the camera is opened or an error occurred // this is optional (if not set a RuntimeException will be thrown if an error occurs) documentScanView.setCameraOpenListener(this); // the view can be configured via a json file in the assets, and this config is set here try { final JSONObject json = new JSONObject(configJson); documentScanView.setScanConfig(json, licenseKey); } catch (Exception e) { e.printStackTrace(); } // initialize Anyline with the license key and a Listener that is called if a result is found documentScanView.getScanViewPlugin().addScanResultListener(new DocumentScanResultListener() { @Override public void onResult(ScanResult documentResult) { // handle the result document images here if (progressDialog != null && progressDialog.isShowing()) { progressDialog.dismiss(); } AnylineImage transformedImage = (AnylineImage) documentResult.getResult(); AnylineImage fullFrame = documentResult.getFullImage(); // resize display view based on larger side of document, and display document int widthDP, heightDP; Bitmap bmpTransformedImage = transformedImage.getBitmap(); if (bmpTransformedImage.getHeight() > bmpTransformedImage.getWidth()) { widthDP = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 100, getResources().getDisplayMetrics()); heightDP = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 160, getResources().getDisplayMetrics()); //Add a comment to this line imageViewResult.getLayoutParams().width = widthDP; imageViewResult.getLayoutParams().height = ViewGroup.LayoutParams.WRAP_CONTENT; } else { widthDP = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 160, getResources().getDisplayMetrics()); heightDP = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 100, getResources().getDisplayMetrics()); imageViewResult.getLayoutParams().width = ViewGroup.LayoutParams.WRAP_CONTENT; imageViewResult.getLayoutParams().height = heightDP; } imageViewResult.setImageBitmap( Bitmap.createScaledBitmap(transformedImage.getBitmap(), widthDP, heightDP, false)); /** * IMPORTANT: cache provided frames here, and release them at the end of this onResult. Because * keeping them in memory (e.g. setting the full frame to an ImageView) * will result in a OutOfMemoryError soon. This error is reported in {@link #onTakePictureError * (Throwable)} * * Use a DiskCache http://developer.android.com/training/displaying-bitmaps/cache-bitmap.html#disk-cache * for example * */ File outDir = new File(getCacheDir(), "ok"); outDir.mkdir(); // change the file ending to png if you want a png JSONObject jsonResult = new JSONObject(); try { // convert the transformed image into a gray scaled image internally // transformedImage.getGrayCvMat(false); // get the transformed image as bitmap // Bitmap bmp = transformedImage.getBitmap(); // save the image with quality 100 (only used for jpeg, ignored for png) File imageFile = TempFileUtil.createTempFileCheckCache(Document4Activity.this, UUID.randomUUID().toString(), ".jpg"); transformedImage.save(imageFile, quality); showToast(getString( getResources().getIdentifier("document_image_saved_to", "string", getPackageName())) + " " + imageFile.getAbsolutePath()); jsonResult.put("imagePath", imageFile.getAbsolutePath()); // Save the Full Frame Image if (fullFrame != null) { imageFile = TempFileUtil.createTempFileCheckCache(Document4Activity.this, UUID.randomUUID().toString(), ".jpg"); fullFrame.save(imageFile, quality); jsonResult.put("fullImagePath", imageFile.getAbsolutePath()); } // Put outline and conficence to result jsonResult.put("outline", jsonForOutline(documentResult.getOutline())); jsonResult.put("confidence", documentResult.getConfidence()); } catch (IOException e) { e.printStackTrace(); } catch (JSONException jsonException) { //should not be possible Log.e(TAG, "Error while putting image path to json.", jsonException); } // release the images transformedImage.release(); fullFrame.release(); Boolean cancelOnResult = true; JSONObject jsonObject; try { jsonObject = new JSONObject(configJson); cancelOnResult = jsonObject.getBoolean("cancelOnResult"); } catch (Exception e) { Log.d(TAG, e.getLocalizedMessage()); } if (cancelOnResult) { ResultReporter.onResult(jsonResult, true); setResult(AnylineSDKPlugin.RESULT_OK); finish(); } else { ResultReporter.onResult(jsonResult, false); } } @Override public void onPreviewProcessingSuccess(AnylineImage anylineImage) { // this is called after the preview of the document is completed, and a full picture will be // processed automatically } @Override public void onPreviewProcessingFailure(DocumentScanViewPlugin.DocumentError documentError) { // this is called on any error while processing the document image // Note: this is called every time an error occurs in a run, so that might be quite often // An error message should only be presented to the user after some time showErrorMessageFor(documentError); } @Override public void onPictureProcessingFailure(DocumentScanViewPlugin.DocumentError documentError) { showErrorMessageFor(documentError, true); if (progressDialog != null && progressDialog.isShowing()) { progressDialog.dismiss(); } // if there is a problem, here is how images could be saved in the error case // this will be a full, not cropped, not transformed image AnylineImage image = ((DocumentScanViewPlugin) documentScanView.getScanViewPlugin()) .getCurrentFullImage(); if (image != null) { File outDir = new File(getCacheDir(), "error"); outDir.mkdir(); File outFile = new File(outDir, "" + System.currentTimeMillis() + documentError.name() + ".jpg"); try { image.save(outFile, 100); Log.d(TAG, "error image saved to " + outFile.getAbsolutePath()); } catch (IOException e) { e.printStackTrace(); } image.release(); } } @Override public boolean onDocumentOutlineDetected(List rect, boolean documentShapeAndBrightnessValid) { // is called when the outline of the document is detected. return true if the outline is consumed by // the implementation here, false if the outline should be drawn by the DocumentScanView lastOutline = rect; // saving the outline for the animations return true; } @Override public void onTakePictureSuccess() { // this is called after the image has been captured from the camera and is about to be processed progressDialog = ProgressDialog.show(Document4Activity.this, getString(getResources().getIdentifier("document_processing_picture_header", "string", getPackageName())), getString(getResources().getIdentifier("document_processing_picture", "string", getPackageName())), true); if (errorMessageAnimator != null && errorMessageAnimator.isRunning()) { handler.post(new Runnable() { @Override public void run() { errorMessageAnimator.cancel(); errorMessageLayout.setVisibility(View.GONE); } }); } } @Override public void onTakePictureError(Throwable throwable) { // This is called if the image could not be captured from the camera (most probably because of an // OutOfMemoryError) throw new RuntimeException(throwable); } @Override public void onPictureCornersDetected(AnylineImage anylineImage, List rect) { // this is called after manual corner detection was requested // Note: not implemented in this example } @Override public void onPictureTransformed(AnylineImage anylineImage) { // this is called after a full frame image and 4 corners were passed to the SDK for // transformation (e.g. when a user manually selected the corners in an image) // Note: not implemented in this example } @Override public void onPictureTransformError(DocumentScanViewPlugin.DocumentError documentError) { // this is called on any error while transforming the document image from the 4 corners // Note: not implemented in this example } }); // optionally stop the scan once a valid result was returned // documentScanView.setCancelOnResult(cancelOnResult); }
From source file:com.ruesga.rview.fragments.RevealDialogFragment.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) private void performEnterRevealTransition() { if (!mDoReveal || getDialog() == null || getDialog().getWindow() == null) { mDoReveal = false;/* ww w .jav a 2 s . c o m*/ return; } final View v = getDialog().getWindow().getDecorView(); if (!v.isAttachedToWindow()) { mDoReveal = false; return; } v.setVisibility(View.VISIBLE); Rect dialogRect = computeViewOnScreen(v); int cx = v.getMeasuredWidth() / 2; int cy = v.getMeasuredHeight() / 2; if (mAnchorRect != null) { cx = Math.min(Math.max(mAnchorRect.centerX(), dialogRect.left), dialogRect.right) - dialogRect.left; cy = Math.min(Math.max(mAnchorRect.centerY(), dialogRect.top), dialogRect.bottom) - dialogRect.top; } int finalRadius = Math.max(v.getWidth(), v.getHeight()); Animator anim = ViewAnimationUtils.createCircularReveal(v, cx, cy, 0, finalRadius); anim.setDuration(350); anim.setInterpolator(new AccelerateInterpolator()); anim.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { onDialogReveled(); mDoReveal = false; } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); anim.start(); }
From source file:fr.shywim.antoinedaniel.utils.Utils.java
/** * First part of the click animation./*w w w. ja va2 s . c om*/ * * @param context Any context. * @param v View who will have the effect. * @param isRoot Whether the passed view is the ViewGroup parent. */ public static void clickAnimDown(Context context, View v, boolean isRoot) { RelativeLayout root; if (isRoot) root = (RelativeLayout) v; else root = (RelativeLayout) v.getParent(); final View rectView = new View(context); rectView.setId(R.id.rect_view_id); rectView.setVisibility(View.GONE); rectView.setBackgroundResource(R.drawable.square); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(v.getMeasuredWidth(), v.getMeasuredHeight()); params.addRule(RelativeLayout.ALIGN_TOP, v.getId()); rectView.setLayoutParams(params); AlphaAnimation rectAnim = new AlphaAnimation(0f, 0.4f); rectAnim.setFillAfter(true); rectAnim.setInterpolator(new AccelerateInterpolator()); rectAnim.setDuration(150); rectAnim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { rectView.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } }); root.addView(rectView); rectView.startAnimation(rectAnim); }
From source file:com.example.fragment.ScreenSlidePageFragment.java
public void startAnimation() { // SELECT LAYER ScrollView relate = (ScrollView) mRootView.findViewById(R.id.content); // relate.setVisibility(View.VISIBLE); AnimationSet set = new AnimationSet(true); set.setAnimationListener(this); TranslateAnimation translate;/*from w w w.jav a 2s . co m*/ float toX = -8.0f / 100.0f;//0.0f; float fromX = 0.0f;//-8.0f / 100.0f; float toY = 0.0f; float fromY = 29.0f / 100.0f; translate = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, fromX, Animation.RELATIVE_TO_PARENT, toX, Animation.RELATIVE_TO_PARENT, fromY, Animation.RELATIVE_TO_PARENT, toY); translate.setDuration(2000); translate.setInterpolator(new AccelerateInterpolator()); set.addAnimation(translate); set.setFillBefore(true); // set.setFillBefore(false); // set.setFillAfter(false); set.setFillAfter(true); relate.startAnimation(set); }
From source file:com.numix.calculator.EventListener.java
private void deleteAnimation(View view) { final TextView colorLayout = (TextView) view.getRootView().findViewById(R.id.deleteColor); final LinearLayout displayView = (LinearLayout) view.getRootView().findViewById(R.id.displayLayout); final CalculatorDisplay calculatorDisplay = (CalculatorDisplay) view.getRootView() .findViewById(R.id.display); int finalRadius = Math.max(displayView.getWidth(), displayView.getHeight()); // create the animator for this view (the start radius is zero) Animator colorAnim;/*from w w w .java 2s . co m*/ colorAnim = ViewAnimationUtils.createCircularReveal(colorLayout, (int) displayView.getRight(), (int) displayView.getBottom(), 0, finalRadius); final AlphaAnimation fadeAnim = new AlphaAnimation(1.0f, 0.0f); final AlphaAnimation fadeDisplay = new AlphaAnimation(1.0f, 0.0f); fadeAnim.setDuration(250); fadeAnim.setInterpolator(new AccelerateInterpolator()); fadeAnim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { colorLayout.setVisibility(View.GONE); } @Override public void onAnimationRepeat(Animation animation) { } }); fadeDisplay.setDuration(250); fadeDisplay.setInterpolator(new AccelerateInterpolator()); fadeDisplay.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { mHandler.onClear(); displayView.setAlpha(1.0f); } @Override public void onAnimationRepeat(Animation animation) { } }); colorAnim.setInterpolator(new AccelerateInterpolator()); colorAnim.addListener(new android.animation.Animator.AnimatorListener() { @Override public void onAnimationStart(android.animation.Animator animation) { calculatorDisplay.startAnimation(fadeDisplay); } @Override public void onAnimationRepeat(android.animation.Animator animation) { } @Override public void onAnimationEnd(android.animation.Animator animation) { colorLayout.startAnimation(fadeAnim); } @Override public void onAnimationCancel(android.animation.Animator animation) { } }); colorLayout.setVisibility(View.VISIBLE); colorAnim.start(); }
From source file:xyz.berial.textinputlayout.TextInputLayout.java
public TextInputLayout(Context context, AttributeSet attrs, int defStyleAttr) { // Can't call through to super(Context, AttributeSet, int) since it doesn't exist on API 10 super(context, attrs); setOrientation(VERTICAL);/*from w w w.j ava 2s .c o m*/ setWillNotDraw(false); setAddStatesFromChildren(true); mResources = getResources(); mCollapsingTextHelper.setTextSizeInterpolator(AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR); mCollapsingTextHelper.setPositionInterpolator(new AccelerateInterpolator()); mCollapsingTextHelper.setCollapsedTextGravity(Gravity.TOP | GravityCompat.START); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TextInputLayout, defStyleAttr, R.style.Widget_Design_TextInputLayout); mHint = a.getText(R.styleable.TextInputLayout_hint); mHintAnimationEnabled = a.getBoolean(R.styleable.TextInputLayout_hintAnimationEnabled, true); /*custom*/ final boolean counterEnabled = a.getBoolean(R.styleable.TextInputLayout_counterEnabled, false); mCounterMaxLength = a.getInt(R.styleable.TextInputLayout_counterMaxLength, 0); /*custom*/ if (a.hasValue(R.styleable.TextInputLayout_textColorHint)) { mDefaultTextColor = mFocusedTextColor = a.getColorStateList(R.styleable.TextInputLayout_textColorHint); } final int hintAppearance = a.getResourceId(R.styleable.TextInputLayout_hintTextAppearance, -1); if (hintAppearance != -1) { setHintTextAppearance(a.getResourceId(R.styleable.TextInputLayout_hintTextAppearance, 0)); } mErrorTextAppearance = a.getResourceId(R.styleable.TextInputLayout_errorTextAppearance, 0); final boolean errorEnabled = a.getBoolean(R.styleable.TextInputLayout_errorEnabled, false); a.recycle(); /*custom*/ mBottomBar = new RelativeLayout(context); addView(mBottomBar); setCounterEnabled(counterEnabled); /*custom*/ setErrorEnabled(errorEnabled); if (ViewCompat.getImportantForAccessibility(this) == ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO) { // Make sure we're important for accessibility if we haven't been explicitly not ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES); } ViewCompat.setAccessibilityDelegate(this, new TextInputAccessibilityDelegate()); }
From source file:cn.zhangls.android.weibo.animation.FABehavior.java
private void animateOut(final FloatingActionButton fab) { ViewCompat.animate(fab).setListener(new ViewPropertyAnimatorListener() { @Override//from ww w . j a v a 2 s . c o m public void onAnimationStart(View view) { mIsAnimating = true; fab.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(View view) { mIsAnimating = false; fab.setVisibility(View.INVISIBLE); } @Override public void onAnimationCancel(View view) { mIsAnimating = false; fab.setVisibility(View.VISIBLE); } }).setInterpolator(new AccelerateInterpolator()).setDuration(300).translationY(fab.getHeight()).start(); }