Skip to content

Commit 77a4192

Browse files
committed
libraries update and minor code adjustments
1 parent 6f799d6 commit 77a4192

27 files changed

+116
-107
lines changed

app/build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,12 @@ dependencies {
109109
//////////////////////////////////////////////////////////////////////////////////////////////
110110
//Rx
111111
implementation 'io.reactivex.rxjava3:rxandroid:3.0.0'
112-
implementation 'io.reactivex.rxjava3:rxjava:3.0.12'
112+
implementation 'io.reactivex.rxjava3:rxjava:3.1.5'
113113

114114
//////////////////////////////////////////////////////////////////////////////////////////////
115115
//glide
116-
implementation 'com.github.bumptech.glide:glide:4.11.0'
117-
kapt 'com.github.bumptech.glide:compiler:4.11.0'
116+
implementation 'com.github.bumptech.glide:glide:4.13.2'
117+
kapt 'com.github.bumptech.glide:compiler:4.13.2'
118118

119119
//////////////////////////////////////////////////////////////////////////////////////////////
120120
//navigation
@@ -130,6 +130,6 @@ dependencies {
130130
implementation 'com.facebook.stetho:stetho:1.5.1'
131131
implementation 'com.facebook.shimmer:shimmer:0.5.0'
132132

133-
implementation 'com.github.AppIntro:AppIntro:5.1.0'
134-
implementation 'com.github.nightgoat:kextensions:0.1.3.4'
133+
implementation 'com.github.AppIntro:AppIntro:6.2.0'
134+
implementation 'com.github.nightgoat:kextensions:1.0.2'
135135
}

app/src/main/java/ru/nightgoat/weather/App.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ package ru.nightgoat.weather
33
import com.facebook.stetho.Stetho
44
import dagger.android.AndroidInjector
55
import dagger.android.DaggerApplication
6+
import io.github.nightgoat.kexcore.utils.Kex
67
import io.reactivex.rxjava3.exceptions.UndeliverableException
78
import io.reactivex.rxjava3.plugins.RxJavaPlugins
8-
import ru.nightgoat.kextensions.utils.Kex
9+
import ru.nightgoat.kextensions.utils.logging.TimberLogger
910
import ru.nightgoat.weather.di.components.DaggerAppComponent
1011
import java.net.UnknownHostException
1112

@@ -22,7 +23,7 @@ class App : DaggerApplication() {
2223
setRxErrorHandler()
2324
if (BuildConfig.DEBUG) {
2425
Stetho.initializeWithDefaults(this)
25-
Kex.setTimber()
26+
Kex.setCustomLogger(TimberLogger)
2627
}
2728
}
2829

app/src/main/java/ru/nightgoat/weather/core/delegates/FragmentViewBindingDelegate.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import kotlin.reflect.KProperty
2121
inline fun <reified T : ViewBinding> Fragment.viewBinding() = FragmentViewBindingDelegate(T::class.java, this)
2222

2323
class FragmentViewBindingDelegate<T : ViewBinding>(
24-
private val bindingClass: Class<T>,
24+
bindingClass: Class<T>,
2525
val fragment: Fragment
2626
) : ReadOnlyProperty<Fragment, T> {
2727
private val clearBindingHandler by lazy(LazyThreadSafetyMode.NONE) { Handler(Looper.getMainLooper()) }
@@ -45,7 +45,8 @@ class FragmentViewBindingDelegate<T : ViewBinding>(
4545

4646
override fun getValue(thisRef: Fragment, property: KProperty<*>): T {
4747
// onCreateView may be called between onDestroyView and next Main thread cycle.
48-
// In this case [binding] refers to the previous fragment view. Check that binding's root view matches current fragment view
48+
// In this case [binding] refers to the previous fragment view.
49+
// Check that binding's root view matches current fragment view
4950
if (binding != null && binding?.root !== thisRef.view) {
5051
binding = null
5152
}

app/src/main/java/ru/nightgoat/weather/core/extentions/ContextExt.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import android.content.Context
44
import android.graphics.Typeface
55
import ru.nightgoat.weather.core.utils.FONTS_PATH
66

7-
fun Context.createTypeFace() = Typeface.createFromAsset(
7+
fun Context.createTypeFace(): Typeface? = Typeface.createFromAsset(
88
this.assets,
99
FONTS_PATH
1010
)

app/src/main/java/ru/nightgoat/weather/core/extentions/SharedPrefExt.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package ru.nightgoat.weather.core.extentions
22

33
import android.content.SharedPreferences
4-
import ru.nightgoat.kextensions.orZero
4+
import io.github.nightgoat.kexcore.orZero
55
import ru.nightgoat.weather.R
66
import ru.nightgoat.weather.core.utils.*
77

app/src/main/java/ru/nightgoat/weather/core/utils/Constants.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,6 @@ const val DATE_PATTERN_EEEE_D_MMM = "EEEE, d MMM"
4646
const val DATE_PATTERN_EEEE = "EEEE"
4747

4848
//OTHER
49-
const val pressureFromHPaToMmHgDiv = 1.33322387415
49+
const val PRESSURE_FROM_HPA_TO_MMHG_DIV = 1.33322387415
5050
const val PERCENT = "%"
5151
const val DEFAULT_CITY_ID = 551487
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
package ru.nightgoat.weather.core.utils
22

3-
fun pressureFromHPaToMmHg(value: Int) = (value / pressureFromHPaToMmHgDiv).toInt().toString()
3+
fun pressureFromHPaToMmHg(value: Int) = (value / PRESSURE_FROM_HPA_TO_MMHG_DIV).toInt().toString()
44
fun Double?.toIntOrZero() = (this ?: 0.0).toInt()

app/src/main/java/ru/nightgoat/weather/core/utils/TimeHelper.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package ru.nightgoat.weather.core.utils
22

3+
import io.github.nightgoat.kexcore.normalize
34
import org.joda.time.format.DateTimeFormat
4-
import ru.nightgoat.kextensions.normalize
55
import java.util.*
66

77
fun getNormalDateTime(dt: Long): String =

app/src/main/java/ru/nightgoat/weather/domain/IInteractor.kt

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,21 @@ import ru.nightgoat.weather.data.entity.SearchEntity
1111
interface IInteractor {
1212

1313
fun getAllCities(): Flowable<MutableList<CityEntity>>
14-
1514
fun deleteCity(cityEntity: CityEntity): Completable
16-
17-
fun getCityFromApiAndPutInDB(city: String, units: String, api_key: String): Single<CityEntity>
18-
19-
fun updateAllFromApi(units: String, API_KEY: String): Completable
20-
15+
fun getCityFromApiAndPutInDB(city: String, units: String, apiKey: String): Single<CityEntity>
16+
fun updateAllFromApi(units: String, apiKey: String): Completable
2117
fun swapPositionWithFirst(cityToSwap: CityEntity): Completable
22-
2318
fun updateCityInDB(city: CityEntity): Completable
24-
25-
fun getCityFromDataBaseAndUpdateFromApi(cityId: Int, units: String, API_KEY : String): Flowable<CityEntity>
19+
fun getCityFromDataBaseAndUpdateFromApi(
20+
cityId: Int,
21+
units: String,
22+
apiKey: String
23+
): Flowable<CityEntity>
2624

2725
fun getSearchList(): Single<MutableList<String>>
28-
2926
fun insertSearchEntity(city: SearchEntity): Completable
30-
3127
fun purgeSearchList(): Completable
32-
3328
fun getForecast(cityId: Int): Flowable<MutableList<ForecastEntity>>
34-
3529
fun updateForecast(cityId: Int, units: String, apiKey: String): Completable
36-
37-
fun purgeForecast(cityId: Int) : Completable
30+
fun purgeForecast(cityId: Int): Completable
3831
}

app/src/main/java/ru/nightgoat/weather/domain/WeatherInteractor.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package ru.nightgoat.weather.domain
22

3+
import io.github.nightgoat.kexcore.orIfNull
4+
import io.github.nightgoat.kexcore.orZero
35
import io.reactivex.rxjava3.core.Completable
46
import io.reactivex.rxjava3.core.Flowable
57
import io.reactivex.rxjava3.core.Maybe
68
import io.reactivex.rxjava3.core.Single
79
import io.reactivex.rxjava3.schedulers.Schedulers
8-
import ru.nightgoat.kextensions.orIfNull
9-
import ru.nightgoat.kextensions.orZero
1010
import ru.nightgoat.weather.data.entity.CityEntity
1111
import ru.nightgoat.weather.data.entity.ForecastEntity
1212
import ru.nightgoat.weather.data.entity.SearchEntity
@@ -40,11 +40,11 @@ class WeatherInteractor(private val repository: DBRepository, private val api: O
4040
override fun getCityFromApiAndPutInDB(
4141
city: String,
4242
units: String,
43-
api_key: String
43+
apiKey: String
4444
): Single<CityEntity> {
4545
return api.getCurrentWeather(
4646
city = city,
47-
app_id = api_key,
47+
appId = apiKey,
4848
units = units,
4949
lang = Locale.getDefault().country
5050
).subscribeOn(defaultScheduler)
@@ -57,14 +57,14 @@ class WeatherInteractor(private val repository: DBRepository, private val api: O
5757
}
5858
}
5959

60-
override fun updateAllFromApi(units: String, API_KEY: String): Completable {
60+
override fun updateAllFromApi(units: String, apiKey: String): Completable {
6161
return repository.getAllCitiesSingle()
6262
.observeOn(defaultScheduler)
6363
.flattenAsObservable { Iterable { it.iterator() } }
6464
.flatMapSingle { cityEntity ->
6565
api.getCurrentWeatherById(
6666
id = cityEntity.cityId,
67-
app_id = API_KEY,
67+
appId = apiKey,
6868
units = units,
6969
lang = Locale.getDefault().country
7070
).observeOn(defaultScheduler)
@@ -100,12 +100,12 @@ class WeatherInteractor(private val repository: DBRepository, private val api: O
100100
override fun getCityFromDataBaseAndUpdateFromApi(
101101
cityId: Int,
102102
units: String,
103-
API_KEY: String
103+
apiKey: String
104104
): Flowable<CityEntity> {
105105
return repository.getCityById(cityId)
106106
.concatWith(api.getCurrentWeatherById(
107107
id = cityId,
108-
app_id = API_KEY,
108+
appId = apiKey,
109109
units = units,
110110
lang = Locale.getDefault().country
111111
).map {
@@ -140,7 +140,7 @@ class WeatherInteractor(private val repository: DBRepository, private val api: O
140140
override fun updateForecast(cityId: Int, units: String, apiKey: String): Completable {
141141
return api.getForecast(
142142
id = cityId,
143-
app_id = apiKey,
143+
appId = apiKey,
144144
units = units,
145145
lang = Locale.getDefault().country
146146
).subscribeOn(defaultScheduler)

0 commit comments

Comments
 (0)