mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-01 04:35:57 +00:00
Initialize widget
This commit is contained in:
parent
b2bbc756bc
commit
41aa9633d5
2 changed files with 20 additions and 2 deletions
|
@ -188,6 +188,18 @@ public interface DaoMessage {
|
|||
" ORDER BY message.received")
|
||||
LiveData<List<EntityMessage>> liveUnseenUnified();
|
||||
|
||||
@Query("SELECT COUNT(message.id) FROM message" +
|
||||
" JOIN account ON account.id = message.account" +
|
||||
" JOIN folder ON folder.id = message.folder" +
|
||||
" WHERE account.`synchronize`" +
|
||||
" AND folder.unified" +
|
||||
" AND NOT message.ui_seen" +
|
||||
" AND NOT message.ui_hide" +
|
||||
" AND NOT message.ui_found" +
|
||||
" AND NOT message.ui_ignored" +
|
||||
" ORDER BY message.received")
|
||||
int getUnseenUnified();
|
||||
|
||||
@Query("SELECT uid FROM message" +
|
||||
" WHERE folder = :folder" +
|
||||
" AND received >= :received" +
|
||||
|
|
|
@ -29,8 +29,14 @@ import android.widget.RemoteViews;
|
|||
|
||||
public class Widget extends AppWidgetProvider {
|
||||
@Override
|
||||
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
|
||||
update(appWidgetIds, appWidgetManager, context, -1);
|
||||
public void onUpdate(final Context context, final AppWidgetManager appWidgetManager, final int[] appWidgetIds) {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
DB db = DB.getInstance(context);
|
||||
update(appWidgetIds, appWidgetManager, context, db.message().getUnseenUnified());
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
static void update(Context context, int count) {
|
||||
|
|
Loading…
Reference in a new issue