use of com.instructure.canvasapi.utilities.APIStatusDelegate in project instructure-android by instructure.
the class OAuthWebLogin method removeFromPreviouslySignedInUsers.
public static boolean removeFromPreviouslySignedInUsers(SignedInUser signedInUser, final Context context, String preferenceKey) {
if (TextUtils.isEmpty(preferenceKey)) {
prefNameOtherSignedInUsers = Const.KEY_OTHER_SIGNED_IN_USERS_PREF_NAME;
preferenceKey = prefNameOtherSignedInUsers;
}
// Delete Access Token. We don't care about the result.
APIStatusDelegate apiStatusDelegate = APIHelpers.statusDelegateWithContext(context);
OAuthAPI.deleteToken(signedInUser.token, signedInUser.protocol, signedInUser.domain, new CanvasCallback<Response>(apiStatusDelegate) {
@Override
public void cache(Response response) {
}
@Override
public void firstPage(Response response, LinkHeaders linkHeaders, Response response2) {
}
});
// Save Signed In User to sharedPreferences
SharedPreferences sharedPreferences = context.getSharedPreferences(preferenceKey, MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.remove(getGlobalUserId(signedInUser.domain, signedInUser.user));
return editor.commit();
}
use of com.instructure.canvasapi.utilities.APIStatusDelegate in project instructure-android by instructure.
the class ZendeskDialogStyled method saveZendeskTicket.
public void saveZendeskTicket() {
String comment = descriptionEditText.getText().toString();
String subject = subjectEditText.getText().toString();
if (comment.isEmpty() || subject.isEmpty()) {
Toast.makeText(getContext(), R.string.empty_feedback, Toast.LENGTH_LONG).show();
return;
}
// contact the user
if (fromLogin) {
if (emailAddressEditText.getText() != null && emailAddressEditText.getText().toString() != null) {
User user = new User();
user.setEmail(emailAddressEditText.getText().toString());
APIHelpers.setCacheUser(getActivity(), user);
}
}
final String email = APIHelpers.getCacheUser(getActivity()).getEmail();
String domain = APIHelpers.getDomain(getActivity());
if (domain == null) {
domain = DEFAULT_DOMAIN;
}
// add device info to comment
// try to get the version number and version code
PackageInfo pInfo = null;
String versionName = "";
int versionCode = 0;
try {
pInfo = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0);
versionName = pInfo.versionName;
versionCode = pInfo.versionCode;
} catch (PackageManager.NameNotFoundException e) {
Utils.d(e.getMessage());
}
String deviceInfo = "";
deviceInfo += getString(R.string.device) + " " + Build.MANUFACTURER + " " + Build.MODEL + "\n" + getString(R.string.osVersion) + " " + Build.VERSION.RELEASE + "\n" + getString(R.string.versionNum) + ": " + versionName + " " + versionCode + "\n" + getString(R.string.zendesk_severityText) + " " + getUserSeveritySelectionTag() + "\n" + getString(R.string.utils_installDate) + " " + getInstallDateString() + "\n\n";
comment = deviceInfo + comment;
if (mUseDefaultDomain) {
ErrorReportAPI.postGenericErrorReport(subject, domain, email, comment, getUserSeveritySelectionTag(), new CanvasCallback<ErrorReportResult>((APIStatusDelegate) resultListener) {
@Override
public void firstPage(ErrorReportResult errorReportResult, LinkHeaders linkHeaders, Response response) {
resetCachedUser();
resultListener.onTicketPost();
}
@Override
public boolean onFailure(RetrofitError retrofitError) {
resetCachedUser();
resultListener.onTicketError();
return super.onFailure(retrofitError);
}
});
} else {
ErrorReportAPI.postErrorReport(subject, domain, email, comment, getUserSeveritySelectionTag(), new CanvasCallback<ErrorReportResult>((APIStatusDelegate) resultListener) {
@Override
public void cache(ErrorReportResult errorReportResult) {
resetCachedUser();
}
@Override
public void firstPage(ErrorReportResult errorReportResult, LinkHeaders linkHeaders, Response response) {
cache(errorReportResult);
resultListener.onTicketPost();
}
@Override
public boolean onFailure(RetrofitError retrofitError) {
resetCachedUser();
resultListener.onTicketError();
return super.onFailure(retrofitError);
}
});
}
}
Aggregations