List of usage examples for android.content.res Resources getDimension
public float getDimension(@DimenRes int id) throws NotFoundException
From source file:org.xbmc.kore.ui.sections.video.TVShowProgressFragment.java
/** * Display next episode list/*from w w w .ja v a 2 s . c om*/ * * @param cursor Cursor with the data */ @TargetApi(21) private void displayNextEpisodeList(Cursor cursor) { TextView nextEpisodeTitle = (TextView) getActivity().findViewById(R.id.next_episode_title); GridLayout nextEpisodeList = (GridLayout) getActivity().findViewById(R.id.next_episode_list); if (cursor.moveToFirst()) { nextEpisodeTitle.setVisibility(View.VISIBLE); nextEpisodeList.setVisibility(View.VISIBLE); HostManager hostManager = HostManager.getInstance(getActivity()); View.OnClickListener episodeClickListener = new View.OnClickListener() { @Override public void onClick(View v) { AbstractInfoFragment.DataHolder vh = (AbstractInfoFragment.DataHolder) v.getTag(); listenerActivity.onNextEpisodeSelected(itemId, vh); } }; // Get the art dimensions Resources resources = getActivity().getResources(); int artWidth = (int) (resources.getDimension(R.dimen.detail_poster_width_square) / UIUtils.IMAGE_RESIZE_FACTOR); int artHeight = (int) (resources.getDimension(R.dimen.detail_poster_height_square) / UIUtils.IMAGE_RESIZE_FACTOR); nextEpisodeList.removeAllViews(); do { int episodeId = cursor.getInt(NextEpisodesListQuery.EPISODEID); String title = cursor.getString(NextEpisodesListQuery.TITLE); String seasonEpisode = String.format(getString(R.string.season_episode), cursor.getInt(NextEpisodesListQuery.SEASON), cursor.getInt(NextEpisodesListQuery.EPISODE)); int runtime = cursor.getInt(NextEpisodesListQuery.RUNTIME) / 60; String duration = runtime > 0 ? String.format(getString(R.string.minutes_abbrev), String.valueOf(runtime)) + " | " + cursor.getString(NextEpisodesListQuery.FIRSTAIRED) : cursor.getString(NextEpisodesListQuery.FIRSTAIRED); String thumbnail = cursor.getString(NextEpisodesListQuery.THUMBNAIL); View episodeView = LayoutInflater.from(getActivity()).inflate(R.layout.list_item_next_episode, nextEpisodeList, false); ImageView artView = (ImageView) episodeView.findViewById(R.id.art); TextView titleView = (TextView) episodeView.findViewById(R.id.title); TextView detailsView = (TextView) episodeView.findViewById(R.id.details); TextView durationView = (TextView) episodeView.findViewById(R.id.duration); titleView.setText(title); detailsView.setText(seasonEpisode); durationView.setText(duration); UIUtils.loadImageWithCharacterAvatar(getActivity(), hostManager, thumbnail, title, artView, artWidth, artHeight); AbstractInfoFragment.DataHolder vh = new AbstractInfoFragment.DataHolder(episodeId); vh.setTitle(title); vh.setUndertitle(seasonEpisode); episodeView.setTag(vh); episodeView.setOnClickListener(episodeClickListener); // For the popupmenu ImageView contextMenu = (ImageView) episodeView.findViewById(R.id.list_context_menu); contextMenu.setTag(episodeId); contextMenu.setOnClickListener(contextlistItemMenuClickListener); nextEpisodeList.addView(episodeView); } while (cursor.moveToNext()); } else { // No episodes, hide views nextEpisodeTitle.setVisibility(View.GONE); nextEpisodeList.setVisibility(View.GONE); } }
From source file:org.xbmc.kore.ui.sections.video.TVShowProgressFragment.java
/** * Display the seasons list/*from ww w .j av a 2 s .co m*/ * * @param cursor Cursor with the data */ private void displaySeasonList(Cursor cursor) { TextView seasonsListTitle = (TextView) getActivity().findViewById(R.id.seasons_title); GridLayout seasonsList = (GridLayout) getActivity().findViewById(R.id.seasons_list); if (cursor.moveToFirst()) { seasonsListTitle.setVisibility(View.VISIBLE); seasonsList.setVisibility(View.VISIBLE); HostManager hostManager = HostManager.getInstance(getActivity()); View.OnClickListener seasonListClickListener = new View.OnClickListener() { @Override public void onClick(View v) { listenerActivity.onSeasonSelected(itemId, (int) v.getTag()); } }; // Get the art dimensions Resources resources = getActivity().getResources(); int artWidth = (int) (resources.getDimension(R.dimen.seasonlist_art_width) / UIUtils.IMAGE_RESIZE_FACTOR); int artHeight = (int) (resources.getDimension(R.dimen.seasonlist_art_heigth) / UIUtils.IMAGE_RESIZE_FACTOR); // Get theme colors Resources.Theme theme = getActivity().getTheme(); TypedArray styledAttributes = theme .obtainStyledAttributes(new int[] { R.attr.colorinProgress, R.attr.colorFinished }); int inProgressColor = styledAttributes.getColor(styledAttributes.getIndex(0), resources.getColor(R.color.orange_500)); int finishedColor = styledAttributes.getColor(styledAttributes.getIndex(1), resources.getColor(R.color.green_400)); styledAttributes.recycle(); seasonsList.removeAllViews(); do { int seasonNumber = cursor.getInt(SeasonsListQuery.SEASON); String thumbnail = cursor.getString(SeasonsListQuery.THUMBNAIL); int numEpisodes = cursor.getInt(SeasonsListQuery.EPISODE); int watchedEpisodes = cursor.getInt(SeasonsListQuery.WATCHEDEPISODES); View seasonView = LayoutInflater.from(getActivity()).inflate(R.layout.grid_item_season, seasonsList, false); ImageView seasonPictureView = (ImageView) seasonView.findViewById(R.id.art); TextView seasonNumberView = (TextView) seasonView.findViewById(R.id.season); TextView seasonEpisodesView = (TextView) seasonView.findViewById(R.id.episodes); ProgressBar seasonProgressBar = (ProgressBar) seasonView.findViewById(R.id.season_progress_bar); seasonNumberView .setText(String.format(getActivity().getString(R.string.season_number), seasonNumber)); seasonEpisodesView.setText(String.format(getActivity().getString(R.string.num_episodes), numEpisodes, numEpisodes - watchedEpisodes)); seasonProgressBar.setMax(numEpisodes); seasonProgressBar.setProgress(watchedEpisodes); if (Utils.isLollipopOrLater()) { int watchedColor = (numEpisodes - watchedEpisodes == 0) ? finishedColor : inProgressColor; seasonProgressBar.setProgressTintList(ColorStateList.valueOf(watchedColor)); } UIUtils.loadImageWithCharacterAvatar(getActivity(), hostManager, thumbnail, String.valueOf(seasonNumber), seasonPictureView, artWidth, artHeight); seasonView.setTag(seasonNumber); seasonView.setOnClickListener(seasonListClickListener); seasonsList.addView(seasonView); } while (cursor.moveToNext()); } else { // No seasons, hide views seasonsListTitle.setVisibility(View.GONE); seasonsList.setVisibility(View.GONE); } }
From source file:com.microsoft.azure.engagement.fragment.VideosFragment.java
@Nullable @Override/* ww w.ja v a 2s .c o m*/ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.fragment_videos, container, false); final Resources resources = getResources(); recyclerView = (RecyclerView) view.findViewById(R.id.recyclerView); recyclerView .setLayoutManager(new LinearLayoutManager(view.getContext(), LinearLayoutManager.VERTICAL, false)); recyclerView.addItemDecoration(new MarginItemDecoration((int) resources.getDimension(R.dimen.dimen15dip))); progressBar = view.findViewById(R.id.progressBar); asyncTaskCall(); AzmeTracker.startActivity(getActivity(), "videos"); return view; }
From source file:cn.com.bjnews.thinker.view.MyTabPageIndicator.java
public MyTabPageIndicator(Context context, AttributeSet attrs) { super(context, attrs); setHorizontalScrollBarEnabled(false); Resources resource = (Resources) context.getResources(); selectedColor = (ColorStateList) resource.getColorStateList(cn.com.bjnews.newsroom.R.color.tab_selected); rightMargin = (int) resource.getDimension(cn.com.bjnews.newsroom.R.dimen.main_tab_margin_right); leftMargin = (int) resource.getDimension(cn.com.bjnews.newsroom.R.dimen.main_tab_margin_left); mTabLayout = new IcsLinearLayout(context, R.attr.vpiTabPageIndicatorStyle); addView(mTabLayout, new ViewGroup.LayoutParams(WRAP_CONTENT, MATCH_PARENT)); }
From source file:cn.com.bjnews.thinker.view.MyTabPageIndicator.java
public MyTabPageIndicator(Context context, AttributeSet attrs, int def) { super(context, attrs, def); setHorizontalScrollBarEnabled(false); Resources resource = (Resources) context.getResources(); selectedColor = (ColorStateList) resource.getColorStateList(cn.com.bjnews.newsroom.R.color.tab_selected); rightMargin = (int) resource.getDimension(cn.com.bjnews.newsroom.R.dimen.main_tab_margin_right); leftMargin = (int) resource.getDimension(cn.com.bjnews.newsroom.R.dimen.main_tab_margin_left); mTabLayout = new IcsLinearLayout(context, R.attr.vpiTabPageIndicatorStyle); addView(mTabLayout, new ViewGroup.LayoutParams(WRAP_CONTENT, MATCH_PARENT)); }
From source file:com.lillicoder.demo.carouselview.widget.CarouselView.java
/** * Inflates and initializes this view./* w w w . j a v a2s . co m*/ * @param context {@link Context} for this view. * @param attrs {@link AttributeSet} for this view. * @param defStyle Optional default style for this view. */ private void initialize(Context context, AttributeSet attrs, int defStyle) { setOrientation(LinearLayout.VERTICAL); LayoutInflater inflater = LayoutInflater.from(context); inflater.inflate(R.layout.view_carousel, this); mViewPager = (ViewPager) findViewById(R.id.CarouselView_viewPager); mIndicatorContainer = (ViewGroup) findViewById(R.id.CarouselView_indicatorContainer); if (attrs != null) { TypedArray attributes = context.obtainStyledAttributes(attrs, R.styleable.CarouselView, defStyle, 0); Resources resources = getResources(); mIndicatorDrawableResourceId = attributes.getResourceId(R.styleable.CarouselView_indicator, R.drawable.carousel_indicator); mIndicatorPadding = (int) attributes.getDimension(R.styleable.CarouselView_indicatorPadding, resources.getDimension(R.dimen.indicator_padding)); } mViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrollStateChanged(int state) { } @Override public void onPageScrolled(int position, float floatOffset, int positionOffsetPixels) { } @Override public void onPageSelected(int position) { int childCount = mIndicatorContainer.getChildCount(); for (int childPosition = 0; childPosition < childCount; childPosition++) { Checkable child = (Checkable) mIndicatorContainer.getChildAt(childPosition); if (child != null) { child.setChecked(childPosition == position); } } } }); }
From source file:org.chromium.chrome.browser.media.remote.NotificationTransportControl.java
/** * Scale the specified bitmap to properly fit as a notification icon. If the argument is null * the function returns null.//from w w w . ja va 2s . c om */ private Bitmap scaleBitmapForIcon(Bitmap bitmap) { Resources res = mContext.getResources(); float maxWidth = res.getDimension(R.dimen.remote_notification_logo_max_width); float maxHeight = res.getDimension(R.dimen.remote_notification_logo_max_height); return scaleBitmap(bitmap, (int) maxWidth, (int) maxHeight); }
From source file:com.achep.acdisplay.ui.widgets.CircleView.java
private void init() { Resources res = getResources(); mCornerMargin = res.getDimension(R.dimen.circle_corner_margin); mRadiusTarget = res.getDimension(R.dimen.circle_radius_target); mRadiusDecreaseThreshold = res.getDimension(R.dimen.circle_radius_decrease_threshold); mShortAnimTime = res.getInteger(android.R.integer.config_shortAnimTime); mMediumAnimTime = res.getInteger(android.R.integer.config_mediumAnimTime); mDrawableLeftTopCorner = new CornerIconDrawable(Config.KEY_CORNER_ACTION_LEFT_TOP); mDrawableRightTopCorner = new CornerIconDrawable(Config.KEY_CORNER_ACTION_RIGHT_TOP); mDrawableLeftBottomCorner = new CornerIconDrawable(Config.KEY_CORNER_ACTION_LEFT_BOTTOM); mDrawableRightBottomCorner = new CornerIconDrawable(Config.KEY_CORNER_ACTION_RIGHT_BOTTOM); mPaint = new Paint(); mPaint.setAntiAlias(true);//from w ww .j a va2 s .c o m initInverseColorFilter(); setRadius(0); }
From source file:com.microsoft.azure.engagement.fragment.RecentProductUpdatesFragment.java
@Nullable @Override// w ww . ja v a 2 s . com public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.fragment_recent_product_updates, container, false); final Resources resources = getResources(); recyclerView = (RecyclerView) view.findViewById(R.id.recyclerView); recyclerView .setLayoutManager(new LinearLayoutManager(view.getContext(), LinearLayoutManager.VERTICAL, false)); recyclerView.addItemDecoration(new MarginItemDecoration((int) resources.getDimension(R.dimen.dimen20dip), (int) resources.getDimension(R.dimen.dimen15dip))); progressBar = view.findViewById(R.id.progressBar); retryButton = view.findViewById(R.id.retryButton); retryButton.setOnClickListener(this); errorContainer = view.findViewById(R.id.errorContainer); errorContainer.setVisibility(View.VISIBLE); swipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipeRefreshLayout); swipeRefreshLayout.setOnRefreshListener(this); swipeRefreshLayout.setColorSchemeColors(resources.getIntArray(R.array.refreshColors)); asyncTaskCall(false); AzmeTracker.startActivity(getActivity(), "recent_updates"); return view; }
From source file:com.runmit.sweedee.view.CirclePageIndicator.java
public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return;/*from w w w. j av a 2 s .co m*/ final Resources res = getResources(); defaultFillColor = res.getColor(R.color.default_circle_indicator_fill_color); defaultCommonColor = res.getColor(R.color.default_circle_indicator_stroke_color); final float defaultRadius = res.getDimension(R.dimen.default_circle_indicator_radius); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CirclePageIndicator, defStyle, 0); mRadius = a.getDimension(R.styleable.CirclePageIndicator_radius, defaultRadius); a.recycle(); mColorEvaluator = new ArgbEvaluator(); }