1
0
mirror of https://github.com/etesync/android synced 2024-11-16 04:49:06 +00:00

Create collection: update collection if already exists (info.url is set).

This commit is contained in:
Tom Hacohen 2017-03-08 15:18:53 +00:00
parent e7138842c8
commit ce3483cee2

View File

@ -150,15 +150,20 @@ public class CreateCollectionFragment extends DialogFragment implements LoaderMa
HttpUrl principal = HttpUrl.get(settings.getUri());
JournalManager journalManager = new JournalManager(HttpClient.create(getContext(), account), principal);
JournalManager.Journal journal = new JournalManager.Journal(settings.password(), info.toJson());
// CollectionInfo doesn't have a url at this point, update it.
info.url = journal.getUuid();
journalManager.putJournal(journal);
if (info.url == null) {
// CollectionInfo doesn't have a url at this point, update it.
JournalManager.Journal journal = new JournalManager.Journal(settings.password(), info.toJson());
info.url = journal.getUuid();
journalManager.putJournal(journal);
} else {
JournalManager.Journal journal = new JournalManager.Journal(settings.password(), info.toJson(), info.url);
journalManager.updateJournal(journal);
}
// 2. add collection to service
ContentValues values = info.toDB();
values.put(ServiceDB.Collections.SERVICE_ID, serviceID);
db.insert(ServiceDB.Collections._TABLE, null, values);
db.insertWithOnConflict(ServiceDB.Collections._TABLE, null, values, SQLiteDatabase.CONFLICT_REPLACE);
requestSync(authority);
} catch (IllegalStateException | Exceptions.HttpException e) {