Search in sources :

Example 1 with ConversationsList

use of com.waz.api.ConversationsList in project wire-android by wireapp.

the class ConversationListFragment method onConversationListUpdated.

//////////////////////////////////////////////////////////////////////////////////////////
//
//  Notifications
//
//////////////////////////////////////////////////////////////////////////////////////////
@Override
public void onConversationListUpdated(@NonNull final ConversationsList conversationsList) {
    ConversationsList conversations = mode == Mode.SHARING ? conversationsList.getEstablishedConversations() : conversationsList;
    conversationsListAdapter.setConversationList(conversations);
    // We post this to notify that we are ready after the items are instantiated
    swipeListView.post(new Runnable() {

        @Override
        public void run() {
            if (getContainer() == null) {
                return;
            }
        }
    });
    if (pendingCurrentConversation != null) {
        final int pos = getStoreFactory().getConversationStore().getPositionInList(pendingCurrentConversation);
        if (pos > 0) {
            // set selection after updating the conversationlist
            new Handler().post(new Runnable() {

                @SuppressLint("NewApi")
                @Override
                public void run() {
                    int selectionPos = pos - LIST_VIEW_POSITION_OFFSET < 0 ? 0 : pos - LIST_VIEW_POSITION_OFFSET;
                    swipeListView.setSelectionFromTop(selectionPos, 0);
                    pendingCurrentConversation = null;
                }
            });
        }
    }
    // sync state
    onConversationSyncingStateHasChanged(getStoreFactory().getConversationStore().getConversationSyncingState());
    CoreList<IConversation> archivedConversations = conversationsList.getArchivedConversations();
    if (archivedConversations != null && archivedConversations.size() > 0) {
        archiveBox.setAlpha(1f);
    } else {
        archiveBox.setAlpha(0f);
    }
    if (conversationsList.isReady()) {
        maybeShowNoContactsLabel(conversationsList.size() == 0);
    }
}
Also used : Handler(android.os.Handler) ExceptionHandler(net.hockeyapp.android.ExceptionHandler) SuppressLint(android.annotation.SuppressLint) IConversation(com.waz.api.IConversation) ConversationsList(com.waz.api.ConversationsList) SuppressLint(android.annotation.SuppressLint)

Aggregations

SuppressLint (android.annotation.SuppressLint)1 Handler (android.os.Handler)1 ConversationsList (com.waz.api.ConversationsList)1 IConversation (com.waz.api.IConversation)1 ExceptionHandler (net.hockeyapp.android.ExceptionHandler)1