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

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

源代码1 项目: CloudReader   文件: BaseFragment.java
/**
 * 显示加载中状态
 */
protected void showLoading() {
    ViewStub viewStub = getView(R.id.vs_loading);
    if (viewStub != null) {
        loadingView = viewStub.inflate();
        ImageView img = loadingView.findViewById(R.id.img_progress);
        mAnimationDrawable = (AnimationDrawable) img.getDrawable();
    }
    if (loadingView != null && loadingView.getVisibility() != View.VISIBLE) {
        loadingView.setVisibility(View.VISIBLE);
    }
    // 开始动画
    if (mAnimationDrawable != null && !mAnimationDrawable.isRunning()) {
        mAnimationDrawable.start();
    }
    if (bindingView.getRoot().getVisibility() != View.GONE) {
        bindingView.getRoot().setVisibility(View.GONE);
    }
    if (errorView != null) {
        errorView.setVisibility(View.GONE);
    }
    if (emptyView != null && emptyView.getVisibility() != View.GONE) {
        emptyView.setVisibility(View.GONE);
    }
}
 
源代码2 项目: android_9.0.0_r45   文件: MediaRouteButton.java
private void refreshRoute() {
    final MediaRouter.RouteInfo route = mRouter.getSelectedRoute();
    final boolean isRemote = !route.isDefault() && route.matchesTypes(mRouteTypes);
    final boolean isConnecting = isRemote && route.isConnecting();
    boolean needsRefresh = false;
    if (mRemoteActive != isRemote) {
        mRemoteActive = isRemote;
        needsRefresh = true;
    }
    if (mIsConnecting != isConnecting) {
        mIsConnecting = isConnecting;
        needsRefresh = true;
    }

    if (needsRefresh) {
        refreshDrawableState();
    }
    if (mAttachedToWindow) {
        setEnabled(mRouter.isRouteAvailable(mRouteTypes,
                MediaRouter.AVAILABILITY_FLAG_IGNORE_DEFAULT_ROUTE));
    }
    if (mRemoteIndicator != null
            && mRemoteIndicator.getCurrent() instanceof AnimationDrawable) {
        AnimationDrawable curDrawable = (AnimationDrawable) mRemoteIndicator.getCurrent();
        if (mAttachedToWindow) {
            if ((needsRefresh || isConnecting) && !curDrawable.isRunning()) {
                curDrawable.start();
            }
        } else if (isRemote && !isConnecting) {
            // When the route is already connected before the view is attached, show the last
            // frame of the connected animation immediately.
            if (curDrawable.isRunning()) {
                curDrawable.stop();
            }
            curDrawable.selectDrawable(curDrawable.getNumberOfFrames() - 1);
        }
    }
}
 
private void doAnimation(AnimationDrawable animationDrawable, boolean doIt) {
    if (animationDrawable.isRunning()) {
        animationDrawable.stop();
    }

    //When you want to restart the animation, stop the animation first.
    if (doIt) {
        animationDrawable.start();
    }
}
 
源代码4 项目: 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();
        }
    });
}
 
源代码5 项目: 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);
}
 
源代码6 项目: AssistantBySDK   文件: RspMsgItemView.java
public void startAnimation() {
    try {
        if (mListDrawable.getLevel() == 0) {
            mListDrawable.setLevel(1);
            animation = (AnimationDrawable) mListDrawable.getCurrent();
            if (!animation.isRunning())
                animation.start();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
源代码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();
    }
}
 
源代码8 项目: DragPointView   文件: PointViewAnimObject.java
private void start(AnimationDrawable object, final OnPointDragListener removeListener) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        int duration = 0;
        for (int i = 0; i < object.getNumberOfFrames(); i++) {
            duration += object.getDuration(i);
        }
        view.postDelayed(new Runnable() {
            @Override
            public void run() {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                    view.setBackground(background);
                }
                end(removeListener);
            }
        }, duration + 5);
        view.setText("");
        int drawableL = (view.getWidth() + view.getHeight()) / 2;
        ViewGroup.LayoutParams lp = view.getLayoutParams();
        lp.height = lp.width = drawableL;
        view.setLayoutParams(lp);
        view.setBackground(object);
        if (object.isRunning())
            object.stop();
        object.start();
    } else {
        end(removeListener);
    }
}
 
源代码9 项目: allenglish   文件: WordDetailsAdapter.java
public void stopAnimation() {
    for (AnimationDrawable animation :
            mSentenceHornAnimations) {
        if (animation.isRunning()) {
            animation.selectDrawable(0); // 选择当前动画的第一帧,然后停止
            animation.stop();
        }
    }
}
 
源代码10 项目: sctalk   文件: AudioRenderView.java
public void stopAnimation(){
    AnimationDrawable animationDrawable = (AnimationDrawable) audioAnttView.getBackground();
    if (animationDrawable.isRunning()) {
            animationDrawable.stop();
            animationDrawable.selectDrawable(0);
    }
}
 
