Example usage for android.content.res Resources getDimensionPixelOffset

List of usage examples for android.content.res Resources getDimensionPixelOffset

Introduction

In this page you can find the example usage for android.content.res Resources getDimensionPixelOffset.

Prototype

public int getDimensionPixelOffset(@DimenRes int id) throws NotFoundException 

Source Link

Document

Retrieve a dimensional for a particular resource ID for use as an offset in raw pixels.

Usage

From source file:com.google.android.apps.santatracker.map.cardstream.CardAdapter.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void setupTvCardIfNecessary(CardViewHolder holder) {
    if (mIsTv) {//from   w w w.  jav  a2  s  .co m

        if (mFocusHighlight == null) {
            mFocusHighlight = new TvFocusAnimator();
        }

        final Resources res = holder.itemView.getResources();

        TvFocusAnimator.FocusChangeListener listener = new TvFocusAnimator.FocusChangeListener(mFocusHighlight);

        holder.itemView.setFocusable(true);
        holder.itemView.setFocusableInTouchMode(false);
        holder.itemView.setOnFocusChangeListener(listener);
        holder.itemView.setElevation(res.getDimensionPixelOffset(R.dimen.toolbar_elevation));

        mFocusHighlight.onInitializeView(holder.itemView);

        if (holder.itemView.getBackground() == null) {
            holder.itemView.setBackground(ResourcesCompat.getDrawable(res, R.drawable.tv_tracker_card_selector,
                    holder.itemView.getContext().getTheme()));
        }
    }
}

From source file:org.xbmc.kore.ui.AbstractInfoFragment.java

/**
 * Call this when you are ready to provide the titleTextView, undertitle, details, descriptionExpandableTextView, etc. etc.
 *///w  ww  .  j  ava2 s  .c o  m
protected void updateView(DataHolder dataHolder) {
    titleTextView.setText(dataHolder.getTitle());
    underTitleTextView.setText(dataHolder.getUnderTitle());
    detailsRightTextView.setText(dataHolder.getDetails());

    if (!TextUtils.isEmpty(dataHolder.getDescription())) {
        Resources.Theme theme = getActivity().getTheme();
        TypedArray styledAttributes = theme
                .obtainStyledAttributes(new int[] { R.attr.iconExpand, R.attr.iconCollapse });
        final int iconCollapseResId = styledAttributes.getResourceId(styledAttributes.getIndex(0),
                R.drawable.ic_expand_less_white_24dp);
        final int iconExpandResId = styledAttributes.getResourceId(styledAttributes.getIndex(1),
                R.drawable.ic_expand_more_white_24dp);
        styledAttributes.recycle();
        descriptionContainer.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                descriptionExpandableTextView.toggle();
                expansionImage.setImageResource(
                        descriptionExpandableTextView.isExpanded() ? iconCollapseResId : iconExpandResId);
            }
        });
        descriptionExpandableTextView.setText(dataHolder.getDescription());
        if (expandDescription) {
            descriptionExpandableTextView.expand();
            expansionImage.setImageResource(iconExpandResId);
        }
        descriptionContainer.setVisibility(View.VISIBLE);
    } else {
        descriptionContainer.setVisibility(GONE);
    }

    // Images
    DisplayMetrics displayMetrics = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);

    Resources resources = getActivity().getResources();

    if (dataHolder.getPosterUrl() != null) {
        int posterWidth;
        int posterHeight;
        if (dataHolder.getSquarePoster()) {
            posterWidth = resources.getDimensionPixelOffset(R.dimen.detail_poster_width_square);
            posterHeight = resources.getDimensionPixelOffset(R.dimen.detail_poster_height_square);
        } else {
            posterWidth = resources.getDimensionPixelOffset(R.dimen.detail_poster_width_nonsquare);
            posterHeight = resources.getDimensionPixelOffset(R.dimen.detail_poster_height_nonsquare);
        }

        UIUtils.loadImageWithCharacterAvatar(getActivity(), hostManager, dataHolder.getPosterUrl(),
                dataHolder.getTitle(), posterImageView, posterWidth, posterHeight);
    } else {
        posterImageView.setVisibility(GONE);
        int padding = getActivity().getResources().getDimensionPixelSize(R.dimen.default_padding);
        titleTextView.setPadding(padding, padding, 0, 0);
        underTitleTextView.setPadding(padding, padding, 0, 0);
    }

    int artHeight = resources.getDimensionPixelOffset(R.dimen.detail_art_height);
    int artWidth = displayMetrics.widthPixels;

    UIUtils.loadImageIntoImageview(hostManager,
            TextUtils.isEmpty(dataHolder.getFanArtUrl()) ? dataHolder.getPosterUrl()
                    : dataHolder.getFanArtUrl(),
            artImageView, artWidth, artHeight);

    if (dataHolder.getRating() > 0) {
        ratingTextView.setText(String.format(Locale.getDefault(), "%01.01f", dataHolder.getRating()));
        if (dataHolder.getMaxRating() > 0) {
            maxRatingTextView.setText(
                    String.format(getString(R.string.max_rating), String.valueOf(dataHolder.getMaxRating())));
        }
        if (dataHolder.getVotes() > 0) {
            ratingVotesTextView
                    .setText(String.format(getString(R.string.votes), String.valueOf(dataHolder.getVotes())));
        }
        ratingContainer.setVisibility(View.VISIBLE);
    } else if (TextUtils.isEmpty(dataHolder.getDetails())) {
        mediaDetailsContainer.setVisibility(View.GONE);
    }
}

