List of usage examples for android.content.res Resources getDimensionPixelOffset
public int getDimensionPixelOffset(@DimenRes int id) throws NotFoundException
From source file:org.xbmc.kore.service.NotificationObserver.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) private void buildNotification(PlayerType.GetActivePlayersReturnType getActivePlayerResult, PlayerType.PropertyValue getPropertiesResult, ListType.ItemsAll getItemResult) { final String title, underTitle, poster; int smallIcon, playPauseIcon, rewindIcon, ffIcon; boolean isVideo = ((getItemResult.type.equals(ListType.ItemsAll.TYPE_MOVIE)) || (getItemResult.type.equals(ListType.ItemsAll.TYPE_EPISODE))); switch (getItemResult.type) { case ListType.ItemsAll.TYPE_MOVIE: title = getItemResult.title;//from ww w . j a v a 2 s .c om underTitle = getItemResult.tagline; poster = getItemResult.thumbnail; smallIcon = R.drawable.ic_movie_white_24dp; break; case ListType.ItemsAll.TYPE_EPISODE: title = getItemResult.title; String seasonEpisode = String.format(mContext.getString(R.string.season_episode_abbrev), getItemResult.season, getItemResult.episode); underTitle = String.format("%s | %s", getItemResult.showtitle, seasonEpisode); poster = getItemResult.art.poster; smallIcon = R.drawable.ic_tv_white_24dp; break; case ListType.ItemsAll.TYPE_SONG: title = getItemResult.title; underTitle = getItemResult.displayartist + " | " + getItemResult.album; poster = getItemResult.thumbnail; smallIcon = R.drawable.ic_headset_white_24dp; break; case ListType.ItemsAll.TYPE_MUSIC_VIDEO: title = getItemResult.title; underTitle = Utils.listStringConcat(getItemResult.artist, ", ") + " | " + getItemResult.album; poster = getItemResult.thumbnail; smallIcon = R.drawable.ic_headset_white_24dp; break; default: // We don't know what this is, forget it return; } switch (getPropertiesResult.speed) { case 1: playPauseIcon = R.drawable.ic_pause_white_24dp; break; default: playPauseIcon = R.drawable.ic_play_arrow_white_24dp; break; } // Create the actions, depending on the type of media PendingIntent rewindPendingItent, ffPendingItent, playPausePendingIntent; playPausePendingIntent = buildActionPendingIntent(getActivePlayerResult.playerid, IntentActionsService.ACTION_PLAY_PAUSE); if (getItemResult.type.equals(ListType.ItemsAll.TYPE_SONG)) { rewindPendingItent = buildActionPendingIntent(getActivePlayerResult.playerid, IntentActionsService.ACTION_PREVIOUS); rewindIcon = R.drawable.ic_skip_previous_white_24dp; ffPendingItent = buildActionPendingIntent(getActivePlayerResult.playerid, IntentActionsService.ACTION_NEXT); ffIcon = R.drawable.ic_skip_next_white_24dp; } else { rewindPendingItent = buildActionPendingIntent(getActivePlayerResult.playerid, IntentActionsService.ACTION_REWIND); rewindIcon = R.drawable.ic_fast_rewind_white_24dp; ffPendingItent = buildActionPendingIntent(getActivePlayerResult.playerid, IntentActionsService.ACTION_FAST_FORWARD); ffIcon = R.drawable.ic_fast_forward_white_24dp; } // Setup the collpased and expanded notifications final RemoteViews collapsedRV = new RemoteViews(mContext.getPackageName(), R.layout.notification_colapsed); collapsedRV.setImageViewResource(R.id.rewind, rewindIcon); collapsedRV.setOnClickPendingIntent(R.id.rewind, rewindPendingItent); collapsedRV.setImageViewResource(R.id.play, playPauseIcon); collapsedRV.setOnClickPendingIntent(R.id.play, playPausePendingIntent); collapsedRV.setImageViewResource(R.id.fast_forward, ffIcon); collapsedRV.setOnClickPendingIntent(R.id.fast_forward, ffPendingItent); collapsedRV.setTextViewText(R.id.title, title); collapsedRV.setTextViewText(R.id.text2, underTitle); final RemoteViews expandedRV = new RemoteViews(mContext.getPackageName(), R.layout.notification_expanded); expandedRV.setImageViewResource(R.id.rewind, rewindIcon); expandedRV.setOnClickPendingIntent(R.id.rewind, rewindPendingItent); expandedRV.setImageViewResource(R.id.play, playPauseIcon); expandedRV.setOnClickPendingIntent(R.id.play, playPausePendingIntent); expandedRV.setImageViewResource(R.id.fast_forward, ffIcon); expandedRV.setOnClickPendingIntent(R.id.fast_forward, ffPendingItent); expandedRV.setTextViewText(R.id.title, title); expandedRV.setTextViewText(R.id.text2, underTitle); final int expandedIconResId; if (isVideo) { expandedIconResId = R.id.icon_slim; expandedRV.setViewVisibility(R.id.icon_slim, View.VISIBLE); expandedRV.setViewVisibility(R.id.icon_square, View.GONE); } else { expandedIconResId = R.id.icon_square; expandedRV.setViewVisibility(R.id.icon_slim, View.GONE); expandedRV.setViewVisibility(R.id.icon_square, View.VISIBLE); } // Build the notification NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext); final Notification notification = builder.setSmallIcon(smallIcon).setShowWhen(false).setOngoing(true) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC) .setCategory(NotificationCompat.CATEGORY_TRANSPORT).setContentIntent(mRemoteStartPendingIntent) .setContent(collapsedRV).build(); // This is a convoluted way of loading the image and showing the // notification, but it's what works with Picasso and is efficient. // Here's what's going on: // // 1. The image is loaded asynchronously into a Target, and only after // it is loaded is the notification shown. Using targets is a lot more // efficient than letting Picasso load it directly into the // notification imageview, which causes a lot of flickering // // 2. The target needs to be static, because Picasso only keeps a weak // reference to it, so we need to keed a strong reference and reset it // to null when we're done. We also need to check if it is not null in // case a previous request hasn't finished yet. // // 3. We can only show the notification after the bitmap is loaded into // the target, so it is done in the callback // // 4. We specifically resize the image to the same dimensions used in // the remote, so that Picasso reuses it in the remote and here from the cache Resources resources = mContext.getResources(); final int posterWidth = resources.getDimensionPixelOffset(R.dimen.now_playing_poster_width); final int posterHeight = isVideo ? resources.getDimensionPixelOffset(R.dimen.now_playing_poster_height) : posterWidth; if (picassoTarget == null) { picassoTarget = new Target() { @Override public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) { showNotification(bitmap); } @Override public void onBitmapFailed(Drawable errorDrawable) { CharacterDrawable avatarDrawable = UIUtils.getCharacterAvatar(mContext, title); showNotification(Utils.drawableToBitmap(avatarDrawable, posterWidth, posterHeight)); } @Override public void onPrepareLoad(Drawable placeHolderDrawable) { } private void showNotification(Bitmap bitmap) { collapsedRV.setImageViewBitmap(R.id.icon, bitmap); if (Utils.isJellybeanOrLater()) { notification.bigContentView = expandedRV; expandedRV.setImageViewBitmap(expandedIconResId, bitmap); } NotificationManager notificationManager = (NotificationManager) mContext .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(NOTIFICATION_ID, notification); picassoTarget = null; } }; // Load the image HostManager hostManager = HostManager.getInstance(mContext); hostManager.getPicasso().load(hostManager.getHostInfo().getImageUrl(poster)) .resize(posterWidth, posterHeight).into(picassoTarget); } }
From source file:com.github.crvv.wubinput.wubi.dictionary.suggestions.SuggestionStripView.java
public SuggestionStripView(final Context context, final AttributeSet attrs, final int defStyle) { super(context, attrs, defStyle); final LayoutInflater inflater = LayoutInflater.from(context); inflater.inflate(R.layout.suggestions_strip, this); mSuggestionsStrip = (ViewGroup) findViewById(R.id.suggestions_strip); mStripVisibilityGroup = new StripVisibilityGroup(this, mSuggestionsStrip, null, null); for (int pos = 0; pos < SuggestedWords.MAX_SUGGESTIONS; pos++) { final TextView word = new TextView(context, null, R.attr.suggestionWordStyle); word.setOnClickListener(this); word.setOnLongClickListener(this); mWordViews.add(word);//w w w.j av a 2 s . c om final View divider = inflater.inflate(R.layout.suggestion_divider, null); mDividerViews.add(divider); final TextView info = new TextView(context, null, R.attr.suggestionWordStyle); info.setTextColor(Color.WHITE); info.setTextSize(TypedValue.COMPLEX_UNIT_DIP, DEBUG_INFO_TEXT_SIZE_IN_DIP); } mLayoutHelper = new SuggestionStripLayoutHelper(context, attrs, defStyle, mWordViews, mDividerViews, null); mMoreSuggestionsContainer = inflater.inflate(R.layout.more_suggestions, null); mMoreSuggestionsView = (MoreSuggestionsView) mMoreSuggestionsContainer .findViewById(R.id.more_suggestions_view); mMoreSuggestionsBuilder = new MoreSuggestions.Builder(context, mMoreSuggestionsView); final Resources res = context.getResources(); mMoreSuggestionsModalTolerance = res .getDimensionPixelOffset(R.dimen.config_more_suggestions_modal_tolerance); mMoreSuggestionsSlidingDetector = new GestureDetector(context, mMoreSuggestionsSlidingListener); final TypedArray keyboardAttr = context.obtainStyledAttributes(attrs, R.styleable.Keyboard, defStyle, R.style.SuggestionStripView); keyboardAttr.recycle(); }
From source file:com.syncedsynapse.kore2.ui.AddonDetailsFragment.java
/** * Display the addon details/*from ww w. j a va2s .c om*/ * * @param addonDetails Addon details */ private void displayAddonDetails(AddonType.Details addonDetails) { mediaTitle.setText(addonDetails.name); mediaUndertitle.setText(addonDetails.summary); mediaAuthor.setText(addonDetails.author); mediaVersion.setText(addonDetails.version); mediaDescription.setText(addonDetails.description); // Images Resources resources = getActivity().getResources(); DisplayMetrics displayMetrics = new DisplayMetrics(); getActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); int artHeight = resources.getDimensionPixelOffset(R.dimen.now_playing_art_height), artWidth = displayMetrics.widthPixels; if (!TextUtils.isEmpty(addonDetails.fanart)) { int posterWidth = resources.getDimensionPixelOffset(R.dimen.addondetail_poster_width); int posterHeight = resources.getDimensionPixelOffset(R.dimen.addondetail_poster_heigth); mediaPoster.setVisibility(View.VISIBLE); UIUtils.loadImageIntoImageview(hostManager, addonDetails.thumbnail, mediaPoster, posterWidth, posterHeight); UIUtils.loadImageIntoImageview(hostManager, addonDetails.fanart, mediaArt, artWidth, artHeight); } else { // No fanart, just present the poster mediaPoster.setVisibility(View.GONE); UIUtils.loadImageIntoImageview(hostManager, addonDetails.thumbnail, 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); } setupEnableButton(addonDetails.enabled); }
From source file:com.android.mail.ui.FolderDisplayer.java
protected void initializeDrawableResources() { // Set default values used across all folder chips final Resources res = mContext.getResources(); mFolderDrawableResources.defaultFgColor = res.getColor(R.color.default_folder_foreground_color); mFolderDrawableResources.defaultBgColor = res.getColor(R.color.default_folder_background_color); mFolderDrawableResources.folderRoundedCornerRadius = res .getDimensionPixelOffset(R.dimen.folder_rounded_corner_radius); mFolderDrawableResources.folderInBetweenPadding = res.getDimensionPixelOffset(R.dimen.folder_start_padding); }
From source file:com.syncedsynapse.kore2.service.NotificationService.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) private void buildNotification(PlayerType.GetActivePlayersReturnType getActivePlayerResult, PlayerType.PropertyValue getPropertiesResult, ListType.ItemsAll getItemResult) { final String title, underTitle, poster; int smallIcon, playPauseIcon, rewindIcon, ffIcon; boolean isVideo = ((getItemResult.type.equals(ListType.ItemsAll.TYPE_MOVIE)) || (getItemResult.type.equals(ListType.ItemsAll.TYPE_EPISODE))); switch (getItemResult.type) { case ListType.ItemsAll.TYPE_MOVIE: title = getItemResult.title;/*from w ww .j ava2 s .com*/ underTitle = getItemResult.tagline; poster = getItemResult.thumbnail; smallIcon = R.drawable.ic_movie_white_24dp; break; case ListType.ItemsAll.TYPE_EPISODE: title = getItemResult.title; String seasonEpisode = String.format(getString(R.string.season_episode_abbrev), getItemResult.season, getItemResult.episode); underTitle = String.format("%s | %s", getItemResult.showtitle, seasonEpisode); poster = getItemResult.art.poster; smallIcon = R.drawable.ic_tv_white_24dp; break; case ListType.ItemsAll.TYPE_SONG: title = getItemResult.title; underTitle = getItemResult.displayartist + " | " + getItemResult.album; poster = getItemResult.thumbnail; smallIcon = R.drawable.ic_headset_white_24dp; break; case ListType.ItemsAll.TYPE_MUSIC_VIDEO: title = getItemResult.title; underTitle = Utils.listStringConcat(getItemResult.artist, ", ") + " | " + getItemResult.album; poster = getItemResult.thumbnail; smallIcon = R.drawable.ic_headset_white_24dp; break; default: // We don't know what this is, forget it return; } switch (getPropertiesResult.speed) { case 1: playPauseIcon = R.drawable.ic_pause_white_24dp; break; default: playPauseIcon = R.drawable.ic_play_arrow_white_24dp; break; } // Create the actions, depending on the type of media PendingIntent rewindPendingItent, ffPendingItent, playPausePendingIntent; playPausePendingIntent = buildActionPendingIntent(getActivePlayerResult.playerid, IntentActionsService.ACTION_PLAY_PAUSE); if (getItemResult.type.equals(ListType.ItemsAll.TYPE_SONG)) { rewindPendingItent = buildActionPendingIntent(getActivePlayerResult.playerid, IntentActionsService.ACTION_PREVIOUS); rewindIcon = R.drawable.ic_skip_previous_white_24dp; ffPendingItent = buildActionPendingIntent(getActivePlayerResult.playerid, IntentActionsService.ACTION_NEXT); ffIcon = R.drawable.ic_skip_next_white_24dp; } else { rewindPendingItent = buildActionPendingIntent(getActivePlayerResult.playerid, IntentActionsService.ACTION_REWIND); rewindIcon = R.drawable.ic_fast_rewind_white_24dp; ffPendingItent = buildActionPendingIntent(getActivePlayerResult.playerid, IntentActionsService.ACTION_FAST_FORWARD); ffIcon = R.drawable.ic_fast_forward_white_24dp; } // Setup the collpased and expanded notifications final RemoteViews collapsedRV = new RemoteViews(this.getPackageName(), R.layout.notification_colapsed); collapsedRV.setImageViewResource(R.id.rewind, rewindIcon); collapsedRV.setOnClickPendingIntent(R.id.rewind, rewindPendingItent); collapsedRV.setImageViewResource(R.id.play, playPauseIcon); collapsedRV.setOnClickPendingIntent(R.id.play, playPausePendingIntent); collapsedRV.setImageViewResource(R.id.fast_forward, ffIcon); collapsedRV.setOnClickPendingIntent(R.id.fast_forward, ffPendingItent); collapsedRV.setTextViewText(R.id.title, title); collapsedRV.setTextViewText(R.id.text2, underTitle); final RemoteViews expandedRV = new RemoteViews(this.getPackageName(), R.layout.notification_expanded); expandedRV.setImageViewResource(R.id.rewind, rewindIcon); expandedRV.setOnClickPendingIntent(R.id.rewind, rewindPendingItent); expandedRV.setImageViewResource(R.id.play, playPauseIcon); expandedRV.setOnClickPendingIntent(R.id.play, playPausePendingIntent); expandedRV.setImageViewResource(R.id.fast_forward, ffIcon); expandedRV.setOnClickPendingIntent(R.id.fast_forward, ffPendingItent); expandedRV.setTextViewText(R.id.title, title); expandedRV.setTextViewText(R.id.text2, underTitle); final int expandedIconResId; if (isVideo) { expandedIconResId = R.id.icon_slim; expandedRV.setViewVisibility(R.id.icon_slim, View.VISIBLE); expandedRV.setViewVisibility(R.id.icon_square, View.GONE); } else { expandedIconResId = R.id.icon_square; expandedRV.setViewVisibility(R.id.icon_slim, View.GONE); expandedRV.setViewVisibility(R.id.icon_square, View.VISIBLE); } // Build the notification NotificationCompat.Builder builder = new NotificationCompat.Builder(this); final Notification notification = builder.setSmallIcon(smallIcon).setShowWhen(false).setOngoing(true) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC) .setCategory(NotificationCompat.CATEGORY_TRANSPORT).setContentIntent(mRemoteStartPendingIntent) .setContent(collapsedRV).build(); // This is a convoluted way of loading the image and showing the // notification, but it's what works with Picasso and is efficient. // Here's what's going on: // // 1. The image is loaded asynchronously into a Target, and only after // it is loaded is the notification shown. Using targets is a lot more // efficient than letting Picasso load it directly into the // notification imageview, which causes a lot of flickering // // 2. The target needs to be static, because Picasso only keeps a weak // reference to it, so we need to keed a strong reference and reset it // to null when we're done. We also need to check if it is not null in // case a previous request hasn't finished yet. // // 3. We can only show the notification after the bitmap is loaded into // the target, so it is done in the callback // // 4. We specifically resize the image to the same dimensions used in // the remote, so that Picasso reuses it in the remote and here from the cache Resources resources = this.getResources(); final int posterWidth = resources.getDimensionPixelOffset(R.dimen.now_playing_poster_width); final int posterHeight = isVideo ? resources.getDimensionPixelOffset(R.dimen.now_playing_poster_height) : posterWidth; if (picassoTarget == null) { picassoTarget = new Target() { @Override public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) { showNotification(bitmap); } @Override public void onBitmapFailed(Drawable errorDrawable) { CharacterDrawable avatarDrawable = UIUtils.getCharacterAvatar(NotificationService.this, title); showNotification(Utils.drawableToBitmap(avatarDrawable, posterWidth, posterHeight)); } @Override public void onPrepareLoad(Drawable placeHolderDrawable) { } private void showNotification(Bitmap bitmap) { collapsedRV.setImageViewBitmap(R.id.icon, bitmap); if (Utils.isJellybeanOrLater()) { notification.bigContentView = expandedRV; expandedRV.setImageViewBitmap(expandedIconResId, bitmap); } NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(NOTIFICATION_ID, notification); picassoTarget = null; } }; // Load the image HostManager hostManager = HostManager.getInstance(this); hostManager.getPicasso().load(hostManager.getHostInfo().getImageUrl(poster)) .resize(posterWidth, posterHeight).into(picassoTarget); } }
From source file:com.android.inputmethod.latin.suggestions.SuggestionStripView.java
public SuggestionStripView(final Context context, final AttributeSet attrs, final int defStyle) { super(context, attrs, defStyle); final LayoutInflater inflater = LayoutInflater.from(context); inflater.inflate(R.layout.suggestions_strip, this); mSuggestionsStrip = (ViewGroup) findViewById(R.id.suggestions_strip); mVoiceKey = (ImageButton) findViewById(R.id.suggestions_strip_voice_key); mImportantNoticeStrip = findViewById(R.id.important_notice_strip); mStripVisibilityGroup = new StripVisibilityGroup(this, mSuggestionsStrip, mImportantNoticeStrip); for (int pos = 0; pos < SuggestedWords.MAX_SUGGESTIONS; pos++) { final TextView word = new TextView(context, null, R.attr.suggestionWordStyle); word.setContentDescription(getResources().getString(R.string.spoken_empty_suggestion)); word.setOnClickListener(this); word.setOnLongClickListener(this); mWordViews.add(word);/*from w w w .j a va 2 s.c o m*/ final View divider = inflater.inflate(R.layout.suggestion_divider, null); mDividerViews.add(divider); final TextView info = new TextView(context, null, R.attr.suggestionWordStyle); info.setTextColor(Color.WHITE); info.setTextSize(TypedValue.COMPLEX_UNIT_DIP, DEBUG_INFO_TEXT_SIZE_IN_DIP); mDebugInfoViews.add(info); } mLayoutHelper = new SuggestionStripLayoutHelper(context, attrs, defStyle, mWordViews, mDividerViews, mDebugInfoViews); mMoreSuggestionsContainer = inflater.inflate(R.layout.more_suggestions, null); mMoreSuggestionsView = (MoreSuggestionsView) mMoreSuggestionsContainer .findViewById(R.id.more_suggestions_view); mMoreSuggestionsBuilder = new MoreSuggestions.Builder(context, mMoreSuggestionsView); final Resources res = context.getResources(); mMoreSuggestionsModalTolerance = res .getDimensionPixelOffset(R.dimen.config_more_suggestions_modal_tolerance); mMoreSuggestionsSlidingDetector = new GestureDetector(context, mMoreSuggestionsSlidingListener); final TypedArray keyboardAttr = context.obtainStyledAttributes(attrs, R.styleable.Keyboard, defStyle, R.style.SuggestionStripView); final Drawable iconVoice = keyboardAttr.getDrawable(R.styleable.Keyboard_iconShortcutKey); keyboardAttr.recycle(); mVoiceKey.setImageDrawable(iconVoice); mVoiceKey.setOnClickListener(this); }
From source file:org.xbmc.kore.ui.AddonDetailsFragment.java
private void setImages(String poster, String fanart) { Resources resources = getActivity().getResources(); 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.addondetail_poster_width); int posterHeight = resources.getDimensionPixelOffset(R.dimen.addondetail_poster_height); UIUtils.loadImageIntoImageview(hostManager, TextUtils.isEmpty(fanart) ? poster : fanart, mediaArt, artWidth, artHeight);// ww w . j av a 2 s . c o m UIUtils.loadImageIntoImageview(hostManager, poster, mediaPoster, posterWidth, posterHeight); }
From source file:com.mobiletin.inputmethod.indic.suggestions.SuggestionStripView.java
public SuggestionStripView(final Context context, final AttributeSet attrs, final int defStyle) { super(context, attrs, defStyle); final LayoutInflater inflater = LayoutInflater.from(context); inflater.inflate(R.layout.suggestions_strip, this); mSuggestionsStrip = (ViewGroup) findViewById(R.id.suggestions_strip); mVoiceKey = (ImageButton) findViewById(R.id.suggestions_strip_voice_key); mAddToDictionaryStrip = (ViewGroup) findViewById(R.id.add_to_dictionary_strip); mImportantNoticeStrip = findViewById(R.id.important_notice_strip); mStripVisibilityGroup = new StripVisibilityGroup(this, mSuggestionsStrip, mAddToDictionaryStrip, mImportantNoticeStrip);//from www . ja v a 2s. c o m for (int pos = 0; pos < SuggestedWords.MAX_SUGGESTIONS; pos++) { final TextView word = new TextView(context, null, R.attr.suggestionWordStyle); word.setOnClickListener(this); word.setOnLongClickListener(this); mWordViews.add(word); final View divider = inflater.inflate(R.layout.suggestion_divider, null); mDividerViews.add(divider); final TextView info = new TextView(context, null, R.attr.suggestionWordStyle); info.setTextColor(Color.WHITE); info.setTextSize(TypedValue.COMPLEX_UNIT_DIP, DEBUG_INFO_TEXT_SIZE_IN_DIP); mDebugInfoViews.add(info); } mLayoutHelper = new SuggestionStripLayoutHelper(context, attrs, defStyle, mWordViews, mDividerViews, mDebugInfoViews); mMoreSuggestionsContainer = inflater.inflate(R.layout.more_suggestions, null); mMoreSuggestionsView = (MoreSuggestionsView) mMoreSuggestionsContainer .findViewById(R.id.more_suggestions_view); mMoreSuggestionsBuilder = new MoreSuggestions.Builder(context, mMoreSuggestionsView); final Resources res = context.getResources(); mMoreSuggestionsModalTolerance = res .getDimensionPixelOffset(R.dimen.config_more_suggestions_modal_tolerance); mMoreSuggestionsSlidingDetector = new GestureDetector(context, mMoreSuggestionsSlidingListener); final TypedArray keyboardAttr = context.obtainStyledAttributes(attrs, R.styleable.Keyboard, defStyle, R.style.SuggestionStripView); final Drawable iconVoice = keyboardAttr.getDrawable(R.styleable.Keyboard_iconShortcutKey); keyboardAttr.recycle(); mVoiceKey.setImageDrawable(iconVoice); mVoiceKey.setOnClickListener(this); }
From source file:com.hippo.widget.Slider.java
@SuppressWarnings("deprecation") private void init(Context context, AttributeSet attrs) { mContext = context;//from w w w. j av a2 s .c o m mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); Paint textPaint = new Paint(Paint.ANTI_ALIAS_FLAG); textPaint.setTextAlign(Paint.Align.CENTER); Resources resources = context.getResources(); mBubbleMinWidth = resources.getDimensionPixelOffset(R.dimen.slider_bubble_width); mBubbleMinHeight = resources.getDimensionPixelOffset(R.dimen.slider_bubble_height); mBubble = new BubbleView(context, textPaint); mBubble.setScaleX(0.0f); mBubble.setScaleY(0.0f); AbsoluteLayout absoluteLayout = new AbsoluteLayout(context); absoluteLayout.addView(mBubble); absoluteLayout.setBackgroundDrawable(null); mPopup = new PopupWindow(absoluteLayout); mPopup.setOutsideTouchable(false); mPopup.setTouchable(false); mPopup.setFocusable(false); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Slider); textPaint.setColor(a.getColor(R.styleable.Slider_textColor, Color.WHITE)); textPaint.setTextSize(a.getDimensionPixelSize(R.styleable.Slider_textSize, 12)); updateTextSize(); setRange(a.getInteger(R.styleable.Slider_start, 0), a.getInteger(R.styleable.Slider_end, 0)); setProgress(a.getInteger(R.styleable.Slider_slider_progress, 0)); mThickness = a.getDimension(R.styleable.Slider_thickness, 2); mRadius = a.getDimension(R.styleable.Slider_radius, 6); setColor(a.getColor(R.styleable.Slider_color, Color.BLACK)); mBgPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mBgPaint.setColor(a.getBoolean(R.styleable.Slider_dark, false) ? 0x4dffffff : 0x42000000); a.recycle(); mProgressAnimation = new ValueAnimator(); mProgressAnimation.setInterpolator(AnimationUtils.FAST_SLOW_INTERPOLATOR); mProgressAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(@NonNull ValueAnimator animation) { float value = (Float) animation.getAnimatedValue(); mDrawPercent = value; mDrawProgress = Math.round(MathUtils.lerp((float) mStart, mEnd, value)); updateBubblePosition(); mBubble.setProgress(mDrawProgress); invalidate(); } }); mBubbleScaleAnimation = new ValueAnimator(); mBubbleScaleAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(@NonNull ValueAnimator animation) { float value = (Float) animation.getAnimatedValue(); mDrawBubbleScale = value; mBubble.setScaleX(value); mBubble.setScaleY(value); invalidate(); } }); }
From source file:org.xbmc.kore.ui.TVShowOverviewFragment.java
/** * Display the tv show details//from ww w .ja va 2 s . co m * * @param cursor Cursor with the data */ private void displayTVShowDetails(Cursor cursor) { LogUtils.LOGD(TAG, "displayTVShowDetails"); cursor.moveToFirst(); tvshowTitle = cursor.getString(TVShowDetailsQuery.TITLE); mediaTitle.setText(tvshowTitle); int numEpisodes = cursor.getInt(TVShowDetailsQuery.EPISODE), watchedEpisodes = cursor.getInt(TVShowDetailsQuery.WATCHEDEPISODES); setMediaUndertitle(numEpisodes, watchedEpisodes); setMediaPremiered(cursor.getString(TVShowDetailsQuery.PREMIERED), cursor.getString(TVShowDetailsQuery.STUDIO)); mediaGenres.setText(cursor.getString(TVShowDetailsQuery.GENRES)); setMediaRating(cursor.getDouble(TVShowDetailsQuery.RATING)); 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(), getHostManager(), cursor.getString(TVShowDetailsQuery.THUMBNAIL), tvshowTitle, mediaPoster, posterWidth, posterHeight); int artHeight = resources.getDimensionPixelOffset(R.dimen.now_playing_art_height); UIUtils.loadImageIntoImageview(getHostManager(), cursor.getString(TVShowDetailsQuery.FANART), mediaArt, displayMetrics.widthPixels, artHeight); }