Java Code Examples for android.graphics.drawable.Animatable#start()

The following examples show how to use android.graphics.drawable.Animatable#start() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SecondaryChooserFragment.java    From storage-chooser with Mozilla Public License 2.0 6 votes vote down vote up
private void showAddFolderView() {
        mNewFolderView.setVisibility(View.VISIBLE);
        Animation anim = AnimationUtils.loadAnimation(mContext, R.anim.anim_new_folder_view);
        mNewFolderView.startAnimation(anim);
        mInactiveGradient.startAnimation(anim);


        if (DiskUtil.isLollipopAndAbove()) {
            mNewFolderImageView.setImageDrawable(ContextCompat.getDrawable(mContext, R.drawable.drawable_plus_to_close));
            // image button animation
            Animatable animatable = (Animatable) mNewFolderImageView.getDrawable();
            animatable.start();
        }
        mNewFolderImageView.setOnClickListener(mNewFolderButtonCloseListener);

//        mNewFolderButton.setImageDrawable(ContextCompat.getDrawable(mContext, R.drawable.window_close));

        //listview should not be clickable
        SecondaryChooserAdapter.shouldEnable = false;
    }
 
Example 2
Source File: SecondaryChooserFragment.java    From storage-chooser with Mozilla Public License 2.0 6 votes vote down vote up
private void hideAddFolderView() {
        Animation anim = AnimationUtils.loadAnimation(mContext, R.anim.anim_close_folder_view);
        mNewFolderView.startAnimation(anim);
        mNewFolderView.setVisibility(View.INVISIBLE);

        if (DiskUtil.isLollipopAndAbove()) {
            mNewFolderImageView.setImageDrawable(ContextCompat.getDrawable(mContext, R.drawable.drawable_close_to_plus));
            // image button animation
            Animatable animatable = (Animatable) mNewFolderImageView.getDrawable();
            animatable.start();
        }
        mNewFolderImageView.setOnClickListener(mNewFolderButtonClickListener);

        //listview should be clickable
        SecondaryChooserAdapter.shouldEnable = true;

        mInactiveGradient.startAnimation(anim);
        mInactiveGradient.setVisibility(View.INVISIBLE);

//        mNewFolderButton.setImageDrawable(ContextCompat.getDrawable(mContext, R.drawable.plus));
    }
 
Example 3
Source File: NextDoneButton.java    From IntroActivity with Apache License 2.0 6 votes vote down vote up
/**
 * Toggle the current button style, changing the icon
 * and animating the change if the device supports it.
 */
public void toggle() {
    // Toggle the button style
    mButtonStyle = (mButtonStyle == STYLE_NEXT) ? STYLE_DONE : STYLE_NEXT;

    // Set image drawable depending on the button style
    setImageDrawable(mButtonStyle == STYLE_NEXT ? mNextDrawable : mDoneDrawable);

    // Attempt to animate the button if we're on Lollipop or above
    if (Utils.hasLollipop()) {
        Drawable drawable = getDrawable();
        if (drawable instanceof Animatable) {
            Animatable animatable = (Animatable) drawable;
            if (animatable.isRunning()) {
                animatable.stop();
            }
            animatable.start();
        }
    }
}
 
Example 4
Source File: AnimationButton.java    From hkm-progress-button with MIT License 6 votes vote down vote up
private void changeAnimation(Operation operation) {
    Drawable[] drawables = getCompoundDrawables();
    for (Drawable drawable : drawables) {
        if (drawable != null && drawable instanceof Animatable) {
            Animatable animatable = ((Animatable) drawable);
            switch (operation) {
                case START:
                    animatable.start();
                    break;
                case STOP:
                    animatable.stop();
                    break;
            }
        }
    }
}
 
Example 5
Source File: ToggleAnimationClickListener.java    From fresco with MIT License 6 votes vote down vote up
@Override
public void onClick(View v) {
  DraweeController controller = mDraweeView.getController();
  if (controller == null) {
    return;
  }
  Animatable animatable = controller.getAnimatable();
  if (animatable == null) {
    return;
  }
  if (animatable.isRunning()) {
    animatable.stop();
  } else {
    animatable.start();
  }
}
 
Example 6
Source File: ZxingForegroundView.java    From ProjectX with Apache License 2.0 6 votes vote down vote up
/**
 * 设置开启图片
 *
 * @param drawable 开启图片
 */
