Skip to content

Commit

Permalink
Merge pull request #15 from indrih17/window_leaked_fix
Browse files Browse the repository at this point in the history
Method `hide` replaced `dismiss`.
  • Loading branch information
whalemare authored Apr 1, 2019
2 parents d017ac9 + 5f03ad4 commit 297189a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 20 deletions.
7 changes: 2 additions & 5 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 21 additions & 13 deletions app/src/main/java/ru/whalemare/bottomsheet/MainActivityKotlin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ import androidx.recyclerview.widget.GridLayoutManager
import ru.whalemare.sheetmenu.SheetMenu

open class MainActivityKotlin : AppCompatActivity() {

var needTitle = false

var needIcons = true

private var sheetMenu: SheetMenu? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
Expand All @@ -35,29 +36,36 @@ open class MainActivityKotlin : AppCompatActivity() {
}
}

override fun onPause() {
super.onPause()
sheetMenu?.dismiss()
}

fun setupLinear() {
SheetMenu().apply {
sheetMenu = SheetMenu().apply {
titleId = if (needTitle) R.string.title else 0
click = MenuItem.OnMenuItemClickListener {
toast("Click on ${it.title}")
true
}
menu = R.menu.menu_icons
showIcons = needIcons
}.show(this)
}
sheetMenu?.show(this)
}

fun setupGrid() {
SheetMenu(
titleId = if (needTitle) R.string.title else 0,
menu = R.menu.menu_long_icons,
layoutManager = GridLayoutManager(this, 3),
click = MenuItem.OnMenuItemClickListener {
toast("Click on ${it.title}")
true
},
showIcons = needIcons
).show(this)
sheetMenu = SheetMenu(
titleId = if (needTitle) R.string.title else 0,
menu = R.menu.menu_long_icons,
layoutManager = GridLayoutManager(this, 3),
click = MenuItem.OnMenuItemClickListener {
toast("Click on ${it.title}")
true
},
showIcons = needIcons
)
sheetMenu?.show(this)
}
}

Expand Down
4 changes: 2 additions & 2 deletions sheetmenu/src/main/java/ru/whalemare/sheetmenu/SheetMenu.kt
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ open class SheetMenu(
dialog.show()
}

fun hide() {
dialog?.hide()
fun dismiss() {
dialog?.dismiss()
dialog = null
}

Expand Down

0 comments on commit 297189a

Please sign in to comment.