Java 类android.graphics.drawable.AnimationDrawable 实例源码

项目:GitHub    文件:BGANormalRefreshViewHolder.java   
@Override
public View getRefreshHeaderView() {
    if (mRefreshHeaderView == null) {
        mRefreshHeaderView = View.inflate(mContext, R.layout.view_refresh_header_normal, null);
        mRefreshHeaderView.setBackgroundColor(Color.TRANSPARENT);
        if (mRefreshViewBackgroundColorRes != -1) {
            mRefreshHeaderView.setBackgroundResource(mRefreshViewBackgroundColorRes);
        }
        if (mRefreshViewBackgroundDrawableRes != -1) {
            mRefreshHeaderView.setBackgroundResource(mRefreshViewBackgroundDrawableRes);
        }
        mHeaderStatusTv = (TextView) mRefreshHeaderView.findViewById(R.id.tv_normal_refresh_header_status);
        mHeaderArrowIv = (ImageView) mRefreshHeaderView.findViewById(R.id.iv_normal_refresh_header_arrow);
        mHeaderChrysanthemumIv = (ImageView) mRefreshHeaderView.findViewById(R.id.iv_normal_refresh_header_chrysanthemum);
        mHeaderChrysanthemumAd = (AnimationDrawable) mHeaderChrysanthemumIv.getDrawable();
        mHeaderStatusTv.setText(mPullDownRefreshText);
    }
    return mRefreshHeaderView;
}
项目:MobileMedia    文件:AudioPlayerActivity.java   
private void initViews() {
    mPlayingMatrix = (ImageView) findViewById(R.id.iv_now_playing_matrix);
    AnimationDrawable animationDrawable = (AnimationDrawable) mPlayingMatrix.getBackground();
    animationDrawable.start();
    mSongName = (TextView) findViewById(R.id.tv_now_playing_song_name);
    mArtist = (TextView) findViewById(R.id.tv_now_playing_singer);
    mCurrentPosition = (TextView) findViewById(R.id.tv_now_playing_time);
    mAudioSkb = (SeekBar) findViewById(R.id.sb_audio);
    mPlayModeBtn = (Button) findViewById(R.id.btn_audio_playmode);
    mPreBtn = (Button) findViewById(R.id.btn_audio_previous);
    mPlayPauseBtn = (Button) findViewById(R.id.btn_audio_playing_pause);
    mNextBtn = (Button) findViewById(R.id.btn_audio_next);
    mLyricBtn = (Button) findViewById(R.id.btn_audio_lyrc);
    mPlayModeBtn.setOnClickListener(mClickListener);
    mPreBtn.setOnClickListener(mClickListener);
    mPlayPauseBtn.setOnClickListener(mClickListener);
    mNextBtn.setOnClickListener(mClickListener);
    mLyricBtn.setOnClickListener(mClickListener);
    mLyricShowView = (LyricShowView) findViewById(R.id.lyric_view);
    mAudioSkb.setOnSeekBarChangeListener(new AudioSeekChangeListener());
}
项目:Logistics-guard    文件:TestActivity3.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    setTitle(title);
    infoText = (TextView) findViewById(R.id.infoView);
    imgView = (ImageView) findViewById(R.id.cardbg);
    imgView.setBackgroundResource(R.drawable.myanim);
    _animation = (AnimationDrawable) imgView.getBackground();
    _animation.setOneShot(false);
    uiHandler = new MyHandler(this);

    mBluetoothReader = new BluetoothReader();
    mBluetoothReader.setOnReaderStateListener(new BluetoothReader.OnReaderStateListener() {
        @Override
        public void onReaderStateChange(String readerName, int readerState) {
            if (readerName.isEmpty() == false) {
                uiHandler.obtainMessage(READER_MESSAGE, readerState, -1, readerName).sendToTarget();
            }
        }
    });

    View scan = findViewById(R.id.btScan);
    scan.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            infoText.setText("Select bluetooth reader for connect...");
            Intent serverIntent = new Intent(TestActivity3.this, DeviceListActivity.class);
            startActivityForResult(serverIntent, REQUEST_CONNECT_DEVICE);
        }
    });
}
项目:GitHub    文件:BaseFragment.java   
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    mLlProgressBar = getView(R.id.ll_progress_bar);
    ImageView img = getView(R.id.img_progress);

    // 加载动画
    mAnimationDrawable = (AnimationDrawable) img.getDrawable();
    // 默认进入页面就开启动画
    if (!mAnimationDrawable.isRunning()) {
        mAnimationDrawable.start();
    }
    mRefresh = getView(R.id.ll_error_refresh);
    // 点击加载失败布局
    mRefresh.setOnClickListener(new PerfectClickListener() {
        @Override
        protected void onNoDoubleClick(View v) {
            showLoading();
            onRefresh();
        }
    });
    bindingView.getRoot().setVisibility(View.GONE);

}
项目:GitHub    文件:YunRefreshHeader.java   
private void initView() {
    LayoutInflater.from(mContext).inflate(R.layout.kaws_refresh_header, this);
    ImageView img = (ImageView) findViewById(R.id.img);

    animationDrawable = (AnimationDrawable) img.getDrawable();
    if (animationDrawable.isRunning()) {
        animationDrawable.stop();
    }
    msg = (TextView) findViewById(R.id.msg);
    measure(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    mMeasuredHeight = getMeasuredHeight();
    setGravity(Gravity.CENTER_HORIZONTAL);
    mContainer = (LinearLayout) findViewById(R.id.container);
    mContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, 0));
    this.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
}
项目:GitHub    文件:BGARefreshViewHolder.java   
/**
 * 获取上拉加载更多控件,如果不喜欢这种上拉刷新风格可重写该方法实现自定义LoadMoreFooterView
 *
 * @return
 */
