use of org.edx.mobile.user.UserAPI.AccountDataUpdatedCallback in project edx-app-android by edx.
the class EditUserProfileFragment method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRetainInstance(true);
setHasOptionsMenu(true);
EventBus.getDefault().register(this);
final Activity activity = getActivity();
final TaskMessageCallback mCallback = activity instanceof TaskMessageCallback ? (TaskMessageCallback) activity : null;
getAccountCall = userService.getAccount(username);
getAccountCall.enqueue(new AccountDataUpdatedCallback(activity, username, // Disable default loading indicator, we have our own
null, mCallback, CallTrigger.LOADING_CACHED));
getProfileFormDescriptionTask = new GetProfileFormDescriptionTask(activity) {
@Override
protected void onSuccess(@NonNull FormDescription formDescription) throws Exception {
EditUserProfileFragment.this.formDescription = formDescription;
if (null != viewHolder) {
setData(account, formDescription);
}
}
};
getProfileFormDescriptionTask.setTaskProcessCallback(null);
getProfileFormDescriptionTask.execute();
}
use of org.edx.mobile.user.UserAPI.AccountDataUpdatedCallback in project edx-app-android by edx.
the class EditUserProfileFragment method executeUpdate.
private void executeUpdate(FormField field, String fieldValue) {
final Object valueObject;
if (field.getDataType() == DataType.LANGUAGE) {
if (TextUtils.isEmpty(fieldValue)) {
valueObject = Collections.emptyList();
} else {
valueObject = Collections.singletonList(new LanguageProficiency(fieldValue));
}
} else {
valueObject = fieldValue;
}
userService.updateAccount(username, Collections.singletonMap(field.getName(), valueObject)).enqueue(new AccountDataUpdatedCallback(getActivity(), username, new DialogErrorNotification(this)) {
@Override
protected void onResponse(@NonNull final Account account) {
super.onResponse(account);
EditUserProfileFragment.this.account = account;
setData(account, formDescription);
}
});
}
Aggregations