private void doAnimation(AnimationDrawable animationDrawable, boolean doIt) {
    if (animationDrawable.isRunning()) {
        animationDrawable.stop();
    }

    //When you want to restart the animation, stop the animation first.
    if (doIt) {
        animationDrawable.start();
    }
}
 
源代码12 项目: CloudReader   文件: BaseActivity.java
@Override
public void setContentView(@LayoutRes int layoutResID) {

    mBaseBinding = DataBindingUtil.inflate(LayoutInflater.from(this), R.layout.activity_base, null, false);
    bindingView = DataBindingUtil.inflate(LayoutInflater.from(this), layoutResID, null, false);

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

    loadingView = ((ViewStub) findViewById(R.id.vs_loading)).inflate();
    ImageView img = loadingView.findViewById(R.id.img_progress);

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

    setToolBar(mBaseBinding.toolBar);
    bindingView.getRoot().setVisibility(View.GONE);
    initStatusBar();
    initViewModel();
}
 
源代码13 项目: 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();
    }
}
 
/**
 * Helper method which just calls scrollTo() in the correct scrolling
 * direction.
 *
 * @param value - New Scroll value
 */
protected final void setHeaderScroll(int value) {
	if (DEBUG) {//TODO 刷新值
		Log.d(LOG_TAG, "setHeaderScroll: " + value);
	}
	if(onScrollListener!=null){
		onScrollListener.OnScroll(mRefreshableView, value);
	}
	if(mHeaderLayout.custem_healthy_app){
		if(refreshView.getDrawable() instanceof AnimationDrawable){
			AnimationDrawable animationDrawable=(AnimationDrawable) refreshView.getDrawable();
			if(!animationDrawable.isRunning()){
				custemAnimator(value);
			}
		}else{
			custemAnimator(value);
		}

	}
	// Clamp value to with pull scroll range
	final int maximumPullScroll = getMaximumPullScroll();
	value = Math.min(maximumPullScroll, Math.max(-maximumPullScroll, value));

	if (mLayoutVisibilityChangesEnabled) {
		if (value < 0) {
			mHeaderLayout.setVisibility(View.VISIBLE);
		} else if (value > 0) {
			mFooterLayout.setVisibility(View.VISIBLE);
		} else {
			mHeaderLayout.setVisibility(View.INVISIBLE);
			mFooterLayout.setVisibility(View.INVISIBLE);
		}
	}

	if (USE_HW_LAYERS) {
		/**
		 * Use a Hardware Layer on the Refreshable View if we've scrolled at
		 * all. We don't use them on the Header/Footer Views as they change
		 * often, which would negate any HW layer performance boost.
		 */
		ViewCompat.setLayerType(mRefreshableViewWrapper, value != 0 ? View.LAYER_TYPE_HARDWARE
				: View.LAYER_TYPE_NONE);
	}

	switch (getPullToRefreshScrollDirection()) {
		case VERTICAL:
			scrollTo(0, value);
			break;
		case HORIZONTAL:
			scrollTo(value, 0);
			break;
	}
}
 
源代码15 项目: CloudReader   文件: BaseHeaderActivity.java
@Override
    public void setContentView(@LayoutRes int layoutResID) {
        View ll = getLayoutInflater().inflate(R.layout.activity_header_base, null);

        // 内容
        bindingContentView = DataBindingUtil.inflate(getLayoutInflater(), layoutResID, null, false);
        // 头部
        bindingHeaderView = DataBindingUtil.inflate(getLayoutInflater(), setHeaderLayout(), null, false);
        // 标题
        bindingTitleView = DataBindingUtil.inflate(getLayoutInflater(), R.layout.base_header_title_bar, null, false);

        // title (如自定义很强可以拿出去)
        RelativeLayout.LayoutParams titleParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        bindingTitleView.getRoot().setLayoutParams(titleParams);
        RelativeLayout mTitleContainer = (RelativeLayout) ll.findViewById(R.id.title_container);
        mTitleContainer.addView(bindingTitleView.getRoot());

        // header
        RelativeLayout.LayoutParams headerParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        bindingHeaderView.getRoot().setLayoutParams(headerParams);
        RelativeLayout mHeaderContainer = (RelativeLayout) ll.findViewById(R.id.header_container);
        mHeaderContainer.addView(bindingHeaderView.getRoot());

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

        loadingView = ((ViewStub) getView(R.id.vs_loading)).inflate();

        // 设置自定义元素共享切换动画
//        setMotion(setHeaderPicView(), false);

        // 初始化滑动渐变
//        initSlideShapeTheme(setHeaderImgUrl(), setHeaderImageView());

        // 设置toolbar
        setToolBar();

        ImageView img = loadingView.findViewById(R.id.img_progress);
        // 加载动画
        mAnimationDrawable = (AnimationDrawable) img.getDrawable();
        // 默认进入页面就开启动画
        if (!mAnimationDrawable.isRunning()) {
            mAnimationDrawable.start();
        }
        bindingContentView.getRoot().setVisibility(View.GONE);
    }