Java Code Examples for android.view.animation.AnimationUtils.loadAnimation()

The following are Jave code examples for showing how to use loadAnimation() of the android.view.animation.AnimationUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: Trivia-Knowledge   File: MainGameActivity.java   Source Code and License Vote up 7 votes
private void allAnimation() {

        //Animation
        final Animation myAnim = AnimationUtils.loadAnimation(this, R.anim.bounce);
        // Use bounce interpolator with amplitude 0.2 and frequency 20
        MyBounceInterpolator interpolator = new MyBounceInterpolator(0.11, 10);
        myAnim.setInterpolator(interpolator);
        tvQ.startAnimation(myAnim);


        final Handler handler = new Handler();
        Runnable runnable = new Runnable() {

            public void run() {
                master.startAnimation(inFromLeftAnimation());
                master.setVisibility(View.VISIBLE);   //for interval...
            }
        };
        handler.postDelayed(runnable, 150); //for initial delay..*//*

        for (int i = 0; i < 20; i++) {
            textViewArrayAbove[i].startAnimation(myAnim);
        }
    }
 
Example 2
Project: boohee_v5.6   File: FloatingActionButtonEclairMr1.java   Source Code and License Vote up 6 votes
void show(@Nullable final InternalVisibilityChangedListener listener, boolean fromUser) {
    if (this.mView.getVisibility() != 0 || this.mIsHiding) {
        this.mView.clearAnimation();
        this.mView.internalSetVisibility(0, fromUser);
        Animation anim = AnimationUtils.loadAnimation(this.mView.getContext(), R.anim.design_fab_in);
        anim.setDuration(200);
        anim.setInterpolator(AnimationUtils.LINEAR_OUT_SLOW_IN_INTERPOLATOR);
        anim.setAnimationListener(new AnimationListenerAdapter() {
            public void onAnimationEnd(Animation animation) {
                if (listener != null) {
                    listener.onShown();
                }
            }
        });
        this.mView.startAnimation(anim);
    } else if (listener != null) {
        listener.onShown();
    }
}
 
Example 3
Project: easyfilemanager   File: AppRate.java   Source Code and License Vote up 6 votes
private void displayViews(ViewGroup mainView) {
    if(null != viewGroup){
        viewGroup.setVisibility(View.VISIBLE);
        viewGroup.addView(mainView);
    }
    else{
        LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
        activity.addContentView(mainView, params);
    }

    Animation fadeInAnimation = AnimationUtils.loadAnimation(activity, android.R.anim.fade_in);
    mainView.startAnimation(fadeInAnimation);

    if (onShowListener != null) onShowListener.onRateAppShowing();
}
 
Example 4
Project: yanohesaplama   File: StartActivity.java   Source Code and License Vote up 6 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_start);
    view = findViewById(android.R.id.content);
    Animation mLoadAnimation = AnimationUtils.loadAnimation(getApplicationContext(), android.R.anim.fade_in);
    mLoadAnimation.setDuration(2000);
    view.startAnimation(mLoadAnimation);
    mHandler.postDelayed(new Runnable() {
        @Override
        public void run() {

            Intent intent = new Intent(StartActivity.this, MainActivity.class);
            startActivity(intent);
            overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
        }
    },4000);
}
 
Example 5
Project: AppLocker   File: LockActivity.java   Source Code and License Vote up 6 votes
protected void onPasscodeError() {
	Encryptor.snackPeak(mActivity,getString(R.string.passcode_wrong));

	Thread thread = new Thread() {
		public void run() {
			Animation animation = AnimationUtils.loadAnimation(
					LockActivity.this, R.anim.shake);
			findViewById(R.id.ll_applock).startAnimation(animation);
			codeField1.setText("");
			codeField2.setText("");
			codeField3.setText("");
			codeField4.setText("");
			codeField1.requestFocus();
		}
	};
	runOnUiThread(thread);
}
 
