Search in sources :

Example 1 with APICallbackWrapper

use of drift.com.drift.wrappers.APICallbackWrapper in project drift-sdk-android by Driftt.

the class ConversationListActivity method refreshData.

@Override
public void refreshData() {
    super.refreshData();
    networkAvailabilityBar.setVisibility(View.GONE);
    final Auth auth = Auth.getInstance();
    if (auth != null && auth.endUser != null) {
        UserManager.getInstance().getUsers(auth.endUser.orgId, new UserManagerCallback() {

            @Override
            public void didLoadUsers(Boolean success) {
                if (success) {
                    ConversationManager.getInstance().getConversationsForEndUser(auth.endUser.id, new APICallbackWrapper<ArrayList<ConversationExtra>>() {

                        @Override
                        public void onResponse(ArrayList<ConversationExtra> response) {
                            if (response != null) {
                                progressBar.setVisibility(View.GONE);
                                LoggerHelper.logMessage(TAG, response.toString());
                                if (response.isEmpty()) {
                                    emptyState.setVisibility(View.VISIBLE);
                                } else {
                                    emptyState.setVisibility(View.GONE);
                                }
                                conversationListAdapter.updateDate(response);
                            } else {
                                Alert.showAlert(ConversationListActivity.this, "Error", "Failed to load conversations", "Retry", new Runnable() {

                                    @Override
                                    public void run() {
                                        refreshData();
                                    }
                                });
                            }
                        }
                    });
                } else {
                    LoggerHelper.logMessage(TAG, "Failed to load users");
                }
            }
        });
    }
}
Also used : UserManagerCallback(drift.com.drift.wrappers.UserManagerCallback) ConversationExtra(drift.com.drift.model.ConversationExtra) Auth(drift.com.drift.model.Auth) ArrayList(java.util.ArrayList) APICallbackWrapper(drift.com.drift.wrappers.APICallbackWrapper)

Example 2 with APICallbackWrapper

use of drift.com.drift.wrappers.APICallbackWrapper in project drift-sdk-android by Driftt.

the class PresentationManager method checkForUnreadMessagesToShow.

public void checkForUnreadMessagesToShow(int orgId, final int endUserId) {
    LoggerHelper.logMessage(TAG, "Checking for Messages to show");
    UserManager.getInstance().getUsersIfWeNeedTo(orgId, new UserManagerCallback() {

        @Override
        public void didLoadUsers(Boolean success) {
            ConversationManager.getInstance().getConversationsForEndUser(endUserId, new APICallbackWrapper<ArrayList<ConversationExtra>>() {

                @Override
                public void onResponse(ArrayList<ConversationExtra> response) {
                    if (response != null) {
                        showMessagePopupFromManager();
                    } else {
                        LoggerHelper.logMessage(TAG, "Failed to get conversation extras");
                    }
                }
            });
        }
    });
}
Also used : UserManagerCallback(drift.com.drift.wrappers.UserManagerCallback) ConversationExtra(drift.com.drift.model.ConversationExtra) ArrayList(java.util.ArrayList) APICallbackWrapper(drift.com.drift.wrappers.APICallbackWrapper)

Aggregations

ConversationExtra (drift.com.drift.model.ConversationExtra)2 APICallbackWrapper (drift.com.drift.wrappers.APICallbackWrapper)2 UserManagerCallback (drift.com.drift.wrappers.UserManagerCallback)2 ArrayList (java.util.ArrayList)2 Auth (drift.com.drift.model.Auth)1