Skip to content

Commit b2c16ab

Browse files
committed
update on outdated implemented
1 parent 1a59f79 commit b2c16ab

File tree

21 files changed

+336
-658
lines changed

21 files changed

+336
-658
lines changed

app/build.gradle

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,6 @@ dependencies {
5656
// WeatherIconView
5757
implementation libs.weathericonview
5858

59-
// TextDrawable
60-
implementation libs.textdrawable
61-
6259
// shimmer
6360
implementation libs.shimmer
64-
65-
66-
testImplementation libs.junit
67-
androidTestImplementation libs.androidx.junit
68-
androidTestImplementation libs.androidx.espresso.core
6961
}

app/src/androidTest/java/rahulstech/android/weatherapp/ExampleInstrumentedTest.kt

Lines changed: 0 additions & 24 deletions
This file was deleted.

app/src/main/java/rahulstech/android/weatherapp/ui/home/HomeActivity.kt

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import android.util.Log
66
import android.util.Pair
77
import android.view.Menu
88
import android.view.MenuItem
9+
import androidx.appcompat.app.AlertDialog
910
import androidx.appcompat.app.AppCompatActivity
1011
import androidx.lifecycle.lifecycleScope
1112
import androidx.recyclerview.widget.LinearLayoutManager
@@ -15,10 +16,10 @@ import kotlinx.coroutines.flow.filterNotNull
1516
import kotlinx.coroutines.launch
1617
import org.koin.androidx.viewmodel.ext.android.viewModel
1718
import rahulstech.android.weatherapp.R
18-
import rahulstech.android.weatherapp.ui.search.CitySearchActivity
19-
import rahulstech.android.weatherapp.ui.forecast.WeatherForecastActivity
2019
import rahulstech.android.weatherapp.databinding.ActivityHomeBinding
2120
import rahulstech.android.weatherapp.setting.SettingsStorage
21+
import rahulstech.android.weatherapp.ui.forecast.WeatherForecastActivity
22+
import rahulstech.android.weatherapp.ui.search.CitySearchActivity
2223
import rahulstech.android.weatherapp.util.get12HourFormattedTimeText
2324
import rahulstech.android.weatherapp.util.getTemperatureCelsiusText
2425
import rahulstech.android.weatherapp.util.getUVLabel
@@ -87,7 +88,21 @@ class HomeActivity : AppCompatActivity() {
8788
override fun onResume() {
8889
super.onResume()
8990
val cityId = setting.getWeatherLocationId()
90-
viewModel.changeCurrentCity(cityId)
91+
if (cityId > 0) {
92+
viewModel.changeCurrentCity(cityId)
93+
}
94+
else {
95+
showCityNotSelectedWarning()
96+
}
97+
}
98+
99+
private fun showCityNotSelectedWarning() {
100+
AlertDialog.Builder(this)
101+
.setMessage(R.string.message_no_city_selected)
102+
.setPositiveButton(R.string.text_choose_city) { di,which -> handleSearchCity() }
103+
.setNeutralButton(R.string.text_exit) { di,which -> finish() }
104+
.setCancelable(false)
105+
.show()
91106
}
92107

93108
private fun onWeatherForecastFetched(
@@ -137,11 +152,8 @@ class HomeActivity : AppCompatActivity() {
137152
}
138153
}
139154
}
140-
else -> {
141-
142-
}
155+
else -> {}
143156
}
144-
145157
}
146158

