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

The following examples show how to use android.graphics.drawable.AnimationDrawable#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: MainActivityDrawerLayout.java    From MyHearts with Apache License 2.0 6 votes vote down vote up
/**
 * 自己去调整
 */
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();

}
 
Example 2
Source File: PopupNotificationActivity.java    From Yahala-Messenger with MIT License 6 votes vote down vote up
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);
    }
}
 
Example 3
Source File: DialogCreator.java    From o2oa with GNU Affero General Public License v3.0 6 votes vote down vote up
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;
}
 
Example 4
Source File: DialogViewBuilder.java    From DialogUtil with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 5
Source File: RCTImageSequenceView.java    From react-native-image-sequence with MIT License 5 votes vote down vote up
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();
}
 
Example 6
Source File: VoiceRecordPlayListener.java    From TestChat with Apache License 2.0 5 votes vote down vote up
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();
}
 
Example 7
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 8
Source File: BaseFragment.java    From Meteorite with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 9
Source File: BaseActivity.java    From Meteorite with Apache License 2.0 5 votes vote down vote up
@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();
        }
    });
}
 
Example 10
Source File: CommProgressDialog.java    From FoodOrdering with Apache License 2.0 5 votes vote down vote up
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();
    }
 
Example 11
Source File: JdRefreshHeader.java    From LbaizxfPulltoRefresh with Apache License 2.0 5 votes vote down vote up
@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();
    }
}
 
Example 12
Source File: VoicePlayClickListener.java    From FanXin-based-HuanXin with GNU General Public License v2.0 5 votes vote down vote up
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();
}
 
Example 13
Source File: LoadingImageView.java    From qvod with MIT License 5 votes vote down vote up
public LoadingImageView(Context context, @Nullable AttributeSet attrs) {
    super(context, attrs);
    setImageResource(R.drawable.anim_yun);
    // 加载动画
    AnimationDrawable mAnimationDrawable = (AnimationDrawable) getDrawable();
    // 默认进入页面就开启动画
    if (!mAnimationDrawable.isRunning()) {
        mAnimationDrawable.start();
    }
}
 
Example 14
Source File: JDAppHeaderAdpater.java    From UltimateRefreshView with Apache License 2.0 5 votes vote down vote up
@Override
public void headerRefreshing() {
    headerText.setText("更新中…");
    loading.setImageResource(R.drawable.jd_loading);
    AnimationDrawable mAnimationDrawable= (AnimationDrawable) loading.getDrawable();
    mAnimationDrawable.start();
}
 
Example 15
Source File: TraditionHeaderAdapter.java    From UltimateRefreshView with Apache License 2.0 5 votes vote down vote up
@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("正在刷新…");
}
 
Example 16
Source File: ConversationListView.java    From o2oa with GNU Affero General Public License v3.0 4 votes vote down vote up
public void showLoadingHeader() {
    mLoadingIv.setVisibility(View.VISIBLE);
    mLoadingTv.setVisibility(View.VISIBLE);
    AnimationDrawable drawable = (AnimationDrawable) mLoadingIv.getDrawable();
    drawable.start();
}
 
Example 17
Source File: ConversationListView.java    From o2oa with GNU Affero General Public License v3.0 4 votes vote down vote up
public void showLoadingHeader() {
    mLoadingIv.setVisibility(View.VISIBLE);
    mLoadingTv.setVisibility(View.VISIBLE);
    AnimationDrawable drawable = (AnimationDrawable) mLoadingIv.getDrawable();
    drawable.start();
}
 
Example 18
Source File: ContactsView.java    From o2oa with GNU Affero General Public License v3.0 4 votes vote down vote up
public void showLoadingHeader() {
    mLoadingIv.setVisibility(View.VISIBLE);
    mLoadingTv.setVisibility(View.VISIBLE);
    AnimationDrawable drawable = (AnimationDrawable) mLoadingIv.getDrawable();
    drawable.start();
}
 
Example 19
Source File: MediaItemViewHolder.java    From android-music-player with Apache License 2.0 4 votes vote down vote up
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;
}
 
Example 20
Source File: AndroidProgressHUD.java    From reader with MIT License 4 votes vote down vote up
public void onWindowFocusChanged(boolean hasFocus){
ImageView imageView = (ImageView) findViewById(context.getResources().getIdentifier("spinnerImageView", "id", context.getPackageName()));
       AnimationDrawable spinner = (AnimationDrawable) imageView.getBackground();
       spinner.start();
   }