Example 6
Project: GitHub   File: LoginFragment.java   Source Code and License Vote up 6 votes
@Override public void showError() {

    viewState.setShowError();

    setFormEnabled(true);
    loginButton.setProgress(0);

    if (!isRestoringViewState()) {
      // Enable animations only if not restoring view state
      loginForm.clearAnimation();
      Animation shake = AnimationUtils.loadAnimation(getActivity(), R.anim.shake);
      loginForm.startAnimation(shake);
    }

    errorView.setVisibility(View.VISIBLE);
  }
 
Example 7
Project: SlidingPanel   File: SlidingPanelLinear.java   Source Code and License Vote up 6 votes
/**
 * Default constructor for this custom view class.
 *
 * @param context - activity or application context for obtaining custom attributes.
 * @param attrs   - AttributeSet parameter which allows to obtain attributes and use them in java code.
 */
public SlidingPanelLinear(Context context, @Nullable AttributeSet attrs) {
    super(context, attrs);

    TypedArray typedArray = context.obtainStyledAttributes(attrs,
            R.styleable.SettingsPanel,
            0, 0);

    attrSpeed = typedArray.getInt(R.styleable.SettingsPanel_speed, Utilities.DEFAULT_ANIMATION_SPEED);
    attrInterpolator = typedArray.getNonResourceString(R.styleable.SettingsPanel_interpolator);
    attrDirection = typedArray.getNonResourceString(R.styleable.SettingsPanel_direction);

    typedArray.recycle();

    fadeAnimation = AnimationUtils.loadAnimation(context, R.anim.fade);
}
 
Example 8
Project: proSwipeButton   File: UiUtils.java   Source Code and License Vote up 5 votes
public static void animateFadeShow(Context context, View view) {
    if (view.getVisibility() != View.VISIBLE) {
        Animation animFadeIn = AnimationUtils.loadAnimation(context, R.anim.fade_in);

        view.startAnimation(animFadeIn);
        view.setVisibility(View.VISIBLE);
    }
}
 
Example 9
Project: mobile-app-dev-book   File: SignUpActivity.java   Source Code and License Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sign_up);
    ButterKnife.bind(this);
    setSupportActionBar(toolbar);
    mAuth = FirebaseAuth.getInstance();
    shake = AnimationUtils.loadAnimation(this, R.anim.shake);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
 
Example 10
Project: ywApplication   File: IndicatorLayout.java   Source Code and License Vote up 5 votes
public IndicatorLayout(Context context, PullToRefreshBase.Mode mode) {
	super(context);
	mArrowImageView = new ImageView(context);

	Drawable arrowD = getResources().getDrawable(R.drawable.indicator_arrow);
	mArrowImageView.setImageDrawable(arrowD);

	final int padding = getResources().getDimensionPixelSize(R.dimen.indicator_internal_padding);
	mArrowImageView.setPadding(padding, padding, padding, padding);
	addView(mArrowImageView);

	int inAnimResId, outAnimResId;
	switch (mode) {
		case PULL_FROM_END:
			inAnimResId = R.anim.slide_in_from_bottom;
			outAnimResId = R.anim.slide_out_to_bottom;
			setBackgroundResource(R.drawable.indicator_bg_bottom);

			// Rotate Arrow so it's pointing the correct way
			mArrowImageView.setScaleType(ScaleType.MATRIX);
			Matrix matrix = new Matrix();
			matrix.setRotate(180f, arrowD.getIntrinsicWidth() / 2f, arrowD.getIntrinsicHeight() / 2f);
			mArrowImageView.setImageMatrix(matrix);
			break;
		default:
		case PULL_FROM_START:
			inAnimResId = R.anim.slide_in_from_top;
			outAnimResId = R.anim.slide_out_to_top;
			setBackgroundResource(R.drawable.indicator_bg_top);
			break;
	}

	mInAnim = AnimationUtils.loadAnimation(context, inAnimResId);
	mInAnim.setAnimationListener(this);

	mOutAnim = AnimationUtils.loadAnimation(context, outAnimResId);
	mOutAnim.setAnimationListener(this);

	final Interpolator interpolator = new LinearInterpolator();
	mRotateAnimation = new RotateAnimation(0, -180, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
			0.5f);
	mRotateAnimation.setInterpolator(interpolator);
	mRotateAnimation.setDuration(DEFAULT_ROTATION_ANIMATION_DURATION);
	mRotateAnimation.setFillAfter(true);

	mResetRotateAnimation = new RotateAnimation(-180, 0, Animation.RELATIVE_TO_SELF, 0.5f,
			Animation.RELATIVE_TO_SELF, 0.5f);
	mResetRotateAnimation.setInterpolator(interpolator);
	mResetRotateAnimation.setDuration(DEFAULT_ROTATION_ANIMATION_DURATION);
	mResetRotateAnimation.setFillAfter(true);

}
 
