mirror of
https://github.com/hmalik144/Weather-apps.git
synced 2026-03-17 23:16:01 +00:00
- Dialog changes added
- updated properties retrieval Took 13 minutes
This commit is contained in:
@@ -26,8 +26,8 @@ android {
|
||||
buildConfigField "String", "ParamOne", properties.getProperty('WEATHER_API')
|
||||
buildConfigField "String", "ParamTwo", properties.getProperty('SEARCH_API')
|
||||
} else {
|
||||
buildConfigField "String", "ParamOne", "${WEATHER_API}"
|
||||
buildConfigField "String", "ParamTwo", "${SEARCH_API}"
|
||||
buildConfigField "String", "ParamOne", properties.getProperty('WEATHER_API')
|
||||
buildConfigField "String", "ParamTwo", properties.getProperty('SEARCH_API')
|
||||
}
|
||||
}
|
||||
android {
|
||||
|
||||
@@ -20,7 +20,9 @@ abstract class BaseDeclarationDialog(val context: Context): DeclarationBuilder {
|
||||
abstract override val link: String
|
||||
abstract override val message: String
|
||||
|
||||
fun showDialog(agreeCallback: () -> Unit = { }, disagreeCallback: () -> Unit = { Unit }) {
|
||||
lateinit var dialog: AlertDialog
|
||||
|
||||
fun showDialog(agreeCallback: () -> Unit = { }, disagreeCallback: () -> Unit = { }) {
|
||||
val myMessage = buildMessage()
|
||||
|
||||
val builder = AlertDialog.Builder(context)
|
||||
@@ -40,5 +42,7 @@ abstract class BaseDeclarationDialog(val context: Context): DeclarationBuilder {
|
||||
val msgTxt = alertDialog.findViewById<View>(android.R.id.message) as TextView?
|
||||
msgTxt?.movementMethod = LinkMovementMethod.getInstance()
|
||||
}
|
||||
|
||||
fun dismiss() = dialog.dismiss()
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,8 @@ class HomeFragment : BaseFragment(R.layout.fragment_home) {
|
||||
|
||||
private val viewModel by getFragmentViewModel<MainViewModel>()
|
||||
|
||||
lateinit var dialog: PermissionsDeclarationDialog
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
@@ -40,7 +42,9 @@ class HomeFragment : BaseFragment(R.layout.fragment_home) {
|
||||
|
||||
forecast_listview.adapter = recyclerAdapter
|
||||
|
||||
PermissionsDeclarationDialog(requireContext()).showDialog(agreeCallback = {
|
||||
|
||||
dialog = PermissionsDeclarationDialog(requireContext())
|
||||
dialog.showDialog(agreeCallback = {
|
||||
getPermissionResult(ACCESS_COARSE_LOCATION, LOCATION_PERMISSION_REQUEST) {
|
||||
viewModel.fetchData()
|
||||
}
|
||||
@@ -64,6 +68,11 @@ class HomeFragment : BaseFragment(R.layout.fragment_home) {
|
||||
viewModel.operationRefresh.observe(viewLifecycleOwner, refreshObserver(swipe_refresh))
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
dialog.dismiss()
|
||||
}
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
override fun permissionsGranted() {
|
||||
viewModel.fetchData()
|
||||
|
||||
Reference in New Issue
Block a user