Executor of FeedImageLoader can now be shut down manually
This commit is contained in:
parent
e170605ebc
commit
b6b6129feb
|
@ -59,16 +59,7 @@ public class FeedImageLoader {
|
||||||
|
|
||||||
private FeedImageLoader() {
|
private FeedImageLoader() {
|
||||||
handler = new Handler();
|
handler = new Handler();
|
||||||
executor = Executors.newFixedThreadPool(Runtime.getRuntime()
|
executor = createExecutor();
|
||||||
.availableProcessors(), new ThreadFactory() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Thread newThread(Runnable r) {
|
|
||||||
Thread t = new Thread(r);
|
|
||||||
t.setPriority(Thread.MIN_PRIORITY);
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
coverCache = new LruCache<String, Bitmap>(coverCacheSize) {
|
coverCache = new LruCache<String, Bitmap>(coverCacheSize) {
|
||||||
|
|
||||||
|
@ -99,6 +90,19 @@ public class FeedImageLoader {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ExecutorService createExecutor() {
|
||||||
|
return Executors.newFixedThreadPool(Runtime.getRuntime()
|
||||||
|
.availableProcessors(), new ThreadFactory() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Thread newThread(Runnable r) {
|
||||||
|
Thread t = new Thread(r);
|
||||||
|
t.setPriority(Thread.MIN_PRIORITY);
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public static FeedImageLoader getInstance() {
|
public static FeedImageLoader getInstance() {
|
||||||
if (singleton == null) {
|
if (singleton == null) {
|
||||||
singleton = new FeedImageLoader();
|
singleton = new FeedImageLoader();
|
||||||
|
@ -186,6 +190,13 @@ public class FeedImageLoader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clearExecutorQueue() {
|
||||||
|
executor.shutdownNow();
|
||||||
|
if (AppConfig.DEBUG) Log.d(TAG, "Executor was shut down.");
|
||||||
|
executor = createExecutor();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void wipeImageCache() {
|
public void wipeImageCache() {
|
||||||
coverCache.evictAll();
|
coverCache.evictAll();
|
||||||
thumbnailCache.evictAll();
|
thumbnailCache.evictAll();
|
||||||
|
|
|
@ -20,6 +20,7 @@ import com.actionbarsherlock.app.SherlockListFragment;
|
||||||
import de.danoeh.antennapod.AppConfig;
|
import de.danoeh.antennapod.AppConfig;
|
||||||
import de.danoeh.antennapod.R;
|
import de.danoeh.antennapod.R;
|
||||||
import de.danoeh.antennapod.adapter.MiroGuideChannelListAdapter;
|
import de.danoeh.antennapod.adapter.MiroGuideChannelListAdapter;
|
||||||
|
import de.danoeh.antennapod.asynctask.FeedImageLoader;
|
||||||
import de.danoeh.antennapod.miroguide.con.MiroGuideException;
|
import de.danoeh.antennapod.miroguide.con.MiroGuideException;
|
||||||
import de.danoeh.antennapod.miroguide.con.MiroGuideService;
|
import de.danoeh.antennapod.miroguide.con.MiroGuideService;
|
||||||
import de.danoeh.antennapod.miroguide.model.MiroChannel;
|
import de.danoeh.antennapod.miroguide.model.MiroChannel;
|
||||||
|
@ -122,6 +123,7 @@ public class MiroGuideChannellistFragment extends SherlockListFragment {
|
||||||
if (channelLoader != null) {
|
if (channelLoader != null) {
|
||||||
channelLoader.cancel(true);
|
channelLoader.cancel(true);
|
||||||
}
|
}
|
||||||
|
FeedImageLoader.getInstance().clearExecutorQueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue