Search in sources :

Example 41 with Response

use of retrofit.client.Response in project glasquare by davidvavra.

the class CheckInSearchActivity method loadData.

@Override
protected void loadData() {
    showProgress(R.string.loading);
    LocationUtils.getRecentLocation(new LocationUtils.LocationListener() {

        @Override
        public void onLocationAcquired(Location location) {
            String ll = LocationUtils.getLatLon(location);
            Api.get().create(SearchVenues.class).searchForCheckIn(ll, new Callback<SearchVenues.SearchResponse>() {

                @Override
                public void success(SearchVenues.SearchResponse venuesResponse, Response response) {
                    showContent(new CheckInSearchAdapter(venuesResponse.getVenues()), new CardSelectedListener() {

                        @Override
                        public void onCardSelected(Object item) {
                            SearchVenues.Venue venue = (SearchVenues.Venue) item;
                            CheckInActivity.call(CheckInSearchActivity.this, venue.id, venue.name);
                        }
                    });
                }

                @Override
                public void failure(RetrofitError retrofitError) {
                    showError(R.string.error_please_try_again);
                }
            });
        }

        @Override
        public void onLocationFailed() {
            showError(R.string.no_location);
        }
    });
}
Also used : LocationUtils(cz.destil.glasquare.util.LocationUtils) SearchVenues(cz.destil.glasquare.api.SearchVenues) Response(retrofit.client.Response) CheckInSearchAdapter(cz.destil.glasquare.adapter.CheckInSearchAdapter) Callback(retrofit.Callback) Location(android.location.Location) RetrofitError(retrofit.RetrofitError)

Example 42 with Response

use of retrofit.client.Response in project connect-android-sdk by telenordigital.

the class MobileConnectSdkProfile method onStartAuthorization.

@Override
public void onStartAuthorization(Map<String, String> parameters, final OnStartAuthorizationCallback callback) {
    super.onStartAuthorization(parameters, callback);
    lastAuthNonce = UUID.randomUUID().toString();
    parameters.put("nonce", lastAuthNonce);
    if (parameters.get(ConnectUtils.ACR_VALUES_PARAM_NAME) == null) {
        parameters.put(ConnectUtils.ACR_VALUES_PARAM_NAME, "2");
    }
    if (isInitialized()) {
        callback.onSuccess();
        return;
    }
    TelephonyManager phMgr = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String networkOperator = phMgr.getNetworkOperator();
    if (TextUtils.isEmpty(networkOperator)) {
        callback.onError();
        return;
    }
    final String mcc = networkOperator.substring(0, 3);
    final String mnc = networkOperator.substring(3);
    getOperatorDiscoveryApi().getOperatorDiscoveryResult_ForMccMnc(getOperatorDiscoveryAuthHeader(), operatorDiscoveryConfig.getOperatorDiscoveryRedirectUri(), mcc, mnc, new Callback<OperatorDiscoveryAPI.OperatorDiscoveryResult>() {

        @Override
        public void success(OperatorDiscoveryAPI.OperatorDiscoveryResult operatorDiscoveryResult, Response response) {
            initAndContinue(operatorDiscoveryResult, callback);
        }

        @Override
        public void failure(RetrofitError error) {
            callback.onError();
        }
    });
}
Also used : Response(retrofit.client.Response) OperatorDiscoveryAPI(com.telenor.mobileconnect.operatordiscovery.OperatorDiscoveryAPI) TelephonyManager(android.telephony.TelephonyManager) RetrofitError(retrofit.RetrofitError)

Example 43 with Response

use of retrofit.client.Response in project connect-android-sdk by telenordigital.

the class ConnectSdk method sendAnalyticsData.

private static void sendAnalyticsData() {
    if (getWellKnownConfig().getAnalyticsEndpoint() == null) {
        return;
    }
    String accessToken = getAccessToken();
    final String auth = accessToken != null ? "Bearer " + accessToken : null;
    final String subject = getIdToken() != null ? getIdToken().getSubject() : null;
    RestHelper.getAnalyticsApi(getWellKnownConfig().getAnalyticsEndpoint()).sendAnalyticsData(auth, new AnalyticsAPI.SDKAnalyticsData(getApplicationName(), getApplicationVersion(), subject, getLogSessionId(), getAdvertisingId(), tsSdkInitiliazation, tsLoginButtonClicked, tsRedirectUrlInvoked, tsTokenResponseReceived), new ResponseCallback() {

        @Override
        public void success(Response response) {
        }

        @Override
        public void failure(RetrofitError error) {
            Log.e(ConnectUtils.LOG_TAG, "Failed to send analytics data", error);
        }
    });
}
Also used : Response(retrofit.client.Response) ResponseCallback(retrofit.ResponseCallback) RetrofitError(retrofit.RetrofitError)

