Example usage for android.support.v4.media MediaDescriptionCompat getTitle

List of usage examples for android.support.v4.media MediaDescriptionCompat getTitle

Introduction

In this page you can find the example usage for android.support.v4.media MediaDescriptionCompat getTitle.

Prototype

@Nullable
public CharSequence getTitle() 

Source Link

Document

Returns a title suitable for display or null.

Usage

From source file:nuclei.media.QueueItem.java

public void setIcon(Bitmap bitmap) {
    MediaDescriptionCompat desc = mQueueItem.getDescription();
    desc = new MediaDescriptionCompat.Builder().setTitle(desc.getTitle()).setDescription(desc.getDescription())
            .setMediaId(desc.getMediaId()).setMediaUri(desc.getMediaUri()).setIconUri(desc.getIconUri())
            .setIconBitmap(bitmap).setExtras(desc.getExtras()).setSubtitle(desc.getSubtitle()).build();
    mQueueItem = new MediaSessionCompat.QueueItem(desc, mQueueItem.getQueueId());
}

From source file:dk.glutter.android.knr.ui.MediaItemViewHolder.java

static View setupView(Activity activity, View convertView, ViewGroup parent, MediaDescriptionCompat description,
        int state) {

    if (sColorStateNotPlaying == null || sColorStatePlaying == null) {
        initializeColorStateLists(activity);
    }//from   ww w.  j  a  v a 2 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);
    }

    //TODO: HGL - song list title and  is being set here
    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:
            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.murati.oszk.audiobook.ui.tv.CardViewHolder.java

/**
 * Set the view in this holder to represent the media metadata in {@code description}
 *
 **//*w w w .  j  a v  a  2s  .c  om*/
public void setupCardView(final Context context, MediaDescriptionCompat description) {
    mCardView.setTitleText(description.getTitle());
    mCardView.setContentText(description.getSubtitle());
    mCardView.setMainImageDimensions(CARD_WIDTH, CARD_HEIGHT);

    // Based on state of item, set or unset badge
    Drawable drawable = MediaItemViewHolder.getDrawableByState(context, mItemState);
    mCardView.setBadgeImage(drawable);

    //TODO: replace glide
    Uri artUri = description.getIconUri();
    if (artUri == null) {
        setCardImage(context, description.getIconBitmap());
    } else {
        // IconUri potentially has a better resolution than iconBitmap.
        String artUrl = artUri.toString();
        AlbumArtCache cache = AlbumArtCache.getInstance();
        if (cache.getBigImage(artUrl) != null) {
            // So, we use it immediately if it's cached:
            setCardImage(context, cache.getBigImage(artUrl));
        } else {
            // Otherwise, we use iconBitmap if available while we wait for iconURI
            setCardImage(context, description.getIconBitmap());
            cache.fetch(artUrl, new AlbumArtCache.FetchListener() {
                @Override
                public void onFetched(String artUrl, Bitmap bitmap, Bitmap icon) {
                    setCardImage(context, bitmap);
                }
            });
        }
    }
}

From source file:com.example.android.uamp.ui.tv.CardViewHolder.java

/**
 * Set the view in this holder to represent the media metadata in {@code description}
 *
 **///from  w w w.  ja va 2 s .co m
public void setupCardView(final Context context, MediaDescriptionCompat description) {
    mCardView.setTitleText(description.getTitle());
    mCardView.setContentText(description.getSubtitle());
    mCardView.setMainImageDimensions(CARD_WIDTH, CARD_HEIGHT);

    // Based on state of item, set or unset badge
    Drawable drawable = MediaItemViewHolder.getDrawableByState(context, mItemState);
    mCardView.setBadgeImage(drawable);

    Uri artUri = description.getIconUri();
    if (artUri == null) {
        setCardImage(context, description.getIconBitmap());
    } else {
        // IconUri potentially has a better resolution than iconBitmap.
        String artUrl = artUri.toString();
        AlbumArtCache cache = AlbumArtCache.getInstance();
        if (cache.getBigImage(artUrl) != null) {
            // So, we use it immediately if it's cached:
            setCardImage(context, cache.getBigImage(artUrl));
        } else {
            // Otherwise, we use iconBitmap if available while we wait for iconURI
            setCardImage(context, description.getIconBitmap());
            cache.fetch(artUrl, new AlbumArtCache.FetchListener() {
                @Override
                public void onFetched(String artUrl, Bitmap bitmap, Bitmap icon) {
                    setCardImage(context, bitmap);
                }
            });
        }
    }
}

