Example usage for android.content.res Resources getDimensionPixelSize

List of usage examples for android.content.res Resources getDimensionPixelSize

Introduction

In this page you can find the example usage for android.content.res Resources getDimensionPixelSize.

Prototype

public int getDimensionPixelSize(@DimenRes int id) throws NotFoundException 

Source Link

Document

Retrieve a dimensional for a particular resource ID for use as a size in raw pixels.

Usage

From source file:io.plaidapp.designernews.ui.story.StoryActivity.java

private void bindResources() {
    commentsList = findViewById(R.id.comments_list);
    fab = findViewById(R.id.fab);/*from w ww.  j  a  v a  2  s .  c o  m*/
    fabExpand = findViewById(R.id.fab_expand);
    draggableFrame = findViewById(R.id.comments_container);
    collapsingToolbar = findViewById(R.id.backdrop_toolbar);
    toolbarBackground = findViewById(R.id.story_title_background);
    background = findViewById(R.id.background);
    Resources res = getResources();
    fabExpandDuration = res.getInteger(io.plaidapp.R.integer.fab_expand_duration);
    threadWidth = res.getDimensionPixelSize(io.plaidapp.R.dimen.comment_thread_width);
    threadGap = res.getDimensionPixelSize(io.plaidapp.R.dimen.comment_thread_gap);
}

From source file:org.runbuddy.tomahawk.ui.fragments.ContentHeaderFragment.java

private void setupButtonAnimation(final View view) {
    if (view != null) {
        View moreButton = view.findViewById(R.id.button_panel);
        if (moreButton != null) {
            ViewUtils.afterViewGlobalLayout(new ViewUtils.ViewRunnable(moreButton) {
                @Override//from ww w . jav  a  2 s .c  o m
                public void run() {
                    // get resources first
                    Resources resources = TomahawkApp.getContext().getResources();
                    int buttonHeight = TomahawkApp.getContext().getResources()
                            .getDimensionPixelSize(R.dimen.show_context_menu_icon_height);
                    int largePadding = TomahawkApp.getContext().getResources()
                            .getDimensionPixelSize(R.dimen.padding_large);
                    int smallPadding = resources.getDimensionPixelSize(R.dimen.padding_small);
                    int actionBarHeight = resources
                            .getDimensionPixelSize(R.dimen.abc_action_bar_default_height_material);
                    View pageIndicator = view.findViewById(R.id.page_indicator);
                    int pageIndicatorHeight = 0;
                    if (pageIndicator != null && pageIndicator.getVisibility() == View.VISIBLE) {
                        pageIndicatorHeight = TomahawkApp.getContext().getResources()
                                .getDimensionPixelSize(R.dimen.pager_indicator_height);
                    }

                    // now calculate the animation goal and instantiate the animation
                    int initialY = view.getHeight() - buttonHeight - largePadding - pageIndicatorHeight;
                    ValueAnimator animator = ObjectAnimator
                            .ofFloat(getLayedOutView(), "y", initialY, actionBarHeight + smallPadding)
                            .setDuration(10000);
                    animator.setInterpolator(new LinearInterpolator());
                    addAnimator(ANIM_BUTTON_ID, animator);

                    refreshAnimations();
                }
            });
        }
    }
}

From source file:org.mariotaku.twidere.activity.support.HomeActivity.java

