List of usage examples for android.widget ImageView setImageDrawable
public void setImageDrawable(@Nullable Drawable drawable)
From source file:com.ibm.mil.readyapps.physio.fragments.PainLocationFragment.java
/** * Places a marker on the bodyLayout in the given location. * * @param x x location to place the marker. * @param y y location to place the marker. *//*from w w w .j a va 2s . com*/ private void placePointer(int x, int y) { y -= getYOffset(); //Log.d("PLACE_POINTER", "Placing pointer at: " + x + ", " + y); Drawable pointer_im = getResources().getDrawable(R.drawable.pointer_3x); pointer_im.setBounds(0, 0, 44, 65); ImageView new_pointer = new ImageView(getActivity()); new_pointer.setImageDrawable(pointer_im); new_pointer.setLayoutParams(setLayoutParams(x, y)); bodyLayout.addView(new_pointer); pointers.add(new_pointer); }
From source file:com.itsherpa.andg.imageloader.ImageWorker.java
/** * Called when the processing is complete and the final drawable should be * set on the ImageView./*from w w w . j a v a 2 s. co m*/ * * @param imageView * @param drawable */ // Tamtd - Khong cho phep thay doi background // @SuppressWarnings("deprecation") // @TargetApi(Build.VERSION_CODES.JELLY_BEAN) private void setImageDrawable(ImageView imageView, Drawable drawable, int gender, boolean hasCover, boolean isCircle) { imageView.setImageDrawable(drawable); // tungdx: Do not use below source code because it can't work with // CircleImageView, shouldn't use fadeInBitmap cause CircleImageView // can't not get Bitmap from TransitionDrawable that set to ImageView. /** * if (mFadeInBitmap) { // Transition drawable with a transparent * drawable and the final // drawable Drawable background = * imageView.getDrawable(); if(background == null){ background = new * ColorDrawable(android.R.color.transparent); } final * TransitionDrawable td = new TransitionDrawable( new Drawable[] * {background, drawable}); td.setCrossFadeEnabled(true); // Bitmap * bitmap = getBitmapCover(hasCover, gender,isCircle); // if * (Utility.hasJELLY()) { // imageView.setBackground(new * BitmapDrawable(mResources, bitmap)); // } else { // * imageView.setBackgroundDrawable(new BitmapDrawable(mResources, // * bitmap)); // } imageView.setImageDrawable(td); * td.startTransition(FADE_IN_TIME); // * imageView.setBackgroundResource(android.R.color.transparent); } else * { imageView.setImageDrawable(drawable); } */ }
From source file:com.happynetwork.vrestate.utils.ImageWorker.java
/** * Called when the processing is complete and the final drawable should be * set on the ImageView.// www. j av a2 s .c om * * @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(0x00000000), drawable }); // Set background to loading bitmap imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap)); imageView.setImageDrawable(td); td.startTransition(FADE_IN_TIME); } else { imageView.setImageDrawable(drawable); } }
From source file:com.inter.trade.imageframe.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(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. *//*from www . j a v a 2 s.c o m*/ public void loadImage(Object data, ImageView imageView) { if (mLoadPause) { return; } 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); RelativeLayout mLayout = (RelativeLayout) imageView.getTag(); if (mLayout != null) { mLayout.setVisibility(View.GONE); } } else if (cancelPotentialWork(data, imageView)) { final BitmapWorkerTask task = new BitmapWorkerTask(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, data); // task.execute(data); } }
From source file:com.image.oom.ImageUtil.java
public void load(String url, ImageView imageView) { Log.e(this.toString(), "sHardBitmapCache:" + Integer.toString(sHardBitmapCache.size()) + ",sSoftBitmapCache:" + Integer.toString(sSoftBitmapCache.size())); resetPurgeTimer();//from w w w . j a v a 2 s. c o m Bitmap bitmap = getBitmapFromCache(url); if (bitmap == null) { forceDownload(url, imageView); } else { cancelPotentialDownload(url, imageView); // imageView.setImageBitmap(bitmap); Drawable Avater = new BitmapDrawable(bitmap); imageView.setImageDrawable(Avater); } }
From source file:com.flyingmain.CachingImage.util.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. *//*from w ww .j a va 2s.c om*/ // 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(AsyncTask.DUAL_THREAD_EXECUTOR); // //END_INCLUDE(execute_background_task) // } // } public void loadImage(Object data, String params, ImageView imageView) { if (data == null) { return; } BitmapDrawable value = null; if (mImageCache != null) { value = mImageCache.getBitmapFromMemCache(String.valueOf(data) + params); } if (value != null) { // Bitmap found in memory cache imageView.setImageDrawable(value); } else if (cancelPotentialWork(data + params, imageView)) { //BEGIN_INCLUDE(execute_background_task) final BitmapWorkerTask task = new BitmapWorkerTask(data, params, 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.THREAD_POOL_EXECUTOR); //END_INCLUDE(execute_background_task) } }
From source file:com.jackleeentertainment.oq.ui.layout.fragment.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.//from w ww.ja v a 2 s . c om */ 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(App.getContext().getResources().getColor(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:ch.carteggio.ui.ConversationIconLoader.java
/** * Load a conversation picture and display it using the supplied {@link ImageView} instance. * * <p>//from w w w .j ava 2 s . c o m * If a picture is found in the cache, it is displayed in the {@code ImageView} * immediately. Otherwise a {@link ConversationPictureRetrievalTask} is started to try to load the * conversation picture in a background thread. Depending on the result the contact picture, the group * picture or a fallback picture is then stored in the bitmap cache. * </p> * * @param conversationId * The id of the conversation for which we need to find the image. * @param image * The {@code ImageView} instance to receive the picture. * * @see #mBitmapCache * @see #calculateFallbackBitmap(Address) */ public void loadConversationPicture(long conversationId, ImageView image) { Bitmap bitmap = getBitmapFromCache(conversationId); if (bitmap != null) { // The picture was found in the bitmap cache image.setImageBitmap(bitmap); } else if (cancelPotentialWork(conversationId, image)) { ConversationPictureRetrievalTask task = new ConversationPictureRetrievalTask(image, conversationId); AsyncDrawable asyncDrawable = new AsyncDrawable(mResources, calculateFallbackBitmap(new String[] { "none" }), task); image.setImageDrawable(asyncDrawable); try { task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } catch (RejectedExecutionException e) { // We flooded the thread pool queue... use a fallback picture image.setImageBitmap(calculateFallbackBitmap(new String[] { "none" })); } } }
From source file:com.brkc.common.image.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(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 w w . j av a 2 s . co m public void loadImage(Object data, ImageView imageView) { Log.d(TAG, "data=" + data); if (data == null) { return; } BitmapDrawable value = null; if (mImageCache != null) { value = mImageCache.getBitmapFromMemCache(String.valueOf(data)); } Log.d(TAG, "cachye value=" + value); 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(AsyncTask.DUAL_THREAD_EXECUTOR); //END_INCLUDE(execute_background_task) } }
From source file:com.cnm.cnmrc.fragment.rc.RcBase.java
/** * Loading TapPressAnimation <br>//from w ww. ja v a2 s. c o m */ protected void startLoadingAni(ImageButton view, final ImageView animView) { if (view != null) { view.post(new Runnable() { @Override public void run() { try { mTapPressAnimation = new AnimationDrawable(); mTapPressAnimation.addFrame(getResources().getDrawable(R.drawable.tappress01), 60); mTapPressAnimation.addFrame(getResources().getDrawable(R.drawable.tappress02), 60); mTapPressAnimation.addFrame(getResources().getDrawable(R.drawable.tappress03), 60); mTapPressAnimation.addFrame(getResources().getDrawable(R.drawable.tappress04), 60); mTapPressAnimation.setOneShot(true); animView.setImageDrawable(mTapPressAnimation); // API 2.3.4? ?... ??? // animView.setBackgroundResource(R.drawable.anim_tappress); // mTapPressAnimation = (AnimationDrawable) // animView.getBackground(); mTapPressDuration = 0; for (int i = 0; i < mTapPressAnimation.getNumberOfFrames(); i++) { mTapPressDuration += mTapPressAnimation.getDuration(i); } animView.setVisibility(View.VISIBLE); // Start the animation (looped playback by default). mTapPressAnimation.start(); mHandler.postDelayed(new Runnable() { public void run() { mTapPressAnimation.stop(); mTapPressAnimation = null; animView.setBackgroundResource(0); animView.setVisibility(View.INVISIBLE); oneClickTapPress = true; } }, mTapPressDuration); } catch (Exception e) { e.getStackTrace(); } } }); } //view.post(new Starter()); }