com.amazonaws.mobile.client.Callback Java Examples

The following examples show how to use com.amazonaws.mobile.client.Callback. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HTMobileClient.java    From live-app-android with MIT License 6 votes vote down vote up
public static TripsManager getTripsManager(Context context) {
    return TripsManager.getInstance(context, new AsyncTokenProvider() {
        @Override
        public void getAuthenticationToken(@NonNull final ResultHandler<String> resultHandler) {
            AWSMobileClient.getInstance().getTokens(new com.amazonaws.mobile.client.Callback<Tokens>() {
                @Override
                public void onResult(Tokens result) {
                    resultHandler.onResult(result.getIdToken().getTokenString());
                }

                @Override
                public void onError(Exception e) {
                    resultHandler.onError(e);
                }
            });
        }
    });
}
 
Example #2
Source File: HTMobileClient.java    From live-app-android with MIT License 6 votes vote down vote up
public void signIn(final String email, final String password, @NonNull final Callback callback) {
    AWSMobileClient.getInstance().signIn(email, password, null, new InnerCallback<SignInResult>(callback) {

        @Override
        public void onResult(SignInResult result) {
            updatePublishableKey(callback);
        }

        @Override
        public void onError(Exception e) {
            super.onError(e);
            signUpEmail = email;
            signUpPassword = password;
        }
    });
}
 
Example #3
Source File: HTMobileClient.java    From live-app-android with MIT License 5 votes vote down vote up
public void initialize(@NonNull final Callback callback) {
    AWSMobileClient.getInstance().initialize(mContext, new InnerCallback<UserStateDetails>(callback) {
        @Override
        public void onResult(UserStateDetails userStateDetails) {
            onSuccessHidden(HTMobileClient.this);
        }
    });
}
 
Example #4
Source File: HTMobileClient.java    From live-app-android with MIT License 5 votes vote down vote up
public void signUp(final String email, final String password, Map<String, String> attributes, @NonNull final Callback callback) {
    AWSMobileClient.getInstance().signUp(email, password, attributes, null, new InnerCallback<SignUpResult>(callback) {
        @Override
        public void onResult(SignUpResult result) {
            signUpEmail = email;
            signUpPassword = password;
            onSuccessHidden(HTMobileClient.this);
        }
    });
}
 
Example #5
Source File: HTMobileClient.java    From live-app-android with MIT License 5 votes vote down vote up
public void resendSignUp(@NonNull final Callback callback) {
    if (!TextUtils.isEmpty(signUpEmail)) {
        AWSMobileClient.getInstance().resendSignUp(signUpEmail, new InnerCallback<SignUpResult>(callback) {
            @Override
            public void onResult(SignUpResult result) {
                onSuccessHidden(HTMobileClient.this);
            }
        });
    }
}
 
Example #6
Source File: HTMobileClient.java    From live-app-android with MIT License 5 votes vote down vote up
public void confirmSignIn(@NonNull final Callback callback) {
    AWSMobileClient.getInstance().signIn(signUpEmail, signUpPassword, null, new InnerCallback<SignInResult>(callback) {

        @Override
        public void onResult(SignInResult result) {
            updatePublishableKey(callback);
        }
    });

}
 
Example #7
Source File: HTMobileClient.java    From live-app-android with MIT License 5 votes vote down vote up
public void updatePublishableKey(@NonNull final Callback callback) {
    if (!isAuthorized()) {
        return;
    }

    Request request = new Request("https://live-api.htprod.hypertrack.com/api-key", new Response.Listener<JsonObject>() {
        @Override
        public void onResponse(JsonObject response) {
            Log.d(TAG, "getPublishableKey onResponse: " + response);
            String hyperTrackPublicKey = response.get("key").getAsString();
            SharedPreferences sharedPreferences = mContext.getSharedPreferences(mContext.getString(R.string.app_name), Context.MODE_PRIVATE);
            sharedPreferences.edit()
                    .putString("pub_key", hyperTrackPublicKey)
                    .putBoolean("is_tracking", true)
                    .apply();

            callback.onSuccess(HTMobileClient.this);
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            Log.e(TAG, "onErrorResponse: " + error.getMessage());
            callback.onError(error.getMessage(), null);
        }
    });

    request.setShouldCache(false);

    request(request);
}
 
Example #8
Source File: HTMobileClient.java    From live-app-android with MIT License 4 votes vote down vote up
InnerCallback(Callback callback) {
    this.callback = callback;
}