private void setupSlidingMenu() {
    if (mSlidingMenu == null)
        return;/*w  ww.  j a v a  2 s  .  co m*/
    final Resources res = getResources();
    final int marginThreshold = res.getDimensionPixelSize(R.dimen.default_sliding_menu_margin_threshold);
    final boolean relativeBehindWidth = res.getBoolean(R.bool.relative_behind_width);
    mSlidingMenu.setMode(SlidingMenu.LEFT);
    mSlidingMenu.setShadowWidthRes(R.dimen.default_sliding_menu_shadow_width);
    mSlidingMenu.setShadowDrawable(R.drawable.shadow_left);
    mSlidingMenu.setSecondaryShadowDrawable(R.drawable.shadow_right);
    if (relativeBehindWidth) {
        mSlidingMenu.setBehindOffsetRes(R.dimen.drawer_offset_home);
    } else {
        mSlidingMenu.setBehindWidthRes(R.dimen.drawer_width_home);
    }
    mSlidingMenu.setTouchmodeMarginThreshold(marginThreshold);
    mSlidingMenu.setFadeDegree(0.5f);
    mSlidingMenu.setMenu(R.layout.drawer_home_accounts);
    mSlidingMenu.setOnOpenedListener(this);
    mSlidingMenu.setOnClosedListener(this);
    mLeftDrawerContainer = (LeftDrawerFrameLayout) mSlidingMenu.getMenu()
            .findViewById(R.id.left_drawer_container);
    final boolean isTransparentBackground = ThemeUtils
            .isTransparentBackground(getCurrentThemeBackgroundOption());
    mLeftDrawerContainer.setClipEnabled(isTransparentBackground);
    mLeftDrawerContainer.setScrollScale(mSlidingMenu.getBehindScrollScale());
    mSlidingMenu.setBehindCanvasTransformer(new ListenerCanvasTransformer(this));
    final Window window = getWindow();
    ThemeUtils.applyWindowBackground(this, mSlidingMenu.getContent(), getCurrentThemeResourceId(),
            getThemeBackgroundOption(), getCurrentThemeBackgroundAlpha());
    window.setBackgroundDrawable(new EmptyDrawable());

    mSlidingMenu.addIgnoredView(mActionBarContainer);
}

From source file:com.luseen.spacenavigation.SpaceNavigationView.java

/**
 * Init custom attributes//from w w  w  . ja v a  2s.  c  o m
 *
 * @param attrs attributes
 */
private void init(AttributeSet attrs) {
    if (attrs != null) {
        Resources resources = getResources();

        TypedArray typedArray = context.obtainStyledAttributes(attrs,
                com.luseen.spacenavigation.R.styleable.SpaceNavigationView);
        spaceItemIconSize = typedArray.getDimensionPixelSize(
                com.luseen.spacenavigation.R.styleable.SpaceNavigationView_space_item_icon_size,
                resources.getDimensionPixelSize(
                        com.luseen.spacenavigation.R.dimen.space_item_icon_default_size));
        spaceItemIconOnlySize = typedArray.getDimensionPixelSize(
                com.luseen.spacenavigation.R.styleable.SpaceNavigationView_space_item_icon_only_size,
                resources.getDimensionPixelSize(com.luseen.spacenavigation.R.dimen.space_item_icon_only_size));
        spaceItemTextSize = typedArray.getDimensionPixelSize(
                com.luseen.spacenavigation.R.styleable.SpaceNavigationView_space_item_text_size,
                resources.getDimensionPixelSize(
                        com.luseen.spacenavigation.R.dimen.space_item_text_default_size));
        spaceItemIconOnlySize = typedArray.getDimensionPixelSize(
                com.luseen.spacenavigation.R.styleable.SpaceNavigationView_space_item_icon_only_size,
                resources.getDimensionPixelSize(com.luseen.spacenavigation.R.dimen.space_item_icon_only_size));
        spaceBackgroundColor = typedArray.getColor(
                com.luseen.spacenavigation.R.styleable.SpaceNavigationView_space_background_color,
                resources.getColor(com.luseen.spacenavigation.R.color.default_color));
        centreButtonColor = typedArray.getColor(
                com.luseen.spacenavigation.R.styleable.SpaceNavigationView_centre_button_color,
                resources.getColor(com.luseen.spacenavigation.R.color.centre_button_color));
        activeSpaceItemColor = typedArray.getColor(
                com.luseen.spacenavigation.R.styleable.SpaceNavigationView_active_item_color,
                resources.getColor(com.luseen.spacenavigation.R.color.white));
        inActiveSpaceItemColor = typedArray.getColor(
                com.luseen.spacenavigation.R.styleable.SpaceNavigationView_inactive_item_color,
                resources.getColor(com.luseen.spacenavigation.R.color.default_inactive_item_color));

        typedArray.recycle();
    }
}

From source file:com.android.mylauncher3.allapps.AllAppsGridAdapter.java

