Search in sources :

Example 1 with MessageResult

use of org.thoughtcrime.securesms.search.MessageResult in project Signal-Android by WhisperSystems.

the class ConversationListSearchAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(@NonNull SearchResultViewHolder holder, int position) {
    ThreadRecord conversationResult = getConversationResult(position);
    if (conversationResult != null) {
        holder.bind(conversationResult, glideRequests, eventListener, locale, searchResult.getQuery());
        return;
    }
    Recipient contactResult = getContactResult(position);
    if (contactResult != null) {
        holder.bind(contactResult, glideRequests, eventListener, locale, searchResult.getQuery());
        return;
    }
    MessageResult messageResult = getMessageResult(position);
    if (messageResult != null) {
        holder.bind(messageResult, glideRequests, eventListener, locale, searchResult.getQuery());
    }
}
Also used : ThreadRecord(org.thoughtcrime.securesms.database.model.ThreadRecord) Recipient(org.thoughtcrime.securesms.recipients.Recipient) MessageResult(org.thoughtcrime.securesms.search.MessageResult)

Example 2 with MessageResult

use of org.thoughtcrime.securesms.search.MessageResult in project Signal-Android by WhisperSystems.

the class ConversationParentFragment method initializeSearchObserver.

private void initializeSearchObserver() {
    ConversationSearchViewModel.Factory viewModelFactory = new ConversationSearchViewModel.Factory(getString(R.string.note_to_self));
    searchViewModel = new ViewModelProvider(this, viewModelFactory).get(ConversationSearchViewModel.class);
    searchViewModel.getSearchResults().observe(getViewLifecycleOwner(), result -> {
        if (result == null)
            return;
        if (!result.getResults().isEmpty()) {
            MessageResult messageResult = result.getResults().get(result.getPosition());
            fragment.jumpToMessage(messageResult.getMessageRecipient().getId(), messageResult.getReceivedTimestampMs(), searchViewModel::onMissingResult);
        }
        searchNav.setData(result.getPosition(), result.getResults().size());
    });
}
Also used : ConversationMessageFactory(org.thoughtcrime.securesms.conversation.ConversationMessage.ConversationMessageFactory) MessageResult(org.thoughtcrime.securesms.search.MessageResult) ViewModelProvider(androidx.lifecycle.ViewModelProvider)

Example 3 with MessageResult

use of org.thoughtcrime.securesms.search.MessageResult in project Signal-Android by signalapp.

the class ConversationListSearchAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(@NonNull SearchResultViewHolder holder, int position) {
    ThreadRecord conversationResult = getConversationResult(position);
    if (conversationResult != null) {
        holder.bind(conversationResult, glideRequests, eventListener, locale, searchResult.getQuery());
        return;
    }
    Recipient contactResult = getContactResult(position);
    if (contactResult != null) {
        holder.bind(contactResult, glideRequests, eventListener, locale, searchResult.getQuery());
        return;
    }
    MessageResult messageResult = getMessageResult(position);
    if (messageResult != null) {
        holder.bind(messageResult, glideRequests, eventListener, locale, searchResult.getQuery());
    }
}
Also used : ThreadRecord(org.thoughtcrime.securesms.database.model.ThreadRecord) Recipient(org.thoughtcrime.securesms.recipients.Recipient) MessageResult(org.thoughtcrime.securesms.search.MessageResult)

Example 4 with MessageResult

use of org.thoughtcrime.securesms.search.MessageResult in project Signal-Android by signalapp.

the class ConversationParentFragment method initializeSearchObserver.

private void initializeSearchObserver() {
    ConversationSearchViewModel.Factory viewModelFactory = new ConversationSearchViewModel.Factory(getString(R.string.note_to_self));
    searchViewModel = new ViewModelProvider(this, viewModelFactory).get(ConversationSearchViewModel.class);
    searchViewModel.getSearchResults().observe(getViewLifecycleOwner(), result -> {
        if (result == null)
            return;
        if (!result.getResults().isEmpty()) {
            MessageResult messageResult = result.getResults().get(result.getPosition());
            fragment.jumpToMessage(messageResult.getMessageRecipient().getId(), messageResult.getReceivedTimestampMs(), searchViewModel::onMissingResult);
        }
        searchNav.setData(result.getPosition(), result.getResults().size());
    });
}
Also used : ConversationMessageFactory(org.thoughtcrime.securesms.conversation.ConversationMessage.ConversationMessageFactory) MessageResult(org.thoughtcrime.securesms.search.MessageResult) ViewModelProvider(androidx.lifecycle.ViewModelProvider)

Aggregations

MessageResult (org.thoughtcrime.securesms.search.MessageResult)4 ViewModelProvider (androidx.lifecycle.ViewModelProvider)2 ConversationMessageFactory (org.thoughtcrime.securesms.conversation.ConversationMessage.ConversationMessageFactory)2 ThreadRecord (org.thoughtcrime.securesms.database.model.ThreadRecord)2 Recipient (org.thoughtcrime.securesms.recipients.Recipient)2