147159
private fun onCurrentWeatherLoaded(city: CityModel, dailyForecast: DayWeatherModel, hourlyForecast: List<HourWeatherModel>) {
@@ -202,16 +214,10 @@ class HomeActivity : AppCompatActivity() {
202214

203215
private fun onHourlyForecastsLoaded(hourlyForecast: List<HourWeatherModel>) {
204216
Log.i(TAG, "hourly forecast ${hourlyForecast.size}")
205-
val currentHour = LocalTime.now().hour
206-
val filtered = hourlyForecast.filter { forecast ->
207-
val time = forecast.datetime.toLocalTime()
208-
time.hour >= currentHour
209-
}
210-
hourlyForecastAdapter.submitList(filtered)
217+
hourlyForecastAdapter.submitList(hourlyForecast)
211218
}
212219

213220
private fun onDailyForecastFetched(dailyForecastResource: Resource<DayWeatherModel>) {
214-
215221
when(dailyForecastResource){
216222
is Resource.Loading -> {
217223
binding.apply {

app/src/main/java/rahulstech/android/weatherapp/util/helpers.kt

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
11
package rahulstech.android.weatherapp.util
22

33
import android.content.Context
4-
import android.graphics.Color
5-
import android.graphics.Typeface
6-
import android.graphics.drawable.Drawable
74
import android.view.View
85
import androidx.annotation.StringRes
9-
import androidx.appcompat.content.res.AppCompatResources
10-
import androidx.core.content.res.ResourcesCompat
11-
import com.amulyakhare.textdrawable.TextDrawable
12-
import com.amulyakhare.textdrawable.util.ColorGenerator
136
import rahulstech.android.weatherapp.R
14-
import rahulstech.weather.repository.WeatherCondition
157
import java.time.LocalTime
168
import java.time.format.DateTimeFormatter
179

@@ -74,7 +66,7 @@ fun getWeatherConditionText(ctx: Context, code: Int): String {
7466
return ctx.getString(resId)
7567
}
7668

77-
enum class WeatherIcon(
69+
private enum class WeatherIcon(
7870
@StringRes private val dayIconResource: Int,
7971
@StringRes private val nightIconResource: Int
8072
) {

app/src/main/res/values/strings.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
<string name="text_saving_city">saving city</string>
2525
<string name="text_city_not_saved">city not saved</string>
2626
<string name="text_city_removed_successfully">%1$s removed</string>
27-
27+
<string name="message_no_city_selected">No city selected for weather</string>
28+
<string name="text_choose_city">Choose City</string>
29+
<string name="text_exit">Exit</string>
2830

2931
</resources>

app/src/test/java/rahulstech/android/weatherapp/ExampleUnitTest.kt

Lines changed: 0 additions & 17 deletions
This file was deleted.

backend/weather-api/build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ plugins {
55

66
android {
77
namespace 'com.weather.api'
8-
compileSdk 34
8+
compileSdk 36
99

1010
defaultConfig {
1111
minSdk 26
12+
targetSdk 36
1213

1314
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1415
consumerProguardFiles "consumer-rules.pro"
@@ -31,13 +32,12 @@ android {
3132

3233
dependencies {
3334

35+
implementation libs.androidx.core.ktx
36+
implementation libs.androidx.appcompat
37+
3438
api libs.retrofit
3539
api libs.retrofir.converter.gson
3640

3741
testImplementation libs.mockwebserver
38-
39-
implementation libs.androidx.core.ktx
40-
implementation libs.androidx.appcompat
4142
testImplementation libs.junit
42-
androidTestImplementation libs.androidx.junit
4343
}

backend/weather-database/build.gradle

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ plugins {
66

77
android {
88
namespace 'rahulstech.weather.database'
9-
compileSdk 34
9+
compileSdk 36
1010

1111
defaultConfig {
1212
minSdk 26
13+
targetSdk 36
1314

1415
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1516
consumerProguardFiles "consumer-rules.pro"
@@ -49,15 +50,13 @@ android {
4950
}
5051

5152
dependencies {
52-
5353
// room
5454
implementation libs.room.ktx
5555
api libs.room.runtime
56+
5657
//noinspection KaptUsageInsteadOfKsp
5758
kapt libs.room.compiler
5859

5960
implementation libs.androidx.core.ktx
6061
implementation libs.androidx.appcompat
61-
testImplementation libs.junit
62-
androidTestImplementation libs.androidx.junit
6362
}

backend/weather-database/src/androidTest/java/rahulstech/weather/database/dao/CityDaoTest.kt

Lines changed: 0 additions & 64 deletions
This file was deleted.

backend/weather-database/src/androidTest/java/rahulstech/weather/database/dao/DayWeatherDaoTest.kt

Lines changed: 0 additions & 93 deletions
This file was deleted.

0 commit comments

Comments
 (0)