mirror of
https://github.com/hmalik144/Weather-apps.git
synced 2025-12-10 02:05:20 +00:00
fix to permissions dialog
Took 24 minutes
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user