C# Class FFImageLoading.Drawables.SelfDisposingBitmapDrawable

A BitmapDrawable that uses reference counting to determine when internal resources should be freed (Disposed). On Android versions Honeycomb and higher the internal Bitmap is Dispose()d but not recycled. On all other Android versions the Bitmap is recycled then disposed.
Inheritance: Android.Graphics.Drawables.BitmapDrawable, ISelfDisposingBitmapDrawable
Show file Open project: daniel-luberda/FFImageLoading Class Usage Examples

Protected Properties

Property Type Description
monitor object

Private Properties

Property Type Description
CheckState void

Public Methods

Method Description
SelfDisposingBitmapDrawable ( ) : Android.Content.Res
SelfDisposingBitmapDrawable ( Android.Graphics.Bitmap bitmap ) : Android.Content.Res
SelfDisposingBitmapDrawable ( IntPtr handle, JniHandleOwnership transfer ) : Android.Content.Res
SelfDisposingBitmapDrawable ( Resources resources ) : Android.Content.Res
SelfDisposingBitmapDrawable ( Resources resources, Android.Graphics.Bitmap bitmap ) : Android.Content.Res
SelfDisposingBitmapDrawable ( Resources resources, Stream stream ) : Android.Content.Res
SelfDisposingBitmapDrawable ( Resources resources, string filePath ) : Android.Content.Res
SelfDisposingBitmapDrawable ( Stream stream ) : Android.Content.Res
SelfDisposingBitmapDrawable ( string filePath ) : Android.Content.Res
SetIsCached ( bool isCached ) : void

This should only be called by caching entities. Increments or decrements the cache reference count. This count represents if the instance is cached by something and should not free its resources when no longer displayed.

SetIsDisplayed ( bool isDisplayed ) : void

This should only be called by Views that are actually going to draw the drawable. Increments or decrements the internal displayed reference count. If the internal reference count becomes 0, NoLongerDisplayed will be raised. If the internal reference count becomes 1, Displayed will be raised. This method should be called from the main thread.

SetIsRetained ( bool isRetained ) : void

If you wish to use the instance beyond the lifecycle managed by the caching entity call this method with true. But be aware that you must also have the same number of calls with false or the instance and its resources will be leaked. Also be aware that once retained, the caching entity will not allow the internal Bitmap allocation to be reused. Retaining an instance does not guarantee it a place in the cache, it can be evicted at any time.

SetNoLongerDisplayed ( ) : void

Protected Methods

Method Description
OnFreeResources ( ) : void

Private Methods

Method Description
CheckState ( ) : void

Method Details

OnFreeResources() protected method

protected OnFreeResources ( ) : void
return void

SelfDisposingBitmapDrawable() public method

public SelfDisposingBitmapDrawable ( ) : Android.Content.Res
return Android.Content.Res

SelfDisposingBitmapDrawable() public method

public SelfDisposingBitmapDrawable ( Android.Graphics.Bitmap bitmap ) : Android.Content.Res
bitmap Android.Graphics.Bitmap
return Android.Content.Res

SelfDisposingBitmapDrawable() public method

public SelfDisposingBitmapDrawable ( IntPtr handle, JniHandleOwnership transfer ) : Android.Content.Res
handle System.IntPtr
transfer JniHandleOwnership
return Android.Content.Res

SelfDisposingBitmapDrawable() public method

public SelfDisposingBitmapDrawable ( Resources resources ) : Android.Content.Res
resources Resources
return Android.Content.Res

SelfDisposingBitmapDrawable() public method

public SelfDisposingBitmapDrawable ( Resources resources, Android.Graphics.Bitmap bitmap ) : Android.Content.Res
resources Resources
bitmap Android.Graphics.Bitmap
return Android.Content.Res

SelfDisposingBitmapDrawable() public method

public SelfDisposingBitmapDrawable ( Resources resources, Stream stream ) : Android.Content.Res
resources Resources
stream Stream
return Android.Content.Res

SelfDisposingBitmapDrawable() public method

public SelfDisposingBitmapDrawable ( Resources resources, string filePath ) : Android.Content.Res
resources Resources
filePath string
return Android.Content.Res

SelfDisposingBitmapDrawable() public method

public SelfDisposingBitmapDrawable ( Stream stream ) : Android.Content.Res
stream Stream
return Android.Content.Res

SelfDisposingBitmapDrawable() public method

public SelfDisposingBitmapDrawable ( string filePath ) : Android.Content.Res
filePath string
return Android.Content.Res

SetIsCached() public method

This should only be called by caching entities. Increments or decrements the cache reference count. This count represents if the instance is cached by something and should not free its resources when no longer displayed.
public SetIsCached ( bool isCached ) : void
isCached bool If set to true is cached.
return void

SetIsDisplayed() public method

This should only be called by Views that are actually going to draw the drawable. Increments or decrements the internal displayed reference count. If the internal reference count becomes 0, NoLongerDisplayed will be raised. If the internal reference count becomes 1, Displayed will be raised. This method should be called from the main thread.
public SetIsDisplayed ( bool isDisplayed ) : void
isDisplayed bool If set to true reference count is /// incremented, otherwise it is decremented.
return void

SetIsRetained() public method

If you wish to use the instance beyond the lifecycle managed by the caching entity call this method with true. But be aware that you must also have the same number of calls with false or the instance and its resources will be leaked. Also be aware that once retained, the caching entity will not allow the internal Bitmap allocation to be reused. Retaining an instance does not guarantee it a place in the cache, it can be evicted at any time.
public SetIsRetained ( bool isRetained ) : void
isRetained bool If set to true is retained.
return void

SetNoLongerDisplayed() public method

public SetNoLongerDisplayed ( ) : void
return void

Property Details

monitor protected property

protected object monitor
return object