Пример #1
0
 public Video buildFromMediaDesc(MediaDescription desc) {
   return new Video(
       Long.parseLong(desc.getMediaId()),
       "", // Category - not provided by MediaDescription.
       String.valueOf(desc.getTitle()),
       String.valueOf(desc.getDescription()),
       "", // Media URI - not provided by MediaDescription.
       "", // Background Image URI - not provided by MediaDescription.
       String.valueOf(desc.getIconUri()),
       String.valueOf(desc.getSubtitle()));
 }
Пример #2
0
  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);
          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;
  }