List of usage examples for android.widget ImageView setImageDrawable
public void setImageDrawable(@Nullable Drawable drawable)
From source file:com.br.chat.gallery.ImageWorker.java
/** * Load an image specified by the data parameter into an ImageView (override * {@link ImageWorker#processBitmap(Object)} to define the processing logic). A memory and * disk cache will be used if an {@link ImageCache} has been added using * {@link ImageWorker#addImageCache(android.support.v4.app.FragmentManager, ImageCache.ImageCacheParams)}. If the * image is found in the memory cache, it is set immediately, otherwise an {@link AsyncTask} * will be created to asynchronously load the bitmap. * * @param data The URL of the image to download. * @param imageView The ImageView to bind the downloaded image to. *//*w ww . j av a 2 s.co m*/ public void loadImage(Object data, ImageView imageView) { if (data == null) { return; } BitmapDrawable value = null; if (mImageCache != null) { value = mImageCache.getBitmapFromMemCache(String.valueOf(data)); } if (value != null) { // Bitmap found in memory cache imageView.setImageDrawable(value); } else if (cancelPotentialWork(data, imageView)) { //BEGIN_INCLUDE(execute_background_task) final BitmapWorkerTask task = new BitmapWorkerTask(data, imageView); final AsyncDrawable asyncDrawable = new AsyncDrawable(mResources, mLoadingBitmap, task); imageView.setImageDrawable(asyncDrawable); // NOTE: This uses a custom version of AsyncTask that has been pulled from the // framework and slightly modified. Refer to the docs at the top of the class // for more info on what was changed. task.executeOnExecutor(com.br.chat.gallery.AsyncTask.DUAL_THREAD_EXECUTOR); //END_INCLUDE(execute_background_task) } }
From source file:com.dimelo.sampleapp.google.IconSlidingTabLayout.java
private void updateIcon(ImageView iconImageView, int position) { if (mViewPager == null) { return;/*from www . jav a2s .c o m*/ } int icon_id; ViewPagerIconAndTextAdapter adapter = (ViewPagerIconAndTextAdapter) mViewPager.getAdapter(); if (position == mViewPager.getCurrentItem()) { icon_id = adapter.getSelectedPageIconId(position); } else { icon_id = adapter.getPageIconId(position); } Resources resources = getContext().getResources(); Drawable icon = DrawableCompat.wrap(resources.getDrawable(icon_id)); DrawableCompat.setTint(icon, resources.getColor(R.color.accent)); iconImageView.setImageDrawable(icon); }
From source file:com.almalence.opencam.ui.AlmalenceStore.java
private void initStoreList() { storeViews.clear();//from ww w . ja va2 s. c o m buttonStoreViewAssoc.clear(); // <!-- -+- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainScreen.getMainContext()); boolean bOnSale = prefs.getBoolean("bOnSale", false); for (int i = 0; i < STORE_ELEMENTS_NUMBER; i++) { LayoutInflater inflator = MainScreen.getInstance().getLayoutInflater(); View item = inflator.inflate(R.layout.gui_almalence_store_grid_element, null, false); ImageView icon = (ImageView) item.findViewById(R.id.storeImage); TextView description = (TextView) item.findViewById(R.id.storeText); TextView price = (TextView) item.findViewById(R.id.storePriceText); switch (i) { case 0: // unlock all icon.setImageDrawable(MainScreen.getAppResources().getDrawable(R.drawable.store_all)); description .setText(MainScreen.getAppResources().getString(R.string.Pref_Upgrde_All_Preference_Title)); if (MainScreen.getInstance().isPurchasedAll()) price.setText(R.string.already_unlocked); else { if (MainScreen.getInstance().isCouponSale()) { price.setText(MainScreen.getInstance().titleUnlockAllCoupon); ((ImageView) item.findViewById(R.id.storeSaleImage)).setVisibility(View.VISIBLE); } else { price.setText(MainScreen.getInstance().titleUnlockAll); if (bOnSale) ((ImageView) item.findViewById(R.id.storeSaleImage)).setVisibility(View.VISIBLE); } } break; case 1: // Super icon.setImageDrawable(MainScreen.getAppResources().getDrawable(R.drawable.store_super)); description.setText( MainScreen.getAppResources().getString(R.string.Pref_Upgrde_Super_Preference_Title)); if (MainScreen.getInstance().isPurchasedSuper() || MainScreen.getInstance().isPurchasedAll()) price.setText(R.string.already_unlocked); else { if (CameraController.isSuperModePossible()) price.setText(MainScreen.getInstance().titleUnlockSuper); else price.setText( MainScreen.getAppResources().getString(R.string.Pref_Upgrde_SuperNotSupported)); } break; case 2: // HDR icon.setImageDrawable(MainScreen.getAppResources().getDrawable(R.drawable.store_hdr)); description .setText(MainScreen.getAppResources().getString(R.string.Pref_Upgrde_HDR_Preference_Title)); if (MainScreen.getInstance().isPurchasedHDR() || MainScreen.getInstance().isPurchasedAll()) price.setText(R.string.already_unlocked); else price.setText(MainScreen.getInstance().titleUnlockHDR); break; case 3: // Panorama icon.setImageDrawable(MainScreen.getAppResources().getDrawable(R.drawable.store_panorama)); description.setText( MainScreen.getAppResources().getString(R.string.Pref_Upgrde_Panorama_Preference_Title)); if (MainScreen.getInstance().isPurchasedPanorama() || MainScreen.getInstance().isPurchasedAll()) price.setText(R.string.already_unlocked); else price.setText(MainScreen.getInstance().titleUnlockPano); break; case 4: // multishot icon.setImageDrawable(MainScreen.getAppResources().getDrawable(R.drawable.store_moving)); description.setText( MainScreen.getAppResources().getString(R.string.Pref_Upgrde_Moving_Preference_Title)); if (MainScreen.getInstance().isPurchasedMoving() || MainScreen.getInstance().isPurchasedAll()) price.setText(R.string.already_unlocked); else price.setText(MainScreen.getInstance().titleUnlockMoving); break; case 5: // Promo code icon.setImageDrawable(MainScreen.getAppResources().getDrawable(R.drawable.store_promo)); description.setText( MainScreen.getAppResources().getString(R.string.Pref_Upgrde_PromoCode_Preference_Title)); if (MainScreen.getInstance().isPurchasedAll()) price.setText(R.string.already_unlocked); else price.setText(""); break; default: break; } item.setOnClickListener(new OnClickListener() { public void onClick(View v) { // get inapp associated with pressed button purchasePressed(v); } }); buttonStoreViewAssoc.put(item, i); storeViews.add(item); } //-+- --> storeAdapter.Elements = storeViews; }
From source file:com.example.mohmurtu.registration.imagesUtil.ImageWorker.java
public void loadImage(Object data, ImageView imageView) { if (data == null) { return;/* w ww . j a v a 2s . c om*/ } BitmapDrawable value = null; if (mImageCache != null) { value = mImageCache.getBitmapFromMemCache(String.valueOf(data)); } if (value != null) { // Bitmap found in memory cache imageView.setImageDrawable(value); } else if (cancelPotentialWork(data, imageView)) { //BEGIN_INCLUDE(execute_background_task) final BitmapWorkerTask task = new BitmapWorkerTask(data, imageView, 0); // Modified by Mohsin added 0 in arguments final AsyncDrawable asyncDrawable = new AsyncDrawable(mResources, mLoadingBitmap, task); imageView.setImageDrawable(asyncDrawable); // NOTE: This uses a custom version of AsyncTask that has been pulled from the // framework and slightly modified. Refer to the docs at the top of the class // for more info on what was changed. task.executeOnExecutor(AsyncTask.DUAL_THREAD_EXECUTOR); //END_INCLUDE(execute_background_task) } }
From source file:com.example.android.displayingbitmaps.imageloader.ImageWorker.java
/** * Load an image specified by the data parameter into an ImageView (override * {@link ImageWorker#processBitmap(Object)} to define the processing logic). A memory and * disk cache will be used if an {@link ImageCache} has been added using * {@link ImageWorker#addImageCache(android.support.v4.app.FragmentManager, ImageCache.ImageCacheParams)}. If the * image is found in the memory cache, it is set immediately, otherwise an {@link AsyncTask} * will be created to asynchronously load the bitmap. * * @param data The URI of the image./*from w w w . ja v a 2s .c o m*/ * @param imageView The ImageView to bind the downloaded image to. */ public void loadImage(Object data, ImageView imageView) { if (data == null) { return; } BitmapDrawable value = null; if (mImageCache != null) { value = mImageCache.getBitmapFromMemCache(String.valueOf(data)); } if (value != null) { // Bitmap found in memory cache imageView.setImageDrawable(value); imageView.setBackgroundColor(Color.TRANSPARENT); } else if (cancelPotentialWork(data, imageView)) { //BEGIN_INCLUDE(execute_background_task) final BitmapWorkerTask task = new BitmapWorkerTask(data, imageView); final AsyncDrawable asyncDrawable = new AsyncDrawable(mResources, mLoadingBitmap, task); imageView.setImageDrawable(asyncDrawable); // NOTE: This uses a custom version of AsyncTask that has been pulled from the // framework and slightly modified. Refer to the docs at the top of the class // for more info on what was changed. task.executeOnExecutor(AsyncTask.DUAL_THREAD_EXECUTOR); //END_INCLUDE(execute_background_task) } }
From source file:android.com.example.contactslist.util.ImageLoader.java
/** * Called when the processing is complete and the final bitmap should be set on the ImageView. * * @param imageView The ImageView to set the bitmap to. * @param bitmap The new bitmap to set.// w ww . j a v a2s . com */ private void setImageBitmap(ImageView imageView, Bitmap bitmap) { if (mFadeInBitmap) { // Transition drawable to fade from loading bitmap to final bitmap final TransitionDrawable td = new TransitionDrawable(new Drawable[] { new ColorDrawable(android.R.color.transparent), new BitmapDrawable(mResources, bitmap) }); imageView.setBackgroundDrawable(imageView.getDrawable()); imageView.setImageDrawable(td); td.startTransition(FADE_IN_TIME); } else { imageView.setImageBitmap(bitmap); } }
From source file:com.layer.atlas.cells.GeoCell.java
@Override public View onBind(final ViewGroup cellContainer) { ViewGroup cellRoot = (ViewGroup) Tools.findChildById(cellContainer, R.id.atlas_view_messages_cell_geo); if (cellRoot == null) { cellRoot = (ViewGroup) LayoutInflater.from(cellContainer.getContext()) .inflate(R.layout.atlas_view_messages_cell_geo, cellContainer, false); if (debug) Log.w(TAG, "geo.onBind() inflated geo cell"); }/*w ww .ja va2 s . com*/ ImageView geoImageMy = (ImageView) cellRoot.findViewById(R.id.atlas_view_messages_cell_geo_image_my); ImageView geoImageTheir = (ImageView) cellRoot.findViewById(R.id.atlas_view_messages_cell_geo_image_their); View containerMy = cellRoot.findViewById(R.id.atlas_view_messages_cell_geo_container_my); View containerTheir = cellRoot.findViewById(R.id.atlas_view_messages_cell_geo_container_their); boolean myMessage = messagesList.getLayerClient().getAuthenticatedUserId() .equals(messagePart.getMessage().getSender().getUserId()); if (myMessage) { containerMy.setVisibility(View.VISIBLE); containerTheir.setVisibility(View.GONE); } else { containerMy.setVisibility(View.GONE); containerTheir.setVisibility(View.VISIBLE); } ImageView geoImage = myMessage ? geoImageMy : geoImageTheir; ShapedFrameLayout cellCustom = (ShapedFrameLayout) (myMessage ? containerMy : containerTheir); Object imageId = messagePart.getId(); Bitmap bmp = (Bitmap) Atlas.imageLoader.getImageFromCache(imageId); if (bmp != null) { if (debug) Log.d(TAG, "geo.onBind() bitmap: " + bmp.getWidth() + "x" + bmp.getHeight()); geoImage.setImageBitmap(bmp); } else { if (debug) Log.d(TAG, "geo.onBind() spec: " + spec); geoImage.setImageDrawable(Tools.EMPTY_DRAWABLE); // schedule image File tileFile = getTileFile(cellContainer.getContext()); if (tileFile.exists()) { if (debug) Log.d(TAG, "geo.onBind() decodeImage: " + tileFile); // request decoding spec = Atlas.imageLoader.requestImage(imageId, new Atlas.FileStreamProvider(tileFile), (int) Tools.getPxFromDp(150, cellContainer.getContext()), (int) Tools.getPxFromDp(150, cellContainer.getContext()), false, this); } else { int width = 300; int height = 300; int zoom = 16; final String url = new StringBuilder().append("https://maps.googleapis.com/maps/api/staticmap?") .append("format=png32&").append("center=").append(lat).append(",").append(lon).append("&") .append("zoom=").append(zoom).append("&").append("size=").append(width).append("x") .append(height).append("&").append("maptype=roadmap&").append("markers=color:red%7C") .append(lat).append(",").append(lon).toString(); Atlas.downloadQueue.schedule(url, tileFile, this); if (debug) Log.d(TAG, "geo.onBind() show stub and download image: " + tileFile); } } // clustering cellCustom.setCornerRadiusDp(16, 16, 16, 16); if (AtlasMessagesList.CLUSTERED_BUBBLES) { if (myMessage) { if (this.clusterHeadItemId == this.clusterItemId && !this.clusterTail) { cellCustom.setCornerRadiusDp(16, 16, 2, 16); } else if (this.clusterTail && this.clusterHeadItemId != this.clusterItemId) { cellCustom.setCornerRadiusDp(16, 2, 16, 16); } else if (this.clusterHeadItemId != this.clusterItemId && !this.clusterTail) { cellCustom.setCornerRadiusDp(16, 2, 2, 16); } } else { if (this.clusterHeadItemId == this.clusterItemId && !this.clusterTail) { cellCustom.setCornerRadiusDp(16, 16, 16, 2); } else if (this.clusterTail && this.clusterHeadItemId != this.clusterItemId) { cellCustom.setCornerRadiusDp(2, 16, 16, 16); } else if (this.clusterHeadItemId != this.clusterItemId && !this.clusterTail) { cellCustom.setCornerRadiusDp(2, 16, 16, 2); } } } return cellRoot; }
From source file:com.zia.freshdocs.widget.CMISAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { View view = super.getView(position, convertView, parent); NodeRef nodeRef = getItem(position); TextView textView = (TextView) view.findViewById(R.id.node_ref_label); textView.setText(nodeRef.getName()); TextView textModifiedView = (TextView) view.findViewById(R.id.node_ref_modified); String lastModified = nodeRef.getLastModifiedBy(); textModifiedView.setText(lastModified); String dateStr = nodeRef.getLastModificationDate(); SimpleDateFormat parseFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.S'Z'"); Date date = null;//w ww. ja va2s . c o m try { date = parseFormat.parse(dateStr); SimpleDateFormat outFormat = new SimpleDateFormat("HH:mm:ss MM/dd/yyyy"); dateStr = outFormat.format(date); } catch (Exception e) { e.printStackTrace(); } if (lastModified == null) { textModifiedView.setText(dateStr); } else { TextView textModDateView = (TextView) view.findViewById(R.id.node_ref_modified_date); textModDateView.setText(dateStr); } ImageView imgView = (ImageView) view.findViewById(R.id.node_ref_img); String contentType = nodeRef.getContentType(); Drawable icon = getDrawableForType(contentType == null ? "cmis/folder" : contentType); imgView.setImageDrawable(icon); return view; }
From source file:com.androidpi.bricks.gallery.lru.cache.ImageWorker.java
/** * Load an image specified by the data parameter into an ImageView (override {@link * ImageWorker#processBitmap(Object)} to define the processing logic). A memory and disk cache * will be used if an {@link ImageCache} has been added using {@link * ImageWorker#addImageCache(android.support.v4.app.FragmentManager, * ImageCache.ImageCacheParams)} . If the image is found in the memory cache, it is set * immediately, otherwise an {@link AsyncTask} will be created to asynchronously load the * bitmap./*from w w w. j a v a 2 s.c om*/ * * @param data The URL of the image to download. * @param imageView The ImageView to bind the downloaded image to. */ public void loadImage(Object data, ImageView imageView) { if (data == null) { return; } BitmapDrawable value = null; if (mImageCache != null) { value = mImageCache.getBitmapFromMemCache(String.valueOf(data)); } if (value != null) { // Bitmap found in memory cache imageView.setImageDrawable(value); } else if (cancelPotentialWork(data, imageView)) { // BEGIN_INCLUDE(execute_background_task) final BitmapWorkerTask task = new BitmapWorkerTask(data, imageView); final AsyncDrawable asyncDrawable = new AsyncDrawable(mResources, mLoadingBitmap, task); imageView.setImageDrawable(asyncDrawable); // NOTE: This uses a custom version of AsyncTask that has been // pulled from the // framework and slightly modified. Refer to the docs at the top of // the class // for more info on what was changed. task.executeOnExecutor(AsyncExecutor.instance().THREAD_POOL_EXECUTOR); // END_INCLUDE(execute_background_task) } }
From source file:com.cloudsynch.quickshare.utils.thumbnail.ImageWorker.java
/** * Called when the processing is complete and the final drawable should be * set on the ImageView.// w w w .ja v a 2 s .c o m * * @param imageView * @param drawable */ private void setImageDrawable(ImageView imageView, Drawable drawable) { if (mFadeInBitmap) { // Transition drawable with a transparent drawable and the final // drawable final TransitionDrawable td = new TransitionDrawable( new Drawable[] { new ColorDrawable(android.R.color.transparent), drawable }); imageView.setImageDrawable(td); td.startTransition(FADE_IN_TIME); } else { imageView.setImageDrawable(drawable); } }