- Dialog changes added

- updated properties retrieval

Took 13 minutes
This commit is contained in:
2022-06-10 00:35:31 +01:00
parent d30992452e
commit d606717808
3 changed files with 17 additions and 4 deletions

View File

@@ -26,8 +26,8 @@ android {
buildConfigField "String", "ParamOne", properties.getProperty('WEATHER_API') buildConfigField "String", "ParamOne", properties.getProperty('WEATHER_API')
buildConfigField "String", "ParamTwo", properties.getProperty('SEARCH_API') buildConfigField "String", "ParamTwo", properties.getProperty('SEARCH_API')
} else { } else {
buildConfigField "String", "ParamOne", "${WEATHER_API}" buildConfigField "String", "ParamOne", properties.getProperty('WEATHER_API')
buildConfigField "String", "ParamTwo", "${SEARCH_API}" buildConfigField "String", "ParamTwo", properties.getProperty('SEARCH_API')
} }
} }
android { android {

View File

@@ -20,7 +20,9 @@ abstract class BaseDeclarationDialog(val context: Context): DeclarationBuilder {
abstract override val link: String abstract override val link: String
abstract override val message: 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 myMessage = buildMessage()
val builder = AlertDialog.Builder(context) 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? val msgTxt = alertDialog.findViewById<View>(android.R.id.message) as TextView?
msgTxt?.movementMethod = LinkMovementMethod.getInstance() msgTxt?.movementMethod = LinkMovementMethod.getInstance()
} }
fun dismiss() = dialog.dismiss()
} }

View File

@@ -30,6 +30,8 @@ class HomeFragment : BaseFragment(R.layout.fragment_home) {
private val viewModel by getFragmentViewModel<MainViewModel>() private val viewModel by getFragmentViewModel<MainViewModel>()
lateinit var dialog: PermissionsDeclarationDialog
@SuppressLint("MissingPermission") @SuppressLint("MissingPermission")
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
@@ -40,7 +42,9 @@ class HomeFragment : BaseFragment(R.layout.fragment_home) {
forecast_listview.adapter = recyclerAdapter forecast_listview.adapter = recyclerAdapter
PermissionsDeclarationDialog(requireContext()).showDialog(agreeCallback = {
dialog = PermissionsDeclarationDialog(requireContext())
dialog.showDialog(agreeCallback = {
getPermissionResult(ACCESS_COARSE_LOCATION, LOCATION_PERMISSION_REQUEST) { getPermissionResult(ACCESS_COARSE_LOCATION, LOCATION_PERMISSION_REQUEST) {
viewModel.fetchData() viewModel.fetchData()
} }
@@ -64,6 +68,11 @@ class HomeFragment : BaseFragment(R.layout.fragment_home) {
viewModel.operationRefresh.observe(viewLifecycleOwner, refreshObserver(swipe_refresh)) viewModel.operationRefresh.observe(viewLifecycleOwner, refreshObserver(swipe_refresh))
} }
override fun onStop() {
super.onStop()
dialog.dismiss()
}
@SuppressLint("MissingPermission") @SuppressLint("MissingPermission")
override fun permissionsGranted() { override fun permissionsGranted() {
viewModel.fetchData() viewModel.fetchData()