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

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

源代码1 项目: MyHearts   文件: MainActivityDrawerLayout.java
/**
 * 自己去调整
 */
private void initAnimation() {
    // 获取ImageView上的动画背景
    AnimationDrawable spinnerLive = (AnimationDrawable) mIvLive.getBackground();

    // 开始动画
    spinnerLive.start();

    mIvImg = (ImageView) findViewById(R.id.img_img);

    // 获取ImageView上的动画背景
    AnimationDrawable spinnerImg = (AnimationDrawable) mIvImg.getBackground();
    // 开始动画
    spinnerImg.start();

}
 
private void setTypingAnimation(boolean start) {
    if (actionBarLayer == null) {
        return;
    }
    if (start) {
        try {
            actionBarLayer.setSubTitleIcon(R.drawable.typing_dots, OSUtilities.dp(4));
            AnimationDrawable mAnim = (AnimationDrawable) actionBarLayer.getSubTitleIcon();
            mAnim.setAlpha(200);
            mAnim.start();
        } catch (Exception e) {
            FileLog.e("tmessages", e);
        }
    } else {
        actionBarLayer.setSubTitleIcon(0, 0);
    }
}
 
源代码3 项目: o2oa   文件: DialogCreator.java
public static Dialog createLoadingDialog(Context context, String msg) {
    LayoutInflater inflater = LayoutInflater.from(context);
    View v = inflater.inflate(IdHelper.getLayout(context, "jmui_loading_view"), null);
    RelativeLayout layout = (RelativeLayout) v.findViewById(IdHelper.getViewID(context, "jmui_dialog_view"));
    ImageView mLoadImg = (ImageView) v.findViewById(IdHelper.getViewID(context, "jmui_loading_img"));
    TextView mLoadText = (TextView) v.findViewById(IdHelper.getViewID(context, "jmui_loading_txt"));
    AnimationDrawable mDrawable = (AnimationDrawable) mLoadImg.getDrawable();
    mDrawable.start();
    mLoadText.setText(msg);
    final Dialog loadingDialog = new Dialog(context, R.style.loading_dialog);
    loadingDialog.setCancelable(true);
    loadingDialog.setContentView(layout, new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.MATCH_PARENT));
    return loadingDialog;
}
 
源代码4 项目: DialogUtil   文件: DialogViewBuilder.java
protected  ConfigBean buildLoading(ConfigBean bean){
    View root = View.inflate(bean.context, R.layout.loading,null);
    ImageView gifMovieView = (ImageView) root.findViewById(R.id.iv_loading);
    AnimationDrawable drawable = (AnimationDrawable) gifMovieView.getDrawable();
    if(drawable!=null){
        drawable.start();
    }
    TextView tvMsg = (TextView) root.findViewById(R.id.loading_msg);
    tvMsg.setText(bean.msg);
    bean.dialog.setContentView(root);
    return bean;
}
 
@Override
public void headerRefreshing() {
    pull_to_refresh_image.setImageDrawable(null);
    pull_to_refresh_image.clearAnimation();
    pull_to_refresh_image.setVisibility(View.GONE);
    pull_to_refresh_image1.setVisibility(View.VISIBLE);
    pull_to_refresh_image1.setImageResource(R.drawable.simple_loading);
    AnimationDrawable mAnimationDrawable= (AnimationDrawable) pull_to_refresh_image1.getDrawable();
    mAnimationDrawable.start();
    pull_to_refresh_text.setText("正在刷新…");
}
 
源代码6 项目: UltimateRefreshView   文件: JDAppHeaderAdpater.java
@Override
public void headerRefreshing() {
    headerText.setText("更新中…");
    loading.setImageResource(R.drawable.jd_loading);
    AnimationDrawable mAnimationDrawable= (AnimationDrawable) loading.getDrawable();
    mAnimationDrawable.start();
}
 
源代码7 项目: qvod   文件: LoadingImageView.java
public LoadingImageView(Context context, @Nullable AttributeSet attrs) {
    super(context, attrs);
    setImageResource(R.drawable.anim_yun);
    // 加载动画
    AnimationDrawable mAnimationDrawable = (AnimationDrawable) getDrawable();
    // 默认进入页面就开启动画
    if (!mAnimationDrawable.isRunning()) {
        mAnimationDrawable.start();
    }
}
 
