List of usage examples for android.animation ObjectAnimator setDuration
@Override @NonNull public ObjectAnimator setDuration(long duration)
From source file:com.bar.foldinglayout.sample.FoldingLayoutActivity.java
/** * Animates the folding view inwards (to a completely folded state) from its * current state and then back out to its original state. *//* w ww . ja v a 2s .c o m*/ public void animateFold() { float foldFactor = mFoldLayout.getFoldFactor(); ObjectAnimator animator = ObjectAnimator.ofFloat(mFoldLayout, "foldFactor", foldFactor, 1); animator.setRepeatMode(ValueAnimator.REVERSE); animator.setRepeatCount(1); animator.setDuration(FOLD_ANIMATION_DURATION); animator.setInterpolator(new AccelerateInterpolator()); animator.start(); }
From source file:com.github.jokar.rxupload.widget.ProgressDownloadView.java
public void drawSuccess() { mTarget = 100;/* w ww .j a v a2s. co m*/ final ObjectAnimator successAnim = ObjectAnimator.ofFloat(this, "flip", 1, -1); successAnim.setInterpolator(new OvershootInterpolator()); successAnim.setDuration(ANIMATION_DURATION_BASE); ObjectAnimator anim = ObjectAnimator.ofFloat(this, "progress", getProgress(), mTarget); anim.setInterpolator(new DecelerateInterpolator()); anim.setDuration((long) (ANIMATION_DURATION_BASE + Math.abs(mTarget * 10 - getProgress() * 10) / 2)); anim.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { mState = State.STATE_SUCCESS; successAnim.start(); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); anim.start(); }
From source file:com.amitupadhyay.aboutexample.ui.widget.BottomSheet.java
private void animateSettle(int initialOffset, final int targetOffset, float initialVelocity) { if (settling) return;//from w w w. ja va2 s.c om if (sheetOffsetHelper.getTopAndBottomOffset() == targetOffset) { if (targetOffset >= dismissOffset) { dispatchDismissCallback(); } return; } settling = true; final boolean dismissing = targetOffset == dismissOffset; final long duration = computeSettleDuration(initialVelocity, dismissing); final ObjectAnimator settleAnim = ObjectAnimator.ofInt(sheetOffsetHelper, ViewOffsetHelper.OFFSET_Y, initialOffset, targetOffset); settleAnim.setDuration(duration); settleAnim.setInterpolator(getSettleInterpolator(dismissing, initialVelocity)); settleAnim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { dispatchPositionChangedCallback(); if (dismissing) { dispatchDismissCallback(); } settling = false; } }); if (callbacks != null && !callbacks.isEmpty()) { settleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { if (animation.getAnimatedFraction() > 0f) { dispatchPositionChangedCallback(); } } }); } settleAnim.start(); }
From source file:me.hammarstrom.imagerecognition.activities.MainActivity.java
/** * Helper method to show / hide progress bar * * @param show if progress should be shown or not *///w ww .ja v a2 s .co m private void showLoading(final boolean show) { ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(mLoadingLayout, "alpha", show ? 0f : 1f, show ? 1f : 0f); alphaAnimator.setDuration(200); alphaAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); if (!show) { mLoadingLayout.setVisibility(View.GONE); } } @Override public void onAnimationStart(Animator animation) { super.onAnimationStart(animation); if (show) { mLoadingLayout.setAlpha(0f); mLoadingLayout.setVisibility(View.VISIBLE); mTts.speak(getString(R.string.tts_processing_image), TextToSpeech.QUEUE_FLUSH, null); } } }); alphaAnimator.start(); }
From source file:com.lovejjfg.blogdemo.ui.BottomSheet.java
private void animateSettle(int initialOffset, final int targetOffset, long duration) { if (settling) return;/* w ww. j a va 2 s . c om*/ if (sheetOffsetHelper.getTopAndBottomOffset() == targetOffset) return; settling = true; final ObjectAnimator settleAnim = ObjectAnimator.ofInt(sheetOffsetHelper, ViewOffsetHelper.OFFSET_Y, initialOffset, targetOffset); settleAnim.setDuration(duration); settleAnim.setInterpolator(AnimUtils.getFastOutSlowInInterpolator(getContext())); settleAnim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { dispatchPositionChangedCallback(); if (targetOffset == dismissOffset) { dispatchDismissCallback(); } settling = false; } }); if (callbacks != null && !callbacks.isEmpty()) { settleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { if (animation.getAnimatedFraction() > 0f) { dispatchPositionChangedCallback(); } } }); } settleAnim.start(); }
From source file:com.github.dfa.diaspora_android.activity.DiasporaStreamFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { AppLog.d(this, "StreamFragment.onOptionsItemSelected()"); ShareUtil shu = new ShareUtil(getContext()).setFileProviderAuthority(BuildConfig.APPLICATION_ID); PermissionChecker permc = new PermissionChecker(getActivity()); switch (item.getItemId()) { case R.id.action_reload: { if (WebHelper.isOnline(getContext())) { reloadUrl();/* w ww.java 2s .c om*/ return true; } else { return false; } } case R.id.action_go_to_top: { ObjectAnimator anim = ObjectAnimator.ofInt(webView, "scrollY", webView.getScrollY(), 0); anim.setDuration(400); anim.start(); return true; } case R.id.action_share_link: { Intent sharingIntent = new Intent(Intent.ACTION_SEND); sharingIntent.setType("text/plain"); sharingIntent.putExtra(Intent.EXTRA_SUBJECT, webView.getTitle()); sharingIntent.putExtra(Intent.EXTRA_TEXT, webView.getUrl()); startActivity(Intent.createChooser(sharingIntent, getResources().getString(R.string.share_dotdotdot))); return true; } case R.id.action_share_pdf: { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { shu.createPdf(webView, "dandelion-" + ShareUtil.SDF_SHORT.format(new Date())); } return true; } case R.id.action_share_link_to_clipboard: { shu.setClipboard(webView.getUrl()); Toast.makeText(getContext(), R.string.link_adress_copied, Toast.LENGTH_SHORT).show(); return true; } case R.id.action_create_launcher_shortcut: { if (webView.getUrl() != null) { Intent intent = new Intent(getContext(), MainActivity.class); intent.setAction(Intent.ACTION_VIEW); intent.setData(Uri.parse(webView.getUrl())); shu.createLauncherDesktopShortcut(intent, R.drawable.ic_launcher, webView.getTitle()); } return true; } case R.id.action_take_screenshot: { if (permc.doIfExtStoragePermissionGranted(getString(R.string.screenshot_permission__appspecific))) { File fileSaveDirectory = appSettings.getAppSaveDirectory(); if (permc.mkdirIfStoragePermissionGranted(fileSaveDirectory)) { Bitmap bmp = ShareUtil.getBitmapFromWebView(webView); String filename = "dandelion-" + ShareUtil.SDF_SHORT.format(new Date()) + ".jpg"; _cu.writeImageToFileJpeg(new File(fileSaveDirectory, filename), bmp); Snackbar.make(webView, getString(R.string.saving_screenshot_as) + " " + filename, Snackbar.LENGTH_LONG).show(); } } return true; } case R.id.action_share_screenshot: { if (permc.doIfExtStoragePermissionGranted(getString(R.string.screenshot_permission__appspecific))) { shu.shareImage(ShareUtil.getBitmapFromWebView(webView), Bitmap.CompressFormat.JPEG); } return true; } } return super.onOptionsItemSelected(item); }
From source file:com.waz.zclient.pages.main.conversation.views.row.footer.FooterViewController.java
private ObjectAnimator getViewTextViewAnimator(final View view, boolean animateIn, float to) { ObjectAnimator animator = ObjectAnimator.ofFloat(view, View.TRANSLATION_Y, to); animator.setDuration( context.getResources().getInteger(com.waz.zclient.ui.R.integer.wire__animation__duration__short)); if (animateIn) { animator.setInterpolator(new Expo.EaseOut()); } else {//from w w w . ja va2s . c o m animator.setInterpolator(new Expo.EaseIn()); } if (animateIn) { animator.setStartDelay( context.getResources().getInteger(com.waz.zclient.ui.R.integer.animation_delay_short)); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { view.setVisibility(View.VISIBLE); } }); } else { animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationCancel(Animator animation) { view.setVisibility(View.GONE); } @Override public void onAnimationEnd(Animator animation) { view.setVisibility(View.GONE); } }); } return animator; }
From source file:com.ibm.mil.readyapps.physio.fragments.LandingFragment.java
private void animateMetricsOut(boolean isInitial) { int delay = 0; if (isInitial) { delay = INIT_DELAY;/*from www. j a va 2 s . c o m*/ } ObjectAnimator weightSlideOutAnimator = ObjectAnimator.ofFloat(weightTab, "translationX", 1f + SLIDE_OFFSET); ObjectAnimator heartRateSlideOutAnimator = ObjectAnimator.ofFloat(heartRateTab, "translationX", 1f + SLIDE_OFFSET); ObjectAnimator stepsSlideOutAnimator = ObjectAnimator.ofFloat(stepsTab, "translationX", 1f + SLIDE_OFFSET); heartRateSlideOutAnimator.setDuration(ANIM_SPEED * 2); heartRateSlideOutAnimator.setStartDelay(ANIM_SPEED * 2); weightSlideOutAnimator.setDuration(ANIM_SPEED * 2); weightSlideOutAnimator.setStartDelay(delay); stepsSlideOutAnimator.setDuration(ANIM_SPEED * 2); stepsSlideOutAnimator.setStartDelay(ANIM_SPEED); AnimatorSet outAnimation = new AnimatorSet(); outAnimation.play(weightSlideOutAnimator).with(stepsSlideOutAnimator).with(heartRateSlideOutAnimator); outAnimation.start(); }
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 ww w. ja v a 2 s.co 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.awt.supark.LayoutHandler.java
public void appBackgroundColorChange(View view, int time, int r, int g, int b) { ColorDrawable wBack = (ColorDrawable) view.getBackground(); int color = wBack.getColor(); int r1 = Color.red(color); int g1 = Color.green(color); int b1 = Color.blue(color); ObjectAnimator colorFade = ObjectAnimator.ofObject(view, "backgroundColor", new ArgbEvaluator(), Color.argb(255, r1, g1, b1), Color.argb(255, r, g, b)); colorFade.setDuration(time); colorFade.start();// www . ja va 2 s . com }