Skip to content

Commit

Permalink
Merge pull request #11 from soucolline/develop
Browse files Browse the repository at this point in the history
Version 1.0.2
  • Loading branch information
soucolline authored Oct 21, 2020
2 parents afefb26 + ac50f01 commit 0d6b034
Show file tree
Hide file tree
Showing 14 changed files with 79 additions and 248 deletions.
10 changes: 3 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
local.properties
gradle.properties
.idea/*
.DS_Store
/build
/captures
Expand Down
125 changes: 0 additions & 125 deletions .idea/codeStyles/Project.xml

This file was deleted.

5 changes: 0 additions & 5 deletions .idea/codeStyles/codeStyleConfig.xml

This file was deleted.

19 changes: 0 additions & 19 deletions .idea/gradle.xml

This file was deleted.

9 changes: 0 additions & 9 deletions .idea/misc.xml

This file was deleted.

12 changes: 0 additions & 12 deletions .idea/runConfigurations.xml

This file was deleted.

40 changes: 26 additions & 14 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,58 @@ apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android.buildTypes.release.ndk.debugSymbolLevel = 'full'

android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.zlatan.uv_today_android"
minSdkVersion 21
targetSdkVersion 29
versionCode 2
versionName "1.0.1"
versionCode 5
versionName "1.0.2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
debug {
buildConfigField "String", "DarkSkyApiKey", SwiftUVAndroid_darkSkyApiKey
buildConfigField "String", "OpenWeatherApiKey", SwiftUVAndroid_openWeatherApiKey
buildConfigField "String", "BugsnagAPIKey", SwiftUVAndroid_bugsnagApiKey
}

release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
buildConfigField "String", "DarkSkyApiKey", SwiftUVAndroid_darkSkyApiKey
buildConfigField "String", "OpenWeatherApiKey", SwiftUVAndroid_openWeatherApiKey
buildConfigField "String", "BugsnagAPIKey", SwiftUVAndroid_bugsnagApiKey
}
}
buildFeatures {
viewBinding {
enabled = true
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation "com.google.android.gms:play-services-location:17.0.0"
implementation 'com.squareup.retrofit2:retrofit:2.6.1'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
implementation "com.google.android.gms:play-services-location:17.1.0"
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'com.squareup.retrofit2:converter-gson:2.6.1'
implementation 'com.bugsnag:bugsnag-android:4.22.3'
implementation "org.koin:koin-android:2.1.0"
implementation "org.koin:koin-android:2.2.0-rc-1"
implementation 'com.github.d-max:spots-dialog:1.1@aar'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
package com.zlatan.uv_today_android.Models.DataModel.ServiceModels

import com.zlatan.uv_today_android.Models.DataModel.Index
import com.google.gson.annotations.SerializedName

class ForecastObjectResponse(val currently: CurrentForecast)

class CurrentForecast(val uvIndex: Index)
data class ForecastObjectResponse(
val lat: Double,
val lon: Double,
@SerializedName("date_iso")
val dateIso: String,
val date: Int,
val value: Double
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package com.zlatan.uv_today_android.Services
import com.zlatan.uv_today_android.Models.DataModel.ServiceModels.ForecastObjectResponse
import retrofit2.Call
import retrofit2.http.GET
import retrofit2.http.Path
import retrofit2.http.Query

interface GetUVApi {
@GET("/forecast/{api_key}/{latitude},{longitude}")
@GET("uvi")
fun getUVIndex(
@Path(value = "api_key", encoded = true) api_key: String,
@Path(value = "latitude", encoded = true) latitude: Double,
@Path(value = "longitude", encoded = true) longitude: Double
@Query(value = "appid", encoded = true) api_key: String,
@Query(value = "lat", encoded = true) latitude: Double,
@Query(value = "lon", encoded = true) longitude: Double
): Call<ForecastObjectResponse>
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import retrofit2.Callback
import retrofit2.Response
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import kotlin.math.roundToInt


interface UVService {
Expand All @@ -20,12 +21,12 @@ class UVServiceImpl: UVService {

override fun getUVIndex(location: Location, result: (Index) -> Unit, error: (String) -> Unit) {
val retrofit = Retrofit.Builder()
.baseUrl("https://api.darksky.net/")
.baseUrl("https://api.openweathermap.org/data/2.5/")
.addConverterFactory(GsonConverterFactory.create())
.build()

val service = retrofit.create(GetUVApi::class.java)
val call = service.getUVIndex(BuildConfig.DarkSkyApiKey, location.latitude, location.longitude)
val call = service.getUVIndex(BuildConfig.OpenWeatherApiKey, location.latitude, location.longitude)

call.enqueue(object : Callback<ForecastObjectResponse> {
override fun onFailure(call: Call<ForecastObjectResponse>, t: Throwable) {
Expand All @@ -34,8 +35,8 @@ class UVServiceImpl: UVService {

override fun onResponse(call: Call<ForecastObjectResponse>, response: Response<ForecastObjectResponse>) {
response.body()?.let {
Log.i("uv-today", "Retrieved uv Index successfully with : ${it.currently.uvIndex}")
result(it.currently.uvIndex)
Log.i("uv-today", "Retrieved uv Index successfully with : ${it.value}")
result(it.value.roundToInt())
}
}
})
Expand Down
Loading

0 comments on commit 0d6b034

Please sign in to comment.