List of usage examples for android.content.res Resources getDimensionPixelOffset
public int getDimensionPixelOffset(@DimenRes int id) throws NotFoundException
From source file:org.xbmc.kore.ui.sections.audio.AlbumDetailsFragment.java
/** * Display the album details//from w ww. j av a 2 s . c om * * @param cursor Cursor with the data */ private void displayAlbumDetails(Cursor cursor) { final Resources resources = getActivity().getResources(); cursor.moveToFirst(); albumTitle = cursor.getString(AlbumDetailsQuery.TITLE); albumDisplayArtist = cursor.getString(AlbumDetailsQuery.DISPLAYARTIST); mediaTitle.setText(albumTitle); mediaUndertitle.setText(albumDisplayArtist); setMediaYear(cursor.getString(AlbumDetailsQuery.GENRE), cursor.getInt(AlbumDetailsQuery.YEAR)); double rating = cursor.getDouble(AlbumDetailsQuery.RATING); if (rating > 0) { mediaRating.setVisibility(View.VISIBLE); mediaMaxRating.setVisibility(View.VISIBLE); setMediaRating(rating); } else { mediaRating.setVisibility(View.GONE); mediaMaxRating.setVisibility(View.GONE); } String description = cursor.getString(AlbumDetailsQuery.DESCRIPTION); if (!TextUtils.isEmpty(description)) { mediaDescription.setVisibility(View.VISIBLE); mediaDescription.setText(description); 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(); mediaDescriptionContainer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mediaDescription.toggle(); mediaShowAll .setImageResource(mediaDescription.isExpanded() ? iconCollapseResId : iconExpandResId); } }); } else { mediaDescriptionContainer.setVisibility(View.GONE); } // Images DisplayMetrics displayMetrics = new DisplayMetrics(); getActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); String fanart = cursor.getString(AlbumDetailsQuery.FANART), poster = cursor.getString(AlbumDetailsQuery.THUMBNAIL); 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, albumTitle, mediaPoster, posterWidth, posterHeight); UIUtils.loadImageIntoImageview(hostManager, TextUtils.isEmpty(fanart) ? poster : fanart, mediaArt, artWidth, artHeight); }
From source file:com.grottworkshop.gwsmaterialdaterangepicker.date.MonthView.java
@SuppressWarnings("deprecation") public MonthView(Context context, AttributeSet attr, DatePickerController controller) { super(context, attr); mController = controller;//from www . j av a2 s. co m Resources res = context.getResources(); mDayLabelCalendar = Calendar.getInstance(); mCalendar = Calendar.getInstance(); mDayOfWeekTypeface = res.getString(R.string.mdtp_day_of_week_label_typeface); mMonthTitleTypeface = res.getString(R.string.mdtp_sans_serif); boolean darkTheme = mController != null && mController.isThemeDark(); if (darkTheme) { //TODO: getColor(int) depreciated mDayTextColor = res.getColor(R.color.mdtp_date_picker_text_normal_dark_theme); //TODO: getColor(int) depreciated mMonthDayTextColor = res.getColor(R.color.mdtp_date_picker_month_day_dark_theme); //TODO: getColor(int) depreciated mDisabledDayTextColor = res.getColor(R.color.mdtp_date_picker_text_disabled_dark_theme); //TODO: getColor(int) depreciated mHighlightedDayTextColor = res.getColor(R.color.mdtp_date_picker_text_highlighted_dark_theme); } else { //TODO: getColor(int) depreciated mDayTextColor = res.getColor(R.color.mdtp_date_picker_text_normal); //TODO: getColor(int) depreciated mMonthDayTextColor = res.getColor(R.color.mdtp_date_picker_month_day); //TODO: getColor(int) depreciated mDisabledDayTextColor = res.getColor(R.color.mdtp_date_picker_text_disabled); //TODO: getColor(int) depreciated mHighlightedDayTextColor = res.getColor(R.color.mdtp_date_picker_text_highlighted); } //TODO: getColor(int) depreciated mSelectedDayTextColor = res.getColor(R.color.mdtp_white); //TODO: getColor(int) depreciated mTodayNumberColor = res.getColor(R.color.mdtp_accent_color); //TODO: getColor(int) depreciated mMonthTitleColor = res.getColor(R.color.mdtp_white); mStringBuilder = new StringBuilder(50); mFormatter = new Formatter(mStringBuilder, Locale.getDefault()); MINI_DAY_NUMBER_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_day_number_size); MONTH_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_month_label_size); MONTH_DAY_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_month_day_label_text_size); MONTH_HEADER_SIZE = res.getDimensionPixelOffset(R.dimen.mdtp_month_list_item_header_height); DAY_SELECTED_CIRCLE_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_day_number_select_circle_radius); mRowHeight = (res.getDimensionPixelOffset(R.dimen.mdtp_date_picker_view_animator_height) - getMonthHeaderSize()) / MAX_NUM_ROWS; // Set up accessibility components. mTouchHelper = getMonthViewTouchHelper(); ViewCompat.setAccessibilityDelegate(this, mTouchHelper); ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES); mLockAccessibilityDelegate = true; // Sets up any standard paints that will be used initView(); }
From source file:org.xbmc.kore.ui.AlbumDetailsFragment.java
/** * Display the album details//from ww w.j av a 2 s . co m * * @param cursor Cursor with the data */ private void displayAlbumDetails(Cursor cursor) { final Resources resources = getActivity().getResources(); cursor.moveToFirst(); albumTitle = cursor.getString(AlbumDetailsQuery.TITLE); albumDisplayArtist = cursor.getString(AlbumDetailsQuery.DISPLAYARTIST); mediaTitle.setText(albumTitle); mediaUndertitle.setText(albumDisplayArtist); setMediaYear(cursor.getString(AlbumDetailsQuery.GENRE), cursor.getInt(AlbumDetailsQuery.YEAR)); double rating = cursor.getDouble(AlbumDetailsQuery.RATING); if (rating > 0) { mediaRating.setVisibility(View.VISIBLE); mediaMaxRating.setVisibility(View.VISIBLE); setMediaRating(rating); } else { mediaRating.setVisibility(View.GONE); mediaMaxRating.setVisibility(View.GONE); } String description = cursor.getString(AlbumDetailsQuery.DESCRIPTION); if (!TextUtils.isEmpty(description)) { mediaDescription.setVisibility(View.VISIBLE); mediaDescription.setText(description); final int maxLines = resources.getInteger(R.integer.description_max_lines); 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(); mediaDescriptionContainer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (!isDescriptionExpanded) { mediaDescription.setMaxLines(Integer.MAX_VALUE); mediaShowAll.setImageResource(iconExpandResId); } else { mediaDescription.setMaxLines(maxLines); mediaShowAll.setImageResource(iconCollapseResId); } isDescriptionExpanded = !isDescriptionExpanded; } }); } else { mediaDescriptionContainer.setVisibility(View.GONE); } // Images DisplayMetrics displayMetrics = new DisplayMetrics(); getActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); String fanart = cursor.getString(AlbumDetailsQuery.FANART), poster = cursor.getString(AlbumDetailsQuery.THUMBNAIL); 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, albumTitle, mediaPoster, posterWidth, posterHeight); UIUtils.loadImageIntoImageview(hostManager, TextUtils.isEmpty(fanart) ? poster : fanart, mediaArt, artWidth, artHeight); }
From source file:com.syncedsynapse.kore2.ui.AlbumDetailsFragment.java
/** * Display the album details/* w w w . j a v a2 s.c o m*/ * * @param cursor Cursor with the data */ private void displayAlbumDetails(Cursor cursor) { final Resources resources = getActivity().getResources(); cursor.moveToFirst(); albumTitle = cursor.getString(AlbumDetailsQuery.TITLE); albumDisplayArtist = cursor.getString(AlbumDetailsQuery.DISPLAYARTIST); mediaTitle.setText(albumTitle); mediaUndertitle.setText(albumDisplayArtist); int year = cursor.getInt(AlbumDetailsQuery.YEAR); String genres = cursor.getString(AlbumDetailsQuery.GENRE); String label = (year > 0) ? (!TextUtils.isEmpty(genres) ? genres + " | " + String.valueOf(year) : String.valueOf(year)) : genres; mediaYear.setText(label); double rating = cursor.getDouble(AlbumDetailsQuery.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_music)); } else { mediaRating.setVisibility(View.GONE); mediaMaxRating.setVisibility(View.GONE); } String description = cursor.getString(AlbumDetailsQuery.DESCRIPTION); if (!TextUtils.isEmpty(description)) { mediaDescription.setVisibility(View.VISIBLE); mediaDescription.setText(description); final int maxLines = resources.getInteger(R.integer.description_max_lines); Resources.Theme theme = getActivity().getTheme(); TypedArray styledAttributes = theme .obtainStyledAttributes(new int[] { R.attr.iconExpand, R.attr.iconCollapse }); final int iconCollapseResId = styledAttributes.getResourceId(0, R.drawable.ic_expand_less_white_24dp); final int iconExpandResId = styledAttributes.getResourceId(1, R.drawable.ic_expand_more_white_24dp); styledAttributes.recycle(); mediaDescriptionContainer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (!isDescriptionExpanded) { mediaDescription.setMaxLines(Integer.MAX_VALUE); mediaShowAll.setImageResource(iconExpandResId); } else { mediaDescription.setMaxLines(maxLines); mediaShowAll.setImageResource(iconCollapseResId); } isDescriptionExpanded = !isDescriptionExpanded; } }); } else { mediaDescriptionContainer.setVisibility(View.GONE); } // Images DisplayMetrics displayMetrics = new DisplayMetrics(); getActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); String fanart = cursor.getString(AlbumDetailsQuery.FANART), poster = cursor.getString(AlbumDetailsQuery.THUMBNAIL); int artHeight = resources.getDimensionPixelOffset(R.dimen.now_playing_art_height), artWidth = displayMetrics.widthPixels; if (!TextUtils.isEmpty(fanart)) { int posterWidth = resources.getDimensionPixelOffset(R.dimen.albumdetail_poster_width); int posterHeight = resources.getDimensionPixelOffset(R.dimen.albumdetail_poster_heigth); mediaPoster.setVisibility(View.VISIBLE); UIUtils.loadImageWithCharacterAvatar(getActivity(), hostManager, poster, albumTitle, 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); } }
From source file:com.tct.mail.browse.ConversationItemView.java
private static synchronized void getItemViewResources(Context context) { if (sConfigurationChangedReceiver == null) { sConfigurationChangedReceiver = new BroadcastReceiver() { @Override/*from w ww . j a v a 2s . c om*/ public void onReceive(Context context, Intent intent) { STAR_OFF = null; //[BUGFIX]-Mod-BEGIN by TCTNB.caixia.chen,01/07/2015,PR 893304 getItemViewResources(context.getApplicationContext()); //[BUGFIX]-Mod-END by TCTNB.caixia.chen } }; context.registerReceiver(sConfigurationChangedReceiver, new IntentFilter(Intent.ACTION_CONFIGURATION_CHANGED)); } if (STAR_OFF == null) { final Resources res = context.getResources(); // Initialize static bitmaps. //TS: junwei-xu 2015-09-02 EMAIL BUGFIX-546917 MOD-S // star off will not show in list item. //STAR_OFF = BitmapFactory.decodeResource(res, R.drawable.ic_star_outline_20dp); STAR_OFF = BitmapFactory.decodeResource(res, R.drawable.ic_importance_normal); //TS: junwei-xu 2015-09-02 EMAIL BUGFIX-546917 MOD-S STAR_ON = BitmapFactory.decodeResource(res, R.drawable.ic_star_20dp); ATTACHMENT = BitmapFactory.decodeResource(res, R.drawable.ic_attach_file_20dp); ONLY_TO_ME = BitmapFactory.decodeResource(res, R.drawable.ic_email_caret_double); TO_ME_AND_OTHERS = BitmapFactory.decodeResource(res, R.drawable.ic_email_caret_single); IMPORTANT_ONLY_TO_ME = BitmapFactory.decodeResource(res, R.drawable.ic_email_caret_double_important_unread); IMPORTANT_TO_ME_AND_OTHERS = BitmapFactory.decodeResource(res, R.drawable.ic_email_caret_single_important_unread); IMPORTANT = BitmapFactory.decodeResource(res, R.drawable.ic_email_caret_none_important_unread); STATE_REPLIED = BitmapFactory.decodeResource(res, R.drawable.ic_badge_reply_holo_light); STATE_FORWARDED = BitmapFactory.decodeResource(res, R.drawable.ic_badge_forward_holo_light); STATE_REPLIED_AND_FORWARDED = BitmapFactory.decodeResource(res, R.drawable.ic_badge_reply_forward_holo_light); STATE_CALENDAR_INVITE = BitmapFactory.decodeResource(res, R.drawable.ic_badge_invite_holo_light); VISIBLE_CONVERSATION_HIGHLIGHT = res.getDrawable(R.drawable.visible_conversation_highlight); RIGHT_EDGE_TABLET = res.getDrawable(R.drawable.list_edge_tablet); //[FEATURE]-Add-BEGIN by TSCD.chao zhang,04/17/2014,FR 631895(porting from FR514398) sHighPriorityIcon = BitmapFactory.decodeResource(res, R.drawable.ic_high_priority); sLowPriorityIcon = BitmapFactory.decodeResource(res, R.drawable.ic_low_priority); sNormalPriorityIcon = BitmapFactory.decodeResource(res, R.drawable.ic_importance_normal); //[FEATURE]-Add-END by TSCD.chao zhang // Initialize colors. sActivatedTextSpan = CharacterStyle .wrap(new ForegroundColorSpan(res.getColor(R.color.senders_text_color))); sSendersTextColor = res.getColor(R.color.senders_text_color); sSubjectTextUnreadSpan = new TextAppearanceSpan(context, R.style.SubjectAppearanceUnreadStyle); sSubjectTextReadSpan = new TextAppearanceSpan(context, R.style.SubjectAppearanceReadStyle); sBadgeTextSpan = new TextAppearanceSpan(context, R.style.BadgeTextStyle); sBadgeBackgroundSpan = new BackgroundColorSpan(res.getColor(R.color.badge_background_color)); sDateTextColorRead = res.getColor(R.color.date_text_color_read); sDateTextColorUnread = res.getColor(R.color.date_text_color_unread); sStarTouchSlop = res.getDimensionPixelSize(R.dimen.star_touch_slop); sSenderImageTouchSlop = res.getDimensionPixelSize(R.dimen.sender_image_touch_slop); sShrinkAnimationDuration = res.getInteger(R.integer.shrink_animation_duration); sSlideAnimationDuration = res.getInteger(R.integer.slide_animation_duration); // Initialize static color. sSendersSplitToken = res.getString(R.string.senders_split_token); sElidedPaddingToken = res.getString(R.string.elided_padding_token); sScrollSlop = res.getInteger(R.integer.swipeScrollSlop); sFoldersStartPadding = res.getDimensionPixelOffset(R.dimen.folders_start_padding); sFoldersInnerPadding = res.getDimensionPixelOffset(R.dimen.folder_cell_content_padding); sFoldersMaxCount = res.getInteger(R.integer.conversation_list_max_folder_count); sFoldersOverflowGradientPadding = res.getDimensionPixelOffset(R.dimen.folders_gradient_padding); sCabAnimationDuration = res.getInteger(R.integer.conv_item_view_cab_anim_duration); sBadgePaddingExtraWidth = res.getDimensionPixelSize(R.dimen.badge_padding_extra_width); sBadgeRoundedCornerRadius = res.getDimensionPixelSize(R.dimen.badge_rounded_corner_radius); sFolderRoundedCornerRadius = res.getDimensionPixelOffset(R.dimen.folder_rounded_corner_radius); sDividerColor = res.getColor(R.color.conversation_list_divider_color); sDividerInset = res.getDimensionPixelSize(R.dimen.conv_list_divider_inset); sDividerHeight = res.getDimensionPixelSize(R.dimen.divider_height); } }