use of org.wordpress.android.models.Note in project WordPress-Android by wordpress-mobile.
the class NotificationsTable method getLatestNotes.
public static ArrayList<Note> getLatestNotes(int limit) {
Cursor cursor = getDb().query(NOTIFICATIONS_TABLE, new String[] { "note_id", "raw_note_data" }, null, null, null, null, "timestamp DESC", "" + limit);
ArrayList<Note> notes = new ArrayList<Note>();
while (cursor.moveToNext()) {
String note_id = cursor.getString(0);
String raw_note_data = cursor.getString(1);
try {
Note note = new Note(note_id, new JSONObject(raw_note_data));
notes.add(note);
} catch (JSONException e) {
AppLog.e(AppLog.T.DB, "Can't parse notification with note_id:" + note_id + ", exception:" + e);
}
}
cursor.close();
return notes;
}
use of org.wordpress.android.models.Note in project WordPress-Android by wordpress-mobile.
the class NotificationsActions method parseNotes.
public static List<Note> parseNotes(JSONObject response) throws JSONException {
List<Note> notes;
JSONArray notesJSON = response.getJSONArray("notes");
notes = new ArrayList<>(notesJSON.length());
for (int i = 0; i < notesJSON.length(); i++) {
Note n = new Note(notesJSON.getJSONObject(i));
notes.add(n);
}
return notes;
}
use of org.wordpress.android.models.Note in project WordPress-Android by wordpress-mobile.
the class NotificationsUtils method buildNoteObjectFromBundle.
public static Note buildNoteObjectFromBundle(Bundle data) {
if (data == null) {
AppLog.e(T.NOTIFS, "Bundle is null! Cannot read '" + GCMMessageService.PUSH_ARG_NOTE_ID + "'.");
return null;
}
Note note;
String noteId = data.getString(GCMMessageService.PUSH_ARG_NOTE_ID, "");
String base64FullData = data.getString(GCMMessageService.PUSH_ARG_NOTE_FULL_DATA);
note = Note.buildFromBase64EncodedData(noteId, base64FullData);
if (note == null) {
// At this point we don't have the note :(
AppLog.w(T.NOTIFS, "Cannot build the Note object by using info available in the PN payload. Please see " + "previous log messages for detailed information about the error.");
}
return note;
}
Aggregations