1
0
mirror of https://github.com/etesync/android synced 2024-11-21 15:38:10 +00:00

WATCH OUT!!!!! SERIALIZABLE BREAKS A FEW THINGS!!!! (CollectionInfo)

Getting entries also works.
This commit is contained in:
Tom Hacohen 2017-11-28 14:11:57 +00:00
parent ffd0ea1c07
commit f418c69067
3 changed files with 57 additions and 2 deletions

View File

@ -0,0 +1,4 @@
package com.etesync.syncadapter.remote;
parcelable JournalEntry;

View File

@ -20,7 +20,9 @@ import com.etesync.syncadapter.model.CollectionInfo;
import com.etesync.syncadapter.model.EntryEntity;
import com.etesync.syncadapter.model.JournalEntity;
import com.etesync.syncadapter.model.JournalModel;
import com.etesync.syncadapter.model.ServiceEntity;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
@ -55,16 +57,21 @@ public class RemoteService extends Service {
Journal ret[] = new Journal[journals.size()];
int i = 0;
for (JournalEntity journal : journals) {
if (!journal.getInfo().isOfTypeService(journalType)) {
continue;
}
ret[i] = new Journal(journal.getUid());
i++;
}
return ret;
return Arrays.copyOf(ret, i);
}
public JournalEntry[] getJournalEntries(String journalUid, String lastUid) throws RemoteException {
EntityDataStore<Persistable> data = ((App) getApplicationContext()).getData();
JournalEntity journal = data.select(JournalEntity.class).where((JournalEntity.DELETED.eq(false))).limit(1).get().firstOrNull();
JournalEntity journal = data.select(JournalEntity.class).where((JournalEntity.DELETED.eq(false)).and(JournalEntity.UID.eq(journalUid))).limit(1).get().firstOrNull();
// FIXME: Should return a proper error
if (journal == null) return null;
// FIXME: Should support generic type
if (!mApiPermissionHelper.isAllowedIgnoreErrors(journal.getInfo().type.toString())) return null;

View File

@ -0,0 +1,44 @@
package com.etesync.syncadapter.remote;
import android.os.Parcel;
import android.os.Parcelable;
public class JournalEntry implements Parcelable {
public String account;
public String id;
public String content;
public JournalEntry(String id) {
this.id = id;
}
protected JournalEntry(Parcel in) {
account = in.readString();
id = in.readString();
content = in.readString();
}
public static final Creator<JournalEntry> CREATOR = new Creator<JournalEntry>() {
@Override
public JournalEntry createFromParcel(Parcel in) {
return new JournalEntry(in);
}
@Override
public JournalEntry[] newArray(int size) {
return new JournalEntry[size];
}
};
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel parcel, int i) {
parcel.writeString(account);
parcel.writeString(id);
parcel.writeString(content);
}
}