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:net.reichholf.dreamdroid.tv.presenter.CardPresenter.java

protected void bindServiceViewHolder(Presenter.ViewHolder viewHolder, Object item) {
    ExtendedHashMap event = (ExtendedHashMap) item;
    String title = event.getString(Event.KEY_SERVICE_NAME);
    String eventTitle = event.getString(Event.KEY_EVENT_TITLE);
    ImageCardView cardView = (ImageCardView) viewHolder.view;
    //cardView.setMainImage(mDefaultCardImage);

    Picon.setPiconForView(cardView.getContext(), cardView.getMainImageView(), event, "tv_picon");
    cardView.setTitleText(title);//from ww  w. j  av  a2  s .  c o  m
    cardView.setContentText(eventTitle);
    cardView.getMainImageView().setScaleType(ImageView.ScaleType.FIT_CENTER);
    Resources res = cardView.getResources();
    int width = res.getDimensionPixelSize(R.dimen.card_width);
    int height = res.getDimensionPixelSize(R.dimen.card_height);
    cardView.setMainImageDimensions(width, height);
}

From source file:com.github.xizzhu.simpletooltip.sample.MainActivity.java

private ToolTip createToolTip(CharSequence text, int backgroundColor) {
    Resources resources = getResources();
    int padding = resources.getDimensionPixelSize(R.dimen.padding);
    int textSize = resources.getDimensionPixelSize(R.dimen.text_size);
    int radius = resources.getDimensionPixelSize(R.dimen.radius);
    return new ToolTip.Builder().withText(text).withTextColor(Color.WHITE).withTextSize(textSize)
            .withBackgroundColor(backgroundColor).withPadding(padding, padding, padding, padding)
            .withCornerRadius(radius).build();
}

From source file:com.google.android.demos.jamendo.app.JamendoActivity.java

protected final String getDimensionPixelSizeAsString(int resId) {
    Resources resources = getResources();
    int size = resources.getDimensionPixelSize(resId);
    return Integer.toString(size);
}

From source file:org.lucasr.smoothie.samples.gallery.GalleryLoader.java

@Override
public Bitmap loadItem(Long id) {
    Uri imageUri = Uri.withAppendedPath(Images.Media.EXTERNAL_CONTENT_URI, String.valueOf(id));

    Resources res = mContext.getResources();
    int width = res.getDimensionPixelSize(R.dimen.image_width);
    int height = res.getDimensionPixelSize(R.dimen.image_height);

    Bitmap bitmap = decodeSampledBitmapFromResource(imageUri, width, height);
    if (bitmap != null) {
        mMemCache.put(id, bitmap);/* w w w . ja va 2s .c o  m*/
    }

    return bitmap;
}

From source file:org.mozilla.gecko.home.HomePagerTabStrip.java

public HomePagerTabStrip(Context context, AttributeSet attrs) {
    super(context, attrs);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.HomePagerTabStrip);
    int color = a.getColor(R.styleable.HomePagerTabStrip_tabIndicatorColor, 0x00);
    a.recycle();/*ww w. j a va 2s.c o m*/

    setTabIndicatorColor(color);

    final Resources res = getResources();
    shadowSize = res.getDimensionPixelSize(R.dimen.tabs_strip_shadow_size);

    shadowPaint = new Paint();
    shadowPaint.setColor(ColorUtils.getColor(context, R.color.url_bar_shadow));
    shadowPaint.setStrokeWidth(0.0f);

    getViewTreeObserver().addOnPreDrawListener(new PreDrawListener());
}

From source file:com.google.android.demos.jamendo.app.SearchActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    setContentView(R.layout.jamendo_list);

    Resources resources = getResources();
    mImageSize = resources.getDimensionPixelSize(R.dimen.gallery_size);

    mResults = new Loadable(getSupportLoaderManager(), LOADER_SEARCH,
            new StatusViewManager(this, LOADER_SEARCH, this, this));

    mAdapter = new SearchAdapter(this);
    ListView listView = (ListView) findViewById(android.R.id.list);
    listView.setAdapter(mAdapter);//from  w  w w  .  jav a 2 s .  c om
    listView.setOnItemClickListener(this);

    Intent intent = getIntent();
    String action = intent.getAction();
    if (action.equals(Intent.ACTION_VIEW)) {
        // Forward intents from suggest system to correct activity
        //
        // TODO: Is there a way to force suggest system to
        // not set the component?
        intent.setComponent(null);
        startActivity(intent);
        finish();
    } else {
        mResults.init();
    }
}

