com.nostra13.universalimageloader.core.imageaware
Class ImageViewAware

java.lang.Object
  extended by com.nostra13.universalimageloader.core.imageaware.ViewAware
      extended by com.nostra13.universalimageloader.core.imageaware.ImageViewAware
All Implemented Interfaces:
ImageAware

public class ImageViewAware
extends ViewAware

Wrapper for Android ImageView. Keeps weak reference of ImageView to prevent memory leaks.

Since:
1.9.0
Author:
Sergey Tarasevich (nostra13[at]gmail[dot]com)

Field Summary
 
Fields inherited from class com.nostra13.universalimageloader.core.imageaware.ViewAware
checkActualViewSize, viewRef, WARN_CANT_SET_BITMAP, WARN_CANT_SET_DRAWABLE
 
Constructor Summary
ImageViewAware(android.widget.ImageView imageView)
          Constructor.
ImageViewAware(android.widget.ImageView imageView, boolean checkActualViewSize)
          Constructor
 
Method Summary
 int getHeight()
          Returns height of image aware view.
 ViewScaleType getScaleType()
          Returns scale type which is used for scaling image for this image aware view.
 int getWidth()
          Returns width of image aware view.
 android.widget.ImageView getWrappedView()
          Returns wrapped Android View.
protected  void setImageBitmapInto(android.graphics.Bitmap bitmap, android.view.View view)
          Should set Bitmap into incoming view.
protected  void setImageDrawableInto(android.graphics.drawable.Drawable drawable, android.view.View view)
          Should set drawable into incoming view.
 
Methods inherited from class com.nostra13.universalimageloader.core.imageaware.ViewAware
getId, isCollected, setImageBitmap, setImageDrawable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageViewAware

public ImageViewAware(android.widget.ImageView imageView)
Constructor.
References ImageViewAware(imageView, true).

Parameters:
imageView - ImageView to work with

ImageViewAware

public ImageViewAware(android.widget.ImageView imageView,
                      boolean checkActualViewSize)
Constructor

Parameters:
imageView - ImageView to work with
checkActualViewSize - true - then getWidth() and getHeight() will check actual size of ImageView. It can cause known issues like this. But it helps to save memory because memory cache keeps bitmaps of actual (less in general) size.

false - then getWidth() and getHeight() will NOT consider actual size of ImageView, just layout parameters.
If you set 'false' it's recommended 'android:layout_width' and 'android:layout_height' (or 'android:maxWidth' and 'android:maxHeight') are set with concrete values. It helps to save memory.

Method Detail

getWidth

public int getWidth()
Returns width of image aware view. This value is used to define scale size for original image. Can return 0 if width is undefined.
Is called on UI thread if ImageLoader was called on UI thread. Otherwise - on background thread.

Width is defined by target view parameters, configuration parameters or device display dimensions.
Size computing algorithm (go by steps until get non-zero value):
1) Get the actual drawn getWidth() of the View
2) Get layout_width
3) Get maxWidth.

Specified by:
getWidth in interface ImageAware
Overrides:
getWidth in class ViewAware

getHeight

public int getHeight()
Returns height of image aware view. This value is used to define scale size for original image. Can return 0 if height is undefined.
Is called on UI thread if ImageLoader was called on UI thread. Otherwise - on background thread.

Height is defined by target view parameters, configuration parameters or device display dimensions.
Size computing algorithm (go by steps until get non-zero value):
1) Get the actual drawn getHeight() of the View
2) Get layout_height
3) Get maxHeight

Specified by:
getHeight in interface ImageAware
Overrides:
getHeight in class ViewAware

getScaleType

public ViewScaleType getScaleType()
Description copied from interface: ImageAware
Returns scale type which is used for scaling image for this image aware view. Must NOT return null.

Specified by:
getScaleType in interface ImageAware
Overrides:
getScaleType in class ViewAware

getWrappedView

public android.widget.ImageView getWrappedView()
Description copied from interface: ImageAware
Returns wrapped Android View. Can return null if no view is wrapped or view was collected by GC.
Is called on UI thread if ImageLoader was called on UI thread. Otherwise - on background thread.

Specified by:
getWrappedView in interface ImageAware
Overrides:
getWrappedView in class ViewAware

setImageDrawableInto

protected void setImageDrawableInto(android.graphics.drawable.Drawable drawable,
                                    android.view.View view)
Description copied from class: ViewAware
Should set drawable into incoming view. Incoming view is guaranteed not null.
This method is called on UI thread.

Specified by:
setImageDrawableInto in class ViewAware

setImageBitmapInto

protected void setImageBitmapInto(android.graphics.Bitmap bitmap,
                                  android.view.View view)
Description copied from class: ViewAware
Should set Bitmap into incoming view. Incoming view is guaranteed not null.< br /> This method is called on UI thread.

Specified by:
setImageBitmapInto in class ViewAware


Copyright © 2011-2014. All Rights Reserved.