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:org.xbmc.kore.ui.BaseMediaActivity.java

private void updateNowPlayingPanel(PlayerType.PropertyValue getPropertiesResult,
        ListType.ItemsAll getItemResult) {
    String title;/* w  w  w . j ava2s. c o  m*/
    String poster;
    String details = null;

    callbackHandler.removeCallbacks(hidePanelRunnable);

    // Only set state to collapsed if panel is currently hidden. This prevents collapsing
    // the panel when the user expanded the panel and started playing the item from a paused
    // state
    if (nowPlayingPanel.getPanelState() == SlidingUpPanelLayout.PanelState.HIDDEN) {
        nowPlayingPanel.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED);
    }

    nowPlayingPanel.setMediaProgress(getPropertiesResult.time, getPropertiesResult.totaltime);

    nowPlayingPanel.setPlayButton(getPropertiesResult.speed > 0);
    nowPlayingPanel.setShuffled(getPropertiesResult.shuffled);
    nowPlayingPanel.setRepeatMode(getPropertiesResult.repeat);
    nowPlayingPanel.setSpeed(getPropertiesResult.speed);

    switch (getItemResult.type) {
    case ListType.ItemsAll.TYPE_MOVIE:
        title = getItemResult.title;
        details = getItemResult.tagline;
        poster = TextUtils.isEmpty(getItemResult.thumbnail) ? getItemResult.fanart : getItemResult.thumbnail;
        break;
    case ListType.ItemsAll.TYPE_EPISODE:
        title = getItemResult.title;
        String seasonEpisode = String.format(getString(R.string.season_episode_abbrev), getItemResult.season,
                getItemResult.episode);
        details = String.format("%s | %s", getItemResult.showtitle, seasonEpisode);
        poster = TextUtils.isEmpty(getItemResult.art.poster) ? getItemResult.art.fanart
                : getItemResult.art.poster;
        break;
    case ListType.ItemsAll.TYPE_SONG:
        title = getItemResult.title;
        details = getItemResult.displayartist + " | " + getItemResult.album;
        poster = TextUtils.isEmpty(getItemResult.thumbnail) ? getItemResult.fanart : getItemResult.thumbnail;
        break;
    case ListType.ItemsAll.TYPE_MUSIC_VIDEO:
        title = getItemResult.title;
        details = Utils.listStringConcat(getItemResult.artist, ", ") + " | " + getItemResult.album;
        poster = TextUtils.isEmpty(getItemResult.thumbnail) ? getItemResult.fanart : getItemResult.thumbnail;
        break;
    case ListType.ItemsAll.TYPE_CHANNEL:
        title = getItemResult.label;
        details = getItemResult.title;
        poster = TextUtils.isEmpty(getItemResult.thumbnail) ? getItemResult.fanart : getItemResult.thumbnail;
        break;
    default:
        title = getItemResult.label;
        poster = TextUtils.isEmpty(getItemResult.thumbnail) ? getItemResult.fanart : getItemResult.thumbnail;
        break;
    }

    if (title.contentEquals(nowPlayingPanel.getTitle()))
        return; // Still showing same item as previous call

    nowPlayingPanel.setTitle(title);

    if (details != null) {
        nowPlayingPanel.setDetails(details);
    }

    if ((getItemResult.type.contentEquals(ListType.ItemsAll.TYPE_MUSIC_VIDEO))
            || (getItemResult.type.contentEquals(ListType.ItemsAll.TYPE_SONG))) {
        nowPlayingPanel.setNextPrevVisibility(View.VISIBLE);
    } else {
        nowPlayingPanel.setNextPrevVisibility(View.GONE);
    }

    Resources resources = getResources();
    int posterWidth = resources.getDimensionPixelOffset(R.dimen.now_playing_panel_art_width);
    int posterHeight = resources.getDimensionPixelOffset(R.dimen.now_playing_panel_height);

    // If not video, change aspect ration of poster to a square
    boolean isVideo = (getItemResult.type.equals(ListType.ItemsAll.TYPE_MOVIE))
            || (getItemResult.type.equals(ListType.ItemsAll.TYPE_EPISODE));

    nowPlayingPanel.setSquarePoster(!isVideo);

    UIUtils.loadImageWithCharacterAvatar(this, hostManager, poster, title, nowPlayingPanel.getPoster(),
            (isVideo) ? posterWidth : posterHeight, posterHeight);
}

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

private void setArt(String poster, String fanart) {
    final Resources resources = getActivity().getResources();

    // Images/*from  w  w  w. ja  va 2s  .co  m*/
    DisplayMetrics displayMetrics = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);

    int artHeight = resources.getDimensionPixelOffset(R.dimen.now_playing_art_height),
            artWidth = displayMetrics.widthPixels;
    int posterWidth = resources.getDimensionPixelOffset(R.dimen.albumdetail_poster_width);
    int posterHeight = resources.getDimensionPixelOffset(R.dimen.albumdetail_poster_heigth);
    UIUtils.loadImageWithCharacterAvatar(getActivity(), hostManager, poster, artistTitle, mediaPoster,
            posterWidth, posterHeight);
    UIUtils.loadImageIntoImageview(hostManager, TextUtils.isEmpty(fanart) ? poster : fanart, mediaArt, artWidth,
            artHeight);
}

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

