use of com.google.samples.apps.iosched.rpc.userdata.model.UserData in project iosched by google.
the class RemoteUserDataHelper method asUserData.
/**
* Builds and returns a {@link UserData} object from a {@link UserDataModel}. The returned
* object can be used to write data to the user data endpoint.
*
* @param model Data from the user data endpoint represented as a {@link UserDataModel}.
*/
static UserData asUserData(UserDataModel model) {
UserData userData = new UserData();
JsonMap bookmarkedSessionsJsonMap = new JsonMap();
for (final Map.Entry<String, UserDataModel.StarredSession> entry : model.getStarredSessions().entrySet()) {
ArrayMap<String, String> arrayMap = new ArrayMap<>();
arrayMap.put(SESSION_ID, entry.getKey());
arrayMap.put(IN_SCHEDULE, String.valueOf(entry.getValue().inSchedule));
arrayMap.put(TIMESTAMP_UTC, String.valueOf(entry.getValue().timestamp));
bookmarkedSessionsJsonMap.set(entry.getKey(), arrayMap);
}
userData.setBookmarkedSessions(bookmarkedSessionsJsonMap);
List<String> reviewSessionsList = new ArrayList<>();
for (String reviewedSessionId : model.getFeedbackSubmittedSessionIds()) {
reviewSessionsList.add(reviewedSessionId);
}
userData.setReviewedSessions(reviewSessionsList);
return userData;
}
use of com.google.samples.apps.iosched.rpc.userdata.model.UserData in project iosched by google.
the class UserDataSyncHelper method performSync.
private void performSync(final List<UserAction> actions) {
mUserdataHandler = RemoteUserDataHelper.getUserdataHandler(mContext);
try {
UserData remoteUserDataJson = mUserdataHandler.getAll().execute();
buildRemoteData(remoteUserDataJson);
buildLocalData(actions);
reconcileRemoteAndLocal();
} catch (IOException e) {
LOGW(TAG, "Failed to get user data from remote." + e);
}
}
Aggregations