fix to permissions dialog

Took 24 minutes
This commit is contained in:
2022-06-10 01:08:42 +01:00
parent 730c7064b1
commit cb8f683f06
2 changed files with 13 additions and 10 deletions

View File

@@ -35,11 +35,11 @@ abstract class BaseDeclarationDialog(val context: Context): DeclarationBuilder {
.setMessage(myMessage)
.setCancelable(false)
val alertDialog = builder.create()
alertDialog.show()
dialog = builder.create()
dialog.show()
// Make the textview clickable. Must be called after show()
val msgTxt = alertDialog.findViewById<View>(android.R.id.message) as TextView?
val msgTxt = dialog.findViewById<View>(android.R.id.message) as TextView?
msgTxt?.movementMethod = LinkMovementMethod.getInstance()
}

View File

@@ -41,14 +41,7 @@ class HomeFragment : BaseFragment(R.layout.fragment_home) {
})
forecast_listview.adapter = recyclerAdapter
dialog = PermissionsDeclarationDialog(requireContext())
dialog.showDialog(agreeCallback = {
getPermissionResult(ACCESS_COARSE_LOCATION, LOCATION_PERMISSION_REQUEST) {
viewModel.fetchData()
}
})
swipe_refresh.apply {
setOnRefreshListener {
@@ -68,6 +61,16 @@ class HomeFragment : BaseFragment(R.layout.fragment_home) {
viewModel.operationRefresh.observe(viewLifecycleOwner, refreshObserver(swipe_refresh))
}
@SuppressLint("MissingPermission")
override fun onStart() {
super.onStart()
dialog.showDialog(agreeCallback = {
getPermissionResult(ACCESS_COARSE_LOCATION, LOCATION_PERMISSION_REQUEST) {
viewModel.fetchData()
}
})
}
override fun onStop() {
super.onStop()
dialog.dismiss()