/**
 * Display the tv show details/*from   w ww .  ja v  a2  s  .  c  om*/
 *
 * @param cursor Cursor with the data
 */
private void displayTVShowDetails(Cursor cursor) {
    cursor.moveToFirst();
    String tvshowTitle = cursor.getString(TVShowDetailsQuery.TITLE);
    mediaTitle.setText(tvshowTitle);
    int numEpisodes = cursor.getInt(TVShowDetailsQuery.EPISODE),
            watchedEpisodes = cursor.getInt(TVShowDetailsQuery.WATCHEDEPISODES);
    String episodes = String.format(getString(R.string.num_episodes), numEpisodes,
            numEpisodes - watchedEpisodes);
    mediaUndertitle.setText(episodes);

    String premiered = String.format(getString(R.string.premiered),
            cursor.getString(TVShowDetailsQuery.PREMIERED)) + "  |  "
            + cursor.getString(TVShowDetailsQuery.STUDIO);
    mediaPremiered.setText(premiered);
    mediaGenres.setText(cursor.getString(TVShowDetailsQuery.GENRES));

    double rating = cursor.getDouble(TVShowDetailsQuery.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(TVShowDetailsQuery.PLOT));

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

    // 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(TVShowDetailsQuery.THUMBNAIL), tvshowTitle, mediaPoster, posterWidth,
            posterHeight);
    int artHeight = resources.getDimensionPixelOffset(R.dimen.now_playing_art_height);
    UIUtils.loadImageIntoImageview(hostManager, cursor.getString(TVShowDetailsQuery.FANART), mediaArt,
            displayMetrics.widthPixels, artHeight);
}

From source file:android.support.design.internal.NavigationMenuPresenter.java

@Override
public void initForMenu(Context context, MenuBuilder menu) {
    mLayoutInflater = LayoutInflater.from(context);
    mMenu = menu;/*from  www .  j  a  v a2  s. c  om*/
    Resources res = context.getResources();
    mPaddingSeparator = res.getDimensionPixelOffset(R.dimen.design_navigation_separator_vertical_padding);
}

From source file:com.philliphsu.bottomsheetpickers.date.PagingDayPickerView.java

private void init(Context context) {
    mHandler = new Handler();
    setOrientation(VERTICAL);//from   w  ww . j  a  v  a  2 s .co  m
    setLayoutParams(new LayoutParams(MATCH_PARENT, MATCH_PARENT));

    Resources res = getResources();
    MONTH_NAVIGATION_BAR_SIZE = res.getDimensionPixelOffset(R.dimen.bsp_month_navigation_bar_height)
            + res.getDimensionPixelOffset(R.dimen.bsp_month_view_top_padding);

    final View view = LayoutInflater.from(context).inflate(R.layout.bsp_day_picker_content, this, true);
    mMonthAnimator = (DayPickerViewAnimator) findViewById(R.id.bsp_month_animator);
    mMonthPickerView = (MonthPickerView) findViewById(R.id.bsp_month_picker);
    mMonthPickerView.setOnMonthClickListener(this);
    mViewPager = (ViewPager) findViewById(R.id.bsp_viewpager);
    mViewPager.addOnPageChangeListener(this);
    mMonthYearTitleView = (TextView) view.findViewById(R.id.bsp_month_year_title);
    mTitleContainer = view.findViewById(R.id.bsp_month_year_title_container);
    mTitleContainer.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            int newIndex = mCurrentView == DAY_PICKER_INDEX ? MONTH_PICKER_INDEX : DAY_PICKER_INDEX;
            setupCurrentView(newIndex, true);
        }
    });
    mPreviousButton = (ImageButton) view.findViewById(R.id.bsp_prev);
    mPreviousButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            int previousItem = mViewPager.getCurrentItem() - 1;
            if (previousItem >= 0) {
                mViewPager.setCurrentItem(previousItem, true);
            }
        }
    });
    mNextButton = (ImageButton) view.findViewById(R.id.bsp_next);
    mNextButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            int nextItem = mViewPager.getCurrentItem() + 1;
            if (nextItem < mAdapter.getCount()) {
                mViewPager.setCurrentItem(nextItem, true);
            }
        }
    });

    mArrowDownDrawable = AnimatedVectorDrawableCompat.create(context, R.drawable.bsp_animated_arrow_drop_down);
    mArrowUpDrawable = AnimatedVectorDrawableCompat.create(context, R.drawable.bsp_animated_arrow_drop_up);
    setArrowDrawableOnTitle(mArrowDownDrawable);

    // Theme-specific configurations.
    if (mThemeDark) {
        int selectableItemBg = getColor(context, R.color.bsp_selectable_item_background_dark);
        Utils.setColorControlHighlight(mPreviousButton, selectableItemBg);
        Utils.setColorControlHighlight(mNextButton, selectableItemBg);
        Utils.setColorControlHighlight(mTitleContainer, selectableItemBg);
        int cursor = getColor(context, R.color.bsp_text_color_secondary_dark);
        Utils.applyTint(mPreviousButton, cursor);
        Utils.applyTint(mNextButton, cursor);
    }

    // Set up colors.
    int monthYearTitleColor = getColor(context,
            mThemeDark ? R.color.bsp_text_color_primary_dark : R.color.bsp_text_color_primary_light);
    int dropdownArrowColor = getColor(context,
            mThemeDark ? R.color.bsp_icon_color_active_dark : R.color.bsp_icon_color_active_light);

    mMonthYearTitleView.setTextColor(monthYearTitleColor);
    mArrowDownDrawable.setTint(dropdownArrowColor);
    mArrowUpDrawable.setTint(dropdownArrowColor);

    mMonthPickerView.setTheme(context, mThemeDark);
}

