mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-01-31 03:17:13 +01:00
Remove usage of GlobalScope
This commit is contained in:
parent
0711ecc7f4
commit
25b4c32fd0
@ -19,6 +19,7 @@ import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import im.vector.app.core.extensions.cleanup
|
||||
import im.vector.app.core.platform.VectorBaseFragment
|
||||
import im.vector.app.databinding.EmojiChooserFragmentBinding
|
||||
@ -51,6 +52,8 @@ class EmojiChooserFragment @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
override fun getCoroutineScope() = lifecycleScope
|
||||
|
||||
override fun firstVisibleSectionChange(section: Int) {
|
||||
viewModel.setCurrentSection(section)
|
||||
}
|
||||
|
@ -31,8 +31,8 @@ import androidx.transition.AutoTransition
|
||||
import androidx.transition.TransitionManager
|
||||
import im.vector.app.R
|
||||
import im.vector.app.features.reactions.data.EmojiDataSource
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
import javax.inject.Inject
|
||||
import kotlin.math.abs
|
||||
@ -278,6 +278,7 @@ class EmojiRecyclerAdapter @Inject constructor(
|
||||
}
|
||||
|
||||
interface InteractionListener {
|
||||
fun getCoroutineScope(): CoroutineScope
|
||||
fun firstVisibleSectionChange(section: Int)
|
||||
}
|
||||
|
||||
@ -323,11 +324,11 @@ class EmojiRecyclerAdapter @Inject constructor(
|
||||
// Log.i("SCROLL SPEED","scroll speed $dy")
|
||||
isFastScroll = abs(dy) > 50
|
||||
val visible = (recyclerView.layoutManager as GridLayoutManager).findFirstCompletelyVisibleItemPosition()
|
||||
GlobalScope.launch {
|
||||
interactionListener?.getCoroutineScope()?.launch {
|
||||
val section = getSectionForAbsoluteIndex(visible)
|
||||
if (section != currentFirstVisibleSection) {
|
||||
currentFirstVisibleSection = section
|
||||
GlobalScope.launch(Dispatchers.Main) {
|
||||
interactionListener?.getCoroutineScope()?.launch(Dispatchers.Main) {
|
||||
interactionListener?.firstVisibleSectionChange(currentFirstVisibleSection)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user