public View getLoadMoreFooterView() {
    if (!mIsLoadingMoreEnabled) {
        return null;
    }
    if (mLoadMoreFooterView == null) {
        mLoadMoreFooterView = View.inflate(mContext, R.layout.view_normal_refresh_footer, null);
        mLoadMoreFooterView.setBackgroundColor(Color.TRANSPARENT);
        if (mLoadMoreBackgroundColorRes != -1) {
            mLoadMoreFooterView.setBackgroundResource(mLoadMoreBackgroundColorRes);
        }
        if (mLoadMoreBackgroundDrawableRes != -1) {
            mLoadMoreFooterView.setBackgroundResource(mLoadMoreBackgroundDrawableRes);
        }
        mFooterStatusTv = (TextView) mLoadMoreFooterView.findViewById(R.id.tv_normal_refresh_footer_status);
        mFooterChrysanthemumIv = (ImageView) mLoadMoreFooterView.findViewById(R.id.iv_normal_refresh_footer_chrysanthemum);
        mFooterChrysanthemumAd = (AnimationDrawable) mFooterChrysanthemumIv.getDrawable();
        mFooterStatusTv.setText(mLodingMoreText);
    }
    return mLoadMoreFooterView;
}
项目:GitHub    文件:ImageViewAction.java   
@Override public void error(Exception e) {
  ImageView target = this.target.get();
  if (target == null) {
    return;
  }
  Drawable placeholder = target.getDrawable();
  if (placeholder instanceof AnimationDrawable) {
    ((AnimationDrawable) placeholder).stop();
  }
  if (errorResId != 0) {
    target.setImageResource(errorResId);
  } else if (errorDrawable != null) {
    target.setImageDrawable(errorDrawable);
  }

  if (callback != null) {
    callback.onError(e);
  }
}
项目:boohee_v5.6    文件:LoadingLayout.java   
public final void reset() {
    if (this.mHeaderText != null) {
        this.mHeaderText.setText(this.mPullLabel);
    }
    this.mHeaderImage.setVisibility(0);
    if (this.mUseIntrinsicAnimation) {
        ((AnimationDrawable) this.mHeaderImage.getDrawable()).stop();
    } else {
        resetImpl();
    }
    if (this.mSubHeaderText == null) {
        return;
    }
    if (TextUtils.isEmpty(this.mSubHeaderText.getText())) {
        this.mSubHeaderText.setVisibility(8);
    } else {
        this.mSubHeaderText.setVisibility(0);
    }
}
项目:QMark    文件:App.java   
/**
 * 返回是否应该加载数据
 * 
 * @param empty 页面是否为空
 * @param showLoading 如果为空,且有网络的情况下是否显示正在加载,若为false则显示点击重新加载
 * @param 用来显示这些图片的ImageView
 **/
