Pull down to refresh unified folders

pull/146/head
M66B 6 years ago
parent 4e2d91af6a
commit 5244eed68e

@ -39,6 +39,9 @@ public interface DaoFolder {
" ORDER BY CASE WHEN folder.type = '" + EntityFolder.USER + "' THEN 1 ELSE 0 END") " ORDER BY CASE WHEN folder.type = '" + EntityFolder.USER + "' THEN 1 ELSE 0 END")
List<EntityFolder> getFolders(long account, boolean synchronize); List<EntityFolder> getFolders(long account, boolean synchronize);
@Query("SELECT * FROM folder WHERE unified")
List<EntityFolder> getUnifiedFolders();
@Query("SELECT * FROM folder" + @Query("SELECT * FROM folder" +
" WHERE account = :account" + " WHERE account = :account" +
" AND type = '" + EntityFolder.USER + "'") " AND type = '" + EntityFolder.USER + "'")

@ -202,17 +202,23 @@ public class FragmentMessages extends FragmentEx {
@Override @Override
public void onRefresh() { public void onRefresh() {
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putLong("id", folder); args.putLong("account", account);
args.putLong("folder", folder);
new SimpleTask<Void>() { new SimpleTask<Void>() {
@Override @Override
protected Void onLoad(Context context, Bundle args) { protected Void onLoad(Context context, Bundle args) {
long id = args.getLong("id"); long account = args.getLong("account");
long folder = args.getLong("folder");
DB db = DB.getInstance(context); DB db = DB.getInstance(context);
try { try {
db.beginTransaction(); db.beginTransaction();
EntityOperation.sync(db, id); if (account < 0) {
for (EntityFolder unified : db.folder().getUnifiedFolders())
EntityOperation.sync(db, unified.id);
} else
EntityOperation.sync(db, folder);
db.setTransactionSuccessful(); db.setTransactionSuccessful();
} finally { } finally {
@ -1006,7 +1012,7 @@ public class FragmentMessages extends FragmentEx {
((ActivityBase) getActivity()).addBackPressedListener(onBackPressedListener); ((ActivityBase) getActivity()).addBackPressedListener(onBackPressedListener);
// Initialize // Initialize
swipeRefresh.setEnabled(viewType == AdapterMessage.ViewType.FOLDER); swipeRefresh.setEnabled(viewType == AdapterMessage.ViewType.UNIFIED || viewType == AdapterMessage.ViewType.FOLDER);
tvNoEmail.setVisibility(View.GONE); tvNoEmail.setVisibility(View.GONE);
bottom_navigation.setVisibility(View.GONE); bottom_navigation.setVisibility(View.GONE);
grpReady.setVisibility(View.GONE); grpReady.setVisibility(View.GONE);
@ -1082,6 +1088,14 @@ public class FragmentMessages extends FragmentEx {
setSubtitle(getString(R.string.title_folder_unseen, name, unseen)); setSubtitle(getString(R.string.title_folder_unseen, name, unseen));
else else
setSubtitle(name); setSubtitle(name);
boolean refreshing = false;
for (TupleFolderEx folder : folders)
if (folder.sync_state != null) {
refreshing = true;
break;
}
swipeRefresh.setRefreshing(refreshing);
} }
}); });
break; break;

Loading…
Cancel
Save