Better asynchronous loading for Recipient information.

1) Switch back from AsyncTasks to an Executor and Futures.

2) Make the Executor operate LIFO.

3) Make the Executor thread a BACKGROUND_PRIORITY thread.
This commit is contained in:
Moxie Marlinspike
2012-12-27 12:00:14 -08:00
parent 9939830551
commit 9b45e6068b
5 changed files with 1300 additions and 105 deletions

View File

@@ -16,6 +16,10 @@
*/
package org.thoughtcrime.securesms.util;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
public class Util {
public static byte[] combine(byte[] one, byte[] two) {
@@ -62,6 +66,10 @@ public class Util {
return splitString;
}
public static ExecutorService newSingleThreadedLifoExecutor() {
return new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingLifoQueue<Runnable>());
}
// public static Bitmap loadScaledBitmap(InputStream src, int targetWidth, int targetHeight) {
// return BitmapFactory.decodeStream(src);
//// BitmapFactory.Options options = new BitmapFactory.Options();