From source file:com.android.mail.browse.SubjectAndFolderView.java

public SubjectAndFolderView(Context context, AttributeSet attrs) {
    super(context, attrs);

    final Resources res = getResources();
    mNoFolderChipName = res.getString(R.string.add_label);
    mNoFolderBgColor = res.getColor(R.color.conv_header_add_label_background);
    mNoFolderFgColor = res.getColor(R.color.conv_header_add_label_text);
    mImportanceMarkerDrawable = res.getDrawable(R.drawable.ic_email_caret_none_important_unread);
    mImportanceMarkerDrawable.setBounds(0, 0, mImportanceMarkerDrawable.getIntrinsicWidth(),
            mImportanceMarkerDrawable.getIntrinsicHeight());
    mChipVerticalOffset = res.getDimensionPixelOffset(R.dimen.folder_cv_vertical_offset);

    mVisibleFolders = false;/* w  w w . j av  a 2 s .c om*/
    mFolderDisplayer = new ConversationFolderDisplayer(getContext());
}

From source file:com.ruesga.rview.drawer.DrawerNavigationMenuPresenter.java

@Override
public void initForMenu(Context context, MenuBuilder menu) {
    mLayoutInflater = LayoutInflater.from(context);
    mMenu = menu;//w  w w. j  av a  2 s  .  c om
    Resources res = context.getResources();
    mPaddingSeparator = res.getDimensionPixelOffset(R.dimen.drawer_navigation_separator_vertical_padding);
}

From source file:org.xbmc.kore.ui.sections.video.TVShowEpisodeDetailsFragment.java

/**
 * Display the episode details//from  ww w  .j a v a2  s  .  c  om
 *
 * @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(getHostManager(), 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, getResources().getColor(R.color.accent_default)));
        styledAttributes.recycle();
    } else {
        downloadButton.clearColorFilter();
    }
}

From source file:com.android.tv.menu.MenuLayoutManager.java

public MenuLayoutManager(Context context, MenuView menuView) {
    mMenuView = menuView;/*from  ww  w.  j  a v a2  s.  co m*/
    // Load dimensions
    Resources res = context.getResources();
    mRowAlignFromBottom = res.getDimensionPixelOffset(R.dimen.menu_row_align_from_bottom);
    mRowContentsPaddingTop = res.getDimensionPixelOffset(R.dimen.menu_row_contents_padding_top);
    mRowContentsPaddingBottomMax = res.getDimensionPixelOffset(R.dimen.menu_row_contents_padding_bottom_max);
    mRowTitleTextDescenderHeight = res.getDimensionPixelOffset(R.dimen.menu_row_title_text_descender_height);
    mMenuMarginBottomMin = res.getDimensionPixelOffset(R.dimen.menu_margin_bottom_min);
    mRowTitleHeight = res.getDimensionPixelSize(R.dimen.menu_row_title_height);
    mRowScrollUpAnimationOffset = res.getDimensionPixelOffset(R.dimen.menu_row_scroll_up_anim_offset);
    mRowAnimationDuration = res.getInteger(R.integer.menu_row_selection_anim_duration);
    mOldContentsFadeOutDuration = res.getInteger(R.integer.menu_previous_contents_fade_out_duration);
    mCurrentContentsFadeInDuration = res.getInteger(R.integer.menu_current_contents_fade_in_duration);
}

From source file:com.yek.keyboard.keyboards.KeyboardSwitcher.java

public KeyboardSwitcher(@NonNull KeyboardSwitchedListener ime, @NonNull Context context) {
    mDefaultAddOn = new DefaultAddOn(context, context);
    mIME = ime;//  www .  j  a v  a  2s  .c  om
    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.KEYBOARD_ROW_MODE_NORMAL;
}