1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-26 17:57:16 +00:00

Live FAQ compose

This commit is contained in:
M66B 2018-11-12 18:42:36 +01:00
parent b6d759286c
commit f2352fccb1
2 changed files with 10 additions and 24 deletions

View file

@ -56,6 +56,12 @@ public interface DaoAccount {
@Query("SELECT * FROM account WHERE id = :id")
LiveData<EntityAccount> liveAccount(long id);
@Query("SELECT account.* FROM account" +
" JOIN folder ON folder.account = account.id" +
" WHERE (account.id = :id OR (:id IS NULL AND account.`primary`))" +
" AND folder.type = '" + EntityFolder.DRAFTS + "'")
LiveData<EntityAccount> liveAccountDraft(Long id);
@Query("SELECT" +
" (SELECT COUNT(account.id) FROM account WHERE synchronize AND state = 'connected') AS accounts" +
", (SELECT COUNT(operation.id) FROM operation" +

View file

@ -919,35 +919,15 @@ public class FragmentMessages extends FragmentEx {
bottom_navigation.getMenu().findItem(R.id.action_next).setEnabled(pn[1] != null);
bottom_navigation.setVisibility(!nav || (pn[0] == null && pn[1] == null) ? View.GONE : View.VISIBLE);
} else {
// Compose FAB
Bundle args = new Bundle();
args.putLong("account", account);
new SimpleTask<Long>() {
db.account().liveAccountDraft(account < 0 ? null : account).observe(getViewLifecycleOwner(), new Observer<EntityAccount>() {
@Override
protected Long onLoad(Context context, Bundle args) {
long account = args.getLong("account", -1);
if (account < 0) {
EntityFolder primary = DB.getInstance(context).folder().getPrimaryDrafts();
return (primary == null ? null : primary.account);
} else
return account;
}
@Override
protected void onLoaded(Bundle args, Long account) {
public void onChanged(EntityAccount account) {
if (account != null) {
fab.setTag(account);
fab.setTag(account.id);
fab.show();
}
}
@Override
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(getContext(), ex);
}
}.load(this, args);
});
}
}