Sort folders to sync

pull/172/head
M66B 5 years ago
parent f920601a22
commit 9665ff64f2

@ -52,6 +52,7 @@ import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class FragmentAccounts extends FragmentBase {
@ -351,6 +352,10 @@ public class FragmentAccounts extends FragmentBase {
// Unified inbox
List<EntityFolder> folders = db.folder().getFoldersUnified(null, true);
if (folders.size() > 0)
Collections.sort(folders, folders.get(0).getComparator(context));
for (EntityFolder folder : folders) {
EntityOperation.sync(context, folder.id, true);

@ -58,6 +58,7 @@ import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;
import java.text.NumberFormat;
import java.util.Collections;
import java.util.List;
import static android.app.Activity.RESULT_OK;
@ -341,6 +342,9 @@ public class FragmentFolders extends FragmentBase {
else
folders = db.folder().getSynchronizingFolders(aid);
if (folders.size() > 0)
Collections.sort(folders, folders.get(0).getComparator(context));
for (EntityFolder folder : folders) {
EntityOperation.sync(context, folder.id, true);

@ -949,18 +949,8 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
// Open synchronizing folders
List<EntityFolder> folders = db.folder().getFolders(account.id, false, true);
Collections.sort(folders, new Comparator<EntityFolder>() {
@Override
public int compare(EntityFolder f1, EntityFolder f2) {
int s1 = EntityFolder.FOLDER_SORT_ORDER.indexOf(f1.type);
int s2 = EntityFolder.FOLDER_SORT_ORDER.indexOf(f2.type);
int s = Integer.compare(s1, s2);
if (s != 0)
return s;
return f1.name.compareTo(f2.name);
}
});
if (folders.size() > 0)
Collections.sort(folders, folders.get(0).getComparator(ServiceSynchronize.this));
for (final EntityFolder folder : folders) {
if (folder.synchronize && !folder.poll && capIdle && sync) {

Loading…
Cancel
Save