public static boolean showLoadingOrNoNet(boolean empty, boolean showLoading, boolean feedbackIfNoNet, ImageView imgState) {
    if (empty) {
        if (feedbackIfNoNet ? checkNetStateAndFeedbackUser() : Network.isNetConnected(get())) {
            if (showLoading) {
                imgState.setVisibility(View.VISIBLE);
                imgState.setImageResource(R.drawable.anim_list_i_pull_2_refresh_header);
                AnimationDrawable anim = (AnimationDrawable)imgState.getDrawable();
                anim.start();
                return true;
            } else {
                imgState.setVisibility(View.VISIBLE);
                imgState.setImageResource(R.drawable.img_common_click_reload);
            }
        } else {
            imgState.setVisibility(View.VISIBLE);
            imgState.setImageResource(R.drawable.img_common_no_net);
        }
    } else {
        imgState.setImageResource(0);
        imgState.setVisibility(View.GONE);
    }
    return false;
}
项目:FrameAnimator    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Button button =(Button)findViewById(R.id.button);

    view = (ImageView)findViewById(R.id.imageView);
    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            view.setBackgroundResource(R.drawable.face_emotion);
            AnimationDrawable frameAnimation2 = (AnimationDrawable) view.getBackground();
            frameAnimation2.stop();
            frameAnimation2.start();
        }
    });


}
项目:IOSDialog    文件:CamomileSpinner.java   
public void recreateWithParams(Context context, @ColorInt int spinnerColor, int duration, boolean clockwise) {
    boolean wasRunning = false;
    boolean oneShot = isOneShot();

    if (((AnimationDrawable)this.getBackground()).isRunning()) {
        wasRunning = true;
        stop();
    }

    AnimationDrawable newSpinner = createSpinner(context, spinnerColor, duration, clockwise);
    if (newSpinner != null) {
        if (oneShot) newSpinner.setOneShot(true);
        this.spinnerColor = spinnerColor;
        this.duration = duration;
        this.clockwise = clockwise;
        updateSpinner(newSpinner);
    }

    if (wasRunning) start();
}
项目:exciting-app    文件:MediaUtil.java   
/**
 * 结束播放音频
 */
