Search in sources :

Example 1 with TaskListener

use of com.applozic.mobicomkit.api.account.user.UserLoginTask.TaskListener in project Applozic-Android-SDK by AppLozic.

the class ApplozicBridge method startChatActivity.

/**
 * Starts the chat activity if user is not loggedIn then it will login to applozic server and launch the chat-list
 * else if user is loggedIn then directly opens chat-list
 *
 * @param context
 * @param user    :User object
 */
private static void startChatActivity(Context context, User user) {
    if (!MobiComUserPreference.getInstance(context).isLoggedIn()) {
        TaskListener listener = new TaskListener() {

            @Override
            public void onSuccess(RegistrationResponse registrationResponse, Context context) {
                // Todo: get pushnotification id.
                String pushNotificationId = "";
                gcmRegister(context, pushNotificationId);
                launchChat(context);
            }

            @Override
            public void onFailure(RegistrationResponse registrationResponse, Exception exception) {
            }
        };
        user = user != null ? user : getLoggedInUserInformation();
        new UserLoginTask(user, listener, context).execute((Void) null);
    } else {
        launchChat(context);
    }
}
Also used : Context(android.content.Context) UserLoginTask(com.applozic.mobicomkit.api.account.user.UserLoginTask) TaskListener(com.applozic.mobicomkit.api.account.user.UserLoginTask.TaskListener) RegistrationResponse(com.applozic.mobicomkit.api.account.register.RegistrationResponse)

Aggregations

Context (android.content.Context)1 RegistrationResponse (com.applozic.mobicomkit.api.account.register.RegistrationResponse)1 UserLoginTask (com.applozic.mobicomkit.api.account.user.UserLoginTask)1 TaskListener (com.applozic.mobicomkit.api.account.user.UserLoginTask.TaskListener)1