Example usage for android.view.animation Animation setDuration

List of usage examples for android.view.animation Animation setDuration

Introduction

In this page you can find the example usage for android.view.animation Animation setDuration.

Prototype

public void setDuration(long durationMillis) 

Source Link

Document

How long this animation should last.

Usage

From source file:com.spoiledmilk.ibikecph.controls.SortableListView.java

void translate(View v, float deltaY, final boolean finalAnim) {
    float newY = posY + deltaY;
    if (animation != null && animation.isInitialized())
        animation.cancel();/*from   w  w w.j  av a  2  s.  co  m*/
    animation = new TranslateAnimation(0, 0, posY, newY);
    animation.setDuration(finalAnim ? 0 : 100);
    animation.setAnimationListener(new AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            if (!finalAnim) {
                animation.setFillEnabled(true);
                animation.setFillAfter(true);
            } else {
                view.clearAnimation();
                posY = 0;
            }
        }
    });

    posY = newY;

    v.startAnimation(animation);
}

From source file:com.almalence.opencam.ui.AlmalenceStore.java

public void ShowUnlockControl() {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainScreen.getMainContext());
    boolean bOnSale = prefs.getBoolean("bOnSale", false);
    final RotateImageView unlock = ((RotateImageView) guiView.findViewById(R.id.Unlock));
    unlock.setImageDrawable(//from   ww w. j av  a2 s  .c om
            MainScreen.getAppResources().getDrawable(bOnSale ? R.drawable.unlock_sale : R.drawable.unlock));
    unlock.setAlpha(1.0f);
    unlock.setVisibility(View.VISIBLE);

    Animation invisible_alpha = new AlphaAnimation(1, 0.4f);
    invisible_alpha.setDuration(7000);
    invisible_alpha.setRepeatCount(0);

    invisible_alpha.setAnimationListener(new AnimationListener() {
        @Override
        public void onAnimationEnd(Animation animation) {
            unlock.clearAnimation();
            unlock.setImageDrawable(MainScreen.getAppResources().getDrawable(R.drawable.unlock_gray));
            unlock.setAlpha(0.4f);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationStart(Animation animation) {
        }
    });

    unlock.startAnimation(invisible_alpha);
}

From source file:gov.wa.wsdot.android.wsdot.ui.mountainpasses.passitem.MountainPassItemActivity.java

private void startRefreshAnimation() {
    MenuItem item = mToolbar.getMenu().findItem(MENU_ITEM_REFRESH);
    if (item == null) {
        Log.e(TAG, "null");
        return;/* w w w.  j a  va 2 s  .c  o m*/
    }
    // define the animation for rotation
    Animation animation = new RotateAnimation(360.0f, 0.0f, Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);
    animation.setDuration(1000);

    animation.setRepeatCount(Animation.INFINITE);

    animation.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            mToolbar.getMenu().getItem(MENU_ITEM_REFRESH).setActionView(null);
            mToolbar.getMenu().getItem(MENU_ITEM_REFRESH).setIcon(R.drawable.ic_menu_refresh);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }
    });

    ImageView imageView = new ImageView(this, null, android.R.style.Widget_Material_ActionButton);
    imageView.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_menu_refresh));

    imageView.setPadding(31, imageView.getPaddingTop(), 32, imageView.getPaddingBottom());

    imageView.startAnimation(animation);
    item.setActionView(imageView);

}

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  a2 s.  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:com.money.manager.ex.fragment.HomeFragment.java

public LayoutAnimationController setAnimationView(View view) {
    AnimationSet set = new AnimationSet(true);

    Animation animation = new AlphaAnimation(0.0f, 1.0f);
    animation.setDuration(250);
    set.addAnimation(animation);/*from   www.  ja v  a  2 s .  c o  m*/

    animation = 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);
    animation.setDuration(150);
    set.addAnimation(animation);

    LayoutAnimationController controller = new LayoutAnimationController(set, 0.25f);

    return controller;
}

From source file:com.pwned.steamfriends.views.TwitterStream.java

@Override
public void onCreate(Bundle savedInstanceState) {
    setMyTheme();// w ww .ja v a 2  s  . c  om
    super.onCreate(savedInstanceState);
    tracker = GoogleAnalyticsTracker.getInstance();
    tracker.start(Constants.UACODE, 20, this);
    tracker.trackPageView("/TwitterStream");

    mManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    mManager.cancel(APP_ID);

    setContentView(R.layout.twitter);
    m_streams = new ArrayList<Stream>();
    this.m_adapter = new TwitterStreamAdapter(this, R.layout.row, m_streams);
    setListAdapter(this.m_adapter);

    viewStream = new Thread() {
        @Override
        public void run() {
            getStream();
        }
    };

    Animation a = new RotateAnimation(0.0f, 360.0f, Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);
    a.setRepeatMode(Animation.RESTART);
    a.setRepeatCount(Animation.INFINITE);
    a.setDuration(750);

    a.setInterpolator(AnimationUtils.loadInterpolator(this, android.R.anim.linear_interpolator));
    ivLoad = (ImageView) findViewById(R.id.loading_spinner);
    ivLoad.startAnimation(a);

    Thread thread = new Thread(null, viewStream, "SpecialsBackground");
    thread.start();
    //m_ProgressDialog = ProgressDialog.show(TwitterStream.this,"","Loading Twitter Stream...", true);

    steamHeader = (ImageView) findViewById(R.id.headerimage);
    steamHeader.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(Constants.HEADER_URL));
            startActivity(myIntent);
        }
    });
}

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  w w  w  .j  a  v  a  2s  .c  om*/
        }
        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 www . j  ava 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:org.secuso.privacyfriendlypasswordgenerator.activities.MainActivity.java

public void hints(int position) {

    Animation anim = new AlphaAnimation(0.0f, 1.0f);

    if (metadatalist.size() == 0 || position == 0) {

        initialAlert.setVisibility(View.VISIBLE);
        anim.setDuration(1500);
        anim.setStartOffset(20);// ww  w .j av a2 s.c om
        anim.setRepeatMode(Animation.REVERSE);
        anim.setRepeatCount(Animation.INFINITE);
        initialAlert.startAnimation(anim);

    } else {
        initialAlert.setVisibility(View.GONE);
        initialAlert.clearAnimation();
    }

}

From source file:com.libreteam.driver.Driver_RideOffer.java

private void blinkCountDown() {
    //      MediaPlayer  mp = MediaPlayer.create(getActivity(), R.raw.alert);
    //      mp.start();
    Animation anim = new AlphaAnimation(0.0f, 1.0f);
    anim.setDuration(150);
    anim.setStartOffset(120);//from  w  ww .  j ava2 s  .c  om
    anim.setRepeatMode(Animation.REVERSE);
    anim.setRepeatCount(Animation.INFINITE);
    txtCountDown.startAnimation(anim);
}