public static void stopPlayVoice() {
    if (player != null && player.isPlaying()) {
        player.release();
        player = null;
    }
    if (v_playVoice != null) {
        try {
            ((AnimationDrawable) v_playVoice.getBackground()).stop();
            ((AnimationDrawable) v_playVoice.getBackground())
                    .selectDrawable(0);
            v_playVoice = null;
        } catch (Exception e) {
            e.printStackTrace();
        }
        // 注意
        // :此处try\catch用来修复BUG——播放语音时,滑动观看交流信息再点击语音会卡死。若是播放时,来回滑动过多,也有几率造成卡死。
    }
}
项目:Veggietizer    文件:CompareActivity.java   
@Override
public void onWindowFocusChanged(boolean hasFocus) {
    ImageView imageViewAnimTop = (ImageView) findViewById(R.id.imageView_animation_top);
    ImageView imageViewAnimBottom = (ImageView) findViewById(R.id.imageView_animation_bottom);

    AnimationDrawable animTop = (AnimationDrawable) imageViewAnimTop.getBackground();
    AnimationDrawable animBottom = (AnimationDrawable) imageViewAnimBottom.getBackground();

    animTop.start();
    animBottom.start();

    super.onWindowFocusChanged(hasFocus);
}
项目:DragPointView    文件:PointViewAnimObject.java   
public boolean isRunning() {
    if (object == null)
        return false;
    if (object instanceof AnimationDrawable) {
        return ((AnimationDrawable) object).isRunning();
    } else if (object instanceof Animator) {
        return ((Animator) object).isRunning();
    } else if (object instanceof Animation) {
        if (((Animation) object).hasStarted()) {
            return !((Animation) object).hasEnded();
        } else {
            return false;
        }
    }
    return false;
}
项目:CustomAndroidOneSheeld    文件:TextToSpeechFragment.java   
@Override
public void doOnViewCreated(View v, @Nullable Bundle savedInstanceState) {
    speakerLevel = (ImageView) v
            .findViewById(R.id.speaker_shield_imageview);
    femaleBtn = (Button) v.findViewById(R.id.increaseBtn);
    maleBtn = (Button) v.findViewById(R.id.decreaseBtn);
    ttsText = (OneSheeldTextView) v.findViewById(R.id.ttsText);
    ttsText.setMovementMethod(new ScrollingMovementMethod());
    animation = (AnimationDrawable) speakerLevel.getBackground();
}
项目:CustomListView    文件:LoadingLayout.java   
public final void refreshing() {
    if (null != mHeaderText) {
        mHeaderText.setText(mRefreshingLabel);
    }

    if (mUseIntrinsicAnimation) {
        ((AnimationDrawable) mHeaderImage.getDrawable()).start();
    } else {
        // Now call the callback
        refreshingImpl();
    }

    if (null != mSubHeaderText) {
        mSubHeaderText.setVisibility(View.GONE);
    }
}
项目:CustomAndroidOneSheeld    文件:TextToSpeechFragment.java   
@Override
public void onSpeek(final String txt) {
    uiHandler.post(new Runnable() {

        @Override
        public void run() {
            if (canChangeUI()) {
                speakerLevel
                        .setBackgroundResource(R.anim.tts_animation);
                ttsText.setText(txt);
                animation = (AnimationDrawable) speakerLevel
                        .getBackground();
                speakerLevel.post(runAnimation);
            }
        }
    });
}
项目:chilly    文件:OnboardingFragment.java   
@Override
protected void onPageChanged(final int newPage, int previousPage) {
    if (mContentAnimator != null) {
        mContentAnimator.end();
    }
    ArrayList<Animator> animators = new ArrayList<>();
    Animator fadeOut = createFadeOutAnimator(mContentView);

    fadeOut.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            mContentView.setImageDrawable(getResources().getDrawable(pageImages[newPage]));
            ((AnimationDrawable) mContentView.getDrawable()).start();
        }
    });
    animators.add(fadeOut);
    animators.add(createFadeInAnimator(mContentView));
    AnimatorSet set = new AnimatorSet();
    set.playSequentially(animators);
    set.start();
    mContentAnimator = set;
}
项目:boohee_v5.6    文件:AppCompatProgressBarHelper.java   
private Drawable tileifyIndeterminate(Drawable drawable) {
    if (!(drawable instanceof AnimationDrawable)) {
        return drawable;
    }
    AnimationDrawable background = (AnimationDrawable) drawable;
    int N = background.getNumberOfFrames();
    Drawable newBg = new AnimationDrawable();
    newBg.setOneShot(background.isOneShot());
    for (int i = 0; i < N; i++) {
        Drawable frame = tileify(background.getFrame(i), true);
        frame.setLevel(10000);
        newBg.addFrame(frame, background.getDuration(i));
    }
    newBg.setLevel(10000);
    return newBg;
}
项目:OSchina_resources_android    文件:TweetDetailActivity.java   
private void resolveVoice() {
    if (tweet == null || tweet.getAudio() == null || tweet.getAudio().length == 0) return;
    mRecordLayout.setVisibility(View.VISIBLE);
    final AnimationDrawable drawable = (AnimationDrawable) mImgRecord.getBackground();
    mRecordLayout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (tweet == null) return;
            getRecordUtil().startPlay(tweet.getAudio()[0].getHref(), mSecondRecord);
        }
    });
    getRecordUtil().setOnPlayListener(new RecordButtonUtil.OnPlayListener() {
        @Override
        public void stopPlay() {
            drawable.stop();
            mImgRecord.setBackgroundDrawable(drawable.getFrame(0));
        }

        @Override
        public void starPlay() {
            drawable.start();
            mImgRecord.setBackgroundDrawable(drawable);
        }
    });
}
项目:AndroidSkinAnimator    文件:SkinCompatProgressBarHelper.java   
/**
 * Convert a AnimationDrawable for use as a barberpole animation.
 * Each frame of the animation is wrapped in a ClipDrawable and
 * given a tiling BitmapShader.
 */
