diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
index 30aa626..554ffcd 100644
--- a/.idea/codeStyles/Project.xml
+++ b/.idea/codeStyles/Project.xml
@@ -1,29 +1,161 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ xmlns:android
+
+ ^$
+
+
+
+
+
+
+
+
+ xmlns:.*
+
+ ^$
+
+
+ BY_NAME
+
+
+
+
+
+
+ .*:id
+
+ http://schemas.android.com/apk/res/android
+
+
+
+
+
+
+
+
+ .*:name
+
+ http://schemas.android.com/apk/res/android
+
+
+
+
+
+
+
+
+ name
+
+ ^$
+
+
+
+
+
+
+
+
+ style
+
+ ^$
+
+
+
+
+
+
+
+
+ .*
+
+ ^$
+
+
+ BY_NAME
+
+
+
+
+
+
+ .*
+
+ http://schemas.android.com/apk/res/android
+
+
+ ANDROID_ATTRIBUTE_ORDER
+
+
+
+
+
+
+ .*
+
+ .*
+
+
+ BY_NAME
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/dbnavigator.xml b/.idea/dbnavigator.xml
new file mode 100644
index 0000000..51325a2
--- /dev/null
+++ b/.idea/dbnavigator.xml
@@ -0,0 +1,458 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index 7ac24c7..5cd135a 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -1,8 +1,10 @@
+
-
+
diff --git a/app/src/main/java/com/resocoder/forecastmvvm/data/network/ApixuWeatherApiService.kt b/app/src/main/java/com/resocoder/forecastmvvm/data/network/WeatherApiService .kt
similarity index 86%
rename from app/src/main/java/com/resocoder/forecastmvvm/data/network/ApixuWeatherApiService.kt
rename to app/src/main/java/com/resocoder/forecastmvvm/data/network/WeatherApiService .kt
index 032e6d6..fb16594 100644
--- a/app/src/main/java/com/resocoder/forecastmvvm/data/network/ApixuWeatherApiService.kt
+++ b/app/src/main/java/com/resocoder/forecastmvvm/data/network/WeatherApiService .kt
@@ -12,9 +12,9 @@ import retrofit2.http.GET
import retrofit2.http.Query
-const val API_KEY = "89e8bd89085b41b7a4b142029180210"
+const val API_KEY = "053c944154dc4110b0f23838200804"
-//http://api.apixu.com/v1/current.json?key=89e8bd89085b41b7a4b142029180210&q=London&lang=en
+//https://api.weatherapi.com/v1/current.json?key=053c944154dc4110b0f23838200804&q=London&lang=en
interface ApixuWeatherApiService {
@@ -25,7 +25,7 @@ interface ApixuWeatherApiService {
): Deferred
- // https://api.apixu.com/v1/forecast.json?key=89e8bd89085b41b7a4b142029180210&q=Los%20Angeles&days=1
+ // https://api.weatherapi.com/v1/forecast.json?key=053c944154dc4110b0f23838200804&q=Los%20Angeles&days=1
@GET("forecast.json")
fun getFutureWeather(
@Query("q") location: String,
@@ -59,7 +59,7 @@ interface ApixuWeatherApiService {
return Retrofit.Builder()
.client(okHttpClient)
- .baseUrl("https://api.apixu.com/v1/")
+ .baseUrl("https://api.weatherapi.com/v1/")
.addCallAdapterFactory(CoroutineCallAdapterFactory())
.addConverterFactory(GsonConverterFactory.create())
.build()
diff --git a/app/src/main/java/com/resocoder/forecastmvvm/ui/MainActivity.kt b/app/src/main/java/com/resocoder/forecastmvvm/ui/MainActivity.kt
index 54f0d6a..c0e6022 100644
--- a/app/src/main/java/com/resocoder/forecastmvvm/ui/MainActivity.kt
+++ b/app/src/main/java/com/resocoder/forecastmvvm/ui/MainActivity.kt
@@ -25,7 +25,7 @@ private const val MY_PERMISSION_ACCESS_COARSE_LOCATION = 1
class MainActivity : AppCompatActivity(), KodeinAware {
override val kodein by closestKodein()
- private val fusedLocationProviderClient: FusedLocationProviderClient by instance()
+ private val fusedLocationProviderClient: FusedLocationProviderClient by instance()
private val locationCallback = object : LocationCallback() {
override fun onLocationResult(p0: LocationResult?) {
@@ -63,7 +63,7 @@ class MainActivity : AppCompatActivity(), KodeinAware {
}
override fun onSupportNavigateUp(): Boolean {
- return NavigationUI.navigateUp(null, navController)
+ return NavigationUI.navigateUp(navController, null)
}
private fun requestLocationPermission() {
diff --git a/app/src/main/java/com/resocoder/forecastmvvm/ui/weather/current/CurrentWeatherFragment.kt b/app/src/main/java/com/resocoder/forecastmvvm/ui/weather/current/CurrentWeatherFragment.kt
index 759d77b..869e1a0 100644
--- a/app/src/main/java/com/resocoder/forecastmvvm/ui/weather/current/CurrentWeatherFragment.kt
+++ b/app/src/main/java/com/resocoder/forecastmvvm/ui/weather/current/CurrentWeatherFragment.kt
@@ -6,6 +6,7 @@ import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import android.webkit.URLUtil
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.Observer
@@ -15,6 +16,7 @@ import com.resocoder.forecastmvvm.data.network.ConnectivityInterceptorImpl
import com.resocoder.forecastmvvm.data.network.WeatherNetworkDataSourceImpl
import com.resocoder.forecastmvvm.internal.glide.GlideApp
import com.resocoder.forecastmvvm.ui.base.ScopedFragment
+import com.resocoder.forecastmvvm.utils.formatConditonUrl
import kotlinx.android.synthetic.main.current_weather_fragment.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
@@ -27,7 +29,7 @@ import org.kodein.di.generic.instance
class CurrentWeatherFragment : ScopedFragment(), KodeinAware {
override val kodein by closestKodein()
- private val viewModelFactory: CurrentWeatherViewModelFactory by instance()
+ private val viewModelFactory: CurrentWeatherViewModelFactory by instance()
private lateinit var viewModel: CurrentWeatherViewModel
@@ -69,7 +71,7 @@ class CurrentWeatherFragment : ScopedFragment(), KodeinAware {
updateVisibility(it.visibilityDistance)
GlideApp.with(this@CurrentWeatherFragment)
- .load("http:${it.conditionIconUrl}")
+ .load(formatConditonUrl(it.conditionIconUrl))
.into(imageView_condition_icon)
})
}
diff --git a/app/src/main/java/com/resocoder/forecastmvvm/ui/weather/future/detail/FutureDetailWeatherFragment.kt b/app/src/main/java/com/resocoder/forecastmvvm/ui/weather/future/detail/FutureDetailWeatherFragment.kt
index 7a88e0a..994e43f 100644
--- a/app/src/main/java/com/resocoder/forecastmvvm/ui/weather/future/detail/FutureDetailWeatherFragment.kt
+++ b/app/src/main/java/com/resocoder/forecastmvvm/ui/weather/future/detail/FutureDetailWeatherFragment.kt
@@ -14,6 +14,7 @@ import com.resocoder.forecastmvvm.data.db.LocalDateConverter
import com.resocoder.forecastmvvm.internal.DateNotFoundException
import com.resocoder.forecastmvvm.internal.glide.GlideApp
import com.resocoder.forecastmvvm.ui.base.ScopedFragment
+import com.resocoder.forecastmvvm.utils.formatConditonUrl
import kotlinx.android.synthetic.main.future_detail_weather_fragment.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
@@ -29,13 +30,13 @@ class FutureDetailWeatherFragment : ScopedFragment(), KodeinAware {
override val kodein by closestKodein()
private val viewModelFactoryInstanceFactory
- : ((LocalDate) -> FutureDetailWeatherViewModelFactory) by factory()
+ : ((LocalDate) -> FutureDetailWeatherViewModelFactory) by factory()
private lateinit var viewModel: FutureDetailWeatherViewModel
override fun onCreateView(
- inflater: LayoutInflater, container: ViewGroup?,
- savedInstanceState: Bundle?
+ inflater: LayoutInflater, container: ViewGroup?,
+ savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.future_detail_weather_fragment, container, false)
}
@@ -44,10 +45,11 @@ class FutureDetailWeatherFragment : ScopedFragment(), KodeinAware {
super.onActivityCreated(savedInstanceState)
val safeArgs = arguments?.let { FutureDetailWeatherFragmentArgs.fromBundle(it) }
- val date = LocalDateConverter.stringToDate(safeArgs?.dateString) ?: throw DateNotFoundException()
+ val date = LocalDateConverter.stringToDate(safeArgs?.dateString)
+ ?: throw DateNotFoundException()
viewModel = ViewModelProviders.of(this, viewModelFactoryInstanceFactory(date))
- .get(FutureDetailWeatherViewModel::class.java)
+ .get(FutureDetailWeatherViewModel::class.java)
bindUI()
}
@@ -66,7 +68,7 @@ class FutureDetailWeatherFragment : ScopedFragment(), KodeinAware {
updateDate(weatherEntry.date)
updateTemperatures(weatherEntry.avgTemperature,
- weatherEntry.minTemperature, weatherEntry.maxTemperature)
+ weatherEntry.minTemperature, weatherEntry.maxTemperature)
updateCondition(weatherEntry.conditionText)
updatePrecipitation(weatherEntry.totalPrecipitation)
updateWindSpeed(weatherEntry.maxWindSpeed)
@@ -74,8 +76,8 @@ class FutureDetailWeatherFragment : ScopedFragment(), KodeinAware {
updateUv(weatherEntry.uv)
GlideApp.with(this@FutureDetailWeatherFragment)
- .load("http:" + weatherEntry.conditionIconUrl)
- .into(imageView_condition_icon)
+ .load(formatConditonUrl(weatherEntry.conditionIconUrl))
+ .into(imageView_condition_icon)
})
}
@@ -89,7 +91,7 @@ class FutureDetailWeatherFragment : ScopedFragment(), KodeinAware {
private fun updateDate(date: LocalDate) {
(activity as? AppCompatActivity)?.supportActionBar?.subtitle =
- date.format(DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM))
+ date.format(DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM))
}
private fun updateTemperatures(temperature: Double, min: Double, max: Double) {
diff --git a/app/src/main/java/com/resocoder/forecastmvvm/ui/weather/future/list/FutureWeatherItem.kt b/app/src/main/java/com/resocoder/forecastmvvm/ui/weather/future/list/FutureWeatherItem.kt
index 7a792d4..8cfac74 100644
--- a/app/src/main/java/com/resocoder/forecastmvvm/ui/weather/future/list/FutureWeatherItem.kt
+++ b/app/src/main/java/com/resocoder/forecastmvvm/ui/weather/future/list/FutureWeatherItem.kt
@@ -4,6 +4,7 @@ import com.resocoder.forecastmvvm.R
import com.resocoder.forecastmvvm.data.db.unitlocalized.future.list.MetricSimpleFutureWeatherEntry
import com.resocoder.forecastmvvm.data.db.unitlocalized.future.list.UnitSpecificSimpleFutureWeatherEntry
import com.resocoder.forecastmvvm.internal.glide.GlideApp
+import com.resocoder.forecastmvvm.utils.formatConditonUrl
import com.xwray.groupie.kotlinandroidextensions.Item
import com.xwray.groupie.kotlinandroidextensions.ViewHolder
import kotlinx.android.synthetic.main.item_future_weather.*
@@ -12,7 +13,7 @@ import org.threeten.bp.format.FormatStyle
class FutureWeatherItem(
- val weatherEntry: UnitSpecificSimpleFutureWeatherEntry
+ val weatherEntry: UnitSpecificSimpleFutureWeatherEntry
) : Item() {
override fun bind(viewHolder: ViewHolder, position: Int) {
viewHolder.apply {
@@ -38,7 +39,7 @@ class FutureWeatherItem(
private fun ViewHolder.updateConditionImage() {
GlideApp.with(this.containerView)
- .load("http:" + weatherEntry.conditionIconUrl)
- .into(imageView_condition_icon)
+ .load(formatConditonUrl(weatherEntry.conditionIconUrl))
+ .into(imageView_condition_icon)
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/resocoder/forecastmvvm/utils/UrlUtils.kt b/app/src/main/java/com/resocoder/forecastmvvm/utils/UrlUtils.kt
new file mode 100644
index 0000000..183ffde
--- /dev/null
+++ b/app/src/main/java/com/resocoder/forecastmvvm/utils/UrlUtils.kt
@@ -0,0 +1,6 @@
+package com.resocoder.forecastmvvm.utils
+
+fun formatConditonUrl(conditionUrl: String): String {
+ val split = conditionUrl.split("64x64")
+ return "https:${split[0]}128x128${split[1]}"
+}
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index f49f853..2ab1407 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
- ext.kotlin_version = '1.3.0'
+ ext.kotlin_version = '1.3.10'
ext.room_version = '2.1.0-alpha01'
ext.navigation_version = '1.0.0-alpha06'
ext.kodein_version = '5.2.0'
@@ -13,7 +13,7 @@ buildscript {
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.4.0-alpha02'
+ classpath 'com.android.tools.build:gradle:3.6.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'android.arch.navigation:navigation-safe-args-gradle-plugin:1.0.0-alpha07'
// NOTE: Do not place your application dependencies here; they belong
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index fc5cb56..e4b1485 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Sat Oct 20 20:03:06 CEST 2018
+#Sat May 02 03:08:53 WAT 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip