Search in sources :

Example 1 with Response

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);
        }
    });
}
Also used : Response(retrofit.client.Response) MenuItem(android.view.MenuItem) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RetrofitError(retrofit.RetrofitError)

Example 2 with Response

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();
}
Also used : WebResourceResponse(android.webkit.WebResourceResponse) Response(retrofit.client.Response) LinkHeaders(com.instructure.canvasapi.utilities.LinkHeaders) SharedPreferences(android.content.SharedPreferences) APIStatusDelegate(com.instructure.canvasapi.utilities.APIStatusDelegate)

Example 3 with Response

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;
}
Also used : Response(retrofit.client.Response) CanvasCallback(com.instructure.canvasapi.utilities.CanvasCallback) LinkHeaders(com.instructure.canvasapi.utilities.LinkHeaders) SharedPreferences(android.content.SharedPreferences)

Example 4 with Response

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;
}
Also used : Response(retrofit.client.Response) CanvasCallback(com.instructure.canvasapi.utilities.CanvasCallback) LinkHeaders(com.instructure.canvasapi.utilities.LinkHeaders) SharedPreferences(android.content.SharedPreferences)

Example 5 with Response

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;
}
Also used : StoryResponse(io.plaidapp.data.api.designernews.model.StoryResponse) Response(retrofit.client.Response) Comment(io.plaidapp.data.api.designernews.model.Comment) Callback(retrofit.Callback) SharedElementCallback(android.app.SharedElementCallback) ImageView(android.widget.ImageView) View(android.view.View) AuthorTextView(io.plaidapp.ui.widget.AuthorTextView) TextView(android.widget.TextView) FontTextView(io.plaidapp.ui.widget.FontTextView) PinnedOffsetView(io.plaidapp.ui.widget.PinnedOffsetView) RecyclerView(android.support.v7.widget.RecyclerView) RetrofitError(retrofit.RetrofitError) NonNull(android.support.annotation.NonNull)

Aggregations

Response (retrofit.client.Response)46 RetrofitError (retrofit.RetrofitError)27 LinkHeaders (com.instructure.canvasapi.utilities.LinkHeaders)8 View (android.view.View)7 TextView (android.widget.TextView)7 ImageView (android.widget.ImageView)6 ArrayList (java.util.ArrayList)5 Callback (retrofit.Callback)5 RestAdapter (retrofit.RestAdapter)5 SharedPreferences (android.content.SharedPreferences)4 User (com.instructure.canvasapi.model.User)4 ClientAuthInterceptor (io.plaidapp.data.api.ClientAuthInterceptor)4 HashMap (java.util.HashMap)4 Intent (android.content.Intent)3 HashSet (java.util.HashSet)3 Test (org.junit.Test)3 ForgetPasswordResponse (org.matrix.androidsdk.rest.model.ForgetPasswordResponse)3 RequestEmailValidationResponse (org.matrix.androidsdk.rest.model.RequestEmailValidationResponse)3 RequestPhoneNumberValidationResponse (org.matrix.androidsdk.rest.model.RequestPhoneNumberValidationResponse)3 TokenRefreshResponse (org.matrix.androidsdk.rest.model.login.TokenRefreshResponse)3