List of usage examples for android.view.animation Animation setDuration
public void setDuration(long durationMillis)
From source file:com.megaphone.skoozi.FloatingActionButtonScrollBehavior.java
private void animateOut(final FloatingActionButton button) { if (Build.VERSION.SDK_INT >= 14) { ViewCompat.animate(button).scaleX(0.0F).scaleY(0.0F).alpha(0.0F).setInterpolator(INTERPOLATOR) .withLayer().setListener(new ViewPropertyAnimatorListener() { public void onAnimationStart(View view) { FloatingActionButtonScrollBehavior.this.mIsAnimatingOut = true; }/*from ww w . j a va2 s. c om*/ public void onAnimationCancel(View view) { FloatingActionButtonScrollBehavior.this.mIsAnimatingOut = false; } public void onAnimationEnd(View view) { FloatingActionButtonScrollBehavior.this.mIsAnimatingOut = false; view.setVisibility(View.GONE); } }).start(); } else { Animation anim = AnimationUtils.loadAnimation(button.getContext(), R.anim.fab_out); anim.setInterpolator(INTERPOLATOR); anim.setDuration(200L); anim.setAnimationListener(new Animation.AnimationListener() { public void onAnimationStart(Animation animation) { FloatingActionButtonScrollBehavior.this.mIsAnimatingOut = true; } public void onAnimationEnd(Animation animation) { FloatingActionButtonScrollBehavior.this.mIsAnimatingOut = false; button.setVisibility(View.GONE); } @Override public void onAnimationRepeat(final Animation animation) { } }); button.startAnimation(anim); } }
From source file:com.megaphone.skoozi.FloatingActionButtonScrollMorphBehavior.java
private void animateOut(final FloatingActionButton button) { if (Build.VERSION.SDK_INT >= 14) { ViewCompat.animate(button).scaleX(0.0F).scaleY(0.0F).alpha(0.0F).setInterpolator(INTERPOLATOR) .withLayer().setListener(new ViewPropertyAnimatorListener() { public void onAnimationStart(View view) { FloatingActionButtonScrollMorphBehavior.this.mIsAnimatingOut = true; }/*from ww w .j a va 2 s. c o m*/ public void onAnimationCancel(View view) { FloatingActionButtonScrollMorphBehavior.this.mIsAnimatingOut = false; } public void onAnimationEnd(View view) { FloatingActionButtonScrollMorphBehavior.this.mIsAnimatingOut = false; view.setVisibility(View.GONE); } }).start(); } else { Animation anim = AnimationUtils.loadAnimation(button.getContext(), R.anim.fab_out); anim.setInterpolator(INTERPOLATOR); anim.setDuration(200L); anim.setAnimationListener(new Animation.AnimationListener() { public void onAnimationStart(Animation animation) { FloatingActionButtonScrollMorphBehavior.this.mIsAnimatingOut = true; } public void onAnimationEnd(Animation animation) { FloatingActionButtonScrollMorphBehavior.this.mIsAnimatingOut = false; button.setVisibility(View.GONE); } @Override public void onAnimationRepeat(final Animation animation) { } }); button.startAnimation(anim); } }
From source file:com.evandroid.musica.utils.RefreshButtonBehavior.java
public void animateOut(final FloatingActionButton button) { int translationY = button.getHeight() + ((CoordinatorLayout.LayoutParams) button.getLayoutParams()).bottomMargin; if (Build.VERSION.SDK_INT >= 14) { ViewCompat.animate(button).translationY(translationY).setInterpolator(INTERPOLATOR).withLayer() .setListener(new ViewPropertyAnimatorListener() { public void onAnimationStart(View view) { RefreshButtonBehavior.this.mIsAnimatingOut = true; }/* ww w .ja v a 2 s . com*/ public void onAnimationCancel(View view) { RefreshButtonBehavior.this.mIsAnimatingOut = false; } public void onAnimationEnd(View view) { RefreshButtonBehavior.this.mIsAnimatingOut = false; view.setVisibility(View.GONE); visible = false; } }).start(); } else { Animation anim = AnimationUtils.loadAnimation(button.getContext(), R.anim.refresh_out); anim.setInterpolator(INTERPOLATOR); anim.setDuration(200L); anim.setAnimationListener(new Animation.AnimationListener() { public void onAnimationStart(Animation animation) { RefreshButtonBehavior.this.mIsAnimatingOut = true; } public void onAnimationEnd(Animation animation) { RefreshButtonBehavior.this.mIsAnimatingOut = false; button.setVisibility(View.GONE); visible = false; } @Override public void onAnimationRepeat(final Animation animation) { } }); button.startAnimation(anim); } }
From source file:com.appbase.androidquery.callback.BitmapAjaxCallback.java
private static void setBmAnimate(ImageView iv, Bitmap bm, Bitmap preset, int fallback, int animation, float ratio, float anchor, int source) { bm = filter(iv, bm, fallback);/*from www . j av a2s.c o m*/ if (bm == null) { iv.setImageBitmap(null); return; } Drawable d = makeDrawable(iv, bm, ratio, anchor); Animation anim = null; if (fadeIn(animation, source)) { if (preset == null) { anim = new AlphaAnimation(0, 1); anim.setInterpolator(new DecelerateInterpolator()); anim.setDuration(FADE_DUR); } else { Drawable pd = makeDrawable(iv, preset, ratio, anchor); Drawable[] ds = new Drawable[] { pd, d }; TransitionDrawable td = new TransitionDrawable(ds); td.setCrossFadeEnabled(true); td.startTransition(FADE_DUR); d = td; } } else if (animation > 0) { anim = AnimationUtils.loadAnimation(iv.getContext(), animation); } iv.setImageDrawable(d); if (anim != null) { anim.setStartTime(AnimationUtils.currentAnimationTimeMillis()); iv.startAnimation(anim); } else { iv.setAnimation(null); } }
From source file:eu.thedarken.rootvalidator.ValidatorFragment.java
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); AnimationSet set = new AnimationSet(true); Animation fadeIn = new AlphaAnimation(0.0f, 1.0f); fadeIn.setDuration(350); set.addAnimation(fadeIn);/*from w ww . j a v a 2s . com*/ Animation dropDown = new TranslateAnimation(Animation.RELATIVE_TO_SELF, -1.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f); dropDown.setDuration(400); set.addAnimation(dropDown); LayoutAnimationController controller = new LayoutAnimationController(set, 0.2f); mRecyclerView.setLayoutAnimation(controller); mFab.attachToRecyclerView(mRecyclerView); mFab.setVisibility(View.INVISIBLE); mEmptyStartView.setVisibility(View.GONE); mEmptyWorkingView.setVisibility(View.GONE); mListContainer.addView(mEmptyStartView); mListContainer.addView(mEmptyWorkingView); mRecyclerView.setEmptyView(mEmptyStartView); mRecyclerView.setItemAnimator(new DefaultItemAnimator()); }
From source file:org.glucosio.android.fragment.AssistantFragment.java
@OnClick(R.id.fragment_assistant_archived) void archivedButtonClicked() { populateWithArchivedTips();/*from ww w . ja va 2 s .c om*/ adapter.notifyDataSetChanged(); tipsRecycler.swapAdapter(adapter, false); archivedDismissButton.setVisibility(View.VISIBLE); final Animation slide = new TranslateAnimation(0, 0, 0, 200); slide.setDuration(500); archivedButton.startAnimation(slide); archivedButton.setVisibility(View.GONE); }
From source file:de.grobox.liberario.ui.LocationInputGPSView.java
public void activateGPS() { if (isSearching()) return;//w w w .ja va 2 s . c om // check permissions if (ContextCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // we don't have a permission, so store the information that we are requesting it request_permission = true; // Should we show an explanation? if (ActivityCompat.shouldShowRequestPermissionRationale(context, Manifest.permission.ACCESS_FINE_LOCATION)) { Toast.makeText(context, R.string.permission_denied_gps, Toast.LENGTH_LONG).show(); } else { // No explanation needed, we can request the permission ActivityCompat.requestPermissions(context, new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, caller); } return; } // we arrive here only once we have got the permission and are not longer requesting it request_permission = false; List<String> providers = locationManager.getProviders(true); for (String provider : providers) { // Register the listener with the Location Manager to receive location updates locationManager.requestSingleUpdate(provider, this, null); Log.d(getClass().getSimpleName(), "Register provider for location updates: " + provider); } // check if there is a non-passive provider available if (providers.size() == 0 || (providers.size() == 1 && providers.get(0).equals(LocationManager.PASSIVE_PROVIDER))) { locationManager.removeUpdates(this); Toast.makeText(context, context.getResources().getString(R.string.error_no_location_provider), Toast.LENGTH_LONG).show(); return; } // clear input //noinspection deprecation setLocation(null, context.getResources().getDrawable(R.drawable.ic_gps)); ui.clear.setVisibility(View.VISIBLE); // clear current GPS location, because we are looking to find a new one gps_location = null; // show GPS button blinking final Animation animation = new AlphaAnimation(1, 0); animation.setDuration(500); animation.setInterpolator(new LinearInterpolator()); animation.setRepeatCount(Animation.INFINITE); animation.setRepeatMode(Animation.REVERSE); ui.status.setAnimation(animation); ui.location.setHint(R.string.stations_searching_position); ui.location.clearFocus(); searching = true; }
From source file:com.github.kaninohon.poi.ui.widget.ScrollAwareFABBehavior.java
private void animateOut(final FloatingActionButton button) { if (Build.VERSION.SDK_INT >= 14) { ViewCompat.animate(button).scaleX(0.0F).scaleY(0.0F).alpha(0.0F).setInterpolator(INTERPOLATOR) .withLayer().setListener(new ViewPropertyAnimatorListener() { public void onAnimationStart(View view) { ScrollAwareFABBehavior.this.mIsAnimatingOut = true; }/*from w w w. j a v a 2s. c om*/ public void onAnimationCancel(View view) { ScrollAwareFABBehavior.this.mIsAnimatingOut = false; } public void onAnimationEnd(View view) { ScrollAwareFABBehavior.this.mIsAnimatingOut = false; view.setVisibility(View.GONE); } }).start(); } else { Animation anim = AnimationUtils.loadAnimation(button.getContext(), android.support.design.R.anim.fab_out); anim.setInterpolator(INTERPOLATOR); anim.setDuration(200L); anim.setAnimationListener(new Animation.AnimationListener() { public void onAnimationStart(Animation animation) { ScrollAwareFABBehavior.this.mIsAnimatingOut = true; } public void onAnimationEnd(Animation animation) { ScrollAwareFABBehavior.this.mIsAnimatingOut = false; button.setVisibility(View.GONE); } @Override public void onAnimationRepeat(final Animation animation) { } }); button.startAnimation(anim); } }
From source file:com.orangemoo.com.beta.widget.ScrollFABBehavior.java
private void animateOut(final FloatingActionButton button) { if (Build.VERSION.SDK_INT >= 14) { ViewCompat.animate(button).scaleX(0.0F).scaleY(0.0F).alpha(0.0F).setInterpolator(INTERPOLATOR) .withLayer().setListener(new ViewPropertyAnimatorListener() { public void onAnimationStart(View view) { ScrollFABBehavior.this.mIsAnimatingOut = true; }//from w ww. j a va 2 s .c o m public void onAnimationCancel(View view) { ScrollFABBehavior.this.mIsAnimatingOut = false; } public void onAnimationEnd(View view) { ScrollFABBehavior.this.mIsAnimatingOut = false; view.setVisibility(View.GONE); } }).setDuration(Utils.SWIPE_BEHAVIOR_ANIMATION_TIME).start(); } else { Animation anim = AnimationUtils.loadAnimation(button.getContext(), android.support.design.R.anim.abc_fade_out); anim.setInterpolator(INTERPOLATOR); anim.setDuration(Utils.SWIPE_BEHAVIOR_ANIMATION_TIME); anim.setAnimationListener(new Animation.AnimationListener() { public void onAnimationStart(Animation animation) { ScrollFABBehavior.this.mIsAnimatingOut = true; } public void onAnimationEnd(Animation animation) { ScrollFABBehavior.this.mIsAnimatingOut = false; button.setVisibility(View.GONE); } @Override public void onAnimationRepeat(final Animation animation) { } }); button.startAnimation(anim); } }
From source file:cn.lingox.android.share.view.ScrollAwareFABBehavior.java
private void animateOut(final FloatingActionButton button) { if (Build.VERSION.SDK_INT >= 14) { ViewCompat.animate(button).scaleX(0.0F).scaleY(0.0F).alpha(0.0F).setInterpolator(INTERPOLATOR) .withLayer().setListener(new ViewPropertyAnimatorListener() { public void onAnimationStart(View view) { ScrollAwareFABBehavior.this.mIsAnimatingOut = true; }//from w w w. j av a2 s . c o m public void onAnimationCancel(View view) { ScrollAwareFABBehavior.this.mIsAnimatingOut = false; } public void onAnimationEnd(View view) { ScrollAwareFABBehavior.this.mIsAnimatingOut = false; view.setVisibility(View.GONE); } }).start(); } else { Animation anim = AnimationUtils.loadAnimation(button.getContext(), android.support.design.R.anim.design_fab_out); anim.setInterpolator(INTERPOLATOR); anim.setDuration(200L); anim.setAnimationListener(new Animation.AnimationListener() { public void onAnimationStart(Animation animation) { ScrollAwareFABBehavior.this.mIsAnimatingOut = true; } public void onAnimationEnd(Animation animation) { ScrollAwareFABBehavior.this.mIsAnimatingOut = false; button.setVisibility(View.GONE); } @Override public void onAnimationRepeat(final Animation animation) { } }); button.startAnimation(anim); } }