private void showAnimation() {
	// play voice, and start animation
	if (message.direct == EMMessage.Direct.RECEIVE) {
		voiceIconView.setImageResource(R.anim.voice_from_icon);
	} else {
		voiceIconView.setImageResource(R.anim.voice_to_icon);
	}
	voiceAnimation = (AnimationDrawable) voiceIconView.getDrawable();
	voiceAnimation.start();
}
 
源代码9 项目: LbaizxfPulltoRefresh   文件: JdRefreshHeader.java
@Override
public void onUIRefreshBegin(PtrFrameLayout frame) {
    // 开始刷新
    mState = STATE_BEGIN;
    // 隐藏商品logo
    mGoodsIv.setVisibility(View.GONE);
    // 开启跑步动画
    mManIv.setBackgroundResource(R.drawable.jd_refresh_header_anim);
    mAnimation = (AnimationDrawable) mManIv.getBackground();
    if (!mAnimation.isRunning()) {
        mAnimation.start();
    }
}
 
源代码10 项目: FoodOrdering   文件: CommProgressDialog.java
public void onWindowFocusChanged(boolean hasFocus){

        if (commProgressDialog == null){
            return;
        }

        ImageView imageView = (ImageView) commProgressDialog.findViewById(R.id.iv_loading);
        if(anim!=0) {
            imageView.setBackgroundResource(anim);
        }
        AnimationDrawable animationDrawable = (AnimationDrawable) imageView.getBackground();
        animationDrawable.start();
    }
 
源代码11 项目: Meteorite   文件: BaseActivity.java
@Override
public void setContentView(@LayoutRes int layoutResID) {
    inflate = LayoutInflater.from(this);
    activity_base = inflate.inflate(R.layout.activity_base, null, false);
    activity = inflate.inflate(layoutResID, null, false);

    // content
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    activity.setLayoutParams(params);
    RelativeLayout mContainer = activity_base.findViewById(R.id.container);
    mContainer.addView(activity);
    getWindow().setContentView(activity_base);

    llProgressBar = getView(R.id.ll_progress_bar);
    refresh = getView(R.id.ll_error_refresh);
    ImageView img = getView(R.id.img_progress);

    // 加载动画
    mAnimationDrawable = (AnimationDrawable) img.getDrawable();
    // 默认进入页面就开启动画
    if (!mAnimationDrawable.isRunning()) {
        mAnimationDrawable.start();
    }

    if(mIsSupportToolBar){
        setToolBar();
    }else{
        toolBar = getView(R.id.tool_bar);
        toolBar.setVisibility(View.GONE);
    }

    // 点击加载失败布局
    refresh.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showLoading();
            onRefresh();
        }
    });
}
 
源代码12 项目: Meteorite   文件: BaseFragment.java
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    mViews = new SparseArray<>();

    mLlProgressBar = getView(R.id.ll_progress_bar);
    ImageView img = getView(R.id.img_progress);
    mRefresh = getView(R.id.ll_error_refresh);
    // 加载动画
    mAnimationDrawable = (AnimationDrawable) img.getDrawable();

    initView();
    isInit = true;
    isCanLoadData();

    Log.d("Meteorite","onActivityCreated   mAnimationDrawable.isRunning() = "+mAnimationDrawable.isRunning());

    // 默认进入页面就开启动画
    if (!mAnimationDrawable.isRunning()) {
        mAnimationDrawable.start();
    }
    // 点击加载失败布局
    mRefresh.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            showLoading();
            onRefresh();
        }
    });
    //contentView.setVisibility(View.GONE);
}
 
源代码13 项目: 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;
    }
}
 
源代码14 项目: TestChat   文件: VoiceRecordPlayListener.java
private void startAnimation() {
        if (mMessage.getBelongId().equals(UserManager.getInstance().getCurrentUserObjectId())) {
                display.setImageResource(R.drawable.animationlist_chat_voice_left);
        } else {
                display.setImageResource(R.drawable.animationlist_chat_voice_right);
        }
        mAnimationDrawable = (AnimationDrawable) display.getDrawable();
        mAnimationDrawable.start();
}
 