private Drawable tileifyIndeterminate(Drawable drawable) {
    if (drawable instanceof AnimationDrawable) {
        AnimationDrawable background = (AnimationDrawable) drawable;
        final int N = background.getNumberOfFrames();
        AnimationDrawable newBg = new AnimationDrawable();
        newBg.setOneShot(background.isOneShot());

        for (int i = 0; i < N; i++) {
            Drawable frame = tileify(background.getFrame(i), true);
            frame.setLevel(10000);
            newBg.addFrame(frame, background.getDuration(i));
        }
        newBg.setLevel(10000);
        drawable = newBg;
    }
    return drawable;
}
项目:Android-skin-support    文件:SkinCompatProgressBarHelper.java   
/**
 * Convert a AnimationDrawable for use as a barberpole animation.
 * Each frame of the animation is wrapped in a ClipDrawable and
 * given a tiling BitmapShader.
 */
private Drawable tileifyIndeterminate(Drawable drawable) {
    if (drawable instanceof AnimationDrawable) {
        AnimationDrawable background = (AnimationDrawable) drawable;
        final int N = background.getNumberOfFrames();
        AnimationDrawable newBg = new AnimationDrawable();
        newBg.setOneShot(background.isOneShot());

        for (int i = 0; i < N; i++) {
            Drawable frame = tileify(background.getFrame(i), true);
            frame.setLevel(10000);
            newBg.addFrame(frame, background.getDuration(i));
        }
        newBg.setLevel(10000);
        drawable = newBg;
    }
    return drawable;
}
项目:MyLife    文件:CustomProgressDialog.java   
private void initData() {

        mImageView.setBackgroundResource(mResid);
        // 通过ImageView对象拿到背景显示的AnimationDrawable
        mAnimation = (AnimationDrawable) mImageView.getBackground();
        // 为了防止在onCreate方法中只显示第一帧的解决方案之一
        mImageView.post(new Runnable() {
            @TargetApi(Build.VERSION_CODES.HONEYCOMB)
            @Override
            public void run() {
                mAnimation.start();

            }
        });
        mLoadingTv.setText(mLoadingTip);

    }
