mirror of https://github.com/M66B/FairEmail.git
Use executor to update widget
This commit is contained in:
parent
906d98a14f
commit
ccb6c259a4
|
@ -28,21 +28,22 @@ import android.content.Intent;
|
||||||
import android.widget.RemoteViews;
|
import android.widget.RemoteViews;
|
||||||
|
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
import static android.os.Process.THREAD_PRIORITY_BACKGROUND;
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
public class Widget extends AppWidgetProvider {
|
public class Widget extends AppWidgetProvider {
|
||||||
|
private static final ExecutorService executor =
|
||||||
|
Executors.newSingleThreadExecutor(Helper.backgroundThreadFactory);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUpdate(final Context context, final AppWidgetManager appWidgetManager, final int[] appWidgetIds) {
|
public void onUpdate(final Context context, final AppWidgetManager appWidgetManager, final int[] appWidgetIds) {
|
||||||
Thread thread = new Thread(new Runnable() {
|
executor.submit(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
DB db = DB.getInstance(context);
|
DB db = DB.getInstance(context);
|
||||||
update(appWidgetIds, appWidgetManager, context, db.message().getUnseenUnified());
|
update(appWidgetIds, appWidgetManager, context, db.message().getUnseenUnified());
|
||||||
}
|
}
|
||||||
}, "widget:update");
|
});
|
||||||
thread.setPriority(THREAD_PRIORITY_BACKGROUND);
|
|
||||||
thread.start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void update(Context context, int count) {
|
static void update(Context context, int count) {
|
||||||
|
|
Loading…
Reference in New Issue