List of usage examples for android.graphics.drawable AnimationDrawable start
@Override public void start()
From source file:com.torrenttunes.android.ui.MediaItemViewHolder.java
static View setupView(Activity activity, View convertView, ViewGroup parent, MediaDescriptionCompat description, int state) { if (sColorStateNotPlaying == null || sColorStatePlaying == null) { initializeColorStateLists(activity); }// w w w .j a va2s.c o m 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( ActivityCompat.getDrawable(activity, R.drawable.ic_play_arrow_black_36dp)); LollipopUtils.setImageTintList(holder.mImageView, sColorStateNotPlaying); holder.mImageView.setVisibility(View.VISIBLE); break; case STATE_PLAYING: AnimationDrawable animation = (AnimationDrawable) ActivityCompat.getDrawable(activity, R.drawable.ic_equalizer_white_36dp); holder.mImageView.setImageDrawable(animation); LollipopUtils.setImageTintList(holder.mImageView, sColorStatePlaying); holder.mImageView.setVisibility(View.VISIBLE); animation.start(); break; case STATE_PAUSED: holder.mImageView.setImageDrawable( ActivityCompat.getDrawable(activity, R.drawable.ic_equalizer1_white_36dp)); LollipopUtils.setImageTintList(holder.mImageView, sColorStateNotPlaying); holder.mImageView.setVisibility(View.VISIBLE); break; default: holder.mImageView.setVisibility(View.GONE); } convertView.setTag(R.id.tag_mediaitem_state_cache, state); } return convertView; }
From source file:com.appdevper.mediaplayer.adater.MediaItemViewHolder.java
static View setupView(Activity activity, View convertView, ViewGroup parent, MediaMetadataCompat item, int state) { if (sColorStateNotPlaying == null || sColorStatePlaying == null) { initializeColorStateLists(activity); }/*from w ww. j av a2 s .c o m*/ 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(item.getString(MediaMetadataCompat.METADATA_KEY_TITLE)); holder.mDescriptionView.setText(item.getString(MediaMetadataCompat.METADATA_KEY_ALBUM)); // 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: Drawable pauseDrawable = ContextCompat.getDrawable(activity, R.drawable.ic_play_arrow_black_36dp); DrawableCompat.setTintList(pauseDrawable, sColorStateNotPlaying); holder.mImageView.setImageDrawable(pauseDrawable); holder.mImageView.setVisibility(View.VISIBLE); break; case STATE_PLAYING: AnimationDrawable animation = (AnimationDrawable) ContextCompat.getDrawable(activity, R.drawable.ic_equalizer_white_36dp); DrawableCompat.setTintList(animation, sColorStatePlaying); holder.mImageView.setImageDrawable(animation); holder.mImageView.setVisibility(View.VISIBLE); animation.start(); break; case STATE_PAUSED: Drawable playDrawable = ContextCompat.getDrawable(activity, R.drawable.ic_equalizer1_white_36dp); DrawableCompat.setTintList(playDrawable, sColorStatePlaying); holder.mImageView.setImageDrawable(playDrawable); holder.mImageView.setVisibility(View.VISIBLE); break; default: holder.mImageView.setVisibility(View.GONE); } convertView.setTag(R.id.tag_mediaitem_state_cache, state); } return convertView; }
From source file:com.appdevper.mediaplayer.adater.MediaItemViewHolder.java
static View setupView(Activity activity, View convertView, ViewGroup parent, ContentItem item, int state) { if (sColorStateNotPlaying == null || sColorStatePlaying == null) { initializeColorStateLists(activity); }/*from w ww. ja va 2s.c o m*/ 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(item.toString()); holder.mDescriptionView.setText(item.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: Drawable pauseDrawable = ContextCompat.getDrawable(activity, R.drawable.ic_play_arrow_black_36dp); DrawableCompat.setTintList(pauseDrawable, sColorStateNotPlaying); holder.mImageView.setImageDrawable(pauseDrawable); holder.mImageView.setVisibility(View.VISIBLE); break; case STATE_PLAYING: AnimationDrawable animation = (AnimationDrawable) ContextCompat.getDrawable(activity, R.drawable.ic_equalizer_white_36dp); DrawableCompat.setTintList(animation, sColorStatePlaying); holder.mImageView.setImageDrawable(animation); holder.mImageView.setVisibility(View.VISIBLE); animation.start(); break; case STATE_PAUSED: Drawable playDrawable = ContextCompat.getDrawable(activity, R.drawable.ic_equalizer1_white_36dp); DrawableCompat.setTintList(playDrawable, sColorStatePlaying); holder.mImageView.setImageDrawable(playDrawable); holder.mImageView.setVisibility(View.VISIBLE); break; case STATE_FOLDER: Drawable folderDrawable = ContextCompat.getDrawable(activity, item.getDefaultResource()); DrawableCompat.setTintList(folderDrawable, sColorStateNotPlaying); holder.mImageView.setImageDrawable(folderDrawable); holder.mImageView.setVisibility(View.VISIBLE); break; default: holder.mImageView.setVisibility(View.GONE); } convertView.setTag(R.id.tag_mediaitem_state_cache, state); } if (state == STATE_IMAGE) { holder.mImageView.setImageTintList(null); holder.mImageView.setVisibility(View.VISIBLE); AppMediaPlayer.getImageLoader().displayImage(item.getResourceUri(), holder.mImageView); } return convertView; }
From source file:com.appdevper.mediaplayer.adater.MediaItemViewHolder.java
static View setupGridView(Activity activity, View convertView, ViewGroup parent, ContentItem item, int state) { if (sColorStateNotPlaying == null || sColorStatePlaying == null) { initializeColorStateLists(activity); }/* w ww .j ava2 s . co m*/ MediaItemViewHolder holder; Integer cachedState = STATE_INVALID; if (convertView == null) { convertView = LayoutInflater.from(activity).inflate(R.layout.media_grid_item, parent, false); holder = new MediaItemViewHolder(); holder.layGrid = (RelativeLayout) convertView.findViewById(R.id.layGrid); holder.mImageBack = (ImageView) convertView.findViewById(R.id.imgBack); 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); } GridView grid = (GridView) parent; int size = grid.getRequestedColumnWidth(); holder.mTitleView.setText(item.toString()); holder.mDescriptionView.setText(item.getSubtitle()); int w = holder.layGrid.getLayoutParams().width; // holder.layGrid.setLayoutParams(new GridView.LayoutParams(w, w)); holder.mImageBack.setLayoutParams(new RelativeLayout.LayoutParams(w, w)); if (item.isContainer()) { holder.mImageBack.setImageResource(item.getDefaultResource()); } else { Utils.downloadBitmap(activity.getResources(), item, holder.mImageBack); } // 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); if (animation != null) 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; }
From source file:org.deviceconnect.android.deviceplugin.sphero.setting.fragment.WakeupFragment.java
@Override public void onResume() { super.onResume(); View root = getView();/*from w w w . ja v a 2 s. com*/ if (root != null) { ImageView image = (ImageView) root.findViewById(R.id.animView001); AnimationDrawable anim = (AnimationDrawable) image.getBackground(); anim.start(); } }
From source file:org.deviceconnect.android.deviceplugin.sphero.setting.fragment.PairingFragment.java
@Override public void onResume() { super.onResume(); View root = getView();//from ww w .j a v a 2 s . c o m if (root != null) { ImageView image = (ImageView) root.findViewById(R.id.animView); AnimationDrawable anim = (AnimationDrawable) image.getBackground(); anim.start(); } if (mBlePermissionBtn != null) { if (BleUtils.isBLEPermission(getActivity())) { mBlePermissionBtn.setText(getString(R.string.bluetooth_settings_ble_permission_on)); mBlePermissionBtn.setBackgroundResource(R.drawable.button_red); } else { mBlePermissionBtn.setText(getString(R.string.bluetooth_settings_ble_permission_off)); mBlePermissionBtn.setBackgroundResource(R.drawable.button_blue); } } }
From source file:com.visenze.visearch.camerademo.fragments.DetailFragment.java
private void startSearch(String imName) { loadingImage.setVisibility(View.VISIBLE); similarListView.setVisibility(View.GONE); //start scan//from w w w . j a v a 2s .c o m AnimationDrawable anim = (AnimationDrawable) loadingImage.getDrawable(); anim.start(); //start id search IdSearchParams params = new IdSearchParams(imName); DataHelper.setIdSearchParams(params.getBaseSearchParams()); viSearch.idSearch(params); }
From source file:com.example.lt.recorder.RecordActivity.java
private void resumeRecord() { mRecorder.resume();//www . j a v a 2 s.c o m mRecordBtn.setImageResource(R.drawable.ic_recording); AnimationDrawable frameAnimation = (AnimationDrawable) mRecordBtn.getDrawable(); frameAnimation.start(); mStatusText.setTextColor(getResources().getColor(R.color.textcolor_main)); mStatusText.setText(R.string.rec_status_recording); }
From source file:com.example.lt.recorder.RecordActivity.java
private void startRecord() { if (reqRecordPermission()) { File file = new File(mRecordDir, System.currentTimeMillis() + Utils.getAudioFileExt()); mRecorder.setOutputFile(file.toString()); mRecorder.start();/*from w w w. jav a 2s.c o m*/ mRecordBtn.setImageResource(R.drawable.ic_recording); AnimationDrawable frameAnimation = (AnimationDrawable) mRecordBtn.getDrawable(); frameAnimation.start(); mStatusText.setTextColor(getResources().getColor(R.color.textcolor_main)); mStatusText.setText(R.string.rec_status_recording); } }
From source file:com.example.android.uamp.ui.tv.CardViewHolder.java
public void attachView() { if (mItemState == MediaItemViewHolder.STATE_PLAYING) { AnimationDrawable badgeDrawable = (AnimationDrawable) mCardView.getBadgeImage(); if (badgeDrawable != null) { badgeDrawable.start(); }/*from w w w. j a va2s. c o m*/ } }