项目:Hotspot-master-devp    文件:ShowProgressDialog.java   
public void onWindowFocusChanged(boolean hasFocus){
    if (progressDialog == null){
        return;
    }

    ImageView imageView = (ImageView) progressDialog.findViewById(R.id.loadingImageView);
    AnimationDrawable animationDrawable = (AnimationDrawable) imageView.getBackground();
    animationDrawable.start();
}
项目:sctalk    文件:LoadingLayout.java   
public final void reset() {
    if (null != mHeaderText) {
        mHeaderText.setText(mPullLabel);
        // mSubHeaderText.setText(mLastRefresh+sdf.format(date));
        date = new Date();
    }
    mHeaderImage.setVisibility(View.VISIBLE);

    if (mUseIntrinsicAnimation) {
        ((AnimationDrawable) mHeaderImage.getDrawable()).stop();
    } else {
        // Now call the callback
        resetImpl();
    }

    // if (null != mSubHeaderText) {
    // if (TextUtils.isEmpty(mSubHeaderText.getText())) {
    // mSubHeaderText.setVisibility(View.GONE);
    // } else {
    // mSubHeaderText.setVisibility(View.VISIBLE);
    // }
    // }
}
项目:DMAudioStreamer    文件:AdapterMusic.java   
private Drawable getDrawableByState(Context context, int state) {
    switch (state) {
        case PlaybackStateCompat.STATE_NONE:
            Drawable pauseDrawable = ContextCompat.getDrawable(context, R.drawable.ic_play);
            DrawableCompat.setTintList(pauseDrawable, colorPlay);
            return pauseDrawable;
        case PlaybackStateCompat.STATE_PLAYING:
            AnimationDrawable animation = (AnimationDrawable) ContextCompat.getDrawable(context, R.drawable.equalizer);
            DrawableCompat.setTintList(animation, colorPlay);
            animation.start();
            return animation;
        case PlaybackStateCompat.STATE_PAUSED:
            Drawable playDrawable = ContextCompat.getDrawable(context, R.drawable.equalizer);
            DrawableCompat.setTintList(playDrawable, colorPause);
            return playDrawable;
        default:
            Drawable noneDrawable = ContextCompat.getDrawable(context, R.drawable.ic_play);
            DrawableCompat.setTintList(noneDrawable, colorPlay);
            return noneDrawable;
    }
}
项目:MeteorView    文件:MainActivity.java   
private void initView() {
    Picasso.with(this).load(R.drawable.star).resize(900, 1600).centerCrop().into(imgBackgroundStar, new Callback() {
        @Override
        public void onSuccess() {
            AnimationDrawable frameAnimation = (AnimationDrawable) imgBackgroundFire.getDrawable();
            frameAnimation.start();

            showButtonStartChat();
        }

        @Override
        public void onError() {

        }
    });
    Picasso.with(this).load(R.drawable.icon_light_moon).resize(100, 100).centerCrop().into(imgBackgroundMoon);
    Picasso.with(this).load(R.drawable.background_main_back).resize(500, 322).centerCrop().into(imgBackgroundTree);
    Picasso.with(this).load(R.drawable.icon_meteor).into(imgMeteor0);
    Picasso.with(this).load(R.drawable.icon_meteor).into(imgMeteor1);
    Picasso.with(this).load(R.drawable.icon_meteor).into(imgMeteor2);
    Picasso.with(this).load(R.drawable.icon_meteor).into(imgMeteor3);

}
项目:Tribe    文件:LoadingLayout.java   
public final void refreshing() {
    if (null != mHeaderText) {
        mHeaderText.setText(mRefreshingLabel);
    }

    if (mUseIntrinsicAnimation) {
        ((AnimationDrawable) mHeaderImage.getDrawable()).start();
    } else {
        // Now call the callback
        refreshingImpl();
    }

    if (null != mSubHeaderText) {
        mSubHeaderText.setVisibility(View.GONE);
    }
}
项目:sctalk    文件:LoadingLayout.java   
public final void refreshing() {
    if (null != mHeaderText) {
        mHeaderText.setText(mRefreshingLabel);
        // mSubHeaderText.setText(mLastRefresh+sdf.format(date));
    }

    if (mUseIntrinsicAnimation) {
        ((AnimationDrawable) mHeaderImage.getDrawable()).start();
    } else {
        // Now call the callback
        refreshingImpl();
    }

    // if (null != mSubHeaderText) {
    // mSubHeaderText.setVisibility(View.GONE);
    // }
}
项目:AndroidUiKit    文件:TestAnimationActivity.java   
@Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        View animView = findViewById(R.id.tv_view);
        animView.setBackgroundResource(R.drawable.test_frame_anim);
        ((AnimationDrawable) animView.getBackground()).start();