public AllAppsGridAdapter(Launcher launcher, AlphabeticalAppsList apps, View.OnTouchListener touchListener,
        View.OnClickListener iconClickListener, View.OnLongClickListener iconLongClickListener) {
    Resources res = launcher.getResources();
    mLauncher = launcher;/*from   ww w .ja  v  a2  s  .  co  m*/
    mApps = apps;
    mEmptySearchMessage = res.getString(R.string.all_apps_loading_message);
    mGridSizer = new GridSpanSizer();
    mGridLayoutMgr = new AppsGridLayoutManager(launcher);
    mGridLayoutMgr.setSpanSizeLookup(mGridSizer);
    mItemDecoration = new GridItemDecoration();
    mLayoutInflater = LayoutInflater.from(launcher);
    mTouchListener = touchListener;
    mIconClickListener = iconClickListener;
    mIconLongClickListener = iconLongClickListener;
    mSectionNamesMargin = res.getDimensionPixelSize(R.dimen.all_apps_grid_view_start_margin);
    mSectionHeaderOffset = res.getDimensionPixelSize(R.dimen.all_apps_grid_section_y_offset);

    mSectionTextPaint = new Paint();
    mSectionTextPaint.setTextSize(res.getDimensionPixelSize(R.dimen.all_apps_grid_section_text_size));
    mSectionTextPaint.setColor(res.getColor(R.color.all_apps_grid_section_text_color));
    mSectionTextPaint.setAntiAlias(true);

    mPredictedAppsDividerPaint = new Paint();
    mPredictedAppsDividerPaint.setStrokeWidth(Utilities.pxFromDp(1f, res.getDisplayMetrics()));
    mPredictedAppsDividerPaint.setColor(0x1E000000);
    mPredictedAppsDividerPaint.setAntiAlias(true);
    mPredictionBarDividerOffset = (-res.getDimensionPixelSize(R.dimen.all_apps_prediction_icon_bottom_padding)
            + res.getDimensionPixelSize(R.dimen.all_apps_icon_top_bottom_padding)) / 2;

    // Resolve the market app handling additional searches
    PackageManager pm = launcher.getPackageManager();
    ResolveInfo marketInfo = pm.resolveActivity(createMarketSearchIntent(""),
            PackageManager.MATCH_DEFAULT_ONLY);
    if (marketInfo != null) {
        mMarketAppName = marketInfo.loadLabel(pm).toString();
    }
}

From source file:android.support.wear.widget.CircularProgressLayout.java

public CircularProgressLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);

    mProgressDrawable = new CircularProgressDrawable(context);
    mProgressDrawable.setProgressRotation(DEFAULT_ROTATION);
    mProgressDrawable.setStrokeCap(Paint.Cap.BUTT);
    setBackground(mProgressDrawable);//from   ww  w  .  j a va 2 s  .  c om

    // If a child view is added, make it center aligned so it fits in the progress drawable.
    setOnHierarchyChangeListener(new OnHierarchyChangeListener() {
        @Override
        public void onChildViewAdded(View parent, View child) {
            // Ensure that child view is aligned in center
            LayoutParams params = (LayoutParams) child.getLayoutParams();
            params.gravity = Gravity.CENTER;
            child.setLayoutParams(params);
        }

        @Override
        public void onChildViewRemoved(View parent, View child) {

        }
    });

    mController = new CircularProgressLayoutController(this);

    Resources r = context.getResources();
    TypedArray a = r.obtainAttributes(attrs, R.styleable.CircularProgressLayout);

    if (a.getType(R.styleable.CircularProgressLayout_colorSchemeColors) == TypedValue.TYPE_REFERENCE
            || !a.hasValue(R.styleable.CircularProgressLayout_colorSchemeColors)) {
        int arrayResId = a.getResourceId(R.styleable.CircularProgressLayout_colorSchemeColors,
                R.array.circular_progress_layout_color_scheme_colors);
        setColorSchemeColors(getColorListFromResources(r, arrayResId));
    } else {
        setColorSchemeColors(a.getColor(R.styleable.CircularProgressLayout_colorSchemeColors, Color.BLACK));
    }

    setStrokeWidth(a.getDimensionPixelSize(R.styleable.CircularProgressLayout_strokeWidth,
            r.getDimensionPixelSize(R.dimen.circular_progress_layout_stroke_width)));

    setBackgroundColor(a.getColor(R.styleable.CircularProgressLayout_backgroundColor,
            ContextCompat.getColor(context, R.color.circular_progress_layout_background_color)));

    setIndeterminate(a.getBoolean(R.styleable.CircularProgressLayout_indeterminate, false));

    a.recycle();
}

