Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,23 +96,12 @@ public void onMessageReceived(RemoteMessage remoteMessage) {
* @param data Map which has the message data in it
*/
private void insertSquawk(final Map<String, String> data) {

// Database operations should not be done on the main thread
AsyncTask<Void, Void, Void> insertSquawkTask = new AsyncTask<Void, Void, Void>() {

@Override
protected Void doInBackground(Void... voids) {
ContentValues newMessage = new ContentValues();
newMessage.put(SquawkContract.COLUMN_AUTHOR, data.get(JSON_KEY_AUTHOR));
newMessage.put(SquawkContract.COLUMN_MESSAGE, data.get(JSON_KEY_MESSAGE).trim());
newMessage.put(SquawkContract.COLUMN_DATE, data.get(JSON_KEY_DATE));
newMessage.put(SquawkContract.COLUMN_AUTHOR_KEY, data.get(JSON_KEY_AUTHOR_KEY));
getContentResolver().insert(SquawkProvider.SquawkMessages.CONTENT_URI, newMessage);
return null;
}
};

insertSquawkTask.execute();
ContentValues newMessage = new ContentValues();
newMessage.put(SquawkContract.COLUMN_AUTHOR, data.get(JSON_KEY_AUTHOR));
newMessage.put(SquawkContract.COLUMN_MESSAGE, data.get(JSON_KEY_MESSAGE).trim());
newMessage.put(SquawkContract.COLUMN_DATE, data.get(JSON_KEY_DATE));
newMessage.put(SquawkContract.COLUMN_AUTHOR_KEY, data.get(JSON_KEY_AUTHOR_KEY));
getContentResolver().insert(SquawkProvider.SquawkMessages.CONTENT_URI, newMessage);
}


Expand Down Expand Up @@ -151,4 +140,4 @@ private void sendNotification(Map<String, String> data) {

notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
}
}
}