//经过运行查看内存比较。传统用法,一次性加载所有帧,内存消耗高,容易溢出导致奔溃。 FrameAnimDrawable 只加载当前动画帧,用完即释放,内存消耗少,动画质量媲美AnimationDrawable。
//        int[] RES_IDS = new int[]{
//          R.drawable.test_pic_01,
//          R.drawable.test_pic_02,
//          R.drawable.test_pic_03,
//          R.drawable.test_pic_04,
//          R.drawable.test_pic_05,
//          R.drawable.test_pic_06,
//          R.drawable.test_pic_07,
//          R.drawable.test_pic_08,
//          R.drawable.test_pic_09,
//          R.drawable.test_pic_10,
//        };

//        FrameAnimDrawable drawable = new FrameAnimDrawable(5, RES_IDS, getResources());
//        animView.setBackgroundDrawable(drawable);
//        drawable.start();
    }
项目:QSRefreshLayout    文件:JDRefreshView.java   
@Override
public void updateStatus(int status) {
    this.status = status;
    jd_pack.setVisibility(VISIBLE);
    if (status == QSRefreshLayout.STATUS_DRAGGING) {
        jd_text.setText("下拉刷新...");
    } else if (status == QSRefreshLayout.STATUS_DRAGGING_REACH) {
        jd_text.setText("松开刷新...");
    } else if (status == QSRefreshLayout.STATUS_REFRESHING) {
        jd_text.setText("刷新中...");
        jd_people.setImageResource(R.drawable.jd_loading);
        ((AnimationDrawable) jd_people.getDrawable()).start();
        jd_pack.setVisibility(GONE);
    } else if (status == QSRefreshLayout.STATUS_REFRESHED) {
        jd_text.setText("刷新完成");
        ((AnimationDrawable) jd_people.getDrawable()).stop();
        jd_people.setImageResource(R.drawable.jd_refresh_people_0);
    }
}
项目:SelectName    文件:ProgressDialog.java   
public void onWindowFocusChanged(boolean hasFocus) {

        if (customProgressDialog == null) {
            return;
        }

        ImageView imageView = (ImageView) customProgressDialog
                .findViewById(R.id.loadingImageView);
        AnimationDrawable animationDrawable = (AnimationDrawable) imageView
                .getBackground();
        animationDrawable.start();
    }
项目:NeiHanDuanZiTV    文件:HomeObjectTabFragment.java   
/**
 * 对用户可见并且view初始化完成时调用(该处加载数据只会加载一次,比如三个tab每个tab加载过一次就不会再次进入这个方法)
 *
 * @param savedInstanceState
 */