From source file:com.syncedsynapse.kore2.ui.TVShowEpisodeDetailsFragment.java

/**
 * Display the episode details/*  w  w  w .  j a  v a  2 s .c  o  m*/
 *
 * @param cursor Cursor with the data
 */
private void displayEpisodeDetails(Cursor cursor) {
    cursor.moveToFirst();
    mediaTitle.setText(cursor.getString(EpisodeDetailsQuery.TITLE));
    mediaUndertitle.setText(cursor.getString(EpisodeDetailsQuery.SHOWTITLE));

    int runtime = cursor.getInt(EpisodeDetailsQuery.RUNTIME) / 60;
    String durationPremiered = runtime > 0
            ? String.format(getString(R.string.minutes_abbrev), String.valueOf(runtime)) + "  |  "
                    + cursor.getString(EpisodeDetailsQuery.FIRSTAIRED)
            : cursor.getString(EpisodeDetailsQuery.FIRSTAIRED);
    mediaPremiered.setText(durationPremiered);
    String season = String.format(getString(R.string.season_episode), cursor.getInt(EpisodeDetailsQuery.SEASON),
            cursor.getInt(EpisodeDetailsQuery.EPISODE));
    mediaSeason.setText(season);

    double rating = cursor.getDouble(EpisodeDetailsQuery.RATING);
    if (rating > 0) {
        mediaRating.setVisibility(View.VISIBLE);
        mediaMaxRating.setVisibility(View.VISIBLE);
        mediaRating.setText(String.format("%01.01f", rating));
        mediaMaxRating.setText(getString(R.string.max_rating_video));
    } else {
        mediaRating.setVisibility(View.INVISIBLE);
        mediaMaxRating.setVisibility(View.INVISIBLE);
    }

    mediaDescription.setText(cursor.getString(EpisodeDetailsQuery.PLOT));
    mediaDirectors.setText(cursor.getString(EpisodeDetailsQuery.DIRECTOR));

    setupSeenButton(cursor.getInt(EpisodeDetailsQuery.PLAYCOUNT));

    // Images
    Resources resources = getActivity().getResources();
    DisplayMetrics displayMetrics = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);

    int posterWidth = resources.getDimensionPixelOffset(R.dimen.now_playing_poster_width);
    int posterHeight = resources.getDimensionPixelOffset(R.dimen.now_playing_poster_height);
    //        UIUtils.loadImageIntoImageview(hostManager,
    //                cursor.getString(EpisodeDetailsQuery.THUMBNAIL),
    //                mediaPoster, posterWidth, posterHeight);
    int artHeight = resources.getDimensionPixelOffset(R.dimen.now_playing_art_height);
    UIUtils.loadImageIntoImageview(hostManager, cursor.getString(EpisodeDetailsQuery.THUMBNAIL), mediaArt,
            displayMetrics.widthPixels, artHeight);

    // Setup movie download info
    tvshowDownloadInfo = new FileDownloadHelper.TVShowInfo(cursor.getString(EpisodeDetailsQuery.SHOWTITLE),
            cursor.getInt(EpisodeDetailsQuery.SEASON), cursor.getInt(EpisodeDetailsQuery.EPISODE),
            cursor.getString(EpisodeDetailsQuery.TITLE), cursor.getString(EpisodeDetailsQuery.FILE));

    // Check if downloaded file exists
    downloadButton.setVisibility(View.VISIBLE);
    if (tvshowDownloadInfo.downloadFileExists()) {
        Resources.Theme theme = getActivity().getTheme();
        TypedArray styledAttributes = theme.obtainStyledAttributes(new int[] { R.attr.colorAccent });
        downloadButton.setColorFilter(styledAttributes.getColor(0, R.color.accent_default));
        styledAttributes.recycle();
    } else {
        downloadButton.clearColorFilter();
    }
}

