android.graphics.drawable.Animatable#start()源码实例Demo

下面列出了android.graphics.drawable.Animatable#start() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

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;
    }
 
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));
    }
 
源代码3 项目: IntroActivity   文件: NextDoneButton.java
/**
 * 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();
        }
    }
}
 
源代码4 项目: hkm-progress-button   文件: AnimationButton.java
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;
            }
        }
    }
}
 
源代码5 项目: fresco   文件: ToggleAnimationClickListener.java
@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();
  }
}
 
源代码6 项目: ProjectX   文件: ZxingForegroundView.java
/**
 * 设置开启图片
 *
 * @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();
}
 
源代码7 项目: ProjectX   文件: ZxingForegroundView.java
/**
 * 设置错误图片
 *
 * @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();
}
 
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;
      }
    }
  }
}
 
源代码9 项目: AndroidAll   文件: ViewAnimationFrameFragment.java
@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;
    }
}
 
源代码10 项目: MoeGallery   文件: ImageFragment.java
@Override
public void run() {
    if (mPhotoView != null && mPhotoView.getDrawable() instanceof Animatable) {
        Animatable animatable = (Animatable) mPhotoView.getDrawable();
        if (isVisibleToUser) {
            animatable.start();
        } else {
            animatable.stop();
        }
    }

}
 
@Override
public void onFinalImageSet(
    String id, @Nullable ImageInfo imageInfo, @Nullable Animatable anim) {
  if (anim != null) {
    // app-specific logic to enable animation starting
    anim.start();
  }
}
 
@Override
public void onFinalImageSet(String id, @Nullable Object info, @Nullable Animatable anim) {
  if (anim != null) {
    anim.start();
  }
}
 
 同类方法