@Override
public void initData(Bundle savedInstanceState) {
    mAnimationDrawable = ((AnimationDrawable) mIvLoading.getDrawable());
    initRecycleView();
    mPresenter.getData(homeTabBean, lastTime, false, 5, true, false);
    mSw.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            mPresenter.getData(homeTabBean, lastTime, true, 30, true, false);
        }
    });
}
项目:ImageLoaderSupportGif    文件:ImageViewAware.java   
@Override
protected void setImageDrawableInto(Drawable drawable, View view) {
    ((ImageView) view).setImageDrawable(drawable);
    if (drawable instanceof AnimationDrawable) {
        ((AnimationDrawable)drawable).start();
    }
}
项目:GankReader    文件:BaseActivity.java   
@Override
public void setContentView(@LayoutRes int layoutResID) {
    mBaseBinding = DataBindingUtil.inflate(LayoutInflater.from(this), R.layout.activity_base, null, false);
    bindingView = DataBindingUtil.inflate(getLayoutInflater(), layoutResID, null, false);

    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());

    //设置透明状态栏
    StatusBarUtil.setColor(this, CommonUtils.getColor(R.color.colorTheme),0);

    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();
    }
    OnceInit.once(this);
    setToolBar();
    bindingView.getRoot().setVisibility(View.GONE);
}
项目:DodaTheExploda    文件:MainActivity.java   
@Override
public void onClick(final View v) {

    if (currentLookForWid.getText().equals(" ")) {
        v.startAnimation(notItAnim);
        return;
    }

    String symv = (String)v.getTag();

    TextView wid2 = activeSyms.get(current);
    if (wid2==null) return;

    String symw = (String)wid2.getTag();

    if (symv.equals(symw)) {

        Log.d("Doda", "Found " + symv.codePointAt(0));
        v.setAlpha(.6f);
        v.startAnimation(wasItAnim);


        final ImageView blow = new ImageView(this);
        blow.setBackgroundResource(R.drawable.explosion);

        Point location = symPoints.get((TextView)v);
        float fac = 1.25f;

        score += Math.max(100, 5000 - (System.currentTimeMillis() - findTime)) * (backgroundImage?1.5:1);

        int msize = spToPx((int)(mMode.getMaxIconSize(bsize)*fac));
        FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(msize, msize);
        lp.setMargins(location.x - (int)(mMode.getMaxIconSize(bsize)*fac/2), location.y - (int)(mMode.getMaxIconSize(bsize)*fac/2), 0, 0);
        lp.gravity = Gravity.START | Gravity.TOP;


        blow.setLayoutParams(lp);
        mSoundEffects.playPlode();

        v.clearAnimation();

        mMainScreen.removeView(v);
        activeSyms.set(current, null);
        mMainScreen.addView(blow);

        AnimationDrawable ad = ((AnimationDrawable) blow.getBackground());
        int time = ad.getNumberOfFrames() * ad.getDuration(0);
        ad.start();
        showNext(false);

        mMainScreen.postDelayed(new Runnable() {
            @Override
            public void run() {
                mMainScreen.removeView(blow);
            }
        }, time + 20);

    } else {

        v.startAnimation(notItAnim);
        if (mMode.isTimed()) {
            startTime -= 5000;
            showMessage(getString(R.string.miss_penalty));
        }

    }

}
项目:GitHub    文件:BaseActivity.java   
@Override
public void setContentView(@LayoutRes int layoutResID) {

    mBaseBinding = DataBindingUtil.inflate(LayoutInflater.from(this), R.layout.activity_base, null, false);
    bindingView = DataBindingUtil.inflate(getLayoutInflater(), 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());

    // 设置透明状态栏
    StatusBarUtil.setColor(this, CommonUtils.getColor(R.color.colorTheme),0);
    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();
    }

    setToolBar();
    // 点击加载失败布局
    refresh.setOnClickListener(new PerfectClickListener() {
        @Override
        protected void onNoDoubleClick(View v) {
            showLoading();
            onRefresh();
        }
    });
    bindingView.getRoot().setVisibility(View.GONE);
}
项目: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);
    }
}
项目:GitHub    文件:LoadingImageView.java   
@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    ImageView target = (ImageView) findViewById(R.id.target);

    target.setImageResource(R.drawable.loading_anim);
    AnimationDrawable animationDrawable = (AnimationDrawable) target.getDrawable();
    animationDrawable.start();
}
项目:GitHub    文件:FlowingGradient.java   
private void init() {
    setBackgroundResource(draw);
    final AnimationDrawable frameAnimation = (AnimationDrawable) getBackground();
    frameAnimation.setEnterFadeDuration(duration);
    frameAnimation.setExitFadeDuration(duration);
    post(new Runnable(){
        public void run(){
            frameAnimation.start();
        }
    });
}