From source file:org.xbmc.kore.ui.MusicVideoDetailsFragment.java

/**
 * Display the video details// w w  w. j a v a2s .  co m
 *
 * @param cursor Cursor with the data
 */
private void displayMusicVideoDetails(Cursor cursor) {
    cursor.moveToFirst();
    String musicVideoTitle = cursor.getString(MusicVideoDetailsQuery.TITLE);
    mediaTitle.setText(musicVideoTitle);

    setMediaUndertitle(cursor.getString(MusicVideoDetailsQuery.ARTIST),
            cursor.getString(MusicVideoDetailsQuery.ALBUM));

    setMediaYear(cursor.getInt(MusicVideoDetailsQuery.RUNTIME), cursor.getInt(MusicVideoDetailsQuery.YEAR));

    mediaGenres.setText(cursor.getString(MusicVideoDetailsQuery.GENRES));

    mediaDescription.setText(cursor.getString(MusicVideoDetailsQuery.PLOT));

    // Images
    Resources resources = getActivity().getResources();
    DisplayMetrics displayMetrics = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);

    String fanart = cursor.getString(MusicVideoDetailsQuery.FANART),
            poster = cursor.getString(MusicVideoDetailsQuery.THUMBNAIL);

    int artHeight = resources.getDimensionPixelOffset(R.dimen.now_playing_art_height),
            artWidth = displayMetrics.widthPixels;
    int posterWidth = resources.getDimensionPixelOffset(R.dimen.musicvideodetail_poster_width);
    int posterHeight = resources.getDimensionPixelOffset(R.dimen.musicvideodetail_poster_width);
    UIUtils.loadImageWithCharacterAvatar(getActivity(), getHostManager(), poster, musicVideoTitle, mediaPoster,
            posterWidth, posterHeight);
    UIUtils.loadImageIntoImageview(getHostManager(), TextUtils.isEmpty(fanart) ? poster : fanart, mediaArt,
            artWidth, artHeight);

    // Setup download info
    musicVideoDownloadInfo = new FileDownloadHelper.MusicVideoInfo(musicVideoTitle,
            cursor.getString(MusicVideoDetailsQuery.FILE));

    // Check if downloaded file exists
    if (musicVideoDownloadInfo.downloadFileExists()) {
        Resources.Theme theme = getActivity().getTheme();
        TypedArray styledAttributes = theme.obtainStyledAttributes(new int[] { R.attr.colorAccent });
        downloadButton.setColorFilter(
                styledAttributes.getColor(0, getActivity().getResources().getColor(R.color.accent_default)));
        styledAttributes.recycle();
    } else {
        downloadButton.clearColorFilter();
    }
}

From source file:com.hgdendi.contactslist.common.FloatingBarItemDecoration.java

public FloatingBarItemDecoration(Context context, Map<Integer, String> list) {
    this.mContext = context;
    Resources resources = mContext.getResources();
    this.mList = list;
    this.mTitleHeight = resources.getDimensionPixelSize(R.dimen.item_decoration_title_height);

    mBackgroundPaint = new Paint();
    mBackgroundPaint.setColor(ContextCompat.getColor(mContext, R.color.item_decoration_title_background));

    mTextPaint = new Paint();
    mTextPaint.setColor(ContextCompat.getColor(mContext, R.color.item_decoration_title_fontcolor));
    mTextPaint//from   w ww .  j ava2s. c o m
            .setTextSize(mContext.getResources().getDimensionPixelSize(R.dimen.item_decoration_title_fontsize));

    Paint.FontMetrics fm = mTextPaint.getFontMetrics();
    mTextHeight = (int) (fm.bottom - fm.top);
    mTextBaselineOffset = (int) fm.bottom;
    mTextStartMargin = resources.getDimensionPixelOffset(R.dimen.item_decoration_title_start_margin);
}

From source file:com.syncedsynapse.kore2.ui.MusicVideoDetailsFragment.java

/**
 * Display the video details//from   w w  w .  ja v  a  2 s. com
 *
 * @param cursor Cursor with the data
 */
