Code review fixes.
This commit is contained in:
parent
320915e0a1
commit
2fe03a0016
@ -24,6 +24,8 @@ import android.view.View
|
|||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.view.isGone
|
import androidx.core.view.isGone
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import androidx.fragment.app.FragmentManager
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import com.airbnb.mvrx.fragmentViewModel
|
import com.airbnb.mvrx.fragmentViewModel
|
||||||
import com.airbnb.mvrx.withState
|
import com.airbnb.mvrx.withState
|
||||||
@ -68,6 +70,29 @@ class LocationSharingFragment @Inject constructor(
|
|||||||
|
|
||||||
private var hasRenderedUserAvatar = false
|
private var hasRenderedUserAvatar = false
|
||||||
|
|
||||||
|
private val liveLocationLabsFlagPromotionListener = object : VectorBaseBottomSheetDialogFragment.ResultListener {
|
||||||
|
override fun onBottomSheetResult(resultCode: Int, data: Any?) {
|
||||||
|
handleLiveLocationLabsFlagPromotionResult(resultCode, data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private val fragmentLifecycleCallbacks = object : FragmentManager.FragmentLifecycleCallbacks() {
|
||||||
|
override fun onFragmentResumed(fm: FragmentManager, f: Fragment) {
|
||||||
|
if (f is LiveLocationLabsFlagPromotionBottomSheet) {
|
||||||
|
f.resultListener = liveLocationLabsFlagPromotionListener
|
||||||
|
}
|
||||||
|
super.onFragmentResumed(fm, f)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onFragmentPaused(fm: FragmentManager, f: Fragment) {
|
||||||
|
if (f is LiveLocationLabsFlagPromotionBottomSheet) {
|
||||||
|
f.resultListener = null
|
||||||
|
}
|
||||||
|
super.onFragmentPaused(fm, f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentLocationSharingBinding {
|
override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentLocationSharingBinding {
|
||||||
return FragmentLocationSharingBinding.inflate(inflater, container, false)
|
return FragmentLocationSharingBinding.inflate(inflater, container, false)
|
||||||
}
|
}
|
||||||
@ -75,6 +100,8 @@ class LocationSharingFragment @Inject constructor(
|
|||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
|
activity?.supportFragmentManager?.registerFragmentLifecycleCallbacks(fragmentLifecycleCallbacks, false)
|
||||||
|
|
||||||
mapView = WeakReference(views.mapView)
|
mapView = WeakReference(views.mapView)
|
||||||
views.mapView.onCreate(savedInstanceState)
|
views.mapView.onCreate(savedInstanceState)
|
||||||
|
|
||||||
@ -195,12 +222,6 @@ class LocationSharingFragment @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val liveLocationLabsFlagPromotionListener = object : VectorBaseBottomSheetDialogFragment.ResultListener {
|
|
||||||
override fun onBottomSheetResult(resultCode: Int, data: Any?) {
|
|
||||||
handleLiveLocationLabsFlagPromotionResult(resultCode, data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun handleLiveLocationLabsFlagPromotionResult(resultCode: Int, data: Any?) {
|
private fun handleLiveLocationLabsFlagPromotionResult(resultCode: Int, data: Any?) {
|
||||||
if (resultCode == VectorBaseBottomSheetDialogFragment.ResultListener.RESULT_OK && (data as? Boolean) == true) {
|
if (resultCode == VectorBaseBottomSheetDialogFragment.ResultListener.RESULT_OK && (data as? Boolean) == true) {
|
||||||
vectorPreferences.setLiveLocationLabsEnabled(isEnabled = true)
|
vectorPreferences.setLiveLocationLabsEnabled(isEnabled = true)
|
||||||
@ -212,7 +233,7 @@ class LocationSharingFragment @Inject constructor(
|
|||||||
if (vectorPreferences.labsEnableLiveLocation()) {
|
if (vectorPreferences.labsEnableLiveLocation()) {
|
||||||
startLiveLocationSharing()
|
startLiveLocationSharing()
|
||||||
} else {
|
} else {
|
||||||
LiveLocationLabsFlagPromotionBottomSheet.newInstance(liveLocationLabsFlagPromotionListener)
|
LiveLocationLabsFlagPromotionBottomSheet.newInstance()
|
||||||
.show(requireActivity().supportFragmentManager, "DISPLAY_LIVE_LOCATION_LABS_FLAG_PROMOTION")
|
.show(requireActivity().supportFragmentManager, "DISPLAY_LIVE_LOCATION_LABS_FLAG_PROMOTION")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,10 +50,8 @@ class LiveLocationLabsFlagPromotionBottomSheet :
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun newInstance(resultListener: ResultListener): LiveLocationLabsFlagPromotionBottomSheet {
|
fun newInstance(): LiveLocationLabsFlagPromotionBottomSheet {
|
||||||
return LiveLocationLabsFlagPromotionBottomSheet().also {
|
return LiveLocationLabsFlagPromotionBottomSheet()
|
||||||
it.resultListener = resultListener
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user