From source file:com.aengbee.android.leanback.ui.PlaybackOverlayCustomFragment.java

private void updateMetadata(final Video video) {
    final MediaMetadataCompat.Builder metadataBuilder = new MediaMetadataCompat.Builder();

    metadataBuilder.putString(MediaMetadataCompat.METADATA_KEY_MEDIA_ID, video.id + "");
    metadataBuilder.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_TITLE, video.title);
    metadataBuilder.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_SUBTITLE, video.studio);
    metadataBuilder.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_DESCRIPTION, video.description);

    long duration = Utils.getDuration(video.videoUrl);
    metadataBuilder.putLong(MediaMetadataCompat.METADATA_KEY_DURATION, duration);

    // And at minimum the title and artist for legacy support
    metadataBuilder.putString(MediaMetadataCompat.METADATA_KEY_TITLE, video.title);
    metadataBuilder.putString(MediaMetadataCompat.METADATA_KEY_ARTIST, video.studio);

    Resources res = getResources();
    int cardWidth = res.getDimensionPixelSize(R.dimen.playback_overlay_width);
    int cardHeight = res.getDimensionPixelSize(R.dimen.playback_overlay_height);

    Glide.with(this).load(Uri.parse(video.cardImageUrl)).asBitmap().centerCrop()
            .into(new SimpleTarget<Bitmap>(cardWidth, cardHeight) {
                @Override/*from   w  w w  .jav  a 2  s. c o  m*/
                public void onResourceReady(Bitmap bitmap, GlideAnimation anim) {
                    metadataBuilder.putBitmap(MediaMetadataCompat.METADATA_KEY_ART, bitmap);
                    mSession.setMetadata(metadataBuilder.build());
                }
            });
}

From source file:com.appeaser.sublimepickerlibrary.datepicker.SimpleMonthView.java

private void init() {
    mContext = getContext();/*w w  w .  ja  va  2 s .c  o m*/

    mTouchSlopSquared = ViewConfiguration.get(mContext).getScaledTouchSlop()
            * ViewConfiguration.get(mContext).getScaledTouchSlop();

    final Resources res = mContext.getResources();
    mDesiredMonthHeight = res.getDimensionPixelSize(R.dimen.sp_date_picker_month_height);
    mDesiredDayOfWeekHeight = res.getDimensionPixelSize(R.dimen.sp_date_picker_day_of_week_height);
    mDesiredDayHeight = res.getDimensionPixelSize(R.dimen.sp_date_picker_day_height);
    mDesiredCellWidth = res.getDimensionPixelSize(R.dimen.sp_date_picker_day_width);
    mDesiredDaySelectorRadius = res.getDimensionPixelSize(R.dimen.sp_date_picker_day_selector_radius);
    mPaddingRangeIndicator = res.getDimensionPixelSize(R.dimen.sp_month_view_range_padding);

    // Set up accessibility components.
    mTouchHelper = new MonthViewTouchHelper(this);

    ViewCompat.setAccessibilityDelegate(this, mTouchHelper);
    ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);

    final Locale locale = res.getConfiguration().locale;

    String titleFormat;

    if (SUtils.isApi_18_OrHigher()) {
        titleFormat = DateFormat.getBestDateTimePattern(locale, DEFAULT_TITLE_FORMAT);
    } else {
        titleFormat = DateTimePatternHelper.getBestDateTimePattern(locale, DateTimePatternHelper.PATTERN_MMMMy);
    }

    mTitleFormatter = new SimpleDateFormat(titleFormat, locale);
    mDayOfWeekFormatter = new SimpleDateFormat(DAY_OF_WEEK_FORMAT, locale);
    mDayFormatter = NumberFormat.getIntegerInstance(locale);

    initPaints(res);
}

