Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

cleanup: Take the age parameter in account #54

Merged
merged 2 commits into from

2 participants

@ChristianBecker

The age parameter was unused till now. I updated the delete condition to take the age parameter in account.

@koush koush merged commit 1d4d87b into koush:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 27, 2013
  1. Take the max age of a file in account. #51

    Christian Becker authored
This page is out of date. Refresh to see the latest.
View
10 UrlImageViewHelper/src/com/koushikdutta/urlimageviewhelper/UrlImageViewHelper.java
@@ -10,8 +10,6 @@
import java.util.HashSet;
import java.util.Hashtable;
-import junit.framework.Assert;
-
import org.apache.http.NameValuePair;
import android.annotation.TargetApi;
@@ -402,7 +400,7 @@ public static void cleanup(final Context context, long age) {
}
final File f = new File(context.getFilesDir().getAbsolutePath() + '/' + file);
- if (System.currentTimeMillis() > f.lastModified() + CACHE_DURATION_ONE_WEEK) {
+ if (System.currentTimeMillis() > f.lastModified() + age) {
f.delete();
}
}
@@ -460,7 +458,7 @@ public static Bitmap getCachedBitmap(String url) {
* value can be null.
*/
private static void setUrlDrawable(final Context context, final ImageView imageView, final String url, final Drawable defaultDrawable, final long cacheDurationMs, final UrlImageViewCallback callback) {
- Assert.assertTrue("setUrlDrawable and loadUrlDrawable should only be called from the main thread.", Looper.getMainLooper().getThread() == Thread.currentThread());
+ assert (Looper.getMainLooper().getThread() == Thread.currentThread()) : "setUrlDrawable and loadUrlDrawable should only be called from the main thread.";
cleanup(context);
// disassociate this ImageView from any pending downloads
if (isNullOrEmpty(url)) {
@@ -574,7 +572,7 @@ else if (bitmap != null)
@Override
public void onDownloadComplete(UrlDownloader downloader, InputStream in, String existingFilename) {
try {
- Assert.assertTrue(in == null || existingFilename == null);
+ assert (in == null || existingFilename == null);
if (in == null && existingFilename == null)
return;
String targetFilename = filename;
@@ -605,7 +603,7 @@ public void onDownloadComplete(UrlDownloader downloader, InputStream in, String
final Runnable completion = new Runnable() {
@Override
public void run() {
- Assert.assertEquals(Looper.myLooper(), Looper.getMainLooper());
+ assert (Looper.myLooper().equals(Looper.getMainLooper()));
Bitmap bitmap = loader.result;
Drawable usableResult = null;
if (bitmap != null) {
Something went wrong with that request. Please try again.