mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-23 20:48:43 +00:00
Decouple InlineQueryViewModelV2 instance from activity, parent to fragment instead.
This commit is contained in:
committed by
Cody Henthorne
parent
e3297ab593
commit
94d07f7012
@@ -17,7 +17,7 @@ import org.thoughtcrime.securesms.util.TextSecurePreferences
|
|||||||
import org.thoughtcrime.securesms.util.adapter.mapping.AnyMappingModel
|
import org.thoughtcrime.securesms.util.adapter.mapping.AnyMappingModel
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Activity (at least) scope view model for managing inline queries. The view model needs to be larger scope so it can
|
* View model for managing inline queries. The view model needs to be larger scope so it can
|
||||||
* be shared between the fragment requesting the search and the fragment used for displaying the results.
|
* be shared between the fragment requesting the search and the fragment used for displaying the results.
|
||||||
*/
|
*/
|
||||||
class InlineQueryViewModelV2(
|
class InlineQueryViewModelV2(
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import android.os.Looper
|
|||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.viewModels
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||||
@@ -28,7 +28,9 @@ import org.thoughtcrime.securesms.util.viewholders.RecipientViewHolder
|
|||||||
class MentionsPickerFragmentV2 : LoggingFragment() {
|
class MentionsPickerFragmentV2 : LoggingFragment() {
|
||||||
|
|
||||||
private val lifecycleDisposable: LifecycleDisposable = LifecycleDisposable()
|
private val lifecycleDisposable: LifecycleDisposable = LifecycleDisposable()
|
||||||
private val viewModel: InlineQueryViewModelV2 by activityViewModels()
|
private val viewModel: InlineQueryViewModelV2 by viewModels(
|
||||||
|
ownerProducer = { requireParentFragment() }
|
||||||
|
)
|
||||||
|
|
||||||
private lateinit var adapter: MentionsPickerAdapter
|
private lateinit var adapter: MentionsPickerAdapter
|
||||||
private lateinit var list: RecyclerView
|
private lateinit var list: RecyclerView
|
||||||
|
|||||||
@@ -327,7 +327,6 @@ import org.thoughtcrime.securesms.util.ViewUtil
|
|||||||
import org.thoughtcrime.securesms.util.WindowUtil
|
import org.thoughtcrime.securesms.util.WindowUtil
|
||||||
import org.thoughtcrime.securesms.util.atMidnight
|
import org.thoughtcrime.securesms.util.atMidnight
|
||||||
import org.thoughtcrime.securesms.util.atUTC
|
import org.thoughtcrime.securesms.util.atUTC
|
||||||
import org.thoughtcrime.securesms.util.createActivityViewModel
|
|
||||||
import org.thoughtcrime.securesms.util.doAfterNextLayout
|
import org.thoughtcrime.securesms.util.doAfterNextLayout
|
||||||
import org.thoughtcrime.securesms.util.fragments.requireListener
|
import org.thoughtcrime.securesms.util.fragments.requireListener
|
||||||
import org.thoughtcrime.securesms.util.getQuote
|
import org.thoughtcrime.securesms.util.getQuote
|
||||||
@@ -473,7 +472,9 @@ class ConversationFragment :
|
|||||||
StickerSuggestionsViewModel()
|
StickerSuggestionsViewModel()
|
||||||
}
|
}
|
||||||
|
|
||||||
private lateinit var inlineQueryViewModel: InlineQueryViewModelV2
|
private val inlineQueryViewModel: InlineQueryViewModelV2 by viewModel {
|
||||||
|
InlineQueryViewModelV2(conversationRecipientRepository)
|
||||||
|
}
|
||||||
|
|
||||||
private val shareDataTimestampViewModel: ShareDataTimestampViewModel by activityViewModels()
|
private val shareDataTimestampViewModel: ShareDataTimestampViewModel by activityViewModels()
|
||||||
|
|
||||||
@@ -598,8 +599,6 @@ class ConversationFragment :
|
|||||||
markReadHelper = MarkReadHelper(ConversationId.forConversation(args.threadId), requireContext(), viewLifecycleOwner)
|
markReadHelper = MarkReadHelper(ConversationId.forConversation(args.threadId), requireContext(), viewLifecycleOwner)
|
||||||
markReadHelper.ignoreViewReveals()
|
markReadHelper.ignoreViewReveals()
|
||||||
|
|
||||||
inlineQueryViewModel = createActivityViewModel { InlineQueryViewModelV2(recipientRepository = conversationRecipientRepository) }
|
|
||||||
|
|
||||||
attachmentManager = AttachmentManager(requireContext(), requireView(), AttachmentManagerListener())
|
attachmentManager = AttachmentManager(requireContext(), requireView(), AttachmentManagerListener())
|
||||||
|
|
||||||
initializeConversationThreadUi()
|
initializeConversationThreadUi()
|
||||||
|
|||||||
Reference in New Issue
Block a user