private void displayMusicVideoDetails(Cursor cursor) {
    cursor.moveToFirst();
    String musicVideoTitle = cursor.getString(MusicVideoDetailsQuery.TITLE);
    mediaTitle.setText(musicVideoTitle);
    String artistAlbum = cursor.getString(MusicVideoDetailsQuery.ARTIST) + "  |  "
            + cursor.getString(MusicVideoDetailsQuery.ALBUM);
    mediaUndertitle.setText(artistAlbum);

    int runtime = cursor.getInt(MusicVideoDetailsQuery.RUNTIME);
    String durationYear = runtime > 0
            ? UIUtils.formatTime(runtime) + "  |  " + String.valueOf(cursor.getInt(MusicVideoDetailsQuery.YEAR))
            : String.valueOf(cursor.getInt(MusicVideoDetailsQuery.YEAR));
    mediaYear.setText(durationYear);
    mediaGenres.setText(cursor.getString(MusicVideoDetailsQuery.GENRES));

    mediaDescription.setText(cursor.getString(MusicVideoDetailsQuery.PLOT));

    // Images
    Resources resources = getActivity().getResources();
    DisplayMetrics displayMetrics = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);

    String fanart = cursor.getString(MusicVideoDetailsQuery.FANART),
            poster = cursor.getString(MusicVideoDetailsQuery.THUMBNAIL);

    int artHeight = resources.getDimensionPixelOffset(R.dimen.now_playing_art_height),
            artWidth = displayMetrics.widthPixels;
    if (!TextUtils.isEmpty(fanart)) {
        int posterWidth = resources.getDimensionPixelOffset(R.dimen.musicvideodetail_poster_width);
        int posterHeight = resources.getDimensionPixelOffset(R.dimen.musicvideodetail_poster_heigth);
        mediaPoster.setVisibility(View.VISIBLE);
        UIUtils.loadImageWithCharacterAvatar(getActivity(), hostManager, poster, musicVideoTitle, mediaPoster,
                posterWidth, posterHeight);
        UIUtils.loadImageIntoImageview(hostManager, fanart, mediaArt, artWidth, artHeight);
    } else {
        // No fanart, just present the poster
        mediaPoster.setVisibility(View.GONE);
        UIUtils.loadImageIntoImageview(hostManager, poster, mediaArt, artWidth, artHeight);
        // Reset padding
        int paddingLeft = mediaTitle.getPaddingRight(), paddingRight = mediaTitle.getPaddingRight(),
                paddingTop = mediaTitle.getPaddingTop(), paddingBottom = mediaTitle.getPaddingBottom();
        mediaTitle.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom);
        mediaUndertitle.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom);
    }

    // Setup download info
    musicVideoDownloadInfo = new FileDownloadHelper.MusicVideoInfo(musicVideoTitle,
            cursor.getString(MusicVideoDetailsQuery.FILE));

    // Check if downloaded file exists
    downloadButton.setVisibility(View.VISIBLE);
    if (musicVideoDownloadInfo.downloadFileExists()) {
        Resources.Theme theme = getActivity().getTheme();
        TypedArray styledAttributes = theme.obtainStyledAttributes(new int[] { R.attr.colorAccent });
        downloadButton.setColorFilter(styledAttributes.getColor(0, R.color.accent_default));
        styledAttributes.recycle();
    } else {
        downloadButton.clearColorFilter();
    }
}

From source file:com.anysoftkeyboard.keyboards.KeyboardSwitcher.java

public KeyboardSwitcher(@NonNull KeyboardSwitchedListener ime, @NonNull Context context) {
    mDefaultAddOn = new DefaultAddOn(context, context);
    mKeyboardSwitchedListener = ime;//from ww w  .  j  a  va  2s  . c  o m
    mContext = context;
    final Resources res = mContext.getResources();
    mKeyboardDimens = new KeyboardDimens() {

        public int getSmallKeyHeight() {
            return res.getDimensionPixelOffset(R.dimen.default_key_half_height);
        }

        public float getRowVerticalGap() {
            return res.getDimensionPixelOffset(R.dimen.default_key_vertical_gap);
        }

        public int getNormalKeyHeight() {
            return res.getDimensionPixelOffset(R.dimen.default_key_height);
        }

        public int getLargeKeyHeight() {
            return res.getDimensionPixelOffset(R.dimen.default_key_tall_height);
        }

        public int getKeyboardMaxWidth() {
            return mContext.getResources().getDisplayMetrics().widthPixels;
        }

        public float getKeyHorizontalGap() {
            return res.getDimensionPixelOffset(R.dimen.default_key_horizontal_gap);
        }
    };
    mKeyboardRowMode = KEYBOARD_ROW_MODE_NORMAL;
    //loading saved package-id from prefs
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        loadKeyboardAppMapping();
    }
}

