Code example for SoftReference

Methods: clear

0
	private int number;
	private SoftReference<Bitmap> presentaionImageSoftReference= new SoftReference<Bitmap>(null);
	private SoftReference<Bitmap> lockedImageSoftReference= new SoftReference<Bitmap>(null);
 
	public void clearSoftReferences() { 
		presentaionImageSoftReference.clear();
		lockedImageSoftReference.clear();
	} 
	 
	public Bitmap getPresentaionImage(Context context) {
		int H = (int)(ApplicationManager.SCREEN_H*0.6);
		if(H > ApplicationManager.GALLERY_MAX_BITMAP_SIZE_DP) H = ApplicationManager.GALLERY_MAX_BITMAP_SIZE_DP;//Dimensione massima per le immagini.
		Bitmap data = presentaionImageSoftReference.get();
		if(data == null) {
			Options opts = new BitmapFactory.Options();
	    	opts.inSampleSize=1;
	    	Bitmap.Config conf = Bitmap.Config.RGB_565;
	    	opts.inPreferredConfig = conf;
	    	opts.inTempStorage = new byte[16*1024];
			Bitmap rawdata = BitmapFactory.decodeResource(context.getResources(), getPresentationImage(),opts);
			data = Bitmap.createScaledBitmap(rawdata, H, H, true);