From source file:com.androidzeitgeist.webcards.overlay.HandleView.java

public HandleView(Context context) {
    super(context);

    windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);

    final Resources resources = getResources();

    margin = resources.getDimensionPixelSize(R.dimen.overlay_button_margin);
    openOffsetX = resources.getDimensionPixelSize(R.dimen.overlay_width);

    paint = new Paint();
    paint.setColor(ContextCompat.getColor(context, R.color.overlayAccent));
    paint.setAntiAlias(true);// w  w  w.j  av a 2s .  co m

    streamBitmap = BitmapFactory.decodeResource(resources, R.drawable.ic_action_stream);
    openAppBitmap = BitmapFactory.decodeResource(resources, R.drawable.ic_action_open_app);
    currentBitmap = openAppBitmap;

    setElevation(resources.getDimensionPixelSize(R.dimen.overlay_button_elevation));

    setOutlineProvider(new ViewOutlineProvider() {
        @Override
        public void getOutline(View view, Outline outline) {
            outline.setOval(0, 0, getWidth(), getHeight());
        }
    });
}

From source file:com.frapim.windwatch.Notifier.java

public Notifier(Context context) {
    mContext = context;/* w w w  . j a v a 2s  .co  m*/
    mNotificationManager = NotificationManagerCompat.from(mContext);
    Resources res = context.getResources();
    mBigIconSize = res.getDimensionPixelSize(R.dimen.big_icon_size);
    mArrowWidth = res.getDimensionPixelSize(R.dimen.wind_direction_arrow_width);
    mArrowHeight = res.getDimensionPixelSize(R.dimen.wind_direction_arrow_height);
    mArrowHeadHeight = res.getDimensionPixelSize(R.dimen.wind_direction_arrow_head_height);
}

From source file:piuk.blockchain.android.util.ActionBarFragment.java

@Override
public void onAttach(final Activity activity) {
    final Resources res = getResources();
    final int separatorWidth = res.getDimensionPixelSize(R.dimen.action_bar_button_separator_width);
    final int separatorMargin = res.getDimensionPixelSize(R.dimen.action_bar_button_separator_margin);

    separatorParams = new LinearLayout.LayoutParams(separatorWidth,
            android.view.ViewGroup.LayoutParams.FILL_PARENT, 0f);
    separatorParams.setMargins(0, separatorMargin, 0, separatorMargin);

    super.onAttach(activity);
}

From source file:com.schedjoules.eventdiscovery.framework.eventlist.EventListHeaderFragment.java

private void setupToolbar(SchedjoulesFragmentEventListHeaderBinding views) {
    Toolbar toolbar = views.schedjoulesEventListToolbar;
    toolbar.setTitle(""); // Need to set it to empty, otherwise the activity label is set automatically

    mToolbarTitle = views.schedjoulesEventListToolbarTitle;
    mToolbarTitle.setOnClickListener(new View.OnClickListener() {
        @Override/* ww  w .j ava2s  .c  o  m*/
        public void onClick(View v) {
            new LocationPickerPlaceSelection().start(EventListHeaderFragment.this);
        }
    });

    BaseActivity activity = (BaseActivity) getActivity();
    activity.setSupportActionBar(toolbar);

    Resources res = activity.getResources();
    toolbar.setContentInsetsAbsolute(
            res.getDimensionPixelSize(R.dimen.schedjoules_list_item_padding_horizontal),
            toolbar.getContentInsetRight());

    if (res.getBoolean(R.bool.schedjoules_enableBackArrowOnEventListScreen)) {
        //noinspection ConstantConditions
        activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }

    updateToolbarTitle();
}