Skip to content

Commit

Permalink
Merge pull request #3015 from TeamAmaze/app-chooser-glitch
Browse files Browse the repository at this point in the history
Fix open with dialog glitch
  • Loading branch information
VishalNehra authored Nov 21, 2021
2 parents 59665a3 + fd9d39d commit afa37c6
Showing 1 changed file with 1 addition and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,39 +23,16 @@ package com.amaze.filemanager.ui.base
import android.app.Dialog
import android.os.Bundle
import android.view.View
import android.widget.FrameLayout
import com.amaze.filemanager.R
import com.amaze.filemanager.ui.activities.superclasses.ThemedActivity
import com.amaze.filemanager.ui.theme.AppTheme
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.google.android.material.bottomsheet.BottomSheetDialogFragment

open class BaseBottomSheetFragment : BottomSheetDialogFragment() {

override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val dialog = super.onCreateDialog(savedInstanceState) as BottomSheetDialog

dialog.setOnShowListener {
val bottomSheet = (it as BottomSheetDialog)
.findViewById<FrameLayout>(com.google.android.material.R.id.design_bottom_sheet)
bottomSheet?.run {
val behavior = BottomSheetBehavior.from(this)

behavior.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
override fun onStateChanged(bottomSheet: View, newState: Int) {
if (newState == BottomSheetBehavior.STATE_DRAGGING) {
behavior.state = BottomSheetBehavior.STATE_EXPANDED
}
}

override fun onSlide(bottomSheet: View, slideOffset: Float) {
// do nothing
}
})
}
}
return dialog
return super.onCreateDialog(savedInstanceState) as BottomSheetDialog
}

/**
Expand Down

0 comments on commit afa37c6

Please sign in to comment.