List of usage examples for android.content.res Resources getDimensionPixelOffset
public int getDimensionPixelOffset(@DimenRes int id) throws NotFoundException
From source file:com.hippo.ehviewer.ui.scene.FavoritesScene.java
@Nullable @Override//from www . j a v a 2s. c o m public View onCreateView2(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.scene_favorites, container, false); ContentLayout contentLayout = (ContentLayout) view.findViewById(R.id.content_layout); mRecyclerView = contentLayout.getRecyclerView(); FastScroller fastScroller = contentLayout.getFastScroller(); RefreshLayout refreshLayout = contentLayout.getRefreshLayout(); mSearchBar = (SearchBar) ViewUtils.$$(view, R.id.search_bar); mFabLayout = (FabLayout) ViewUtils.$$(view, R.id.fab_layout); Context context = getContext2(); Assert.assertNotNull(context); Resources resources = context.getResources(); int paddingTopSB = resources.getDimensionPixelOffset(R.dimen.gallery_padding_top_search_bar); mHelper = new FavoritesHelper(); mHelper.setEmptyString(resources.getString(R.string.gallery_list_empty_hit)); contentLayout.setHelper(mHelper); contentLayout.getFastScroller().setOnDragHandlerListener(this); mAdapter = new FavoritesAdapter(inflater, resources, mRecyclerView, Settings.getListMode()); mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, false)); mRecyclerView.setDrawSelectorOnTop(true); mRecyclerView.hasFixedSize(); mRecyclerView.setClipToPadding(false); mRecyclerView.setOnItemClickListener(this); mRecyclerView.setOnItemLongClickListener(this); mRecyclerView.setChoiceMode(EasyRecyclerView.CHOICE_MODE_MULTIPLE_CUSTOM); mRecyclerView.setCustomCheckedListener(this); fastScroller.setPadding(fastScroller.getPaddingLeft(), fastScroller.getPaddingTop() + paddingTopSB, fastScroller.getPaddingRight(), fastScroller.getPaddingBottom()); refreshLayout.setHeaderTranslationY(paddingTopSB); mLeftDrawable = new DrawerArrowDrawable(context); mSearchBar.setLeftDrawable(mLeftDrawable); mSearchBar.setRightDrawable(DrawableManager.getDrawable(context, R.drawable.v_magnify_x24)); mSearchBar.setHelper(this); mSearchBar.setAllowEmptySearch(false); updateSearchBar(); mSearchBarMover = new SearchBarMover(this, mSearchBar, mRecyclerView); mFabLayout.setExpanded(false, false); mFabLayout.setAutoCancel(false); mFabLayout.setHidePrimaryFab(true); mFabLayout.setOnClickFabListener(this); addAboveSnackView(mFabLayout); // Restore search mode if (mSearchMode) { mSearchMode = false; enterSearchMode(false); } // Only refresh for the first time if (!mHasFirstRefresh) { mHasFirstRefresh = true; mHelper.firstRefresh(); } guideCollections(); return view; }
From source file:io.doist.datetimepicker.date.SimpleMonthView.java
public SimpleMonthView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); final Resources res = context.getResources(); mDayOfWeekTypeface = res.getString(R.string.day_of_week_label_typeface); mMonthTitleTypeface = res.getString(R.string.sans_serif); mStringBuilder = new StringBuilder(50); mFormatter = new Formatter(mStringBuilder, Locale.getDefault()); mMiniDayNumberTextSize = res.getDimensionPixelSize(R.dimen.datepicker_day_number_size); mMonthLabelTextSize = res.getDimensionPixelSize(R.dimen.datepicker_month_label_size); mMonthDayLabelTextSize = res.getDimensionPixelSize(R.dimen.datepicker_month_day_label_text_size); mMonthHeaderSize = res.getDimensionPixelOffset(R.dimen.datepicker_month_list_item_header_height); mDaySelectedCircleSize = res.getDimensionPixelSize(R.dimen.datepicker_day_number_select_circle_radius); mRowHeight = (res.getDimensionPixelOffset(R.dimen.datepicker_view_animator_height) - mMonthHeaderSize) / MAX_NUM_ROWS;//from w ww . j a va 2 s . co m // Set up accessibility components. mTouchHelper = new MonthViewTouchHelper(this); ViewCompat.setAccessibilityDelegate(this, mTouchHelper); ViewCompat.setImportantForAccessibility(this, IMPORTANT_FOR_ACCESSIBILITY_YES); mLockAccessibilityDelegate = true; // Sets up any standard paints that will be used initView(); }
From source file:com.edgar.banner.BannerPagerView.java
private void init(AttributeSet attrs, int defStyle) { Context context = getContext(); Resources resource = context.getResources(); LayoutInflater.from(getContext()).inflate(R.layout.banner_layout, this, true); mViewPage = (LoopViewPager) findViewById(R.id.carouse_viewpager); setBannerScroller(new BannerScroller(getContext())); mViewPage.setOverScrollMode(View.OVER_SCROLL_NEVER); mViewPage.setOnPageChangeListener(mCarousePageListener); mBannerPageAdapter = new DefaultBannerPageViewAdapter(); mIndicatorParams.gravity = Gravity.BOTTOM; mPointPadding = resource.getDimensionPixelOffset(R.dimen.point_margin); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.BannerPagerView, defStyle, 0); int N = a.getIndexCount(); for (int i = 0; i < N; i++) { int attr = a.getIndex(i); if (attr == R.styleable.BannerPagerView_bannerAnimation) { int transformerType = a.getInt(attr, 0); setBannerPageTransformer(true, TransformerType.convert(transformerType)); } else if (attr == R.styleable.BannerPagerView_enableAutoPlayer) { setEnableAutoPlay(a.getBoolean(attr, false)); } else if (attr == R.styleable.BannerPagerView_indicatorStyle) { mIndicatorStyle = a.getInt(attr, IndicatorStyle.CIRCLE_INDICATOR); } else if (attr == R.styleable.BannerPagerView_indicatorLayout) { int resId = a.getResourceId(attr, 0); if (resId != 0) { View indicatorView = LayoutInflater.from(context).inflate(resId, this, false); if (!(indicatorView instanceof BannerIndicator)) { throw new IllegalArgumentException("Your indicator must implements BannerIndicator."); }//ww w. j a v a 2 s .c om mIndicatorView = indicatorView; mBannerIndicator = (BannerIndicator) indicatorView; addView(mIndicatorView); } } else if (attr == R.styleable.BannerPagerView_unSelectDrawable) { mUnSelectedDrawable = a.getDrawable(attr); } else if (attr == R.styleable.BannerPagerView_selectedDrawable) { mSelectedDrawable = a.getDrawable(attr); } else if (attr == R.styleable.BannerPagerView_indicatorGravity) { mIndicatorGravity = a.getInt(attr, Gravity.CENTER); } else if (attr == R.styleable.BannerPagerView_pointPadding) { mPointPadding = a.getDimensionPixelOffset(attr, mPointPadding); } else if (attr == R.styleable.BannerPagerView_indicatorBackground) { mIndicatorBackground = a.getDrawable(attr); } } if (mUnSelectedDrawable == null) { mUnSelectedDrawable = ContextCompat.getDrawable(context, R.drawable.def_circle_normal_background); } if (mSelectedDrawable == null) { mSelectedDrawable = ContextCompat.getDrawable(context, R.drawable.def_circle_selected_background); } if (mIndicatorBackground == null) { mIndicatorBackground = new ColorDrawable(resource.getColor(R.color.indicator_background)); } if (mBannerIndicator == null) { setIndicatorStyle(mIndicatorStyle); } a.recycle(); }
From source file:org.xbmc.kore.ui.sections.remote.NowPlayingFragment.java
/** * Sets whats playing information//from w ww . j ava 2 s . c o m * @param getItemResult Return from method {@link org.xbmc.kore.jsonrpc.method.Player.GetItem} */ private void setNowPlayingInfo(PlayerType.GetActivePlayersReturnType getActivePlayerResult, PlayerType.PropertyValue getPropertiesResult, final ListType.ItemsAll getItemResult) { final String title, underTitle, art, poster, genreSeason, year, descriptionPlot, votes, maxRating; double rating; switch (getItemResult.type) { case ListType.ItemsAll.TYPE_MOVIE: switchToPanel(R.id.media_panel); title = getItemResult.title; underTitle = getItemResult.tagline; art = getItemResult.fanart; poster = getItemResult.thumbnail; genreSeason = Utils.listStringConcat(getItemResult.genre, ", "); year = (getItemResult.year > 0) ? String.format("%d", getItemResult.year) : null; descriptionPlot = getItemResult.plot; rating = getItemResult.rating; maxRating = getString(R.string.max_rating_video); votes = (TextUtils.isEmpty(getItemResult.votes)) ? "" : String.format(getString(R.string.votes), getItemResult.votes); break; case ListType.ItemsAll.TYPE_EPISODE: switchToPanel(R.id.media_panel); title = getItemResult.title; underTitle = getItemResult.showtitle; art = getItemResult.thumbnail; poster = getItemResult.art.poster; genreSeason = String.format(getString(R.string.season_episode), getItemResult.season, getItemResult.episode); year = getItemResult.premiered; descriptionPlot = getItemResult.plot; rating = getItemResult.rating; maxRating = getString(R.string.max_rating_video); votes = (TextUtils.isEmpty(getItemResult.votes)) ? "" : String.format(getString(R.string.votes), getItemResult.votes); break; case ListType.ItemsAll.TYPE_SONG: switchToPanel(R.id.media_panel); title = getItemResult.title; underTitle = getItemResult.displayartist + " | " + getItemResult.album; art = getItemResult.fanart; poster = getItemResult.thumbnail; genreSeason = Utils.listStringConcat(getItemResult.genre, ", "); year = (getItemResult.year > 0) ? String.format("%d", getItemResult.year) : null; descriptionPlot = getItemResult.description; rating = getItemResult.rating; maxRating = getString(R.string.max_rating_music); votes = (TextUtils.isEmpty(getItemResult.votes)) ? "" : String.format(getString(R.string.votes), getItemResult.votes); break; case ListType.ItemsAll.TYPE_MUSIC_VIDEO: switchToPanel(R.id.media_panel); title = getItemResult.title; underTitle = Utils.listStringConcat(getItemResult.artist, ", ") + " | " + getItemResult.album; art = getItemResult.fanart; poster = getItemResult.thumbnail; genreSeason = Utils.listStringConcat(getItemResult.genre, ", "); year = (getItemResult.year > 0) ? String.format("%d", getItemResult.year) : null; descriptionPlot = getItemResult.plot; rating = 0; maxRating = null; votes = null; break; case ListType.ItemsAll.TYPE_CHANNEL: switchToPanel(R.id.media_panel); title = getItemResult.label; underTitle = getItemResult.title; art = getItemResult.fanart; poster = getItemResult.thumbnail; genreSeason = Utils.listStringConcat(getItemResult.genre, ", "); year = getItemResult.premiered; descriptionPlot = getItemResult.plot; rating = getItemResult.rating; maxRating = null; votes = null; break; default: // Other type, just present basic info switchToPanel(R.id.media_panel); title = getItemResult.label; underTitle = ""; art = getItemResult.fanart; poster = getItemResult.thumbnail; genreSeason = null; year = getItemResult.premiered; descriptionPlot = removeYouTubeMarkup(getItemResult.plot); rating = 0; maxRating = null; votes = null; break; } mediaTitle.setText(title); mediaUndertitle.setText(underTitle); mediaProgressIndicator.setOnProgressChangeListener(this); mediaProgressIndicator.setMaxProgress(getPropertiesResult.totaltime.ToSeconds()); mediaProgressIndicator.setProgress(getPropertiesResult.time.ToSeconds()); int speed = getPropertiesResult.speed; //TODO: check if following is still necessary for PVR playback if (getItemResult.type.equals(ListType.ItemsAll.TYPE_CHANNEL)) speed = 1; mediaProgressIndicator.setSpeed(speed); if (!TextUtils.isEmpty(year) || !TextUtils.isEmpty(genreSeason)) { mediaYear.setVisibility(View.VISIBLE); mediaGenreSeason.setVisibility(View.VISIBLE); mediaYear.setText(year); mediaGenreSeason.setText(genreSeason); } else { mediaYear.setVisibility(View.GONE); mediaGenreSeason.setVisibility(View.GONE); } // 0 rating will not be shown if (rating > 0) { mediaRating.setVisibility(View.VISIBLE); mediaMaxRating.setVisibility(View.VISIBLE); mediaRatingVotes.setVisibility(View.VISIBLE); mediaRating.setText(String.format("%01.01f", rating)); mediaMaxRating.setText(maxRating); mediaRatingVotes.setText(votes); } else { mediaRating.setVisibility(View.GONE); mediaMaxRating.setVisibility(View.GONE); mediaRatingVotes.setVisibility(View.GONE); } if (!TextUtils.isEmpty(descriptionPlot)) { mediaDescription.setVisibility(View.VISIBLE); mediaDescription.setText(UIUtils.applyMarkup(getContext(), descriptionPlot)); } else { mediaDescription.setVisibility(View.GONE); } UIUtils.setRepeatButton(repeatButton, getPropertiesResult.repeat); shuffleButton.setHighlight(getPropertiesResult.shuffled); 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(art)) { mediaPoster.setVisibility(View.VISIBLE); int posterWidth = resources.getDimensionPixelOffset(R.dimen.now_playing_poster_width); int posterHeight = resources.getDimensionPixelOffset(R.dimen.now_playing_poster_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)); if (!isVideo) { ViewGroup.LayoutParams layoutParams = mediaPoster.getLayoutParams(); layoutParams.height = layoutParams.width; mediaPoster.setLayoutParams(layoutParams); posterHeight = posterWidth; } UIUtils.loadImageWithCharacterAvatar(getActivity(), hostManager, poster, title, mediaPoster, posterWidth, posterHeight); UIUtils.loadImageIntoImageview(hostManager, art, mediaArt, displayMetrics.widthPixels, artHeight); // Reset padding int paddingLeft = resources.getDimensionPixelOffset(R.dimen.poster_width_plus_padding), paddingRight = mediaTitle.getPaddingRight(), paddingTop = mediaTitle.getPaddingTop(), paddingBottom = mediaTitle.getPaddingBottom(); mediaTitle.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom); mediaUndertitle.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom); } else { // No fanart, just present the poster mediaPoster.setVisibility(View.GONE); UIUtils.loadImageWithCharacterAvatar(getActivity(), hostManager, poster, title, 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); } // UIUtils.loadImageIntoImageview(hostManager, poster, mediaPoster); // UIUtils.loadImageIntoImageview(hostManager, art, mediaArt); // Continue for videos // if (getItemResult.type.equals(ListType.ItemsAll.TYPE_EPISODE) || // getItemResult.type.equals(ListType.ItemsAll.TYPE_MOVIE)) { // TODO: change this check to the commeted out one when jsonrpc returns the correct type // if (getPropertiesResult.type.equals(PlayerType.PropertyValue.TYPE_VIDEO)) { if ((getPropertiesResult.audiostreams != null) && (getPropertiesResult.audiostreams.size() > 0)) { overflowButton.setVisibility(View.VISIBLE); videoCastList.setVisibility(View.VISIBLE); // Save subtitles and audiostreams list availableAudioStreams = getPropertiesResult.audiostreams; availableSubtitles = getPropertiesResult.subtitles; currentAudiostreamIndex = getPropertiesResult.currentaudiostream.index; currentSubtitleIndex = getPropertiesResult.currentsubtitle.index; // Cast list UIUtils.setupCastInfo(getActivity(), getItemResult.cast, videoCastList, AllCastActivity .buildLaunchIntent(getActivity(), title, (ArrayList<VideoType.Cast>) getItemResult.cast)); } else { overflowButton.setVisibility(View.GONE); videoCastList.setVisibility(View.GONE); } }
From source file:com.syncedsynapse.kore2.ui.NowPlayingFragment.java
/** * Sets whats playing information/*from w ww. jav a 2s. c o m*/ * @param getItemResult Return from method {@link com.syncedsynapse.kore2.jsonrpc.method.Player.GetItem} */ private void setNowPlayingInfo(PlayerType.PropertyValue getPropertiesResult, ListType.ItemsAll getItemResult) { String title, underTitle, art, poster, genreSeason, year, descriptionPlot, votes, maxRating; double rating; switch (getItemResult.type) { case ListType.ItemsAll.TYPE_MOVIE: switchToPanel(R.id.media_panel); title = getItemResult.title; underTitle = getItemResult.tagline; art = getItemResult.fanart; poster = getItemResult.thumbnail; genreSeason = Utils.listStringConcat(getItemResult.genre, ", "); year = String.format("%d", getItemResult.year); descriptionPlot = getItemResult.plot; rating = getItemResult.rating; maxRating = getString(R.string.max_rating_video); votes = (TextUtils.isEmpty(getItemResult.votes)) ? "" : String.format(getString(R.string.votes), getItemResult.votes); break; case ListType.ItemsAll.TYPE_EPISODE: switchToPanel(R.id.media_panel); title = getItemResult.title; underTitle = getItemResult.showtitle; art = getItemResult.thumbnail; poster = getItemResult.art.poster; genreSeason = String.format(getString(R.string.season_episode), getItemResult.season, getItemResult.episode); year = getItemResult.premiered; descriptionPlot = getItemResult.plot; rating = getItemResult.rating; maxRating = getString(R.string.max_rating_video); votes = (TextUtils.isEmpty(getItemResult.votes)) ? "" : String.format(getString(R.string.votes), getItemResult.votes); break; case ListType.ItemsAll.TYPE_SONG: switchToPanel(R.id.media_panel); title = getItemResult.title; underTitle = getItemResult.displayartist + " | " + getItemResult.album; art = getItemResult.fanart; poster = getItemResult.thumbnail; genreSeason = Utils.listStringConcat(getItemResult.genre, ", "); year = String.format("%d", getItemResult.year); descriptionPlot = getItemResult.description; rating = getItemResult.rating; maxRating = getString(R.string.max_rating_music); votes = (TextUtils.isEmpty(getItemResult.votes)) ? "" : String.format(getString(R.string.votes), getItemResult.votes); break; case ListType.ItemsAll.TYPE_MUSIC_VIDEO: switchToPanel(R.id.media_panel); title = getItemResult.title; underTitle = Utils.listStringConcat(getItemResult.artist, ", ") + " | " + getItemResult.album; art = getItemResult.fanart; poster = getItemResult.thumbnail; genreSeason = Utils.listStringConcat(getItemResult.genre, ", "); year = String.format("%d", getItemResult.year); descriptionPlot = getItemResult.plot; rating = 0; maxRating = null; votes = null; break; default: // Other type, just present basic info switchToPanel(R.id.media_panel); title = getItemResult.label; underTitle = ""; art = getItemResult.fanart; poster = getItemResult.thumbnail; genreSeason = null; year = null; descriptionPlot = null; rating = 0; maxRating = null; votes = null; break; } mediaTitle.setText(title); mediaUndertitle.setText(underTitle); setDurationInfo(getPropertiesResult.time, getPropertiesResult.totaltime, getPropertiesResult.speed); mediaSeekbar.setOnSeekBarChangeListener(seekbarChangeListener); if (!TextUtils.isEmpty(year) || !TextUtils.isEmpty(genreSeason)) { mediaYear.setVisibility(View.VISIBLE); mediaGenreSeason.setVisibility(View.VISIBLE); mediaYear.setText(year); mediaGenreSeason.setText(genreSeason); } else { mediaYear.setVisibility(View.GONE); mediaGenreSeason.setVisibility(View.GONE); } // 0 rating will not be shown if (rating > 0) { mediaRating.setVisibility(View.VISIBLE); mediaMaxRating.setVisibility(View.VISIBLE); mediaRatingVotes.setVisibility(View.VISIBLE); mediaRating.setText(String.format("%01.01f", rating)); mediaMaxRating.setText(maxRating); mediaRatingVotes.setText(votes); } else { mediaRating.setVisibility(View.GONE); mediaMaxRating.setVisibility(View.GONE); mediaRatingVotes.setVisibility(View.GONE); } if (!TextUtils.isEmpty(descriptionPlot)) { mediaDescription.setVisibility(View.VISIBLE); mediaDescription.setText(descriptionPlot); } else { mediaDescription.setVisibility(View.GONE); } Resources.Theme theme = getActivity().getTheme(); TypedArray styledAttributes = theme .obtainStyledAttributes(new int[] { R.attr.colorAccent, R.attr.iconRepeat, R.attr.iconRepeatOne }); if (getPropertiesResult.repeat.equals(PlayerType.Repeat.OFF)) { repeatButton.setImageResource(styledAttributes.getResourceId(1, R.drawable.ic_repeat_white_24dp)); repeatButton.clearColorFilter(); } else if (getPropertiesResult.repeat.equals(PlayerType.Repeat.ONE)) { repeatButton.setImageResource(styledAttributes.getResourceId(2, R.drawable.ic_repeat_one_white_24dp)); repeatButton.setColorFilter(styledAttributes.getColor(0, R.color.accent_default)); } else { repeatButton.setImageResource(styledAttributes.getResourceId(1, R.drawable.ic_repeat_white_24dp)); repeatButton.setColorFilter(styledAttributes.getColor(0, R.color.accent_default)); } if (!getPropertiesResult.shuffled) { shuffleButton.clearColorFilter(); } else { shuffleButton.setColorFilter(styledAttributes.getColor(0, R.color.accent_default)); } styledAttributes.recycle(); 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(art)) { mediaPoster.setVisibility(View.VISIBLE); int posterWidth = resources.getDimensionPixelOffset(R.dimen.now_playing_poster_width); int posterHeight = resources.getDimensionPixelOffset(R.dimen.now_playing_poster_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)); if (!isVideo) { ViewGroup.LayoutParams layoutParams = mediaPoster.getLayoutParams(); layoutParams.height = layoutParams.width; mediaPoster.setLayoutParams(layoutParams); posterHeight = posterWidth; } UIUtils.loadImageWithCharacterAvatar(getActivity(), hostManager, poster, title, mediaPoster, posterWidth, posterHeight); UIUtils.loadImageIntoImageview(hostManager, art, mediaArt, displayMetrics.widthPixels, artHeight); // Reset padding int paddingLeft = resources.getDimensionPixelOffset(R.dimen.poster_width_plus_padding), paddingRight = mediaTitle.getPaddingRight(), paddingTop = mediaTitle.getPaddingTop(), paddingBottom = mediaTitle.getPaddingBottom(); mediaTitle.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom); mediaUndertitle.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom); } 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); } // UIUtils.loadImageIntoImageview(hostManager, poster, mediaPoster); // UIUtils.loadImageIntoImageview(hostManager, art, mediaArt); // Continue for videos // if (getItemResult.type.equals(ListType.ItemsAll.TYPE_EPISODE) || // getItemResult.type.equals(ListType.ItemsAll.TYPE_MOVIE)) { // TODO: change this check to the commeted out one when jsonrpc returns the correct type // if (getPropertiesResult.type.equals(PlayerType.PropertyValue.TYPE_VIDEO)) { if ((getPropertiesResult.audiostreams != null) && (getPropertiesResult.audiostreams.size() > 0)) { overflowButton.setVisibility(View.VISIBLE); videoCastList.setVisibility(View.VISIBLE); videoAdditionalCastTitle.setVisibility(View.VISIBLE); videoAdditionalCastList.setVisibility(View.VISIBLE); // Save subtitles and audiostreams list availableAudioStreams = getPropertiesResult.audiostreams; availableSubtitles = getPropertiesResult.subtitles; currentAudiostreamIndex = getPropertiesResult.currentaudiostream.index; currentSubtitleIndex = getPropertiesResult.currentsubtitle.index; // Cast list UIUtils.setupCastInfo(getActivity(), getItemResult.cast, videoCastList, videoAdditionalCastTitle, videoAdditionalCastList); } else { overflowButton.setVisibility(View.GONE); videoCastList.setVisibility(View.GONE); videoAdditionalCastTitle.setVisibility(View.GONE); videoAdditionalCastList.setVisibility(View.GONE); } }
From source file:org.xbmc.kore.ui.NowPlayingFragment.java
/** * Sets whats playing information/* w w w . j ava 2 s .c om*/ * @param getItemResult Return from method {@link org.xbmc.kore.jsonrpc.method.Player.GetItem} */ private void setNowPlayingInfo(PlayerType.PropertyValue getPropertiesResult, final ListType.ItemsAll getItemResult) { final String title, underTitle, art, poster, genreSeason, year, descriptionPlot, votes, maxRating; double rating; switch (getItemResult.type) { case ListType.ItemsAll.TYPE_MOVIE: switchToPanel(R.id.media_panel); title = getItemResult.title; underTitle = getItemResult.tagline; art = getItemResult.fanart; poster = getItemResult.thumbnail; genreSeason = Utils.listStringConcat(getItemResult.genre, ", "); year = (getItemResult.year > 0) ? String.format("%d", getItemResult.year) : null; descriptionPlot = getItemResult.plot; rating = getItemResult.rating; maxRating = getString(R.string.max_rating_video); votes = (TextUtils.isEmpty(getItemResult.votes)) ? "" : String.format(getString(R.string.votes), getItemResult.votes); break; case ListType.ItemsAll.TYPE_EPISODE: switchToPanel(R.id.media_panel); title = getItemResult.title; underTitle = getItemResult.showtitle; art = getItemResult.thumbnail; poster = getItemResult.art.poster; genreSeason = String.format(getString(R.string.season_episode), getItemResult.season, getItemResult.episode); year = getItemResult.premiered; descriptionPlot = getItemResult.plot; rating = getItemResult.rating; maxRating = getString(R.string.max_rating_video); votes = (TextUtils.isEmpty(getItemResult.votes)) ? "" : String.format(getString(R.string.votes), getItemResult.votes); break; case ListType.ItemsAll.TYPE_SONG: switchToPanel(R.id.media_panel); title = getItemResult.title; underTitle = getItemResult.displayartist + " | " + getItemResult.album; art = getItemResult.fanart; poster = getItemResult.thumbnail; genreSeason = Utils.listStringConcat(getItemResult.genre, ", "); year = (getItemResult.year > 0) ? String.format("%d", getItemResult.year) : null; descriptionPlot = getItemResult.description; rating = getItemResult.rating; maxRating = getString(R.string.max_rating_music); votes = (TextUtils.isEmpty(getItemResult.votes)) ? "" : String.format(getString(R.string.votes), getItemResult.votes); break; case ListType.ItemsAll.TYPE_MUSIC_VIDEO: switchToPanel(R.id.media_panel); title = getItemResult.title; underTitle = Utils.listStringConcat(getItemResult.artist, ", ") + " | " + getItemResult.album; art = getItemResult.fanart; poster = getItemResult.thumbnail; genreSeason = Utils.listStringConcat(getItemResult.genre, ", "); year = (getItemResult.year > 0) ? String.format("%d", getItemResult.year) : null; descriptionPlot = getItemResult.plot; rating = 0; maxRating = null; votes = null; break; case ListType.ItemsAll.TYPE_CHANNEL: switchToPanel(R.id.media_panel); title = getItemResult.label; underTitle = getItemResult.title; art = getItemResult.fanart; poster = getItemResult.thumbnail; genreSeason = Utils.listStringConcat(getItemResult.genre, ", "); year = getItemResult.premiered; descriptionPlot = getItemResult.plot; rating = getItemResult.rating; maxRating = null; votes = null; break; default: // Other type, just present basic info switchToPanel(R.id.media_panel); title = getItemResult.label; underTitle = ""; art = getItemResult.fanart; poster = getItemResult.thumbnail; genreSeason = null; year = getItemResult.premiered; descriptionPlot = removeYouTubeMarkup(getItemResult.plot); rating = 0; maxRating = null; votes = null; break; } mediaTitle.setText(title); mediaUndertitle.setText(underTitle); setDurationInfo(getItemResult.type, getPropertiesResult.time, getPropertiesResult.totaltime, getPropertiesResult.speed); mediaSeekbar.setOnSeekBarChangeListener(seekbarChangeListener); if (!TextUtils.isEmpty(year) || !TextUtils.isEmpty(genreSeason)) { mediaYear.setVisibility(View.VISIBLE); mediaGenreSeason.setVisibility(View.VISIBLE); mediaYear.setText(year); mediaGenreSeason.setText(genreSeason); } else { mediaYear.setVisibility(View.GONE); mediaGenreSeason.setVisibility(View.GONE); } // 0 rating will not be shown if (rating > 0) { mediaRating.setVisibility(View.VISIBLE); mediaMaxRating.setVisibility(View.VISIBLE); mediaRatingVotes.setVisibility(View.VISIBLE); mediaRating.setText(String.format("%01.01f", rating)); mediaMaxRating.setText(maxRating); mediaRatingVotes.setText(votes); } else { mediaRating.setVisibility(View.GONE); mediaMaxRating.setVisibility(View.GONE); mediaRatingVotes.setVisibility(View.GONE); } if (!TextUtils.isEmpty(descriptionPlot)) { mediaDescription.setVisibility(View.VISIBLE); mediaDescription.setText(descriptionPlot); } else { mediaDescription.setVisibility(View.GONE); } Resources.Theme theme = getActivity().getTheme(); TypedArray styledAttributes = theme .obtainStyledAttributes(new int[] { R.attr.colorAccent, R.attr.iconRepeat, R.attr.iconRepeatOne }); int accentDefaultColor = getResources().getColor(R.color.accent_default); if (getPropertiesResult.repeat.equals(PlayerType.Repeat.OFF)) { repeatButton.setImageResource( styledAttributes.getResourceId(styledAttributes.getIndex(1), R.drawable.ic_repeat_white_24dp)); repeatButton.clearColorFilter(); } else if (getPropertiesResult.repeat.equals(PlayerType.Repeat.ONE)) { repeatButton.setImageResource(styledAttributes.getResourceId(styledAttributes.getIndex(2), R.drawable.ic_repeat_one_white_24dp)); repeatButton .setColorFilter(styledAttributes.getColor(styledAttributes.getIndex(0), accentDefaultColor)); } else { repeatButton.setImageResource( styledAttributes.getResourceId(styledAttributes.getIndex(1), R.drawable.ic_repeat_white_24dp)); repeatButton .setColorFilter(styledAttributes.getColor(styledAttributes.getIndex(0), accentDefaultColor)); } if (!getPropertiesResult.shuffled) { shuffleButton.clearColorFilter(); } else { shuffleButton .setColorFilter(styledAttributes.getColor(styledAttributes.getIndex(0), accentDefaultColor)); } styledAttributes.recycle(); 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(art)) { mediaPoster.setVisibility(View.VISIBLE); int posterWidth = resources.getDimensionPixelOffset(R.dimen.now_playing_poster_width); int posterHeight = resources.getDimensionPixelOffset(R.dimen.now_playing_poster_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)); if (!isVideo) { ViewGroup.LayoutParams layoutParams = mediaPoster.getLayoutParams(); layoutParams.height = layoutParams.width; mediaPoster.setLayoutParams(layoutParams); posterHeight = posterWidth; } UIUtils.loadImageWithCharacterAvatar(getActivity(), hostManager, poster, title, mediaPoster, posterWidth, posterHeight); UIUtils.loadImageIntoImageview(hostManager, art, mediaArt, displayMetrics.widthPixels, artHeight); // Reset padding int paddingLeft = resources.getDimensionPixelOffset(R.dimen.poster_width_plus_padding), paddingRight = mediaTitle.getPaddingRight(), paddingTop = mediaTitle.getPaddingTop(), paddingBottom = mediaTitle.getPaddingBottom(); mediaTitle.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom); mediaUndertitle.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom); } else { // No fanart, just present the poster mediaPoster.setVisibility(View.GONE); UIUtils.loadImageWithCharacterAvatar(getActivity(), hostManager, poster, title, 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); } // UIUtils.loadImageIntoImageview(hostManager, poster, mediaPoster); // UIUtils.loadImageIntoImageview(hostManager, art, mediaArt); // Continue for videos // if (getItemResult.type.equals(ListType.ItemsAll.TYPE_EPISODE) || // getItemResult.type.equals(ListType.ItemsAll.TYPE_MOVIE)) { // TODO: change this check to the commeted out one when jsonrpc returns the correct type // if (getPropertiesResult.type.equals(PlayerType.PropertyValue.TYPE_VIDEO)) { if ((getPropertiesResult.audiostreams != null) && (getPropertiesResult.audiostreams.size() > 0)) { overflowButton.setVisibility(View.VISIBLE); videoCastList.setVisibility(View.VISIBLE); // Save subtitles and audiostreams list availableAudioStreams = getPropertiesResult.audiostreams; availableSubtitles = getPropertiesResult.subtitles; currentAudiostreamIndex = getPropertiesResult.currentaudiostream.index; currentSubtitleIndex = getPropertiesResult.currentsubtitle.index; // Cast list UIUtils.setupCastInfo(getActivity(), getItemResult.cast, videoCastList, AllCastActivity .buildLaunchIntent(getActivity(), title, (ArrayList<VideoType.Cast>) getItemResult.cast)); } else { overflowButton.setVisibility(View.GONE); videoCastList.setVisibility(View.GONE); } }
From source file:hide.com.android.datetimepicker.date.SimpleMonthView.java
public SimpleMonthView(Context context) { super(context); Resources res = context.getResources(); mDayLabelCalendar = Calendar.getInstance(); mCalendar = Calendar.getInstance(); mDayOfWeekTypeface = res.getString(R.string.day_of_week_label_typeface); mMonthTitleTypeface = res.getString(R.string.sans_serif); mDayTextColor = res.getColor(R.color.date_picker_text_normal); mTodayNumberColor = res.getColor(R.color.blue); mMonthTitleColor = res.getColor(R.color.white); mMonthTitleBGColor = res.getColor(R.color.circle_background); MINI_DAY_NUMBER_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.day_number_size); MONTH_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.month_label_size); MONTH_DAY_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.month_day_label_text_size); MONTH_HEADER_SIZE = res.getDimensionPixelOffset(R.dimen.month_list_item_header_height); DAY_SELECTED_CIRCLE_SIZE = res.getDimensionPixelSize(R.dimen.day_number_select_circle_radius); mRowHeight = (res.getDimensionPixelOffset(R.dimen.date_picker_view_animator_height) - MONTH_HEADER_SIZE) / MAX_NUM_ROWS;//from w w w .j a v a2s . c o m // Set up accessibility components. mNodeProvider = new MonthViewNodeProvider(context, this); ViewCompat.setAccessibilityDelegate(this, mNodeProvider.getAccessibilityDelegate()); ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES); mLockAccessibilityDelegate = true; // Sets up any standard paints that will be used initView(); }
From source file:com.android.screenspeak.contextmenu.RadialMenuView.java
public RadialMenuView(Context context, RadialMenu menu, boolean useNodeProvider) { super(context); mRootMenu = menu;// w ww . j a v a 2 s .c o m mRootMenu.setLayoutListener(new RadialMenu.MenuLayoutListener() { @Override public void onLayoutChanged() { invalidate(); } }); mPaint = new Paint(); mPaint.setAntiAlias(true); mHandler = new LongPressHandler(context); mHandler.setListener(new LongPressHandler.LongPressListener() { @Override public void onLongPress() { onItemLongPressed(mFocusedItem); } }); final SurfaceHolder holder = getHolder(); holder.setFormat(PixelFormat.TRANSLUCENT); holder.addCallback(new SurfaceHolder.Callback() { @Override public void surfaceCreated(SurfaceHolder holder) { mHolder = holder; } @Override public void surfaceDestroyed(SurfaceHolder holder) { mHolder = null; } @Override public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { invalidate(); } }); final Resources res = context.getResources(); final ViewConfiguration config = ViewConfiguration.get(context); mSingleTapRadiusSq = config.getScaledTouchSlop(); // Dimensions. mInnerRadius = res.getDimensionPixelSize(R.dimen.inner_radius); mOuterRadius = res.getDimensionPixelSize(R.dimen.outer_radius); mCornerRadius = res.getDimensionPixelSize(R.dimen.corner_radius); mExtremeRadius = res.getDimensionPixelSize(R.dimen.extreme_radius); mSpacing = res.getDimensionPixelOffset(R.dimen.spacing); mTextSize = res.getDimensionPixelSize(R.dimen.text_size); mTextShadowRadius = res.getDimensionPixelSize(R.dimen.text_shadow_radius); mShadowRadius = res.getDimensionPixelSize(R.dimen.shadow_radius); // Colors. mOuterFillColor = res.getColor(R.color.outer_fill); mTextFillColor = res.getColor(R.color.text_fill); mCornerFillColor = res.getColor(R.color.corner_fill); mCornerTextFillColor = res.getColor(R.color.corner_text_fill); mDotFillColor = res.getColor(R.color.dot_fill); mDotStrokeColor = res.getColor(R.color.dot_stroke); mSelectionColor = res.getColor(R.color.selection_fill); mSelectionTextFillColor = res.getColor(R.color.selection_text_fill); mSelectionShadowColor = res.getColor(R.color.selection_shadow); mCenterFillColor = res.getColor(R.color.center_fill); mCenterTextFillColor = res.getColor(R.color.center_text_fill); mTextShadowColor = res.getColor(R.color.text_shadow); // Gradient colors. final int gradientInnerColor = res.getColor(R.color.gradient_inner); final int gradientOuterColor = res.getColor(R.color.gradient_outer); final int[] colors = new int[] { gradientInnerColor, gradientOuterColor }; mGradientBackground = new GradientDrawable(Orientation.TOP_BOTTOM, colors); mGradientBackground.setGradientType(GradientDrawable.RADIAL_GRADIENT); mGradientBackground.setGradientRadius(mExtremeRadius * 2.0f); final int subMenuOverlayColor = res.getColor(R.color.submenu_overlay); // Lighting filters generated from colors. mSubMenuFilter = new PorterDuffColorFilter(subMenuOverlayColor, PorterDuff.Mode.SCREEN); mInnerRadiusSq = (mInnerRadius * mInnerRadius); mExtremeRadiusSq = (mExtremeRadius * mExtremeRadius); mUseNodeProvider = useNodeProvider; if (mUseNodeProvider) { // Lazily-constructed node provider helper. ViewCompat.setAccessibilityDelegate(this, new RadialMenuHelper(this)); } // Corner shapes only need to be invalidated and cached once. initializeCachedShapes(); }
From source file:com.googlecode.eyesfree.widget.RadialMenuView.java
public RadialMenuView(Context context, RadialMenu menu, boolean useNodeProvider) { super(context); mRootMenu = menu;/*w w w.j av a 2 s .com*/ mRootMenu.setLayoutListener(mLayoutListener); mPaint = new Paint(); mPaint.setAntiAlias(true); mHandler = new LongPressHandler(context); mHandler.setListener(mLongPressListener); final SurfaceHolder holder = getHolder(); holder.setFormat(PixelFormat.TRANSLUCENT); holder.addCallback(mSurfaceCallback); final Resources res = context.getResources(); final ViewConfiguration config = ViewConfiguration.get(context); mSingleTapRadiusSq = config.getScaledTouchSlop(); // Dimensions. mInnerRadius = res.getDimensionPixelSize(R.dimen.inner_radius); mOuterRadius = res.getDimensionPixelSize(R.dimen.outer_radius); mCornerRadius = res.getDimensionPixelSize(R.dimen.corner_radius); mExtremeRadius = res.getDimensionPixelSize(R.dimen.extreme_radius); mSpacing = res.getDimensionPixelOffset(R.dimen.spacing); mTextSize = res.getDimensionPixelSize(R.dimen.text_size); mTextShadowRadius = res.getDimensionPixelSize(R.dimen.text_shadow_radius); mShadowRadius = res.getDimensionPixelSize(R.dimen.shadow_radius); // Colors. mOuterFillColor = res.getColor(R.color.outer_fill); mTextFillColor = res.getColor(R.color.text_fill); mCornerFillColor = res.getColor(R.color.corner_fill); mCornerTextFillColor = res.getColor(R.color.corner_text_fill); mDotFillColor = res.getColor(R.color.dot_fill); mDotStrokeColor = res.getColor(R.color.dot_stroke); mSelectionColor = res.getColor(R.color.selection_fill); mSelectionTextFillColor = res.getColor(R.color.selection_text_fill); mSelectionShadowColor = res.getColor(R.color.selection_shadow); mCenterFillColor = res.getColor(R.color.center_fill); mCenterTextFillColor = res.getColor(R.color.center_text_fill); mTextShadowColor = res.getColor(R.color.text_shadow); // Gradient colors. final int gradientInnerColor = res.getColor(R.color.gradient_inner); final int gradientOuterColor = res.getColor(R.color.gradient_outer); final int[] colors = new int[] { gradientInnerColor, gradientOuterColor }; mGradientBackground = new GradientDrawable(Orientation.TOP_BOTTOM, colors); mGradientBackground.setGradientType(GradientDrawable.RADIAL_GRADIENT); mGradientBackground.setGradientRadius(mExtremeRadius * 2.0f); final int subMenuOverlayColor = res.getColor(R.color.submenu_overlay); // Lighting filters generated from colors. mSubMenuFilter = new PorterDuffColorFilter(subMenuOverlayColor, PorterDuff.Mode.SCREEN); mInnerRadiusSq = (mInnerRadius * mInnerRadius); mExtremeRadiusSq = (mExtremeRadius * mExtremeRadius); mUseNodeProvider = useNodeProvider; if (mUseNodeProvider) { mTouchExplorer = new RadialMenuHelper(this); ViewCompat.setAccessibilityDelegate(this, mTouchExplorer); } // Corner shapes only need to be invalidated and cached once. initializeCachedShapes(); }
From source file:app.android.datetimepicker.date.SimpleMonthView.java
public SimpleMonthView(Context context) { super(context); Resources res = context.getResources(); mDayLabelCalendar = Calendar.getInstance(); mCalendar = Calendar.getInstance(); mDayOfWeekTypeface = res.getString(R.string.day_of_week_label_typeface); mMonthTitleTypeface = res.getString(R.string.sans_serif); mDayTextColor = res.getColor(R.color.date_picker_text_normal); mTodayNumberColor = res.getColor(R.color.blue); mMonthTitleColor = res.getColor(R.color.white); mMonthTitleBGColor = res.getColor(R.color.circle_background); mStringBuilder = new StringBuilder(50); mFormatter = new Formatter(mStringBuilder, Locale.getDefault()); MINI_DAY_NUMBER_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.day_number_size); MONTH_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.month_label_size); MONTH_DAY_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.month_day_label_text_size); MONTH_HEADER_SIZE = res.getDimensionPixelOffset(R.dimen.month_list_item_header_height); DAY_SELECTED_CIRCLE_SIZE = res.getDimensionPixelSize(R.dimen.day_number_select_circle_radius); mRowHeight = (res.getDimensionPixelOffset(R.dimen.date_picker_view_animator_height) - MONTH_HEADER_SIZE) / MAX_NUM_ROWS;//from w w w . j ava2s .c o m // Set up accessibility components. mTouchHelper = new MonthViewTouchHelper(this); ViewCompat.setAccessibilityDelegate(this, mTouchHelper); ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES); mLockAccessibilityDelegate = true; // Sets up any standard paints that will be used initView(); }