use of retrofit.client.Response in project cw-omnibus by commonsguy.
the class QuestionsFragment method onViewCreated.
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
setLayoutManager(new LinearLayoutManager(getActivity()));
so.questions("android", new Callback<SOQuestions>() {
@Override
public void success(SOQuestions results, Response response) {
for (Item item : results.items) {
Question question = new Question(item);
questions.add(question);
questionMap.put(question.id, question);
}
setAdapter(new QuestionsAdapter(questions));
}
@Override
public void failure(RetrofitError error) {
onError(error);
}
});
}
use of retrofit.client.Response 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 retrofit.client.Response in project instructure-android by instructure.
the class App method logoutUser.
/**
* Log out the currently signed in user. Permanently remove credential information.
*
* @return
*/
public boolean logoutUser() {
// if this has already ran, data is already cleared causing null pointer exceptions
if (APIHelpers.getToken(this) != null && !APIHelpers.getToken(this).equals("")) {
// Delete token from server
// We don't actually care about this coming back. Fire and forget.
CanvasCallback<Response> deleteTokenCallback = new CanvasCallback<Response>(APIHelpers.statusDelegateWithContext(this)) {
@Override
public void cache(Response response) {
}
@Override
public void firstPage(Response response, LinkHeaders linkHeaders, Response response2) {
}
};
OAuthAPI.deleteToken(deleteTokenCallback);
// Remove Signed In User from sharedPreferences
SharedPreferences sharedPreferences = getSharedPreferences(OTHER_SIGNED_IN_USERS_PREF_NAME, MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.remove(getGlobalUserId(APIHelpers.getDomain(this), APIHelpers.getCacheUser(this)));
editor.commit();
// Clear shared preferences, but keep the important stuff.
safeClearSharedPreferences();
// CLear masquerading preferences.
clearMasqueradingPreferences();
// Clear all Shared Preferences.
APIHelpers.clearAllData(this);
}
return true;
}
use of retrofit.client.Response in project instructure-android by instructure.
the class ApplicationManager method logoutUser.
/**
* Log out the currently signed in user. Permanently remove credential information.
*
* @return
*/
public boolean logoutUser() {
// if this has already ran, data is already cleared causing null pointer exceptions
if (APIHelpers.getToken(this) != null && !APIHelpers.getToken(this).equals("")) {
// Delete token from server
// We don't actually care about this coming back. Fire and forget.
CanvasCallback<Response> deleteTokenCallback = new CanvasCallback<Response>(APIHelpers.statusDelegateWithContext(this)) {
@Override
public void cache(Response response) {
}
@Override
public void firstPage(Response response, LinkHeaders linkHeaders, Response response2) {
}
};
OAuthAPI.deleteToken(deleteTokenCallback);
// Remove Signed In User from sharedPreferences
SharedPreferences sharedPreferences = getSharedPreferences(OTHER_SIGNED_IN_USERS_PREF_NAME, MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.remove(OAuthWebLogin.getGlobalUserId(APIHelpers.getDomain(this), APIHelpers.getCacheUser(this)));
editor.commit();
// Clear shared preferences, but keep the important stuff.
safeClearSharedPreferences();
// CLear masquerading preferences.
clearMasqueradingPreferences();
// Clear all Shared Preferences.
APIHelpers.clearAllData(this);
}
return true;
}
use of retrofit.client.Response in project sbt-android by scala-android.
the class DesignerNewsStory method setupCommentField.
@NonNull
private View setupCommentField() {
View enterCommentView = getLayoutInflater().inflate(R.layout.designer_news_enter_comment, commentsList, false);
enterComment = (EditText) enterCommentView.findViewById(R.id.comment);
postComment = (ImageButton) enterCommentView.findViewById(R.id.post_comment);
postComment.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (designerNewsPrefs.isLoggedIn()) {
if (TextUtils.isEmpty(enterComment.getText()))
return;
enterComment.setEnabled(false);
postComment.setEnabled(false);
designerNewsApi.comment(story.id, enterComment.getText().toString(), new Callback<Comment>() {
@Override
public void success(Comment comment, Response response) {
enterComment.getText().clear();
enterComment.setEnabled(true);
postComment.setEnabled(true);
((DesignerNewsCommentsAdapter) commentsList.getAdapter()).addComment(new ThreadedComment(0, comment));
}
@Override
public void failure(RetrofitError error) {
Toast.makeText(getApplicationContext(), "Failed to post comment :(", Toast.LENGTH_SHORT).show();
enterComment.setEnabled(true);
postComment.setEnabled(true);
}
});
} else {
needsLogin(postComment, 0);
}
enterComment.clearFocus();
}
});
enterComment.setOnFocusChangeListener(enterCommentFocus);
return enterCommentView;
}
Aggregations