List of usage examples for android.support.v4.content.res ResourcesCompat getDrawable
public static Drawable getDrawable(Resources resources, int i, Theme theme) throws NotFoundException
From source file:com.example.android.leanback.BrowseAnimationFragment.java
@Override public void onCreate(Bundle savedInstanceState) { Log.i(TAG, "onCreate"); super.onCreate(savedInstanceState); setBadgeDrawable(ResourcesCompat.getDrawable(getActivity().getResources(), R.drawable.ic_title, getActivity().getTheme()));//from w w w.j a v a 2 s. co m setTitle("Leanback Sample App"); setHeadersState(HEADERS_ENABLED); setOnSearchClickedListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(getActivity(), SearchActivity.class); startActivity(intent); } }); setupRows(); setOnItemViewClickedListener(new ItemViewClickedListener()); }
From source file:com.nttec.everychan.chans.samachan.SamachanModule.java
@Override public Drawable getChanFavicon() { return ResourcesCompat.getDrawable(resources, R.drawable.favicon_samachan, null); }
From source file:com.facebook.litho.reference.DrawableResourcesCache.java
public @Nullable Drawable get(int resId, Resources resources, @Nullable Resources.Theme theme) { SimplePoolWithCount<Drawable> drawablesPool = mDrawableCache.get(resId); if (drawablesPool == null) { drawablesPool = new SimplePoolWithCount<>(DRAWABLES_POOL_MAX_ITEMS); mDrawableCache.put(resId, drawablesPool); }//w ww . j a va 2 s . co m Drawable drawable = drawablesPool.acquire(); if (drawable == null) { drawable = ResourcesCompat.getDrawable(resources, resId, theme); } // We never want this pool to remain empty otherwise we would risk to resolve a new drawable // when get is called again. So if the pool is about to drain we just put a new Drawable in it // to keep it warm. if (drawable != null && drawablesPool.getPoolSize() == 0) { drawablesPool.release(drawable.getConstantState().newDrawable()); } return drawable; }
From source file:com.android.contacts.model.account.FallbackAccountType.java
@Override public Drawable getDisplayIcon(Context context) { final Drawable icon = ResourcesCompat.getDrawable(context.getResources(), iconRes, null); icon.mutate().setColorFilter(ContextCompat.getColor(context, R.color.actionbar_icon_color_grey), PorterDuff.Mode.SRC_ATOP);/*from ww w. j a va2 s.co m*/ return icon; }
From source file:com.ibm.mil.readyapps.telco.usage.IncomingOutgoingBinder.java
/** * @param usageViewHolder the ViewHolder to use onBind * has all the associated views in this layout * @param position the position of this ViewHolder in the binder */// www . ja v a 2 s.co m @Override public void bindViewHolder(UsageViewHolder usageViewHolder, int position) { if (currentUsage.getType() == PlanConstants.TEXT) { usageViewHolder.incomingBar .setImageSource(ResourcesCompat.getDrawable(resources, R.drawable.intext, null)); usageViewHolder.outgoingBar .setImageSource(ResourcesCompat.getDrawable(resources, R.drawable.outtext, null)); usageViewHolder.incomingBar .setBottomRightText(currentUsage.getIncoming() + " " + PlanConstants.TEXT_UNIT); usageViewHolder.outgoingBar .setBottomRightText(currentUsage.getOutgoing() + " " + PlanConstants.TEXT_UNIT); } else { usageViewHolder.incomingBar .setBottomRightText(currentUsage.getIncoming() + " " + PlanConstants.TALK_UNIT); usageViewHolder.outgoingBar .setBottomRightText(currentUsage.getOutgoing() + " " + PlanConstants.TALK_UNIT); } usageViewHolder.incomingBar.setPercentUsed((currentUsage.getIncoming() * 100) / currentUsage.getTotal()); usageViewHolder.outgoingBar.setPercentUsed((currentUsage.getOutgoing() * 100) / currentUsage.getTotal()); }
From source file:com.yanzhenjie.album.sample.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); DisplayUtils.initScreen(this); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);//from w w w.j a v a2 s .co m noneView = findViewById(R.id.none_view); mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view); mRecyclerView.setLayoutManager(new GridLayoutManager(this, 3)); Drawable drawable = ResourcesCompat.getDrawable(getResources(), R.drawable.decoration_white, null); mRecyclerView.addItemDecoration(new AlbumVerticalGirdDecoration(drawable)); assert drawable != null; int itemSize = (DisplayUtils.screenWidth - (drawable.getIntrinsicWidth() * 4)) / 3; mGridAdapter = new GridAdapter(this, (view, position) -> previewImage(position), itemSize); mRecyclerView.setAdapter(mGridAdapter); mImageList = new ArrayList<>(); }
From source file:org.iota.wallet.ui.adapter.NeighborsListAdapter.java
@Override public void onBindViewHolder(NeighborViewHolder holder, int position) { int adapterPosition = holder.getAdapterPosition(); Neighbor neighbor = getItem(adapterPosition); if (neighbor != null) { holder.ipAddressTextView.setText(neighbor.getAddress()); if (neighbor.isOnline()) { holder.statusView.setImageDrawable( ResourcesCompat.getDrawable(context.getResources(), R.drawable.indicator_online, null)); if (neighbor.getNumberOfAllTransactions() != null && neighbor.getNumberOfInvalidTransactions() != null && neighbor.getNumberOfNewTransactions() != null) { holder.numberOfAllTransactionsTextView.setText(context.getString(R.string.all_transactions) + " " + neighbor.getNumberOfAllTransactions()); holder.numberOfInvalidTransactionsTextView .setText(context.getString(R.string.invalid_transactions) + " " + neighbor.getNumberOfInvalidTransactions()); holder.numberOfNewTransactionsTextView.setText(context.getString(R.string.new_transactions) + " " + neighbor.getNumberOfNewTransactions()); holder.numberOfRandomTransactionRequestsTextView .setText(context.getString(R.string.random_transaction_requests) + " " + neighbor.getNumberOfRandomTransactionRequests()); holder.numberOfSentTransactionsTextView.setText(context.getString(R.string.sent_transactions) + " " + neighbor.getNumberOfSentTransactions()); holder.connectionTypeTextView.setText( context.getString(R.string.connection_type) + " " + neighbor.getConnectionType()); } else { holder.numberOfAllTransactionsTextView.setText( context.getString(R.string.all_transactions) + " " + context.getString(R.string.na)); holder.numberOfInvalidTransactionsTextView .setText(context.getString(R.string.invalid_transactions) + " " + context.getString(R.string.na)); holder.numberOfNewTransactionsTextView.setText( context.getString(R.string.new_transactions) + " " + context.getString(R.string.na)); holder.numberOfRandomTransactionRequestsTextView .setText(context.getString(R.string.random_transaction_requests) + " " + context.getString(R.string.na)); holder.numberOfSentTransactionsTextView.setText( context.getString(R.string.sent_transactions) + " " + context.getString(R.string.na)); holder.connectionTypeTextView.setText( context.getString(R.string.connection_type) + " " + context.getString(R.string.na)); }/*from w w w. java 2s . c o m*/ } else { holder.statusView.setImageDrawable( ResourcesCompat.getDrawable(context.getResources(), R.drawable.indicator_offline, null)); holder.numberOfInvalidTransactionsTextView.setText("-"); holder.numberOfAllTransactionsTextView.setText("-"); holder.numberOfNewTransactionsTextView.setText("-"); holder.numberOfRandomTransactionRequestsTextView.setText("-"); holder.numberOfSentTransactionsTextView.setText("-"); holder.connectionTypeTextView.setText("-"); } } }
From source file:nya.miku.wishmaster.chans.kakashinenpo.KakashiNenpoModule.java
@Override public Drawable getChanFavicon() { return ResourcesCompat.getDrawable(resources, R.drawable.favicon_kakashinenpo, null); }
From source file:nya.miku.wishmaster.chans.depreschan.DepresModule.java
@Override public Drawable getChanFavicon() { return ResourcesCompat.getDrawable(resources, R.drawable.favicon_depreschan, null); }
From source file:org.mariotaku.twidere.fragment.OpenStreetMapViewerFragment.java
@Override public void onActivityCreated(final Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); setHasOptionsMenu(true);//from w w w . j a v a 2 s. c o m final Bundle args = getArguments(); final double latitude = args.getDouble(EXTRA_LATITUDE, Double.NaN); final double longitude = args.getDouble(EXTRA_LONGITUDE, Double.NaN); if (Double.isNaN(latitude) || Double.isNaN(longitude)) { getActivity().finish(); return; } mLatitude = latitude; mLongitude = longitude; mMapView.setMultiTouchControls(true); mMapView.setBuiltInZoomControls(true); mMapView.setTilesScaledToDpi(true); final List<Overlay> overlays = mMapView.getOverlays(); final GeoPoint gp = new GeoPoint((int) (latitude * 1E6), (int) (longitude * 1E6)); final Drawable d = ResourcesCompat.getDrawable(getResources(), R.drawable.ic_map_marker, null); final Itemization markers = new Itemization(d, mMapView.getResourceProxy()); final OverlayItem overlayitem = new OverlayItem("", "", gp); markers.addOverlay(overlayitem); overlays.add(markers); final IMapController mc = mMapView.getController(); mc.setZoom(12); mc.setCenter(gp); }