From source file:org.xbmc.kore.ui.MovieDetailsFragment.java

/**
 * Display the movie details/*from  w  ww  .  j ava 2 s  .  co  m*/
 *
 * @param cursor Cursor with the data
 */
private void displayMovieDetails(Cursor cursor) {
    LogUtils.LOGD(TAG, "Refreshing movie details");
    cursor.moveToFirst();
    movieTitle = cursor.getString(MovieDetailsQuery.TITLE);
    mediaTitle.setText(movieTitle);
    mediaUndertitle.setText(cursor.getString(MovieDetailsQuery.TAGLINE));

    setMediaYear(cursor.getInt(MovieDetailsQuery.RUNTIME) / 60, cursor.getInt(MovieDetailsQuery.YEAR));

    mediaGenres.setText(cursor.getString(MovieDetailsQuery.GENRES));

    double rating = cursor.getDouble(MovieDetailsQuery.RATING);
    if (rating > 0) {
        mediaRating.setVisibility(View.VISIBLE);
        mediaMaxRating.setVisibility(View.VISIBLE);
        mediaRatingVotes.setVisibility(View.VISIBLE);
        setMediaRating(rating);
        String votes = cursor.getString(MovieDetailsQuery.VOTES);
        mediaRatingVotes
                .setText((TextUtils.isEmpty(votes)) ? "" : String.format(getString(R.string.votes), votes));
    } else {
        mediaRating.setVisibility(View.INVISIBLE);
        mediaMaxRating.setVisibility(View.INVISIBLE);
        mediaRatingVotes.setVisibility(View.INVISIBLE);
    }

    mediaDescription.setText(cursor.getString(MovieDetailsQuery.PLOT));
    mediaDirectors.setText(cursor.getString(MovieDetailsQuery.DIRECTOR));

    // IMDB button
    imdbButton.setTag(cursor.getString(MovieDetailsQuery.IMDBNUMBER));

    setupSeenButton(cursor.getInt(MovieDetailsQuery.PLAYCOUNT));

    // Images
    Resources resources = getActivity().getResources();
    DisplayMetrics displayMetrics = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);

    int posterWidth = resources.getDimensionPixelOffset(R.dimen.now_playing_poster_width);
    int posterHeight = resources.getDimensionPixelOffset(R.dimen.now_playing_poster_height);
    UIUtils.loadImageWithCharacterAvatar(getActivity(), getHostManager(),
            cursor.getString(MovieDetailsQuery.THUMBNAIL), movieTitle, mediaPoster, posterWidth, posterHeight);
    int artHeight = resources.getDimensionPixelOffset(R.dimen.now_playing_art_height);
    UIUtils.loadImageIntoImageview(getHostManager(), cursor.getString(MovieDetailsQuery.FANART), mediaArt,
            displayMetrics.widthPixels, artHeight);

    // Setup movie download info
    movieDownloadInfo = new FileDownloadHelper.MovieInfo(movieTitle, cursor.getString(MovieDetailsQuery.FILE));

    // Check if downloaded file exists
    if (movieDownloadInfo.downloadFileExists()) {
        Resources.Theme theme = getActivity().getTheme();
        TypedArray styledAttributes = theme.obtainStyledAttributes(new int[] { R.attr.colorAccent });
        downloadButton.setColorFilter(
                styledAttributes.getColor(0, getActivity().getResources().getColor(R.color.accent_default)));
        styledAttributes.recycle();
    } else {
        downloadButton.clearColorFilter();
    }
}

From source file:com.syncedsynapse.kore2.ui.MovieDetailsFragment.java

/**
 * Display the movie details/*from  w ww  . j a  va2  s. c  om*/
 *
 * @param cursor Cursor with the data
 */