From source file:com.example.chu.googleplaylibrary.ui.FullScreenPlayerActivity.java

private void updateMediaDescription(MediaDescriptionCompat description) {
    if (description == null) {
        return;//from w  w w .  ja  v  a  2s . c  o  m
    }
    LogHelper.d(TAG, "updateMediaDescription called ");
    mLine1.setText(description.getTitle());
    mLine2.setText(description.getSubtitle());
}

From source file:com.scooter1556.sms.android.presenter.MediaDescriptionPresenter.java

@Override
public void onBindViewHolder(ViewHolder viewHolder, Object item) {
    MediaDescriptionCompat description = (MediaDescriptionCompat) item;

    if (description == null) {
        return;/*w  w  w  . ja v  a2s.com*/
    }

    ImageCardView cardView = (ImageCardView) viewHolder.view;

    // Get title
    cardView.setMainImageDimensions(CARD_WIDTH, CARD_HEIGHT);
    cardView.setMainImageScaleType(ImageView.ScaleType.CENTER);
    cardView.setTitleText(description.getTitle());
    cardView.setContentText(description.getSubtitle());

    // Get default icon
    Drawable icon;

    switch (MediaUtils.getMediaTypeFromID(description.getMediaId())) {
    case MediaElement.MediaElementType.AUDIO:
        icon = defaultAudioIcon;
        break;

    case MediaElement.MediaElementType.VIDEO:
        icon = defaultVideoIcon;
        break;

    default:
        icon = defaultAudioIcon;
        break;
    }

    List<String> id = MediaUtils.parseMediaId((description.getMediaId()));

    if (id.size() > 1) {
        // Set image
        RequestOptions options = new RequestOptions().error(icon);

        Glide.with(viewHolder.view.getContext()).asBitmap()
                .load(RESTService.getInstance().getConnection().getUrl() + "/image/" + id.get(1)
                        + "/cover?scale=" + CARD_HEIGHT)
                .apply(options).into(cardView.getMainImageView());
    }
}

From source file:cat.terrones.devops.radiofx.ui.FullScreenPlayerActivity.java

private void updateMediaDescription(MediaDescriptionCompat description) {
    if (description == null) {
        return;//www .  ja va2s .  c om
    }
    LogHelper.d(TAG, "updateMediaDescription called ");
    mLine1.setText(description.getTitle());
    mLine2.setText(description.getSubtitle());
    fetchImageAsync(description);
}

From source file:com.scooter1556.sms.android.activity.FullScreenPlayerActivity.java

private void updateMediaDescription(MediaDescriptionCompat description) {
    if (description == null) {
        return;/*from   w w w. j a  va 2  s.c  o m*/
    }

    title.setText(description.getTitle());
    subtitle.setText(description.getSubtitle());

    // Cover Art
    RequestOptions options = new RequestOptions().fallback(R.drawable.ic_not_interested_black_48dp);

    Glide.with(this).load(description.getIconUri().toString()).apply(options).into(backgroundImage);
}

From source file:com.bayapps.android.robophish.ui.FullScreenPlayerActivity.java

private void updateMediaDescription(MediaDescriptionCompat description, String venue, String location) {
    if (description == null) {
        return;//from   ww w.j  a  v a2  s.  c o m
    }
    LogHelper.d(TAG, "updateMediaDescription called ");
    mLine1.setText(description.getTitle());
    mLine2.setText(description.getDescription());
    mLine3.setText(venue);
    mLine4.setText(location);
    fetchImageAsync(description);
}

From source file:com.murati.oszk.audiobook.ui.FullScreenPlayerActivity.java

private void updateMediaDescription(MediaDescriptionCompat description) {
    if (description == null) {
        return;//from  ww w.  ja v  a 2 s .co  m
    }
    LogHelper.d(TAG, "updateMediaDescription called ");
    mMediaItem = description;

    mLine1.setText(description.getTitle());
    mLine2.setText(description.getSubtitle());

    fetchImageAsync(description);
}