- Removal of kotlin synthetics

- Upgrade gradle to 8.0.0
 - Change dependency versioning
This commit is contained in:
2024-06-24 18:30:31 +01:00
parent b63caaa9cd
commit 2561b6ddf9
22 changed files with 270 additions and 166 deletions

View File

@@ -6,11 +6,12 @@ import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.appttude.h_mal.atlas_weather.R
import com.appttude.h_mal.atlas_weather.model.forecast.WeatherDisplay
import com.appttude.h_mal.atlas_weather.ui.home.adapter.WeatherRecyclerAdapter
import com.appttude.h_mal.atlas_weather.utils.navigateTo
import kotlinx.android.synthetic.main.fragment_home.*
class WorldItemFragment : Fragment() {
@@ -40,7 +41,7 @@ class WorldItemFragment : Fragment() {
param1?.let { recyclerAdapter.addCurrent(it) }
forecast_listview.apply {
view.findViewById<RecyclerView>(R.id.forecast_listview).apply {
layoutManager = LinearLayoutManager(context)
adapter = recyclerAdapter
}

View File

@@ -4,10 +4,11 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.fragment.app.Fragment
import com.appttude.h_mal.atlas_weather.R
import com.appttude.h_mal.atlas_weather.model.forecast.Forecast
import kotlinx.android.synthetic.main.activity_further_info.*
private const val WEATHER = "param1"
@@ -36,14 +37,12 @@ class FurtherInfoFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
maxtemp.text = param1?.mainTemp
averagetemp.text = param1?.averageTemp
minimumtemp.text = param1?.minorTemp
windtext.text = param1?.windText
preciptext.text = param1?.precipitation
humiditytext.text = param1?.humidity
uvtext.text = param1?.uvi
sunrisetext.text = param1?.sunrise
sunsettext.text = param1?.sunset
view.findViewById<TextView>(R.id.maxtemp).text = param1?.mainTemp
view.findViewById<TextView>(R.id.averagetemp).text = param1?.averageTemp
view.findViewById<TextView>(R.id.minimumtemp).text = param1?.minorTemp
view.findViewById<TextView>(R.id.windtext).text = param1?.windText
view.findViewById<TextView>(R.id.preciptext).text = param1?.precipitation
view.findViewById<TextView>(R.id.sunrisetext).text = param1?.sunrise
view.findViewById<TextView>(R.id.sunsettext).text = param1?.sunset
}
}

View File

@@ -12,6 +12,8 @@ import android.view.View
import androidx.fragment.app.Fragment
import androidx.navigation.Navigation.findNavController
import androidx.navigation.ui.onNavDestinationSelected
import androidx.recyclerview.widget.RecyclerView
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import com.appttude.h_mal.atlas_weather.R
import com.appttude.h_mal.atlas_weather.application.AtlasApp
import com.appttude.h_mal.atlas_weather.base.BaseFragment
@@ -22,7 +24,7 @@ import com.appttude.h_mal.atlas_weather.ui.home.adapter.WeatherRecyclerAdapter
import com.appttude.h_mal.atlas_weather.utils.displayToast
import com.appttude.h_mal.atlas_weather.utils.navigateTo
import com.appttude.h_mal.atlas_weather.viewmodel.MainViewModel
import kotlinx.android.synthetic.main.fragment_home.*
import permissions.dispatcher.NeedsPermission
import permissions.dispatcher.OnNeverAskAgain
import permissions.dispatcher.OnPermissionDenied
@@ -38,14 +40,15 @@ import permissions.dispatcher.RuntimePermissions
@RuntimePermissions
class HomeFragment : BaseFragment<MainViewModel>(R.layout.fragment_home) {
lateinit var recyclerAdapter: WeatherRecyclerAdapter
private lateinit var recyclerAdapter: WeatherRecyclerAdapter
private lateinit var swipeRefresh: SwipeRefreshLayout
@SuppressLint("MissingPermission")
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setHasOptionsMenu(true)
swipe_refresh.apply {
swipeRefresh = view.findViewById<SwipeRefreshLayout>(R.id.swipe_refresh).apply {
setOnRefreshListener {
showLocationWithPermissionCheck()
isRefreshing = true
@@ -56,7 +59,7 @@ class HomeFragment : BaseFragment<MainViewModel>(R.layout.fragment_home) {
navigateToFurtherDetails(it)
})
forecast_listview.adapter = recyclerAdapter
view.findViewById<RecyclerView>(R.id.forecast_listview).adapter = recyclerAdapter
scheduleNotification()
}
@@ -69,7 +72,7 @@ class HomeFragment : BaseFragment<MainViewModel>(R.layout.fragment_home) {
override fun onSuccess(data: Any?) {
super.onSuccess(data)
swipe_refresh.isRefreshing = false
swipeRefresh.isRefreshing = false
if (data is WeatherDisplay) {
recyclerAdapter.addCurrent(data)
@@ -78,7 +81,7 @@ class HomeFragment : BaseFragment<MainViewModel>(R.layout.fragment_home) {
override fun onFailure(error: Any?) {
super.onFailure(error)
swipe_refresh.isRefreshing = false
swipeRefresh.isRefreshing = false
}
private fun navigateToFurtherDetails(forecast: Forecast) {
@@ -96,6 +99,7 @@ class HomeFragment : BaseFragment<MainViewModel>(R.layout.fragment_home) {
return item.onNavDestinationSelected(navController) || super.onOptionsItemSelected(item)
}
@Deprecated("Deprecated in Java")
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
// NOTE: delegate the permission handling to generated method

View File

@@ -2,13 +2,13 @@ package com.appttude.h_mal.atlas_weather.ui.world
import android.os.Bundle
import android.view.View
import android.widget.Button
import android.widget.TextView
import com.appttude.h_mal.atlas_weather.R
import com.appttude.h_mal.atlas_weather.base.BaseFragment
import com.appttude.h_mal.atlas_weather.utils.displayToast
import com.appttude.h_mal.atlas_weather.utils.goBack
import com.appttude.h_mal.atlas_weather.viewmodel.WorldViewModel
import kotlinx.android.synthetic.main.activity_add_forecast.location_name_tv
import kotlinx.android.synthetic.main.activity_add_forecast.submit
class AddLocationFragment : BaseFragment<WorldViewModel>(R.layout.activity_add_forecast) {
@@ -16,8 +16,11 @@ class AddLocationFragment : BaseFragment<WorldViewModel>(R.layout.activity_add_f
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val submit = view.findViewById<Button>(R.id.submit)
submit.setOnClickListener {
val locationName = location_name_tv.text?.trim()?.toString()
val locationName =
view.findViewById<TextView>(R.id.location_name_tv).text?.trim()?.toString()
if (locationName.isNullOrBlank()) {
submit.error = "Location cannot be blank"
return@setOnClickListener

View File

@@ -4,13 +4,13 @@ import android.os.Bundle
import android.view.View
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.appttude.h_mal.atlas_weather.R
import com.appttude.h_mal.atlas_weather.base.BaseFragment
import com.appttude.h_mal.atlas_weather.model.forecast.WeatherDisplay
import com.appttude.h_mal.atlas_weather.utils.navigateTo
import com.appttude.h_mal.atlas_weather.viewmodel.WorldViewModel
import kotlinx.android.synthetic.atlasWeather.fragment_add_location.floatingActionButton
import kotlinx.android.synthetic.atlasWeather.fragment_add_location.world_recycler
import com.google.android.material.floatingactionbutton.FloatingActionButton
/**
@@ -29,12 +29,12 @@ class WorldFragment : BaseFragment<WorldViewModel>(R.layout.fragment_add_locatio
navigateTo(direction)
}
world_recycler.apply {
view.findViewById<RecyclerView>(R.id.world_recycler).apply {
layoutManager = LinearLayoutManager(context)
adapter = recyclerAdapter
}
floatingActionButton.setOnClickListener {
view.findViewById<FloatingActionButton>(R.id.floatingActionButton).setOnClickListener {
navigateTo(R.id.action_worldFragment_to_addLocationFragment)
}
}