Java Code Examples for android.support.v4.content.res.ResourcesCompat#getDrawable()
The following examples show how to use
android.support.v4.content.res.ResourcesCompat#getDrawable() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AvatarService.java From Conversations with GNU General Public License v3.0 | 6 votes |
private static Bitmap getRoundLauncherIcon(Resources resources) { final Drawable drawable = ResourcesCompat.getDrawable(resources, R.mipmap.new_launcher_round,null); if (drawable == null) { return null; } if (drawable instanceof BitmapDrawable) { return ((BitmapDrawable)drawable).getBitmap(); } Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); drawable.draw(canvas); return bitmap; }
Example 2
Source File: SuntimesUtils.java From SuntimesWidget with GNU General Public License v3.0 | 6 votes |
/** * @param context context used to get resources * @param resourceID drawable resourceID to a LayerDrawable * @param fillColor fill color to apply to drawable * @param strokeColor stroke color to apply to drawable * @param strokePx width of stroke (pixels) * @return a Bitmap of the drawable */ public static Bitmap layerDrawableToBitmap(Context context, int resourceID, int fillColor, int strokeColor, int strokePx) { Drawable drawable = ResourcesCompat.getDrawable(context.getResources(), resourceID, null); LayerDrawable layers = (LayerDrawable)drawable; int w = 1, h = 1; if (layers != null) { Drawable layer0 = layers.getDrawable(0); w = layers.getIntrinsicWidth(); h = (layer0 != null ? layer0.getIntrinsicHeight() : layers.getIntrinsicHeight()); } Drawable tinted = tintDrawable(layers, fillColor, strokeColor, strokePx); return drawableToBitmap(context, tinted, w, h, true); }
Example 3
Source File: MapViewerOsmDroid.java From AIMSICDL with GNU General Public License v3.0 | 5 votes |
/** * Description: Initialises the Map and sets initial options such as: * Zoom levels and controls * Compass * ScaleBar * Cluster Pin colors * Location update settings */ private void setUpMapIfNeeded() { // Check if we were successful in obtaining the map. mMap.setBuiltInZoomControls(true); mMap.setMultiTouchControls(true); mMap.setMinZoomLevel(3); mMap.setMaxZoomLevel(19); // Latest OSM can go to 21! mMap.getTileProvider().createTileCache(); mCompassOverlay = new CompassOverlay(this, new InternalCompassOrientationProvider(this), mMap); ScaleBarOverlay mScaleBarOverlay = new ScaleBarOverlay(this); mScaleBarOverlay.setScaleBarOffset(getResources().getDisplayMetrics().widthPixels / 2, 10); mScaleBarOverlay.setCentred(true); // Sets cluster pin color mCellTowerGridMarkerClusterer = new CellTowerGridMarkerClusterer(MapViewerOsmDroid.this); //BitmapDrawable mapPinDrawable = (BitmapDrawable) getResources().getDrawable(R.drawable.ic_map_pin_orange); BitmapDrawable mapPinDrawable = (BitmapDrawable) ResourcesCompat.getDrawable(getResources(),R.drawable.ic_map_pin_orange, null); mCellTowerGridMarkerClusterer.setIcon(mapPinDrawable == null ? null : mapPinDrawable.getBitmap()); GpsMyLocationProvider gpsMyLocationProvider = new GpsMyLocationProvider(MapViewerOsmDroid.this.getBaseContext()); gpsMyLocationProvider.setLocationUpdateMinDistance(100); // [m] // Set the minimum distance for location updates gpsMyLocationProvider.setLocationUpdateMinTime(10000); // [ms] // Set the minimum time interval for location updates mMyLocationOverlay = new MyLocationNewOverlay(MapViewerOsmDroid.this.getBaseContext(), gpsMyLocationProvider, mMap); mMyLocationOverlay.setDrawAccuracyEnabled(true); mMap.getOverlays().add(mCellTowerGridMarkerClusterer); mMap.getOverlays().add(mMyLocationOverlay); mMap.getOverlays().add(mCompassOverlay); mMap.getOverlays().add(mScaleBarOverlay); }
Example 4
Source File: ImgURIUtil.java From weex-uikit with MIT License | 5 votes |
public static Drawable getDrawableFromLoaclSrc(Context context, Uri rewrited) { Resources resources = context.getResources(); List<String> segments = rewrited.getPathSegments(); if (segments.size() != 1) { WXLogUtils.e("Local src format is invalid."); return null; } int id = resources.getIdentifier(segments.get(0), "drawable", context.getPackageName()); return id == 0 ? null : ResourcesCompat.getDrawable(resources, id, null); }
Example 5
Source File: SublimeThemer.java From SublimeNavigationView with Apache License 2.0 | 5 votes |
public Drawable getGroupCollapseDrawable() { if (mGroupCollapseDrawable == null) { mGroupCollapseDrawable = ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.snv_collapse, mContext.getTheme()); } // Return a new drawable since this method will be // called multiple times return mGroupCollapseDrawable.getConstantState().newDrawable(); }
Example 6
Source File: DrawableUtils.java From PainlessMusicPlayer with Apache License 2.0 | 5 votes |
@Nullable public static Drawable getTintedDrawable(@NonNull final Context context, @DrawableRes final int res, @Nullable final ColorStateList tint) { final Drawable d = ResourcesCompat.getDrawable(context.getResources(), res, context.getTheme()); return getTintedDrawable(d, tint); }
Example 7
Source File: SublimeThemer.java From SublimeNavigationView with Apache License 2.0 | 5 votes |
public Drawable getGroupExpandDrawable() { if (mGroupExpandDrawable == null) { mGroupExpandDrawable = ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.snv_expand, mContext.getTheme()); } // Return a new drawable since this method will be // called multiple times return mGroupExpandDrawable.getConstantState().newDrawable(); }
Example 8
Source File: StandardShowcaseDrawer.java From xDrip-plus with GNU General Public License v3.0 | 5 votes |
public StandardShowcaseDrawer(Resources resources, Resources.Theme theme) { PorterDuffXfermode xfermode = new PorterDuffXfermode(PorterDuff.Mode.MULTIPLY); eraserPaint = new Paint(); eraserPaint.setColor(0xFFFFFF); eraserPaint.setAlpha(0); eraserPaint.setXfermode(xfermode); eraserPaint.setAntiAlias(true); basicPaint = new Paint(); showcaseRadius = resources.getDimension(com.github.amlcurran.showcaseview.R.dimen.showcase_radius); showcaseDrawable = ResourcesCompat.getDrawable(resources, com.github.amlcurran.showcaseview.R.drawable.cling_bleached, theme); }
Example 9
Source File: MapFragment.java From AIMSICDL with GNU General Public License v3.0 | 5 votes |
/** * Description: Initialises the Map and sets initial options such as: * Zoom levels and controls * Compass * ScaleBar * Cluster Pin colors * Location update settings */ private void setUpMapIfNeeded() { // Check if we were successful in obtaining the map. mMap.setBuiltInZoomControls(true); mMap.setMultiTouchControls(true); mMap.setMinZoomLevel(3); mMap.setMaxZoomLevel(19); // Latest OSM can go to 21! mMap.getTileProvider().createTileCache(); mCompassOverlay = new CompassOverlay(getActivity(), new InternalCompassOrientationProvider(getActivity()), mMap); ScaleBarOverlay mScaleBarOverlay = new ScaleBarOverlay(getActivity()); mScaleBarOverlay.setScaleBarOffset(getResources().getDisplayMetrics().widthPixels / 2, 10); mScaleBarOverlay.setCentred(true); // Sets cluster pin color mCellTowerGridMarkerClusterer = new CellTowerGridMarkerClusterer(getActivity()); //BitmapDrawable mapPinDrawable = (BitmapDrawable) getResources().getDrawable(R.drawable.ic_map_pin_orange); BitmapDrawable mapPinDrawable = (BitmapDrawable) ResourcesCompat.getDrawable(getResources(), R.drawable.ic_map_pin_orange, null); mCellTowerGridMarkerClusterer.setIcon(mapPinDrawable == null ? null : mapPinDrawable.getBitmap()); GpsMyLocationProvider gpsMyLocationProvider = new GpsMyLocationProvider(getActivity().getBaseContext()); gpsMyLocationProvider.setLocationUpdateMinDistance(100); // [m] // Set the minimum distance for location updates gpsMyLocationProvider.setLocationUpdateMinTime(10000); // [ms] // Set the minimum time interval for location updates mMyLocationOverlay = new MyLocationNewOverlay(getActivity().getBaseContext(), gpsMyLocationProvider, mMap); mMyLocationOverlay.setDrawAccuracyEnabled(true); mMap.getOverlays().add(mCellTowerGridMarkerClusterer); mMap.getOverlays().add(mMyLocationOverlay); mMap.getOverlays().add(mCompassOverlay); mMap.getOverlays().add(mScaleBarOverlay); }
Example 10
Source File: FullScreenDialogFragment.java From FullScreenDialog with Apache License 2.0 | 5 votes |
private void setThemeBackground(View view) { TypedValue a = new TypedValue(); getActivity().getTheme().resolveAttribute(android.R.attr.windowBackground, a, true); if (a.type >= TypedValue.TYPE_FIRST_COLOR_INT && a.type <= TypedValue.TYPE_LAST_COLOR_INT) { view.setBackgroundColor(a.data); } else { try { Drawable d = ResourcesCompat.getDrawable(getActivity().getResources(), a.resourceId, getActivity().getTheme()); ViewCompat.setBackground(view, d); } catch (Resources.NotFoundException ignore) { } } }
Example 11
Source File: SublimeThemer.java From SublimeNavigationView with Apache License 2.0 | 5 votes |
public Drawable getGroupCollapseDrawable() { if (mGroupCollapseDrawable == null) { mGroupCollapseDrawable = ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.snv_collapse, mContext.getTheme()); } // Return a new drawable since this method will be // called multiple times return mGroupCollapseDrawable.getConstantState().newDrawable(); }
Example 12
Source File: SmileBar.java From SmileBar with Apache License 2.0 | 4 votes |
private void init(AttributeSet attrs) { isSliding = false; if (attrs != null) { TypedArray ta = getContext().obtainStyledAttributes(attrs, R.styleable.SmileBar, 0, 0); try { smileWidth = ta.getDimensionPixelSize(R.styleable.SmileBar_smileWidth, 0); smileHeight = ta.getDimensionPixelSize(R.styleable.SmileBar_smileHeight, 0); horizontalSpacing = ta.getDimensionPixelSize(R.styleable.SmileBar_horizontalSpacing, 0); isEnabled = ta.getBoolean(R.styleable.SmileBar_enabled, true); rating = ta.getInt(R.styleable.SmileBar_rating, NO_RATING); int resDefault = ta.getResourceId(R.styleable.SmileBar_smileDefault, R.drawable.smile_rate_none); int res1 = ta.getResourceId(R.styleable.SmileBar_smileRate1, R.drawable.smile_rate_1); int res2 = ta.getResourceId(R.styleable.SmileBar_smileRate2, R.drawable.smile_rate_2); int res3 = ta.getResourceId(R.styleable.SmileBar_smileRate3, R.drawable.smile_rate_3); int res4 = ta.getResourceId(R.styleable.SmileBar_smileRate4, R.drawable.smile_rate_4); int res5 = ta.getResourceId(R.styleable.SmileBar_smileRate5, R.drawable.smile_rate_5); defaultSmile = ResourcesCompat.getDrawable(getResources(), resDefault, null); ratingSmiles = new Drawable[] { ResourcesCompat.getDrawable(getResources(), res1, null), ResourcesCompat.getDrawable(getResources(), res2, null), ResourcesCompat.getDrawable(getResources(), res3, null), ResourcesCompat.getDrawable(getResources(), res4, null), ResourcesCompat.getDrawable(getResources(), res5, null) }; if (smileWidth == 0) smileWidth = defaultSmile.getIntrinsicWidth(); if (smileHeight == 0) smileHeight = defaultSmile.getIntrinsicHeight(); } finally { ta.recycle(); } } points = new PointF[MAX_RATE]; for (int i = 0; i < MAX_RATE; i++) { points[i] = new PointF(); } if (rating != NO_RATING) setRating(rating); }
Example 13
Source File: VichanModule.java From Overchan-Android with GNU General Public License v3.0 | 4 votes |
@Override public Drawable getChanFavicon() { return ResourcesCompat.getDrawable(resources, R.drawable.favicon_vichan, null); }
Example 14
Source File: OwlchanModule.java From Overchan-Android with GNU General Public License v3.0 | 4 votes |
@Override public Drawable getChanFavicon() { return ResourcesCompat.getDrawable(resources, R.drawable.favicon_owlchan, null); }
Example 15
Source File: HeaderAboutItem.java From EasyAbout with MIT License | 4 votes |
public Builder setIcon(@DrawableRes int icon) { this.icon = ResourcesCompat.getDrawable(context.getResources(), icon, null); return this; }
Example 16
Source File: UchanModule.java From Overchan-Android with GNU General Public License v3.0 | 4 votes |
@Override public Drawable getChanFavicon() { return ResourcesCompat.getDrawable(resources, R.drawable.favicon_uchan, null); }
Example 17
Source File: MentachsuModule.java From Overchan-Android with GNU General Public License v3.0 | 4 votes |
@Override public Drawable getChanFavicon() { return ResourcesCompat.getDrawable(resources, R.drawable.favicon_02ch, null); }
Example 18
Source File: DobroModule.java From Overchan-Android with GNU General Public License v3.0 | 4 votes |
@Override public Drawable getChanFavicon() { return ResourcesCompat.getDrawable(resources, R.drawable.favicon_dobrochan, null); }
Example 19
Source File: Chan410Module.java From Overchan-Android with GNU General Public License v3.0 | 4 votes |
@Override public Drawable getChanFavicon() { return ResourcesCompat.getDrawable(resources, R.drawable.favicon_410chan, null); }
Example 20
Source File: BubbleActions.java From BubbleActions with Apache License 2.0 | 2 votes |
/** * Set the indicator drawable. The default is a semi-transparent circle. * * @param indicatorRes drawable resource id to be drawn indicating what the bubble actions * are acting on * @return the BubbleActions instance that called this method */ public BubbleActions withIndicator(int indicatorRes) { this.indicator = ResourcesCompat.getDrawable(root.getResources(), indicatorRes, root.getContext().getTheme()); return this; }