List of usage examples for android.view.animation Animation setInterpolator
public void setInterpolator(Interpolator i)
From source file:com.dbeginc.dbweather.utils.animations.widgets.SnowFallView.java
@Override protected void onSizeChanged(int width, int height, int oldWidth, int oldHeight) { super.onSizeChanged(width, height, oldWidth, oldHeight); Random random = new SecureRandom(); Interpolator interpolator = new LinearInterpolator(); snow_flake_count = Math.max(width, height) / 20; coords = new int[snow_flake_count][]; drawables.clear();/*ww w . ja v a 2 s . c o m*/ for (int i = 0; i < snow_flake_count; i++) { Animation animation = new TranslateAnimation(0, height / 10 - random.nextInt(height / 5), 0, height + 30); animation.setDuration(10 * height + random.nextInt(5 * height)); animation.setRepeatCount(-1); animation.initialize(10, 10, 10, 10); animation.setInterpolator(interpolator); coords[i] = new int[] { random.nextInt(width - 30), -30 }; drawables.add(new AnimateDrawable(snow_flake, animation)); animation.setStartOffset(random.nextInt(20 * height)); animation.startNow(); int y; y = random.nextInt(2); if (y == 0) { drawables.add(new AnimateDrawable(snow_flake, animation)); } else { drawables.add(new AnimateDrawable(snow_flake)); } } }
From source file:io.github.runassudo.ptoffline.ui.LocationGpsView.java
public void activateGPS() { if (searching) return;//w ww . j av a2 s . c om // check permissions if (ContextCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // Should we show an explanation? if (ActivityCompat.shouldShowRequestPermissionRationale(activity, Manifest.permission.ACCESS_FINE_LOCATION)) { Toast.makeText(getContext(), R.string.permission_denied_gps, Toast.LENGTH_LONG).show(); } else { // No explanation needed, we can request the permission ActivityCompat.requestPermissions(activity, new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, caller); } return; } searching = true; 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(getContext(), getContext().getString(R.string.error_no_location_provider), Toast.LENGTH_LONG).show(); // Set the flag that there is currently no active search. Otherwise the App won't // allow new searches even after GPS has been reenabled, because the app "hangs" in // a semistate where searching = true but now real search is active. searching = false; return; } // clear input setLocation(null, TransportrUtils.getTintedDrawable(getContext(), 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.startAnimation(animation); ui.location.setHint(R.string.stations_searching_position); ui.location.clearFocus(); if (gpsListener != null) gpsListener.activateGPS(); }
From source file:io.imoji.sdk.grid.ui.ResultView.java
private Animation getAppearAnimation() { Animation fadeInAnimation = AnimationUtils.loadAnimation(context, R.anim.search_widget_result_fade_in); fadeInAnimation.setInterpolator(PathInterpolatorCompat.create(0.3f, 0.14f, 0.36f, 1.36f)); return fadeInAnimation; }
From source file:io.imoji.sdk.grid.ui.ResultView.java
private Animation getDisappearAnimation() { Animation fadeOutAnimation = AnimationUtils.loadAnimation(context, R.anim.search_widget_result_fade_out); fadeOutAnimation.setInterpolator(PathInterpolatorCompat.create(0.25f, 0.1f, 0.25f, 1)); return fadeOutAnimation; }
From source file:com.codefororlando.transport.MapsActivity.java
private void removeSelectableItemFragment() { final Fragment selectableItemFragment = getFragmentManager().findFragmentByTag(ISelectableItemFragment.TAG); if (selectableItemFragment != null) { final View view = selectableItemFragment.getView(); if (view == null) { return; }/* w w w .ja v a2s . c om*/ final int animationDuration = getResources().getInteger(android.R.integer.config_shortAnimTime); { final Animation animation = new TranslateAnimation(0, 0, 0, view.getHeight()); animation.setDuration(animationDuration); animation.setInterpolator(new AccelerateDecelerateInterpolator()); filterView.startAnimation(animation); } { final FragmentManager fragmentManager = getFragmentManager(); final Animation animation = new TranslateAnimation(0, 0, 0, view.getHeight()); animation.setDuration(animationDuration); animation.setAnimationListener(new EmptyAnimationListener() { @Override public void onAnimationEnd(Animation animation) { try { fragmentManager.beginTransaction().remove(selectableItemFragment) .commitAllowingStateLoss(); } catch (Exception e) { e.printStackTrace(); } } }); view.startAnimation(animation); } } }
From source file:android.support.design.widget.FloatingActionButtonEclairMr1.java
@Override void hide(@Nullable final InternalVisibilityChangedListener listener, final boolean fromUser) { if (mIsHiding || mView.getVisibility() != View.VISIBLE) { // A hide animation is in progress, or we're already hidden. Skip the call if (listener != null) { listener.onHidden();// w w w . j a v a 2s. c o m } return; } Animation anim = android.view.animation.AnimationUtils.loadAnimation(mView.getContext(), R.anim.design_fab_out); anim.setInterpolator(AnimationUtils.FAST_OUT_LINEAR_IN_INTERPOLATOR); anim.setDuration(SHOW_HIDE_ANIM_DURATION); anim.setAnimationListener(new AnimationUtils.AnimationListenerAdapter() { @Override public void onAnimationStart(Animation animation) { mIsHiding = true; } @Override public void onAnimationEnd(Animation animation) { mIsHiding = false; mView.internalSetVisibility(View.GONE, fromUser); if (listener != null) { listener.onHidden(); } } }); mView.startAnimation(anim); }
From source file:android.support.designox.widget.FloatingActionButtonEclairMr1.java
@Override void hide(@Nullable final InternalVisibilityChangedListener listener, final boolean fromUser) { if (mIsHiding || mView.getVisibility() != View.VISIBLE) { // A hide animation is in progress, or we're already hidden. Skip the call if (listener != null) { listener.onHidden();//from ww w. j a va2 s . c o m } return; } Animation anim = android.view.animation.AnimationUtils.loadAnimation(mView.getContext(), R.anim.design_fab_out_ox); anim.setInterpolator(AnimationUtils.FAST_OUT_LINEAR_IN_INTERPOLATOR); anim.setDuration(SHOW_HIDE_ANIM_DURATION); anim.setAnimationListener(new AnimationUtils.AnimationListenerAdapter() { @Override public void onAnimationStart(Animation animation) { mIsHiding = true; } @Override public void onAnimationEnd(Animation animation) { mIsHiding = false; mView.internalSetVisibility(View.GONE, fromUser); if (listener != null) { listener.onHidden(); } } }); mView.startAnimation(anim); }
From source file:android.support.design.widget.FloatingActionButtonGingerbread.java
@Override void hide(@Nullable final InternalVisibilityChangedListener listener, final boolean fromUser) { if (isOrWillBeHidden()) { // We either are or will soon be hidden, skip the call return;/*from w w w . j a v a 2 s .c o m*/ } mAnimState = ANIM_STATE_HIDING; Animation anim = android.view.animation.AnimationUtils.loadAnimation(mView.getContext(), R.anim.design_fab_out); anim.setInterpolator(AnimationUtils.FAST_OUT_LINEAR_IN_INTERPOLATOR); anim.setDuration(SHOW_HIDE_ANIM_DURATION); anim.setAnimationListener(new AnimationListenerAdapter() { @Override public void onAnimationEnd(Animation animation) { mAnimState = ANIM_STATE_NONE; mView.internalSetVisibility(fromUser ? View.GONE : View.INVISIBLE, fromUser); if (listener != null) { listener.onHidden(); } } }); mView.startAnimation(anim); }
From source file:jp.tkgktyk.xposed.forcetouchdetector.app.util.fab.FloatingActionButtonEclairMr1.java
@Override void show() {//from w w w .ja v a2 s.c o m if (mView.getVisibility() != View.VISIBLE || mIsHiding) { // If the view is not visible, or is visible and currently being hidden, run // the show animation mView.clearAnimation(); mView.setVisibility(View.VISIBLE); Animation anim = android.view.animation.AnimationUtils.loadAnimation(mView.getContext(), R.anim.design_fab_in); anim.setDuration(SHOW_HIDE_ANIM_DURATION); anim.setInterpolator(AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR); mView.startAnimation(anim); } }
From source file:org.fs.publication.views.ReadActivity.java
@Override public void showNavigation() { clearAnimations();/*from ww w.j a v a2s . c o m*/ // toolbar Animation showToolbarAnim = AnimationUtils.loadAnimation(getContext(), R.anim.top_in); showToolbarAnim.setDuration(300L); showToolbarAnim.setInterpolator(new FancyInterpolator()); showToolbarAnim.setAnimationListener(new SimpleAnimationListener() { @Override public void onAnimationStart(Animation animation) { if (isAvailable()) { toolbar.setVisibility(View.VISIBLE); } } }); toolbar.setAnimation(showToolbarAnim); // navigation Animation showMenuAnim = AnimationUtils.loadAnimation(getContext(), R.anim.bottom_in); showMenuAnim.setDuration(300L); showMenuAnim.setInterpolator(new FancyInterpolator()); showMenuAnim.setAnimationListener(new SimpleAnimationListener() { @Override public void onAnimationStart(Animation animation) { if (isAvailable()) { layout.setVisibility(View.VISIBLE); } } }); layout.setAnimation(showMenuAnim); // start showToolbarAnim.start(); showMenuAnim.start(); }