Skip to content

Commit fb4c822

Browse files
committed
Add image loading delay write policy setting.
1 parent 83d2dbb commit fb4c822

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

src/com/androidquery/callback/BitmapAjaxCallback.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ public class BitmapAjaxCallback extends AbstractAjaxCallback<Bitmap, BitmapAjaxC
6868
private static int BIG_PIXELS = 400 * 400;
6969
private static int BIG_TPIXELS = 1000000;
7070

71+
private static boolean DELAY_WRITE = false;
72+
7173
private static Map<String, Bitmap> smallCache;
7274
private static Map<String, Bitmap> bigCache;
7375
private static Map<String, Bitmap> invalidCache;
@@ -524,6 +526,20 @@ public static void setCacheLimit(int limit){
524526
clearCache();
525527
}
526528

529+
/**
530+
* Sets the file cache write policy. If set to true, images load from network will be served quicker before caching to disk,
531+
* this however increase the chance of out of memory due to memory allocation.
532+
*
533+
* Default is false.
534+
*
535+
* @param limit the new cache limit
536+
*/
537+
public static void setDelayWrite(boolean delay){
538+
DELAY_WRITE = delay;
539+
}
540+
541+
542+
527543
/**
528544
* Sets the pixel limit per image. Image larger than limit will not be memcached.
529545
*
@@ -911,9 +927,7 @@ public void async(Context context){
911927

912928
@Override
913929
protected boolean isStreamingContent(){
914-
915-
return true;
916-
930+
return !DELAY_WRITE;
917931
}
918932

919933
private void addQueue(String url, ImageView iv){

0 commit comments

Comments
 (0)