private void displayMovieDetails(Cursor cursor) {
    LogUtils.LOGD(TAG, "Refreshing movie details");
    cursor.moveToFirst();
    String movieTitle = cursor.getString(MovieDetailsQuery.TITLE);
    mediaTitle.setText(movieTitle);
    mediaUndertitle.setText(cursor.getString(MovieDetailsQuery.TAGLINE));

    int runtime = cursor.getInt(MovieDetailsQuery.RUNTIME) / 60;
    String durationYear = runtime > 0
            ? String.format(getString(R.string.minutes_abbrev), String.valueOf(runtime)) + "  |  "
                    + String.valueOf(cursor.getInt(MovieDetailsQuery.YEAR))
            : String.valueOf(cursor.getInt(MovieDetailsQuery.YEAR));
    mediaYear.setText(durationYear);
    mediaGenres.setText(cursor.getString(MovieDetailsQuery.GENRES));

    double rating = cursor.getDouble(MovieDetailsQuery.RATING);
    if (rating > 0) {
        mediaRating.setVisibility(View.VISIBLE);
        mediaMaxRating.setVisibility(View.VISIBLE);
        mediaRatingVotes.setVisibility(View.VISIBLE);
        mediaRating.setText(String.format("%01.01f", rating));
        mediaMaxRating.setText(getString(R.string.max_rating_video));
        String votes = cursor.getString(MovieDetailsQuery.VOTES);
        mediaRatingVotes
                .setText((TextUtils.isEmpty(votes)) ? "" : String.format(getString(R.string.votes), votes));
    } else {
        mediaRating.setVisibility(View.INVISIBLE);
        mediaMaxRating.setVisibility(View.INVISIBLE);
        mediaRatingVotes.setVisibility(View.INVISIBLE);
    }

    mediaDescription.setText(cursor.getString(MovieDetailsQuery.PLOT));
    mediaDirectors.setText(cursor.getString(MovieDetailsQuery.DIRECTOR));

    // IMDB button
    imdbButton.setTag(cursor.getString(MovieDetailsQuery.IMDBNUMBER));

    setupSeenButton(cursor.getInt(MovieDetailsQuery.PLAYCOUNT));

    // Images
    Resources resources = getActivity().getResources();
    DisplayMetrics displayMetrics = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);

    int posterWidth = resources.getDimensionPixelOffset(R.dimen.now_playing_poster_width);
    int posterHeight = resources.getDimensionPixelOffset(R.dimen.now_playing_poster_height);
    UIUtils.loadImageWithCharacterAvatar(getActivity(), hostManager,
            cursor.getString(MovieDetailsQuery.THUMBNAIL), movieTitle, mediaPoster, posterWidth, posterHeight);
    int artHeight = resources.getDimensionPixelOffset(R.dimen.now_playing_art_height);
    UIUtils.loadImageIntoImageview(hostManager, cursor.getString(MovieDetailsQuery.FANART), mediaArt,
            displayMetrics.widthPixels, artHeight);

    // Setup movie download info
    movieDownloadInfo = new FileDownloadHelper.MovieInfo(movieTitle, cursor.getString(MovieDetailsQuery.FILE));

    // Check if downloaded file exists
    downloadButton.setVisibility(View.VISIBLE);
    if (movieDownloadInfo.downloadFileExists()) {
        Resources.Theme theme = getActivity().getTheme();
        TypedArray styledAttributes = theme.obtainStyledAttributes(new int[] { R.attr.colorAccent });
        downloadButton.setColorFilter(styledAttributes.getColor(0, R.color.accent_default));
        styledAttributes.recycle();
    } else {
        downloadButton.clearColorFilter();
    }
}

From source file:com.xycode.xylibrary.uiKit.recyclerview.FloatingBarItemDecoration.java

public FloatingBarItemDecoration(Context context, List sourceList, Options options,
        ITitleTextGetter iTitleTextGetter) {
    this.mContext = context;
    Resources resources = mContext.getResources();
    this.iTitleTextGetter = iTitleTextGetter;
    this.headerList = preHeaderList(sourceList);
    this.mTitleHeight = resources.getDimensionPixelSize(options.titleHeight);

    mBackgroundPaint = new Paint();
    mBackgroundPaint.setColor(ContextCompat.getColor(mContext, options.backgroundColorRes));

    mTextPaint = new Paint();
    mTextPaint.setColor(ContextCompat.getColor(mContext, options.textColor));
    mTextPaint.setTextSize(mContext.getResources().getDimensionPixelSize(options.textSize));

    Paint.FontMetrics fm = mTextPaint.getFontMetrics();
    mTextHeight = (int) (fm.bottom - fm.top);
    mTextBaselineOffset = (int) fm.bottom;
    mTextStartMargin = resources.getDimensionPixelOffset(options.textStartMargin);
}