Search in sources :

Example 1 with UserData

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;
}
Also used : UserData(com.google.samples.apps.iosched.rpc.userdata.model.UserData) ArrayList(java.util.ArrayList) ArrayMap(com.google.api.client.util.ArrayMap) JsonMap(com.google.samples.apps.iosched.rpc.userdata.model.JsonMap) HashMap(java.util.HashMap) ArrayMap(com.google.api.client.util.ArrayMap) JsonMap(com.google.samples.apps.iosched.rpc.userdata.model.JsonMap) Map(java.util.Map)

Example 2 with 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);
    }
}
Also used : UserData(com.google.samples.apps.iosched.rpc.userdata.model.UserData) IOException(java.io.IOException)

Aggregations

UserData (com.google.samples.apps.iosched.rpc.userdata.model.UserData)2 ArrayMap (com.google.api.client.util.ArrayMap)1 JsonMap (com.google.samples.apps.iosched.rpc.userdata.model.JsonMap)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1