From source file:com.android.launcher3.allapps.AllAppsGridAdapter.java

public AllAppsGridAdapter(Launcher launcher, AlphabeticalAppsList apps, View.OnTouchListener touchListener,
        View.OnClickListener iconClickListener, View.OnLongClickListener iconLongClickListener) {
    Resources res = launcher.getResources();
    mLauncher = launcher;//from w w  w  .  j ava 2s. c om
    mApps = apps;
    mEmptySearchMessage = res.getString(R.string.all_apps_loading_message);
    mGridSizer = new GridSpanSizer();
    mGridLayoutMgr = new AppsGridLayoutManager(launcher);
    mGridLayoutMgr.setSpanSizeLookup(mGridSizer);
    mItemDecoration = new GridItemDecoration();
    mLayoutInflater = LayoutInflater.from(launcher);
    mTouchListener = touchListener;
    mIconClickListener = iconClickListener;
    mIconLongClickListener = iconLongClickListener;
    mSectionNamesMargin = res.getDimensionPixelSize(R.dimen.all_apps_grid_view_start_margin);
    mSectionHeaderOffset = res.getDimensionPixelSize(R.dimen.all_apps_grid_section_y_offset);
    mIsRtl = Utilities.isRtl(res);

    mSectionTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mSectionTextPaint.setTextSize(res.getDimensionPixelSize(R.dimen.all_apps_grid_section_text_size));
    mSectionTextPaint.setColor(res.getColor(R.color.all_apps_grid_section_text_color));

    mPredictedAppsDividerPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPredictedAppsDividerPaint.setStrokeWidth(Utilities.pxFromDp(1f, res.getDisplayMetrics()));
    mPredictedAppsDividerPaint.setColor(0x1E000000);
    mPredictionBarDividerOffset = (-res.getDimensionPixelSize(R.dimen.all_apps_prediction_icon_bottom_padding)
            + res.getDimensionPixelSize(R.dimen.all_apps_icon_top_bottom_padding)) / 2;
}

From source file:com.miuhouse.yourcompany.student.view.widget.date.datepicker.SimpleMonthView.java

private void init() {
    mContext = getContext();/*w ww  .  j a v a  2 s  .  com*/

    mTouchSlopSquared = ViewConfiguration.get(mContext).getScaledTouchSlop()
            * ViewConfiguration.get(mContext).getScaledTouchSlop();

    final Resources res = mContext.getResources();
    mDesiredMonthHeight = res.getDimensionPixelSize(R.dimen.sp_date_picker_month_height);
    mDesiredDayOfWeekHeight = res.getDimensionPixelSize(R.dimen.sp_date_picker_day_of_week_height);
    mDesiredDayHeight = res.getDimensionPixelSize(R.dimen.sp_date_picker_day_height);
    mDesiredCellWidth = res.getDimensionPixelSize(R.dimen.sp_date_picker_day_width);
    mDesiredDaySelectorRadius = res.getDimensionPixelSize(R.dimen.sp_date_picker_day_selector_radius);
    mPaddingRangeIndicator = res.getDimensionPixelSize(R.dimen.sp_month_view_range_padding);

    // Set up accessibility components.
    //        mTouchHelper = new MonthViewTouchHelper(this);

    //        ViewCompat.setAccessibilityDelegate(this, mTouchHelper);
    ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);

    final Locale locale = res.getConfiguration().locale;

    String titleFormat;

    if (SUtils.isApi_18_OrHigher()) {
        titleFormat = DateFormat.getBestDateTimePattern(locale, DEFAULT_TITLE_FORMAT);
    } else {
        titleFormat = DateTimePatternHelper.getBestDateTimePattern(locale, DateTimePatternHelper.PATTERN_MMMMy);
    }

    mTitleFormatter = new SimpleDateFormat(titleFormat, locale);
    mDayOfWeekFormatter = new SimpleDateFormat(DAY_OF_WEEK_FORMAT, locale);
    mDayFormatter = NumberFormat.getIntegerInstance(locale);

    initPaints(res);
}