private void setupAnimationDrawable() {
    AnimationDrawable animationDrawable = new AnimationDrawable();
    for (int index = 0; index < bitmaps.size(); index++) {
        BitmapDrawable drawable = new BitmapDrawable(this.getResources(), bitmaps.get(index));
        animationDrawable.addFrame(drawable, 1000 / framesPerSecond);
    }

    animationDrawable.setOneShot(!this.loop);

    this.setImageDrawable(animationDrawable);
    animationDrawable.start();
}
 
源代码16 项目: reader   文件: AndroidProgressHUD.java
public void onWindowFocusChanged(boolean hasFocus){
ImageView imageView = (ImageView) findViewById(context.getResources().getIdentifier("spinnerImageView", "id", context.getPackageName()));
       AnimationDrawable spinner = (AnimationDrawable) imageView.getBackground();
       spinner.start();
   }
 
源代码17 项目: android-music-player   文件: MediaItemViewHolder.java
static View setupView(Activity activity, View convertView, ViewGroup parent,
                                MediaDescription description, int state) {

    if (sColorStateNotPlaying == null || sColorStatePlaying == null) {
        initializeColorStateLists(activity);
    }

    MediaItemViewHolder holder;

    Integer cachedState = STATE_INVALID;

    if (convertView == null) {
        convertView = LayoutInflater.from(activity)
                .inflate(R.layout.media_list_item, parent, false);
        holder = new MediaItemViewHolder();
        holder.mImageView = (ImageView) convertView.findViewById(R.id.play_eq);
        holder.mTitleView = (TextView) convertView.findViewById(R.id.title);
        holder.mDescriptionView = (TextView) convertView.findViewById(R.id.description);
        convertView.setTag(holder);
    } else {
        holder = (MediaItemViewHolder) convertView.getTag();
        cachedState = (Integer) convertView.getTag(R.id.tag_mediaitem_state_cache);
    }

    holder.mTitleView.setText(description.getTitle());
    holder.mDescriptionView.setText(description.getSubtitle());

    // If the state of convertView is different, we need to adapt the view to the
    // new state.
    if (cachedState == null || cachedState != state) {
        switch (state) {
            case STATE_PLAYABLE:
                holder.mImageView.setImageDrawable(
                    activity.getDrawable(R.drawable.ic_play_arrow_black_36dp));
                holder.mImageView.setImageTintList(sColorStateNotPlaying);
                holder.mImageView.setVisibility(View.VISIBLE);
                break;
            case STATE_PLAYING:
                AnimationDrawable animation = (AnimationDrawable)
                    activity.getDrawable(R.drawable.ic_equalizer_white_36dp);
                holder.mImageView.setImageDrawable(animation);
                holder.mImageView.setImageTintList(sColorStatePlaying);
                holder.mImageView.setVisibility(View.VISIBLE);
                animation.start();
                break;
            case STATE_PAUSED:
                holder.mImageView.setImageDrawable(
                    activity.getDrawable(R.drawable.ic_equalizer1_white_36dp));
                holder.mImageView.setImageTintList(sColorStateNotPlaying);
                holder.mImageView.setVisibility(View.VISIBLE);
                break;
            default:
                holder.mImageView.setVisibility(View.GONE);
        }
        convertView.setTag(R.id.tag_mediaitem_state_cache, state);
    }

    return convertView;
}
 
源代码18 项目: o2oa   文件: ContactsView.java
public void showLoadingHeader() {
    mLoadingIv.setVisibility(View.VISIBLE);
    mLoadingTv.setVisibility(View.VISIBLE);
    AnimationDrawable drawable = (AnimationDrawable) mLoadingIv.getDrawable();
    drawable.start();
}
 
源代码19 项目: o2oa   文件: ConversationListView.java
public void showLoadingHeader() {
    mLoadingIv.setVisibility(View.VISIBLE);
    mLoadingTv.setVisibility(View.VISIBLE);
    AnimationDrawable drawable = (AnimationDrawable) mLoadingIv.getDrawable();
    drawable.start();
}
 
源代码20 项目: o2oa   文件: ConversationListView.java
public void showLoadingHeader() {
    mLoadingIv.setVisibility(View.VISIBLE);
    mLoadingTv.setVisibility(View.VISIBLE);
    AnimationDrawable drawable = (AnimationDrawable) mLoadingIv.getDrawable();
    drawable.start();
}