use of ai.saiy.android.cognitive.identity.provider.microsoft.containers.ProfileItem in project Saiy-PS by brandall76.
the class SaiyAccountHelper method updateEnrollmentStatus.
/**
* Update the enrollment status of a profile
*
* @param ctx the application context
* @param operationStatus the {@link OperationStatus} object
* @param profileId of the user
* @return true if the profile was successfully updated, false otherwise
*/
public static boolean updateEnrollmentStatus(@NonNull final Context ctx, @Nullable final OperationStatus operationStatus, @NonNull final String profileId) {
if (DEBUG) {
MyLog.i(CLS_NAME, "updateEnrollmentStatus");
}
if (operationStatus == null || operationStatus.getProcessingResult() == null) {
return false;
}
if (haveAccounts(ctx)) {
boolean save = false;
final SaiyAccountList accountList = getAccountList(ctx);
for (final SaiyAccount account : accountList.getSaiyAccountList()) {
if (account.getProfileItem() != null) {
final ProfileItem item = account.getProfileItem();
final String id = item.getId();
if (UtilsString.notNaked(id)) {
if (id.matches(Pattern.quote(profileId))) {
if (DEBUG) {
MyLog.i(CLS_NAME, "updateEnrollmentStatus: have match");
}
item.setCreated(operationStatus.getCreated());
item.setLastAction(operationStatus.getLastAction());
item.setRemainingSpeechTime(operationStatus.getProcessingResult().getRemainingSpeechTime());
item.setSpeechTime(operationStatus.getProcessingResult().getSpeechTime());
item.setStatus(operationStatus.getStatus());
save = true;
break;
}
} else {
if (DEBUG) {
MyLog.w(CLS_NAME, "updateEnrollmentStatus: id naked");
}
}
} else {
if (DEBUG) {
MyLog.w(CLS_NAME, "updateEnrollmentStatus: getProfileItem null");
}
}
}
if (save) {
if (DEBUG) {
MyLog.i(CLS_NAME, "updateEnrollmentStatus: saving");
}
saveSaiyAccountList(ctx, accountList);
if (DEBUG) {
debugAccountList(ctx);
}
return true;
}
} else {
if (DEBUG) {
MyLog.w(CLS_NAME, "updateEnrollmentStatus: no account");
}
}
return false;
}
Aggregations