Example 11
Project: MyDemo   File: EmptyLayout.java   Source Code and License Vote up 5 votes
/**
 * 切换视图
 */
private void switchEmptyView() {
    switch (mCurrentStatus) {
        case STATUS_LOADING:
            setVisibility(VISIBLE);
            mEmptyContainer.setVisibility(GONE);
            mLoadingView.setVisibility(VISIBLE);
            Animation animation = AnimationUtils.loadAnimation(mContext, R.anim.anim_rotate);
            mIvLoading.startAnimation(animation);
            break;
        case STATUS_NO_DATA:
            setVisibility(VISIBLE);
            mIvLoading.clearAnimation();
            mLoadingView.setVisibility(GONE);
            mEmptyContainer.setVisibility(VISIBLE);
            mTvEmptyMessage.setText("暂无数据");
            Drawable drawableNoData=getResources().getDrawable(R.drawable.ic_no_data);
            drawableNoData.setBounds(0, 0, drawableNoData.getMinimumWidth(), drawableNoData.getMinimumHeight());
            mTvEmptyMessage.setCompoundDrawables(null, drawableNoData, null, null);
            break;
        case STATUS_NO_NET:
            setVisibility(VISIBLE);
            mIvLoading.clearAnimation();
            mLoadingView.setVisibility(GONE);
            mEmptyContainer.setVisibility(VISIBLE);
            mTvEmptyMessage.setText("网络异常,点击重试");
            Drawable drawableNoNet=getResources().getDrawable(R.drawable.ic_net_error);
            drawableNoNet.setBounds(0, 0, drawableNoNet.getMinimumWidth(), drawableNoNet.getMinimumHeight());
            mTvEmptyMessage.setCompoundDrawables(null, drawableNoNet,null, null);
            break;
        case STATUS_HIDE:
            setVisibility(GONE);
            mIvLoading.clearAnimation();
            break;
    }
}
 
Example 12
Project: CFAlertDialog   File: CFAlertDialog.java   Source Code and License Vote up 5 votes
private Animation getDismissAnimation(CFAlertStyle style) {
    switch (style) {
        case NOTIFICATION:
            return AnimationUtils.loadAnimation(params.context, R.anim.dialog_dismiss_top);
        case ALERT:
            return AnimationUtils.loadAnimation(params.context, R.anim.dialog_dismiss_center);
        case BOTTOM_SHEET:
            return AnimationUtils.loadAnimation(params.context, R.anim.dialog_dismiss_bottom);
        default:
            return AnimationUtils.loadAnimation(params.context, R.anim.dialog_dismiss_center);
    }
}
 
Example 13
Project: android-project-gallery   File: AnimationUtil.java   Source Code and License Vote up 5 votes
/**
 * Load anim and set duration
 * 
 * @param anim
 * @param duration
 * @return
 */
public static Animation loadAnimation(Context context, int anim, int duration)
{
	Animation animation = AnimationUtils.loadAnimation(context, anim);
	animation.setDuration(duration);

	return animation;
}
 