public void setOpenDrawable(Drawable drawable) {
    if (mOpenDrawable == drawable)
        return;
    if (mOpenDrawable != null) {
        if (mOpenDrawable instanceof Animatable)
            ((Animatable) mOpenDrawable).stop();
        mOpenDrawable.setCallback(null);
    }
    mOpenDrawable = drawable;
    if (mOpenDrawable != null) {
        mOpenDrawable.setCallback(this);
        if (mOpenDrawable instanceof Animatable) {
            Animatable animatable = (Animatable) mOpenDrawable;
            if (!animatable.isRunning())
                animatable.start();
        }
    }
    invalidate();
}
 
Example 7
Source File: ZxingForegroundView.java    From ProjectX with Apache License 2.0 6 votes vote down vote up
/**
 * 设置错误图片
 *
 * @param drawable 错误图片
 */
public void setErrorDrawable(Drawable drawable) {
    if (mErrorDrawable == drawable)
        return;
    if (mErrorDrawable != null) {
        if (mErrorDrawable instanceof Animatable)
            ((Animatable) mErrorDrawable).stop();
        mErrorDrawable.setCallback(null);
    }
    mErrorDrawable = drawable;
    if (mErrorDrawable != null) {
        mErrorDrawable.setCallback(this);
        if (mErrorDrawable instanceof Animatable) {
            Animatable animatable = (Animatable) mErrorDrawable;
            if (!animatable.isRunning())
                animatable.start();
        }
    }
    invalidate();
}
 
Example 8
Source File: AnimatedCompoundDrawableActivity.java    From advanced-textview with Apache License 2.0 6 votes vote down vote up
private void changeAnimation(Operation operation) {
  Drawable[] drawables = textView.getCompoundDrawables();
  for (Drawable drawable : drawables) {
    if (drawable != null && drawable instanceof Animatable) {
      Animatable animatable = ((Animatable) drawable);
      switch (operation) {
        case START:
          animatable.start();
          break;
        case STOP:
          animatable.stop();
          break;
      }
    }
  }
}
 
Example 9
Source File: ViewAnimationFrameFragment.java    From AndroidAll with Apache License 2.0 5 votes vote down vote up
@Override
public void onClick(View v) {
    super.onClick(v);
    switch (v.getId()) {
        case R.id.btn_start_upload:
            ivUpload.setBackgroundResource(R.drawable.frame_animation_upload);
            AnimationDrawable uploadAnimation = (AnimationDrawable) ivUpload.getBackground();
            uploadAnimation.start();
            break;
        case R.id.btn_start_sound:
            ivSound.setBackgroundResource(R.drawable.frame_animation_sound);
            AnimationDrawable uploadAnimation2 = (AnimationDrawable) ivSound.getBackground();
            uploadAnimation2.start();
            break;
        case R.id.btn_start_loading:
            ivLoading.setBackgroundResource(R.drawable.rotation_animation1);
            Animatable uploadAnimation1 = (Animatable) ivLoading.getBackground();
            uploadAnimation1.start();
            break;

        case R.id.btn_start_loading2:
            Animation a = AnimationUtils.loadAnimation(getContext(),
                    R.anim.rotation_animation2);
            a.setInterpolator(new android.view.animation.Interpolator() {
                //总共有多少帧(具体根据图片来设置)
                private final int frameCount = 12;

                @Override
                public float getInterpolation(float input) {
                    return (float) Math.floor(input * frameCount) / frameCount;
                }
            });
            a.setDuration(1500);
            ivLoading2.startAnimation(a);
            break;
        case R.id.iv_loading3:
            ivLoading3.toggleAnimation();
            break;
    }
}
 
Example 10
Source File: ImageFragment.java    From MoeGallery with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void run() {
    if (mPhotoView != null && mPhotoView.getDrawable() instanceof Animatable) {
        Animatable animatable = (Animatable) mPhotoView.getDrawable();
        if (isVisibleToUser) {
            animatable.start();
        } else {
            animatable.stop();
        }
    }

}
 
Example 11
Source File: RetainingDataSourceSupplierFragment.java    From fresco with MIT License 5 votes vote down vote up
@Override
public void onFinalImageSet(
    String id, @Nullable ImageInfo imageInfo, @Nullable Animatable anim) {
  if (anim != null) {
    // app-specific logic to enable animation starting
    anim.start();
  }
}
 
Example 12
Source File: AbstractDraweeControllerBuilder.java    From FanXin-based-HuanXin with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onFinalImageSet(String id, @Nullable Object info, @Nullable Animatable anim) {
  if (anim != null) {
    anim.start();
  }
}