@Override public void onScrollStateChanged(AbsListView absListView, int scrollState) { // Pause image loader to ensure smoother scrolling when flinging if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_FLING) { contactImageLoader.setPauseWork(true); } else { contactImageLoader.setPauseWork(false); } }
/** * Load an image specified by the data parameter into an ImageView (override * {@link ImageLoader#processBitmap(Object)} to define the processing logic). If the image is * found in the memory cache, it is set immediately, otherwise an {@link android.os.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. */ public void loadImage(Object data, ImageView imageView) { loadImage(data, imageView, null, null); }
/** * Creating a new ImageCache object using the specified parameters. * * @param memCacheSizePercent The cache size as a percent of available app memory. */ private ImageCache(float memCacheSizePercent) { init(memCacheSizePercent); }
/** * Find and return an existing ImageCache stored in a {@link ImageCache.RetainFragment}, if not found a new * one is created using the supplied params and saved to a {@link ImageCache.RetainFragment}. * * @param fragmentManager The fragment manager to use when dealing with the retained fragment. * @param memCacheSizePercent The cache size as a percent of available app memory. * @return An existing retained ImageCache object or a new one if one did not exist */ public static ImageCache getInstance( FragmentManager fragmentManager, float memCacheSizePercent) { // Search for, or create an instance of the non-UI RetainFragment final RetainFragment mRetainFragment = findOrCreateRetainFragment(fragmentManager); // See if we already have an ImageCache stored in RetainFragment ImageCache imageCache = (ImageCache) mRetainFragment.getObject(); // No existing ImageCache, create one and store it in RetainFragment if (imageCache == null) { imageCache = new ImageCache(memCacheSizePercent); mRetainFragment.setObject(imageCache); } return imageCache; }
private void showPreview(Message message, ImageView preview, LinearLayout attachmentDownloadLayout) { imageThumbnailLoader.setImageFadeIn(false); imageThumbnailLoader.setLoadingImage(R.id.media_upload_progress_bar); imageThumbnailLoader.loadImage(message, preview); attachmentDownloadLayout.setVisibility(View.GONE); }
public ScheduledMessageAdapter(Context context, int textViewResourceId, List<Message> smsList) { super(context, textViewResourceId, smsList); baseContactService = new AppContactService(context); mImageLoader = new ImageLoader(getContext(), ImageUtils.getLargestScreenDimension((Activity) getContext())) { @Override protected Bitmap processBitmap(Object data) { return loadContactPhoto((Uri) data, getImageSize()); } }; mImageLoader.setLoadingImage(R.drawable.applozic_ic_contact_picture_180_holo_light); mImageLoader.setImageFadeIn(false); }
/** * Adds an {@link ImageCache} to this image loader. * * @param fragmentManager A FragmentManager to use to retain the cache over configuration * changes such as an orientation change. * @param memCacheSizePercent The cache size as a percent of available app memory. */ public void addImageCache(FragmentManager fragmentManager, float memCacheSizePercent) { mImageCache = ImageCache.getInstance(fragmentManager, memCacheSizePercent); }
/** * Cancels any pending work attached to the provided ImageView. */ public static void cancelWork(ImageView imageView) { final BitmapWorkerTask bitmapWorkerTask = getBitmapWorkerTask(imageView); if (bitmapWorkerTask != null) { bitmapWorkerTask.cancel(true); if (BuildConfig.DEBUG) { final Object bitmapData = bitmapWorkerTask.data; Log.d(TAG, "cancelWork - cancelled work for " + bitmapData); } } }
/** * Measure item size in kilobytes rather than units which is more practical * for a bitmap cache */ @Override protected int sizeOf(String key, Bitmap bitmap) { final int bitmapSize = getBitmapSize(bitmap) / 1024; return bitmapSize == 0 ? 1 : bitmapSize; } };
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Make sure this Fragment is retained over a configuration change setRetainInstance(true); }
/** * @param imageView Any imageView * @return Retrieve the currently active work task (if any) associated with this imageView. * null if there is no such task. */ private static BitmapWorkerTask getBitmapWorkerTask(ImageView imageView) { if (imageView != null) { final Drawable drawable = imageView.getDrawable(); if (drawable instanceof AsyncDrawable) { final AsyncDrawable asyncDrawable = (AsyncDrawable) drawable; return asyncDrawable.getBitmapWorkerTask(); } } return null; }
public void loadImage(Object data, ImageView imageView, TextView textView) { loadImage(data, imageView, null, textView); }
@Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { if (recyclerDetailConversationAdapter != null) { recyclerDetailConversationAdapter.contactImageLoader.setPauseWork(newState == RecyclerView.SCROLL_STATE_DRAGGING); } }
public void loadImage(Object data, ImageView imageView, ProgressBar progressBar) { loadImage(data, imageView, progressBar, null); }
@Override public void onScrollStateChanged(AbsListView absListView, int scrollState) { mChannelImageLoader.setPauseWork(scrollState == AbsListView.OnScrollListener.SCROLL_STATE_FLING); }
@Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { super.onScrollStateChanged(recyclerView, newState); if (recyclerAdapter != null) { recyclerAdapter.contactImageLoader.setPauseWork(newState == RecyclerView.SCROLL_STATE_DRAGGING); recyclerAdapter.channelImageLoader.setPauseWork(newState == RecyclerView.SCROLL_STATE_DRAGGING); } }
@Override public void onPause() { super.onPause(); // In the case onPause() is called during a fling the image loader is // un-paused to let any remaining background work complete. mImageLoader.setPauseWork(false); }
@Override public void onPause() { super.onPause(); // In the case onPause() is called during a fling the image loader is // un-paused to let any remaining background work complete. mImageLoader.setPauseWork(false); }
@Override public void onPause() { super.onPause(); if (mChannelImageLoader != null) { mChannelImageLoader.setPauseWork(false); } }
@Override public void onPause() { super.onPause(); // In the case onPause() is called during a fling the image loader is // un-paused to let any remaining background work complete. mImageLoader.setPauseWork(false); }