Example 14
Project: CSipSimple   File: ActionBarSherlockCompat.java   Source Code and License Vote up 5 votes
private void hideProgressBars(IcsProgressBar horizontalProgressBar, IcsProgressBar spinnyProgressBar) {
    final int features = mFeatures;//getLocalFeatures();
    Animation anim = AnimationUtils.loadAnimation(mActivity, android.R.anim.fade_out);
    anim.setDuration(1000);
    if ((features & (1 << Window.FEATURE_INDETERMINATE_PROGRESS)) != 0 &&
            spinnyProgressBar.getVisibility() == View.VISIBLE) {
        spinnyProgressBar.startAnimation(anim);
        spinnyProgressBar.setVisibility(View.INVISIBLE);
    }
    if ((features & (1 << Window.FEATURE_PROGRESS)) != 0 &&
            horizontalProgressBar.getVisibility() == View.VISIBLE) {
        horizontalProgressBar.startAnimation(anim);
        horizontalProgressBar.setVisibility(View.INVISIBLE);
    }
}
 
Example 15
Project: SuperSelector   File: AnimUtil.java   Source Code and License Vote up 4 votes
public AnimUtil(Context context, int resId) {
	this.animation = AnimationUtils.loadAnimation(context, resId);
	this.animation.setAnimationListener(this);
}
 
Example 16
Project: Android-Bubble-Game   File: AnimationHelper.java   Source Code and License Vote up 4 votes
public static Animation getButtonAnimation () {
  final Animation animation = AnimationUtils.loadAnimation(MainMenu.getAppContext(), R.anim.bounce);
  AnimationBounceInterpolator interpolator = new AnimationBounceInterpolator(0.2, 20);
  animation.setInterpolator(interpolator);
  return animation;
}
 
Example 17
Project: hanoi-animation   File: PillarLayout.java   Source Code and License Vote up 4 votes
void addDisk(final DiskView diskView) {
    addView(diskView, 0);

    Animation drop = AnimationUtils.loadAnimation(getContext(), R.anim.disk_drop);
    diskView.startAnimation(drop);
}
 
Example 18
Project: CartCounter   File: CartCounterActionView.java   Source Code and License Vote up 4 votes
private void animateBadge() {
    Animation bounce = AnimationUtils.loadAnimation(mIcon.getContext(), layoutAnimationId);
    this.startAnimation(bounce);
}
 
Example 19
Project: Sanxing   File: CalendarHelpFragment.java   Source Code and License Vote up 4 votes
void showAnimation() {
    Animation shake = AnimationUtils.loadAnimation(this.getContext(), R.anim.shake);
    Animation rightEnter = AnimationUtils.loadAnimation(this.getContext(), R.anim.right_enter);
    imageView.startAnimation(shake);
    barHolder.startAnimation(rightEnter);
}
 
Example 20
Project: Selector   File: QuickOptionDialog.java   Source Code and License Vote up 3 votes
private QuickOptionDialog(Context context, int theme) {

    super(context, theme);

    View contentView = getLayoutInflater().inflate(R.layout.quick_option_dialog, null);

    mShare = (LinearLayout) contentView.findViewById(R.id.share_friend);
    saveLocal = (LinearLayout) contentView.findViewById(R.id.save_phone);
    collection = (LinearLayout) contentView.findViewById(R.id.collection);


    mOperatingAnim = AnimationUtils.loadAnimation(getContext(), R.anim.quick_option_close);

    LinearInterpolator lin = new LinearInterpolator();

    mOperatingAnim.setInterpolator(lin);

    contentView.setOnTouchListener(new View.OnTouchListener() {

      @Override

      public boolean onTouch(View v, MotionEvent event) {

        QuickOptionDialog.this.dismiss();

        return true;

      }

    });

    super.setContentView(contentView);

  }