Skip to content

Commit

Permalink
removed launch
Browse files Browse the repository at this point in the history
fixed issue with getting the offlineCompose feature status
  • Loading branch information
amoh-mega committed Sep 29, 2023
1 parent d4e50d7 commit a67b000
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import androidx.core.view.isVisible
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import androidx.fragment.app.viewModels
import androidx.lifecycle.lifecycleScope
import androidx.navigation.fragment.findNavController
import androidx.viewpager2.widget.ViewPager2
import com.google.android.material.dialog.MaterialAlertDialogBuilder
Expand All @@ -35,7 +34,7 @@ import com.zhpan.bannerview.constants.IndicatorGravity
import com.zhpan.bannerview.utils.BannerUtils
import com.zhpan.indicator.enums.IndicatorStyle
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import mega.privacy.android.analytics.Analytics
import mega.privacy.android.app.R
import mega.privacy.android.app.arch.extensions.collectFlow
Expand Down Expand Up @@ -141,11 +140,6 @@ class HomepageFragment : Fragment() {

var isFabExpanded = false

/**
* Feature Flag for OfflineCompose
*/
private var enableOfflineCompose: Boolean = false

/** The click listener for clicking on the file category buttons.
* Clicking to navigate to corresponding fragments */
private val categoryClickListener = OnClickListener {
Expand Down Expand Up @@ -228,32 +222,26 @@ class HomepageFragment : Fragment() {

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
lifecycleScope.launch {
runCatching {
enableOfflineCompose = getFeatureFlagValueUseCase(AppFeatures.OfflineCompose)
}
setupMask()
setupSearchView()
setupBannerView()
setupCategories()
setupBottomSheetUI()
setupBottomSheetBehavior()
setupFabs()
setupMask()
setupSearchView()
setupBannerView()
setupCategories()
setupBottomSheetUI()
setupBottomSheetBehavior()
setupFabs()

(activity as? ManagerActivity)?.adjustTransferWidgetPositionInHomepage()
(activity as? ManagerActivity)?.adjustTransferWidgetPositionInHomepage()

if (savedInstanceState?.getBoolean(START_SCREEN_DIALOG_SHOWN, false) == true) {
showChooseStartScreenDialog()
}
viewLifecycleOwner.collectFlow(viewModel.monitorConnectivity) { isConnected ->
if (isConnected) {
showOnlineMode()
} else {
showOfflineMode()
}
if (savedInstanceState?.getBoolean(START_SCREEN_DIALOG_SHOWN, false) == true) {
showChooseStartScreenDialog()
}
viewLifecycleOwner.collectFlow(viewModel.monitorConnectivity) { isConnected ->
if (isConnected) {
showOnlineMode()
} else {
showOfflineMode()
}
}

}

override fun onResume() {
Expand Down Expand Up @@ -434,9 +422,16 @@ class HomepageFragment : Fragment() {
* Set up the view pager, tab layout and fragments contained in the Homepage main bottom sheet
*/
private fun setupBottomSheetUI() {
var enableOfflineCompose: Boolean
runBlocking {
enableOfflineCompose = getFeatureFlagValueUseCase(AppFeatures.OfflineCompose)
}
viewPager = viewDataBinding.homepageBottomSheet.viewPager
val adapter =
BottomSheetPagerAdapter(fragment = this, enableOfflineCompose = enableOfflineCompose)
BottomSheetPagerAdapter(
fragment = this@HomepageFragment,
enableOfflineCompose = enableOfflineCompose
)
// By setting this will make BottomSheetPagerAdapter create all the fragments on initialization.
viewPager.offscreenPageLimit = adapter.itemCount
viewPager.adapter = adapter
Expand All @@ -450,7 +445,6 @@ class HomepageFragment : Fragment() {
// Pass selected page view to HomepageBottomSheetBehavior which would seek for
// the nested scrolling child views and deal with the logic of nested scrolling
viewPager.registerOnPageChangeCallback(pageChangeCallback)

setupBottomSheetBackground()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -906,8 +906,7 @@ class ManagerActivity : TransfersManagementActivity(), MegaRequestListenerInterf
override fun onCreate(savedInstanceState: Bundle?) {
Timber.d("onCreate")
super.onCreate(savedInstanceState)

lifecycleScope.launch {
runBlocking {
enableOfflineCompose =
getFeatureFlagValueUseCase(AppFeatures.OfflineCompose)
}
Expand Down Expand Up @@ -8323,7 +8322,10 @@ class ManagerActivity : TransfersManagementActivity(), MegaRequestListenerInterf
val isFromOpenChatPreview: Boolean = request.flag
val type: Int = request.paramType
val link: String = request.link
val waitingRoom = MegaChatApi.hasChatOptionEnabled(MegaChatApi.CHAT_OPTION_WAITING_ROOM, request.privilege)
val waitingRoom = MegaChatApi.hasChatOptionEnabled(
MegaChatApi.CHAT_OPTION_WAITING_ROOM,
request.privilege
)
if (joiningToChatLink && TextUtil.isTextEmpty(link) && chatId == MegaChatApiJava.MEGACHAT_INVALID_HANDLE) {
showSnackbar(
Constants.SNACKBAR_TYPE,
Expand Down

0 comments on commit a67b000

Please sign in to comment.