Example 44 with Response

use of retrofit.client.Response in project matrix-android-sdk by matrix-org.

the class LoginRestClient method loginWithToken.

/**
 * Attempt a user/token log in.
 *
 * @param user       the user name
 * @param token      the token
 * @param txn_id     the client transaction id to include in the request
 * @param deviceName the device name
 * @param callback   the callback success and failure callback
 */
public void loginWithToken(final String user, final String token, final String txn_id, String deviceName, final ApiCallback<Credentials> callback) {
    // privacy
    // final String description = "loginWithPassword user : " + user;
    final String description = "loginWithPassword user";
    TokenLoginParams params = new TokenLoginParams();
    params.user = user;
    params.token = token;
    params.txn_id = txn_id;
    if ((null != deviceName) && !TextUtils.isEmpty(deviceName.trim())) {
        params.initial_device_display_name = deviceName.trim();
    } else {
        params.initial_device_display_name = Build.MODEL.trim();
    }
    try {
        mApi.login(params, new RestAdapterCallback<JsonObject>(description, mUnsentEventsManager, callback, new RestAdapterCallback.RequestRetryCallBack() {

            @Override
            public void onRetry() {
                loginWithToken(user, token, txn_id, callback);
            }
        }) {

            @Override
            public void success(JsonObject jsonObject, Response response) {
                onEventSent();
                mCredentials = gson.fromJson(jsonObject, Credentials.class);
                callback.onSuccess(mCredentials);
            }
        });
    } catch (Throwable t) {
        callback.onUnexpectedError(new Exception(t));
    }
}
Also used : LoginFlowResponse(org.matrix.androidsdk.rest.model.login.LoginFlowResponse) Response(retrofit.client.Response) JsonObject(com.google.gson.JsonObject) TokenLoginParams(org.matrix.androidsdk.rest.model.login.TokenLoginParams)

Example 45 with Response

use of retrofit.client.Response in project matrix-android-sdk by matrix-org.

the class ProfileRestClient method refreshTokens.

/**
 * Attempt a user/password registration.
 * @param callback the callback success and failure callback
 */
public void refreshTokens(final ApiCallback<Credentials> callback) {
    final String description = "refreshTokens";
    TokenRefreshParams params = new TokenRefreshParams();
    params.refresh_token = mCredentials.refreshToken;
    try {
        mApi.tokenrefresh(params, new RestAdapterCallback<TokenRefreshResponse>(description, mUnsentEventsManager, callback, null) {

            @Override
            public void success(TokenRefreshResponse tokenreponse, Response response) {
                onEventSent();
                mCredentials.refreshToken = tokenreponse.refresh_token;
                mCredentials.accessToken = tokenreponse.access_token;
                if (null != callback) {
                    callback.onSuccess(mCredentials);
                }
            }
        });
    } catch (Throwable t) {
        callback.onUnexpectedError(new Exception(t));
    }
}
Also used : TokenRefreshResponse(org.matrix.androidsdk.rest.model.login.TokenRefreshResponse) RequestPhoneNumberValidationResponse(org.matrix.androidsdk.rest.model.RequestPhoneNumberValidationResponse) AccountThreePidsResponse(org.matrix.androidsdk.rest.model.pid.AccountThreePidsResponse) ForgetPasswordResponse(org.matrix.androidsdk.rest.model.ForgetPasswordResponse) Response(retrofit.client.Response) RequestEmailValidationResponse(org.matrix.androidsdk.rest.model.RequestEmailValidationResponse) TokenRefreshParams(org.matrix.androidsdk.rest.model.login.TokenRefreshParams) TokenRefreshResponse(org.matrix.androidsdk.rest.model.login.TokenRefreshResponse)

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