mirror of
https://github.com/etesync/android
synced 2024-11-24 17:08:11 +00:00
WATCH OUT!!!!! SERIALIZABLE BREAKS A FEW THINGS!!!! (CollectionInfo)
Getting entries also works.
This commit is contained in:
parent
ffd0ea1c07
commit
f418c69067
@ -0,0 +1,4 @@
|
|||||||
|
package com.etesync.syncadapter.remote;
|
||||||
|
|
||||||
|
parcelable JournalEntry;
|
||||||
|
|
@ -20,7 +20,9 @@ import com.etesync.syncadapter.model.CollectionInfo;
|
|||||||
import com.etesync.syncadapter.model.EntryEntity;
|
import com.etesync.syncadapter.model.EntryEntity;
|
||||||
import com.etesync.syncadapter.model.JournalEntity;
|
import com.etesync.syncadapter.model.JournalEntity;
|
||||||
import com.etesync.syncadapter.model.JournalModel;
|
import com.etesync.syncadapter.model.JournalModel;
|
||||||
|
import com.etesync.syncadapter.model.ServiceEntity;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -55,16 +57,21 @@ public class RemoteService extends Service {
|
|||||||
Journal ret[] = new Journal[journals.size()];
|
Journal ret[] = new Journal[journals.size()];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (JournalEntity journal : journals) {
|
for (JournalEntity journal : journals) {
|
||||||
|
if (!journal.getInfo().isOfTypeService(journalType)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
ret[i] = new Journal(journal.getUid());
|
ret[i] = new Journal(journal.getUid());
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return Arrays.copyOf(ret, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
public JournalEntry[] getJournalEntries(String journalUid, String lastUid) throws RemoteException {
|
public JournalEntry[] getJournalEntries(String journalUid, String lastUid) throws RemoteException {
|
||||||
EntityDataStore<Persistable> data = ((App) getApplicationContext()).getData();
|
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
|
// FIXME: Should support generic type
|
||||||
if (!mApiPermissionHelper.isAllowedIgnoreErrors(journal.getInfo().type.toString())) return null;
|
if (!mApiPermissionHelper.isAllowedIgnoreErrors(journal.getInfo().type.toString())) return null;
|
||||||
|
|
||||||
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user