diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..aa724b7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,15 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..7643783 --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,123 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..fb7f4a8 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..5cd135a --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..0380d8d --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..a2f5006 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..797acea --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..9b5b964 --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,68 @@ +plugins { + id 'com.android.application' + id 'kotlin-android' + id 'kotlin-kapt' +} + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "gr.georgiopoulos.weather_forecast" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = '1.8' + } + + viewBinding { + enabled = true + } +} + +dependencies { + + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation 'androidx.core:core-ktx:1.5.0' + implementation 'androidx.appcompat:appcompat:1.3.0' + implementation 'com.google.android.material:material:1.3.0' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + implementation 'androidx.core:core-ktx:1.5.0' + implementation "com.google.android.material:material:1.3.0" + implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' + implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.3.1" + //Dialogs + implementation "com.afollestad.material-dialogs:core:2.8.0" + //Network + implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.3' + implementation 'com.google.code.gson:gson:2.8.6' + implementation "com.squareup.retrofit2:retrofit:2.9.0" + implementation "com.squareup.retrofit2:converter-gson:2.9.0" + implementation 'com.squareup.okhttp3:logging-interceptor:4.9.1' + // Room components + implementation 'androidx.room:room-runtime:2.3.0' + kapt 'androidx.room:room-compiler:2.3.0' + //Image Handling + implementation 'com.squareup.picasso:picasso:2.71828' + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.2' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' +} \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/app/src/androidTest/java/gr/georgiopoulos/weather_forecast/ExampleInstrumentedTest.kt b/app/src/androidTest/java/gr/georgiopoulos/weather_forecast/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..a5098fb --- /dev/null +++ b/app/src/androidTest/java/gr/georgiopoulos/weather_forecast/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package gr.georgiopoulos.weather_forecast + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("gr.georgiopoulos.weather_forecast", appContext.packageName) + } +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..f5ab3a1 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/ic_launcher-playstore.png b/app/src/main/ic_launcher-playstore.png new file mode 100644 index 0000000..0123307 Binary files /dev/null and b/app/src/main/ic_launcher-playstore.png differ diff --git a/app/src/main/java/gr/georgiopoulos/weather_forecast/common/definitions/Definitions.kt b/app/src/main/java/gr/georgiopoulos/weather_forecast/common/definitions/Definitions.kt new file mode 100644 index 0000000..c6ae02c --- /dev/null +++ b/app/src/main/java/gr/georgiopoulos/weather_forecast/common/definitions/Definitions.kt @@ -0,0 +1,12 @@ +package gr.georgiopoulos.weather_forecast.common + +object DefinitionsApi { + const val DOMAIN = "https://api.worldweatheronline.com/premium/v1/" + const val KEY = "a3f757787b24422f9fa152335212705" + const val DAYS = "5" + const val FORMAT = "json" +} + +object PlacesApi { + const val KEY = "AIzaSyDLVRDmqHzwOQ1C3D7JV6xi0JiH8oiO33M" +} \ No newline at end of file diff --git a/app/src/main/java/gr/georgiopoulos/weather_forecast/common/extensions/RecyclerViewExtensions.kt b/app/src/main/java/gr/georgiopoulos/weather_forecast/common/extensions/RecyclerViewExtensions.kt new file mode 100644 index 0000000..2c9eea0 --- /dev/null +++ b/app/src/main/java/gr/georgiopoulos/weather_forecast/common/extensions/RecyclerViewExtensions.kt @@ -0,0 +1,2 @@ +package gr.georgiopoulos.weather_forecast.common.extensions + diff --git a/app/src/main/java/gr/georgiopoulos/weather_forecast/common/extensions/StringExtensions.kt b/app/src/main/java/gr/georgiopoulos/weather_forecast/common/extensions/StringExtensions.kt new file mode 100644 index 0000000..2c9eea0 --- /dev/null +++ b/app/src/main/java/gr/georgiopoulos/weather_forecast/common/extensions/StringExtensions.kt @@ -0,0 +1,2 @@ +package gr.georgiopoulos.weather_forecast.common.extensions + diff --git a/app/src/main/java/gr/georgiopoulos/weather_forecast/common/extensions/ViewExtensions.kt b/app/src/main/java/gr/georgiopoulos/weather_forecast/common/extensions/ViewExtensions.kt new file mode 100644 index 0000000..88b8c9d --- /dev/null +++ b/app/src/main/java/gr/georgiopoulos/weather_forecast/common/extensions/ViewExtensions.kt @@ -0,0 +1,4 @@ +package gr.georgiopoulos.weather_forecast.common.extensions + +class ViewExtensions { +} \ No newline at end of file diff --git a/app/src/main/java/gr/georgiopoulos/weather_forecast/common/logger/CommonLogger.kt b/app/src/main/java/gr/georgiopoulos/weather_forecast/common/logger/CommonLogger.kt new file mode 100644 index 0000000..6bdd187 --- /dev/null +++ b/app/src/main/java/gr/georgiopoulos/weather_forecast/common/logger/CommonLogger.kt @@ -0,0 +1,4 @@ +package gr.georgiopoulos.weather_forecast.common.logger + +class CommonLogger { +} \ No newline at end of file diff --git a/app/src/main/java/gr/georgiopoulos/weather_forecast/common/logger/Logger.kt b/app/src/main/java/gr/georgiopoulos/weather_forecast/common/logger/Logger.kt new file mode 100644 index 0000000..ba69aca --- /dev/null +++ b/app/src/main/java/gr/georgiopoulos/weather_forecast/common/logger/Logger.kt @@ -0,0 +1,4 @@ +package gr.georgiopoulos.weather_forecast.common.logger + +interface Logger { +} \ No newline at end of file diff --git a/app/src/main/java/gr/georgiopoulos/weather_forecast/database/CityDatabase.kt b/app/src/main/java/gr/georgiopoulos/weather_forecast/database/CityDatabase.kt new file mode 100644 index 0000000..9a17c2f --- /dev/null +++ b/app/src/main/java/gr/georgiopoulos/weather_forecast/database/CityDatabase.kt @@ -0,0 +1,5 @@ +package gr.georgiopoulos.weather_forecast.database + +@Database(entities = [MovieDbTable::class], version = 1, exportSchema = false) +abstract class CityDatabase { +} \ No newline at end of file diff --git a/app/src/main/java/gr/georgiopoulos/weather_forecast/database/dao/CityTable.kt b/app/src/main/java/gr/georgiopoulos/weather_forecast/database/dao/CityTable.kt new file mode 100644 index 0000000..cb0235d --- /dev/null +++ b/app/src/main/java/gr/georgiopoulos/weather_forecast/database/dao/CityTable.kt @@ -0,0 +1,4 @@ +package gr.georgiopoulos.weather_forecast.database.dao + +class CityTable { +} \ No newline at end of file diff --git a/app/src/main/java/gr/georgiopoulos/weather_forecast/database/dao/CityTableDao.kt b/app/src/main/java/gr/georgiopoulos/weather_forecast/database/dao/CityTableDao.kt new file mode 100644 index 0000000..2051faa --- /dev/null +++ b/app/src/main/java/gr/georgiopoulos/weather_forecast/database/dao/CityTableDao.kt @@ -0,0 +1,4 @@ +package gr.georgiopoulos.weather_forecast.database.dao + +class CityTableDao { +} \ No newline at end of file diff --git a/app/src/main/java/gr/georgiopoulos/weather_forecast/model/error/Error.kt b/app/src/main/java/gr/georgiopoulos/weather_forecast/model/error/Error.kt new file mode 100644 index 0000000..43a778d --- /dev/null +++ b/app/src/main/java/gr/georgiopoulos/weather_forecast/model/error/Error.kt @@ -0,0 +1,3 @@ +package gr.georgiopoulos.weather_forecast.model.error + +sealed class Error diff --git a/app/src/main/java/gr/georgiopoulos/weather_forecast/model/parser/weather_forecast/WeatherForecast.kt b/app/src/main/java/gr/georgiopoulos/weather_forecast/model/parser/weather_forecast/WeatherForecast.kt new file mode 100644 index 0000000..8842518 --- /dev/null +++ b/app/src/main/java/gr/georgiopoulos/weather_forecast/model/parser/weather_forecast/WeatherForecast.kt @@ -0,0 +1,42 @@ +package gr.georgiopoulos.weather_forecast.model.parser.weather_forecast + +import com.google.gson.annotations.SerializedName + +data class WeatherForecast( + @SerializedName("data") + val data: Data? = null +) + +data class Data( + @SerializedName("weather") + val weather: List? = arrayListOf() +) + +data class Weather( + @SerializedName("date") + val date: String? = "", + @SerializedName("hourly") + val hourly: List? = arrayListOf() +) + +data class Hourly( + @SerializedName("weatherIconUrl") + val weatherIconUrl: List? = arrayListOf(), + @SerializedName("weatherDesc") + val weatherDesc: List? = arrayListOf(), + @SerializedName("time") + val time: String? = "", + @SerializedName("tempC") + val tempC: String? = "" +) + +data class WeatherDescription( + @SerializedName("value") + val value: String? = "" +) + + +data class WeatherIconUrl( + @SerializedName("value") + val value: String? = "" +) diff --git a/app/src/main/java/gr/georgiopoulos/weather_forecast/model/transformer/weather_forecast/ForecastTransformer.kt b/app/src/main/java/gr/georgiopoulos/weather_forecast/model/transformer/weather_forecast/ForecastTransformer.kt new file mode 100644 index 0000000..c04d694 --- /dev/null +++ b/app/src/main/java/gr/georgiopoulos/weather_forecast/model/transformer/weather_forecast/ForecastTransformer.kt @@ -0,0 +1,4 @@ +package gr.georgiopoulos.weather_forecast.model.transformer.weather_forecast + +class ForecastTransformer { +} \ No newline at end of file diff --git a/app/src/main/java/gr/georgiopoulos/weather_forecast/model/transformer/weather_forecast/SectionTransformer.kt b/app/src/main/java/gr/georgiopoulos/weather_forecast/model/transformer/weather_forecast/SectionTransformer.kt new file mode 100644 index 0000000..d0cb95d --- /dev/null +++ b/app/src/main/java/gr/georgiopoulos/weather_forecast/model/transformer/weather_forecast/SectionTransformer.kt @@ -0,0 +1,4 @@ +package gr.georgiopoulos.weather_forecast.model.transformer.weather_forecast + +class WeatherForecastTransformer { +} \ No newline at end of file diff --git a/app/src/main/java/gr/georgiopoulos/weather_forecast/model/transformer/weather_forecast/Transformer.kt b/app/src/main/java/gr/georgiopoulos/weather_forecast/model/transformer/weather_forecast/Transformer.kt new file mode 100644 index 0000000..e6c0457 --- /dev/null +++ b/app/src/main/java/gr/georgiopoulos/weather_forecast/model/transformer/weather_forecast/Transformer.kt @@ -0,0 +1,4 @@ +package gr.georgiopoulos.weather_forecast.model.transformer.weather_forecast + +interface Transformer { +} \ No newline at end of file diff --git a/app/src/main/java/gr/georgiopoulos/weather_forecast/model/transformer/weather_forecast/WeatherForecastTransformerFactory.kt b/app/src/main/java/gr/georgiopoulos/weather_forecast/model/transformer/weather_forecast/WeatherForecastTransformerFactory.kt new file mode 100644 index 0000000..b7bc92c --- /dev/null +++ b/app/src/main/java/gr/georgiopoulos/weather_forecast/model/transformer/weather_forecast/WeatherForecastTransformerFactory.kt @@ -0,0 +1,4 @@ +package gr.georgiopoulos.weather_forecast.model.transformer.weather_forecast + +class WeatherForecastTransformerFactory { +} \ No newline at end of file diff --git a/app/src/main/java/gr/georgiopoulos/weather_forecast/model/ui/weather_forecast/WeatherForecastUiModel.kt b/app/src/main/java/gr/georgiopoulos/weather_forecast/model/ui/weather_forecast/WeatherForecastUiModel.kt new file mode 100644 index 0000000..ba73dc1 --- /dev/null +++ b/app/src/main/java/gr/georgiopoulos/weather_forecast/model/ui/weather_forecast/WeatherForecastUiModel.kt @@ -0,0 +1,3 @@ +package gr.georgiopoulos.weather_forecast.model.ui.weather_forecast + +sealed class WeatherForecastUiModel diff --git a/app/src/main/java/gr/georgiopoulos/weather_forecast/model/validator/wather_forecast/Validator.kt b/app/src/main/java/gr/georgiopoulos/weather_forecast/model/validator/wather_forecast/Validator.kt new file mode 100644 index 0000000..02f1ca6 --- /dev/null +++ b/app/src/main/java/gr/georgiopoulos/weather_forecast/model/validator/wather_forecast/Validator.kt @@ -0,0 +1,4 @@ +package gr.georgiopoulos.weather_forecast.model.validator.wather_forecast + +interface WatherValidator { +} \ No newline at end of file diff --git a/app/src/main/java/gr/georgiopoulos/weather_forecast/model/validator/wather_forecast/Validity.kt b/app/src/main/java/gr/georgiopoulos/weather_forecast/model/validator/wather_forecast/Validity.kt new file mode 100644 index 0000000..0b98f1e --- /dev/null +++ b/app/src/main/java/gr/georgiopoulos/weather_forecast/model/validator/wather_forecast/Validity.kt @@ -0,0 +1,3 @@ +package gr.georgiopoulos.weather_forecast.model.validator + +sealed class Validity diff --git a/app/src/main/java/gr/georgiopoulos/weather_forecast/model/validator/wather_forecast/WeatherForecastValidator.kt b/app/src/main/java/gr/georgiopoulos/weather_forecast/model/validator/wather_forecast/WeatherForecastValidator.kt new file mode 100644 index 0000000..41d2db7 --- /dev/null +++ b/app/src/main/java/gr/georgiopoulos/weather_forecast/model/validator/wather_forecast/WeatherForecastValidator.kt @@ -0,0 +1,4 @@ +package gr.georgiopoulos.weather_forecast.model.validator.wather_forecast + +class WeatherForecastUIModelValidator { +} \ No newline at end of file diff --git a/app/src/main/java/gr/georgiopoulos/weather_forecast/network/api/WeatherForecastApi.kt b/app/src/main/java/gr/georgiopoulos/weather_forecast/network/api/WeatherForecastApi.kt new file mode 100644 index 0000000..18f52ff --- /dev/null +++ b/app/src/main/java/gr/georgiopoulos/weather_forecast/network/api/WeatherForecastApi.kt @@ -0,0 +1,17 @@ +package gr.georgiopoulos.weather_forecast.network.api + +import gr.georgiopoulos.weather_forecast.model.parser.weather_forecast.WeatherForecast +import retrofit2.http.GET +import retrofit2.http.Query + +interface WeatherForecastApi { + + @GET("/weather.ashx") + suspend fun getWeatherForecast( + @Query("key") key: String, + @Query("q", encoded = true) city: String, + @Query("num_of_days") days: String, + @Query("format") format: String + ): WeatherForecast + +} \ No newline at end of file diff --git a/app/src/main/java/gr/georgiopoulos/weather_forecast/network/client/WeatherForecastClient.kt b/app/src/main/java/gr/georgiopoulos/weather_forecast/network/client/WeatherForecastClient.kt new file mode 100644 index 0000000..27e6538 --- /dev/null +++ b/app/src/main/java/gr/georgiopoulos/weather_forecast/network/client/WeatherForecastClient.kt @@ -0,0 +1,43 @@ +package gr.georgiopoulos.weather_forecast.network.client + +import gr.georgiopoulos.weather_forecast.common.DefinitionsApi +import gr.georgiopoulos.weather_forecast.model.parser.weather_forecast.WeatherForecast +import gr.georgiopoulos.weather_forecast.network.api.WeatherForecastApi +import okhttp3.OkHttpClient +import okhttp3.logging.HttpLoggingInterceptor +import retrofit2.Retrofit +import retrofit2.converter.gson.GsonConverterFactory +import java.util.concurrent.TimeUnit + +class WeatherForecastClient { + + private var weatherForecastApi: WeatherForecastApi + + init { + weatherForecastApi = getRetrofit().create(WeatherForecastApi::class.java) + } + + private fun getRetrofit(): Retrofit { + return Retrofit.Builder() + .baseUrl(DefinitionsApi.DOMAIN) + .client(getOkHttpClient()) + .addConverterFactory(GsonConverterFactory.create()) + .build() + } + + private fun getOkHttpClient() = OkHttpClient().newBuilder() + .addInterceptor(HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY)) + .connectTimeout(60L, TimeUnit.SECONDS) + .readTimeout(60L, TimeUnit.SECONDS) + .writeTimeout(60L, TimeUnit.SECONDS) + .build() + + suspend fun getWeatherForecast(city: String): WeatherForecast { + return weatherForecastApi.getWeatherForecast( + key = DefinitionsApi.KEY, + city = city, + days = DefinitionsApi.DAYS, + format = DefinitionsApi.FORMAT + ) + } +} \ No newline at end of file diff --git a/app/src/main/java/gr/georgiopoulos/weather_forecast/ui/activity/base/BaseActivity.kt b/app/src/main/java/gr/georgiopoulos/weather_forecast/ui/activity/base/BaseActivity.kt new file mode 100644 index 0000000..915eb6b --- /dev/null +++ b/app/src/main/java/gr/georgiopoulos/weather_forecast/ui/activity/base/BaseActivity.kt @@ -0,0 +1,77 @@ +package gr.georgiopoulos.weather_forecast.ui.activity.base + +import android.annotation.SuppressLint +import android.view.View +import androidx.appcompat.app.AppCompatActivity +import androidx.lifecycle.Observer +import com.afollestad.materialdialogs.DialogCallback +import com.afollestad.materialdialogs.MaterialDialog +import gr.georgiopoulos.weather_forecast.R +import gr.georgiopoulos.weather_forecast.databinding.LayoutEmptyBinding +import gr.georgiopoulos.weather_forecast.databinding.LayoutLoadingBinding +import gr.georgiopoulos.weather_forecast.mvvm.view_model.base.BaseViewModel + +@SuppressLint("Registered") +open class BaseActivity : AppCompatActivity() { + + private var materialDialog: MaterialDialog? = null + protected var viewModel: T? = null + + override fun onDestroy() { + super.onDestroy() + materialDialog?.dismiss() + materialDialog = null + } + + fun initViewModelState(loadingLayout: LayoutLoadingBinding?, emptyLayout: LayoutEmptyBinding?) { + viewModel?.showLoadingView()?.observe(this, Observer { value -> + value?.let { show -> + loadingLayout?.root?.visibility = if (show) View.VISIBLE else View.GONE + } + }) + + viewModel?.showEmptyView()?.observe(this, Observer { value -> + value?.let { show -> + emptyLayout?.root?.visibility = if (show) View.VISIBLE else View.GONE + } + }) + + viewModel?.showInternetError()?.observe(this, Observer { value -> + value?.let { showError -> + if (showError) { + showNoInternetError() + } + } + }) + + viewModel?.showGenericError()?.observe(this, Observer { value -> + value?.let { showError -> + if (showError) { + showGenericError() + } + } + }) + } + + private fun showGenericError() { + showErrorDialog(getString(R.string.generic_error), closeListener = { dialog -> + dialog.dismiss() + viewModel?.genericErrorLiveData?.value = false + }) + } + + private fun showNoInternetError() { + showErrorDialog(getString(R.string.no_internet), closeListener = { dialog -> + dialog.dismiss() + viewModel?.noInternetLiveData?.value = false + }) + } + + fun showErrorDialog(errorDescription: String = "", closeListener: DialogCallback) { + materialDialog = MaterialDialog(this).show { + title(text = getString(R.string.dialog_title)) + message(text = errorDescription) + positiveButton(text = getString(R.string.ok), click = closeListener) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/gr/georgiopoulos/weather_forecast/ui/activity/home/HomeActivity.kt b/app/src/main/java/gr/georgiopoulos/weather_forecast/ui/activity/home/HomeActivity.kt new file mode 100644 index 0000000..f2a4c55 --- /dev/null +++ b/app/src/main/java/gr/georgiopoulos/weather_forecast/ui/activity/home/HomeActivity.kt @@ -0,0 +1,12 @@ +package gr.georgiopoulos.weather_forecast.ui.home + +import androidx.appcompat.app.AppCompatActivity +import android.os.Bundle +import gr.georgiopoulos.weather_forecast.R + +class HomeActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_home) + } +} \ No newline at end of file diff --git a/app/src/main/java/gr/georgiopoulos/weather_forecast/ui/activity/splash/SplashActivity.kt b/app/src/main/java/gr/georgiopoulos/weather_forecast/ui/activity/splash/SplashActivity.kt new file mode 100644 index 0000000..616b7ef --- /dev/null +++ b/app/src/main/java/gr/georgiopoulos/weather_forecast/ui/activity/splash/SplashActivity.kt @@ -0,0 +1,41 @@ +package gr.georgiopoulos.weather_forecast.ui.splash + +import android.content.Intent +import android.os.Bundle +import android.os.Handler +import android.os.Looper +import androidx.appcompat.app.AppCompatActivity +import gr.georgiopoulos.weather_forecast.R +import gr.georgiopoulos.weather_forecast.ui.home.HomeActivity + +class SplashActivity : AppCompatActivity() { + + companion object { + const val SPLASH_DELAY: Long = 3000 + } + + private var delayHandler: Handler? = null + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_splash) + initLayout() + } + + private val mRunnable: Runnable = Runnable { + if (!isFinishing) { + startActivity(Intent(this, HomeActivity::class.java)) + finish() + } + } + + public override fun onDestroy() { + delayHandler?.removeCallbacks(mRunnable) + super.onDestroy() + } + + private fun initLayout() { + delayHandler = Looper.myLooper()?.let { Handler(it) } + delayHandler?.postDelayed(mRunnable, SPLASH_DELAY) + } +} \ No newline at end of file diff --git a/app/src/main/java/gr/georgiopoulos/weather_forecast/ui/activity/weather_forecast/WeatherForecastActivity.kt b/app/src/main/java/gr/georgiopoulos/weather_forecast/ui/activity/weather_forecast/WeatherForecastActivity.kt new file mode 100644 index 0000000..8d26412 --- /dev/null +++ b/app/src/main/java/gr/georgiopoulos/weather_forecast/ui/activity/weather_forecast/WeatherForecastActivity.kt @@ -0,0 +1,4 @@ +package gr.georgiopoulos.weather_forecast.ui.activity.weather_forecast + +class WeatherForecastActivity { +} \ No newline at end of file diff --git a/app/src/main/java/gr/georgiopoulos/weather_forecast/ui/adapter/cities/CitiesRecyclerViewAdapter.kt b/app/src/main/java/gr/georgiopoulos/weather_forecast/ui/adapter/cities/CitiesRecyclerViewAdapter.kt new file mode 100644 index 0000000..fc837e0 --- /dev/null +++ b/app/src/main/java/gr/georgiopoulos/weather_forecast/ui/adapter/cities/CitiesRecyclerViewAdapter.kt @@ -0,0 +1,4 @@ +package gr.georgiopoulos.weather_forecast.ui.adapter.cities + +class CitiesRecyclerViewAdapter { +} \ No newline at end of file diff --git a/app/src/main/java/gr/georgiopoulos/weather_forecast/ui/adapter/predictions/PredictionsRecyclerViewAdapter.kt b/app/src/main/java/gr/georgiopoulos/weather_forecast/ui/adapter/predictions/PredictionsRecyclerViewAdapter.kt new file mode 100644 index 0000000..86bef55 --- /dev/null +++ b/app/src/main/java/gr/georgiopoulos/weather_forecast/ui/adapter/predictions/PredictionsRecyclerViewAdapter.kt @@ -0,0 +1,45 @@ +package gr.georgiopoulos.weather_forecast.ui.adapter.add_city + +import android.view.LayoutInflater +import android.view.ViewGroup +import androidx.recyclerview.widget.RecyclerView +import gr.georgiopoulos.weather_forecast.databinding.LayoutCityBinding + +class AddCityRecyclerViewAdapter( + private val onCityClick: (String) -> Unit, +) : RecyclerView.Adapter() { + + private var cities: MutableList = mutableListOf() + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CityViewHolder { + val binding = LayoutCityBinding.inflate(LayoutInflater.from(parent.context), parent, false) + return CityViewHolder(binding, onCityClick) + } + + override fun onBindViewHolder(holder: CityViewHolder, position: Int) { + val city = cities[position] + holder.bind(city) + } + + override fun getItemCount(): Int { + return cities.size + } + + fun setCities(cities: MutableList) { + this.cities.clear() + this.cities.addAll(cities) + notifyDataSetChanged() + } + + class CityViewHolder( + private val binding: LayoutCityBinding, + private val onCityClick: (String) -> Unit + ) : RecyclerView.ViewHolder(binding.root) { + fun bind(city: String) { + with(binding) { + cityName.text = city + root.setOnClickListener { onCityClick(city) } + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/gr/georgiopoulos/weather_forecast/ui/adapter/weather_forecast/WeatherForecastRecyclerViewAdapter.kt b/app/src/main/java/gr/georgiopoulos/weather_forecast/ui/adapter/weather_forecast/WeatherForecastRecyclerViewAdapter.kt new file mode 100644 index 0000000..e777743 --- /dev/null +++ b/app/src/main/java/gr/georgiopoulos/weather_forecast/ui/adapter/weather_forecast/WeatherForecastRecyclerViewAdapter.kt @@ -0,0 +1,4 @@ +package gr.georgiopoulos.weather_forecast.ui.adapter.weather_forecast + +class WeatherForecastRecyclerViewAdapter { +} \ No newline at end of file diff --git a/app/src/main/java/gr/georgiopoulos/weather_forecast/use_case/database_access/CitiesDatabaseAccessUseCase.kt b/app/src/main/java/gr/georgiopoulos/weather_forecast/use_case/database_access/CitiesDatabaseAccessUseCase.kt new file mode 100644 index 0000000..0450bee --- /dev/null +++ b/app/src/main/java/gr/georgiopoulos/weather_forecast/use_case/database_access/CitiesDatabaseAccessUseCase.kt @@ -0,0 +1,4 @@ +package gr.georgiopoulos.weather_forecast.use_case.database_access + +class CitiesDatabaseAccessUseCase { +} \ No newline at end of file diff --git a/app/src/main/java/gr/georgiopoulos/weather_forecast/use_case/database_access/DatabaseAccessUseCase.kt b/app/src/main/java/gr/georgiopoulos/weather_forecast/use_case/database_access/DatabaseAccessUseCase.kt new file mode 100644 index 0000000..fa57af7 --- /dev/null +++ b/app/src/main/java/gr/georgiopoulos/weather_forecast/use_case/database_access/DatabaseAccessUseCase.kt @@ -0,0 +1,4 @@ +package gr.georgiopoulos.weather_forecast.use_case.database_access + +interface DatabaseAccessUseCase { +} \ No newline at end of file diff --git a/app/src/main/java/gr/georgiopoulos/weather_forecast/use_case/database_access/result/DatabaseAccessResult.kt b/app/src/main/java/gr/georgiopoulos/weather_forecast/use_case/database_access/result/DatabaseAccessResult.kt new file mode 100644 index 0000000..0e59478 --- /dev/null +++ b/app/src/main/java/gr/georgiopoulos/weather_forecast/use_case/database_access/result/DatabaseAccessResult.kt @@ -0,0 +1,4 @@ +package gr.georgiopoulos.weather_forecast.use_case.database_access.result + +interface DatabaseAccessResult { +} \ No newline at end of file diff --git a/app/src/main/java/gr/georgiopoulos/weather_forecast/use_case/database_access/result/load/DatabaseAccessLoadCitiesResult.kt b/app/src/main/java/gr/georgiopoulos/weather_forecast/use_case/database_access/result/load/DatabaseAccessLoadCitiesResult.kt new file mode 100644 index 0000000..b4de572 --- /dev/null +++ b/app/src/main/java/gr/georgiopoulos/weather_forecast/use_case/database_access/result/load/DatabaseAccessLoadCitiesResult.kt @@ -0,0 +1,4 @@ +package gr.georgiopoulos.weather_forecast.use_case.database_access.result.load + +interface DatabaseAccessLoadCitiesResult { +} \ No newline at end of file diff --git a/app/src/main/java/gr/georgiopoulos/weather_forecast/use_case/places/PlacesPredictionsUseCase.kt b/app/src/main/java/gr/georgiopoulos/weather_forecast/use_case/places/PlacesPredictionsUseCase.kt new file mode 100644 index 0000000..7d02d93 --- /dev/null +++ b/app/src/main/java/gr/georgiopoulos/weather_forecast/use_case/places/PlacesPredictionsUseCase.kt @@ -0,0 +1,4 @@ +package gr.georgiopoulos.weather_forecast.use_case.places + +class PlacesPredictionsUseCase { +} \ No newline at end of file diff --git a/app/src/main/java/gr/georgiopoulos/weather_forecast/use_case/places/PlacesUseCase.kt b/app/src/main/java/gr/georgiopoulos/weather_forecast/use_case/places/PlacesUseCase.kt new file mode 100644 index 0000000..f525385 --- /dev/null +++ b/app/src/main/java/gr/georgiopoulos/weather_forecast/use_case/places/PlacesUseCase.kt @@ -0,0 +1,4 @@ +package gr.georgiopoulos.weather_forecast.use_case.places + +interface PlacesUseCase { +} \ No newline at end of file diff --git a/app/src/main/java/gr/georgiopoulos/weather_forecast/use_case/places/result/PlacesResult.kt b/app/src/main/java/gr/georgiopoulos/weather_forecast/use_case/places/result/PlacesResult.kt new file mode 100644 index 0000000..d698222 --- /dev/null +++ b/app/src/main/java/gr/georgiopoulos/weather_forecast/use_case/places/result/PlacesResult.kt @@ -0,0 +1,4 @@ +package gr.georgiopoulos.weather_forecast.use_case.places.result + +interface PlacesResult { +} \ No newline at end of file diff --git a/app/src/main/java/gr/georgiopoulos/weather_forecast/use_case/weather_forecast/FetchWeatherForecastUseCase.kt b/app/src/main/java/gr/georgiopoulos/weather_forecast/use_case/weather_forecast/FetchWeatherForecastUseCase.kt new file mode 100644 index 0000000..79efc94 --- /dev/null +++ b/app/src/main/java/gr/georgiopoulos/weather_forecast/use_case/weather_forecast/FetchWeatherForecastUseCase.kt @@ -0,0 +1,4 @@ +package gr.georgiopoulos.weather_forecast.use_case.weather_forecast + +interface FetchWeatherForecastUseCase { +} \ No newline at end of file diff --git a/app/src/main/java/gr/georgiopoulos/weather_forecast/use_case/weather_forecast/WeatherForecastUseCase.kt b/app/src/main/java/gr/georgiopoulos/weather_forecast/use_case/weather_forecast/WeatherForecastUseCase.kt new file mode 100644 index 0000000..fa8aef8 --- /dev/null +++ b/app/src/main/java/gr/georgiopoulos/weather_forecast/use_case/weather_forecast/WeatherForecastUseCase.kt @@ -0,0 +1,4 @@ +package gr.georgiopoulos.weather_forecast.use_case.weather_forecast + +interface WeatherForecastUseCase { +} \ No newline at end of file diff --git a/app/src/main/java/gr/georgiopoulos/weather_forecast/use_case/weather_forecast/result/WeatherResult.kt b/app/src/main/java/gr/georgiopoulos/weather_forecast/use_case/weather_forecast/result/WeatherResult.kt new file mode 100644 index 0000000..579ff85 --- /dev/null +++ b/app/src/main/java/gr/georgiopoulos/weather_forecast/use_case/weather_forecast/result/WeatherResult.kt @@ -0,0 +1,4 @@ +package gr.georgiopoulos.weather_forecast.use_case.weather_forecast.result + +interface WeatherResult { +} \ No newline at end of file diff --git a/app/src/main/java/gr/georgiopoulos/weather_forecast/view_model/view_model/base/BaseViewModel.kt b/app/src/main/java/gr/georgiopoulos/weather_forecast/view_model/view_model/base/BaseViewModel.kt new file mode 100644 index 0000000..167237f --- /dev/null +++ b/app/src/main/java/gr/georgiopoulos/weather_forecast/view_model/view_model/base/BaseViewModel.kt @@ -0,0 +1,83 @@ +package gr.georgiopoulos.weather_forecast.mvvm.view_model.base + +import androidx.lifecycle.LiveData +import androidx.lifecycle.MutableLiveData +import androidx.lifecycle.ViewModel +import kotlinx.coroutines.CoroutineDispatcher +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.SupervisorJob +import java.net.UnknownHostException +import kotlin.coroutines.CoroutineContext + +open class BaseViewModel : ViewModel(), CoroutineScope { + + private val viewModelJob = SupervisorJob() + protected val bgDispatcher: CoroutineDispatcher = Dispatchers.IO + protected val uiScope = CoroutineScope(Dispatchers.Main + viewModelJob) + protected var loadingLiveData: MutableLiveData = MutableLiveData() + protected var emptyLiveData: MutableLiveData = MutableLiveData() + var noInternetLiveData: MutableLiveData = MutableLiveData() + var genericErrorLiveData: MutableLiveData = MutableLiveData() + + /** + * This is the job for all coroutines started by this ViewModel. + * + * Cancelling this job will cancel all coroutines started by this ViewModel. + * + * This would ensure that our coroutines do not get canceled even + * when the screen rotates and our activity is recreated + */ + + override val coroutineContext: CoroutineContext + get() = Dispatchers.IO + viewModelJob + + /** + * Cancel all coroutines when the ViewModel is cleared + */ + + override fun onCleared() { + super.onCleared() + viewModelJob.cancel() + } + + fun showEmptyView(): LiveData { + return emptyLiveData + } + + fun showLoadingView(): LiveData { + return loadingLiveData + } + + fun showInternetError(): LiveData { + return noInternetLiveData + } + + fun showGenericError(): LiveData { + return genericErrorLiveData + } + + fun onErrorThrowable(throwable: Throwable?, isShowEmptyView: Boolean = false) { + loadingLiveData.value = false + if (throwable == null) { + genericErrorLiveData.value = true + return + } + if (isNetworkError(throwable)) { + noInternetLiveData.value = true + } else { + genericErrorLiveData.value = true + } + if (isShowEmptyView) + emptyLiveData.value = true + } + + private fun isNetworkError(throwable: Throwable): Boolean { + when (throwable) { + is UnknownHostException -> { + return true + } + } + return false + } +} \ No newline at end of file diff --git a/app/src/main/java/gr/georgiopoulos/weather_forecast/view_model/view_model/base/BaseViewModelFactory.kt b/app/src/main/java/gr/georgiopoulos/weather_forecast/view_model/view_model/base/BaseViewModelFactory.kt new file mode 100644 index 0000000..fc1a1fe --- /dev/null +++ b/app/src/main/java/gr/georgiopoulos/weather_forecast/view_model/view_model/base/BaseViewModelFactory.kt @@ -0,0 +1,12 @@ +package gr.georgiopoulos.weather_forecast.mvvm.view_model.base + +import androidx.lifecycle.ViewModel +import androidx.lifecycle.ViewModelProvider + +@Suppress("UNCHECKED_CAST") +class BaseViewModelFactory(val creator: () -> T) : ViewModelProvider.Factory { + + override fun create(modelClass: Class): T { + return creator() as T + } +} \ No newline at end of file diff --git a/app/src/main/java/gr/georgiopoulos/weather_forecast/view_model/view_model/home/HomeViewModel.kt b/app/src/main/java/gr/georgiopoulos/weather_forecast/view_model/view_model/home/HomeViewModel.kt new file mode 100644 index 0000000..f264e29 --- /dev/null +++ b/app/src/main/java/gr/georgiopoulos/weather_forecast/view_model/view_model/home/HomeViewModel.kt @@ -0,0 +1,6 @@ +package gr.georgiopoulos.weather_forecast.mvvm.view_model.home + +import gr.georgiopoulos.weather_forecast.mvvm.view_model.base.BaseViewModel + +class HomeViewModel: BaseViewModel() { +} \ No newline at end of file diff --git a/app/src/main/res/anim/no_change.xml b/app/src/main/res/anim/no_change.xml new file mode 100644 index 0000000..d05f36c --- /dev/null +++ b/app/src/main/res/anim/no_change.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/slide_down.xml b/app/src/main/res/anim/slide_down.xml new file mode 100644 index 0000000..12607af --- /dev/null +++ b/app/src/main/res/anim/slide_down.xml @@ -0,0 +1,5 @@ + + \ No newline at end of file diff --git a/app/src/main/res/anim/slide_up.xml b/app/src/main/res/anim/slide_up.xml new file mode 100644 index 0000000..d05f36c --- /dev/null +++ b/app/src/main/res/anim/slide_up.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/black_stroke_rectangle.xml b/app/src/main/res/drawable/black_stroke_rectangle.xml new file mode 100644 index 0000000..f244e94 --- /dev/null +++ b/app/src/main/res/drawable/black_stroke_rectangle.xml @@ -0,0 +1,9 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_add.xml b/app/src/main/res/drawable/ic_add.xml new file mode 100644 index 0000000..cc94d5a --- /dev/null +++ b/app/src/main/res/drawable/ic_add.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/ic_back.xml b/app/src/main/res/drawable/ic_back.xml new file mode 100644 index 0000000..31e7df2 --- /dev/null +++ b/app/src/main/res/drawable/ic_back.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/ic_cloud.xml b/app/src/main/res/drawable/ic_cloud.xml new file mode 100644 index 0000000..7d76add --- /dev/null +++ b/app/src/main/res/drawable/ic_cloud.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/ic_delete.xml b/app/src/main/res/drawable/ic_delete.xml new file mode 100644 index 0000000..5c93a9f --- /dev/null +++ b/app/src/main/res/drawable/ic_delete.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/ic_launcher_foreground.xml b/app/src/main/res/drawable/ic_launcher_foreground.xml new file mode 100644 index 0000000..4aaafee --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_foreground.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_see_weather.xml b/app/src/main/res/drawable/ic_see_weather.xml new file mode 100644 index 0000000..dad80a1 --- /dev/null +++ b/app/src/main/res/drawable/ic_see_weather.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/ic_sun.xml b/app/src/main/res/drawable/ic_sun.xml new file mode 100644 index 0000000..7ba8d12 --- /dev/null +++ b/app/src/main/res/drawable/ic_sun.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/ic_sun_animation.xml b/app/src/main/res/drawable/ic_sun_animation.xml new file mode 100644 index 0000000..a8b409b --- /dev/null +++ b/app/src/main/res/drawable/ic_sun_animation.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/white_oval.xml b/app/src/main/res/drawable/white_oval.xml new file mode 100644 index 0000000..efef162 --- /dev/null +++ b/app/src/main/res/drawable/white_oval.xml @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_home.xml b/app/src/main/res/layout/activity_home.xml new file mode 100644 index 0000000..aed3474 --- /dev/null +++ b/app/src/main/res/layout/activity_home.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_weather_forecast.xml b/app/src/main/res/layout/activity_weather_forecast.xml new file mode 100644 index 0000000..cdc89f2 --- /dev/null +++ b/app/src/main/res/layout/activity_weather_forecast.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/bottom_sheet_add_city.xml b/app/src/main/res/layout/bottom_sheet_add_city.xml new file mode 100644 index 0000000..b5ca1e4 --- /dev/null +++ b/app/src/main/res/layout/bottom_sheet_add_city.xml @@ -0,0 +1,58 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/layout_city.xml b/app/src/main/res/layout/layout_city.xml new file mode 100644 index 0000000..cdc89f2 --- /dev/null +++ b/app/src/main/res/layout/layout_city.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/layout_date.xml b/app/src/main/res/layout/layout_date.xml new file mode 100644 index 0000000..cdc89f2 --- /dev/null +++ b/app/src/main/res/layout/layout_date.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/layout_error.xml b/app/src/main/res/layout/layout_error.xml new file mode 100644 index 0000000..2439f08 --- /dev/null +++ b/app/src/main/res/layout/layout_error.xml @@ -0,0 +1,35 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/layout_forecast.xml b/app/src/main/res/layout/layout_forecast.xml new file mode 100644 index 0000000..61b1ed0 --- /dev/null +++ b/app/src/main/res/layout/layout_forecast.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/layout_loading.xml b/app/src/main/res/layout/layout_loading.xml new file mode 100644 index 0000000..e457077 --- /dev/null +++ b/app/src/main/res/layout/layout_loading.xml @@ -0,0 +1,22 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/layout_prediction.xml b/app/src/main/res/layout/layout_prediction.xml new file mode 100644 index 0000000..dbef09f --- /dev/null +++ b/app/src/main/res/layout/layout_prediction.xml @@ -0,0 +1,15 @@ + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..7353dbd --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..7353dbd --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..c9d4bbf Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..540804d Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..b1baaf9 Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..419a307 Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..747a094 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..57a9f23 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..6af1dd1 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..a52de76 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..72c225a Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..cd08e8f Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..999ecd5 --- /dev/null +++ b/app/src/main/res/values/colors.xml @@ -0,0 +1,12 @@ + + + #FFBB86FC + #FF6200EE + #FF3700B3 + #FF03DAC5 + #FF018786 + #87CEEB + #FDB813 + #FF000000 + #FFFFFFFF + \ No newline at end of file diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml new file mode 100644 index 0000000..416ca8d --- /dev/null +++ b/app/src/main/res/values/dimens.xml @@ -0,0 +1,14 @@ + + + + + 12sp + 14sp + 16sp + 18sp + 24sp + + + 160dp + 80dp + \ No newline at end of file diff --git a/app/src/main/res/values/ic_launcher_background.xml b/app/src/main/res/values/ic_launcher_background.xml new file mode 100644 index 0000000..ce094b8 --- /dev/null +++ b/app/src/main/res/values/ic_launcher_background.xml @@ -0,0 +1,4 @@ + + + #87CEEB + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..e6cc4f7 --- /dev/null +++ b/app/src/main/res/values/strings.xml @@ -0,0 +1,8 @@ + + Weather Forecast + No results + Oops! There was an error + Oops + No internet connection + OK + \ No newline at end of file diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml new file mode 100644 index 0000000..37cb14d --- /dev/null +++ b/app/src/main/res/values/themes.xml @@ -0,0 +1,13 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/xml/backup_descriptor.xml b/app/src/main/res/xml/backup_descriptor.xml new file mode 100644 index 0000000..cfcd563 --- /dev/null +++ b/app/src/main/res/xml/backup_descriptor.xml @@ -0,0 +1,4 @@ + + + + diff --git a/app/src/test/java/gr/georgiopoulos/weather_forecast/ExampleUnitTest.kt b/app/src/test/java/gr/georgiopoulos/weather_forecast/ExampleUnitTest.kt new file mode 100644 index 0000000..2865f4c --- /dev/null +++ b/app/src/test/java/gr/georgiopoulos/weather_forecast/ExampleUnitTest.kt @@ -0,0 +1,17 @@ +package gr.georgiopoulos.weather_forecast + +import org.junit.Test + +import org.junit.Assert.* + +/** + * Example local unit test, which will execute on the development machine (host). + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +class ExampleUnitTest { + @Test + fun addition_isCorrect() { + assertEquals(4, 2 + 2) + } +} \ No newline at end of file diff --git a/app/src/test/java/gr/georgiopoulos/weather_forecast/common/extensions/StringExtensionsKtTest.kt b/app/src/test/java/gr/georgiopoulos/weather_forecast/common/extensions/StringExtensionsKtTest.kt new file mode 100644 index 0000000..d8366c5 --- /dev/null +++ b/app/src/test/java/gr/georgiopoulos/weather_forecast/common/extensions/StringExtensionsKtTest.kt @@ -0,0 +1,5 @@ +package gr.georgiopoulos.weather_forecast.common.extensions + +import junit.framework.TestCase + +class StringExtensionsKtTest : TestCase() \ No newline at end of file diff --git a/app/src/test/java/gr/georgiopoulos/weather_forecast/model/validator/wather_forecast/WeatherForecastValidatorTest.kt b/app/src/test/java/gr/georgiopoulos/weather_forecast/model/validator/wather_forecast/WeatherForecastValidatorTest.kt new file mode 100644 index 0000000..a0c6657 --- /dev/null +++ b/app/src/test/java/gr/georgiopoulos/weather_forecast/model/validator/wather_forecast/WeatherForecastValidatorTest.kt @@ -0,0 +1,5 @@ +package gr.georgiopoulos.weather_forecast.model.validator.wather_forecast + +import org.junit.Assert.* + +class WeatherForecastValidatorTest \ No newline at end of file diff --git a/app/src/test/java/gr/georgiopoulos/weather_forecast/view_model/view_model/home/HomeViewModelTest.kt b/app/src/test/java/gr/georgiopoulos/weather_forecast/view_model/view_model/home/HomeViewModelTest.kt new file mode 100644 index 0000000..fc70f7c --- /dev/null +++ b/app/src/test/java/gr/georgiopoulos/weather_forecast/view_model/view_model/home/HomeViewModelTest.kt @@ -0,0 +1,5 @@ +package gr.georgiopoulos.weather_forecast.view_model.view_model.home + +import org.junit.Assert.* + +class HomeViewModelTest \ No newline at end of file diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..2f3d35b --- /dev/null +++ b/build.gradle @@ -0,0 +1,27 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +buildscript { + ext.kotlin_version = "1.5.10" + repositories { + google() + mavenCentral() + } + dependencies { + classpath "com.android.tools.build:gradle:4.2.1" + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + google() + mavenCentral() + jcenter() // Warning: this repository is going to shut down soon + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..2521752 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,19 @@ +# Project-wide Gradle settings. +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true +# AndroidX package structure to make it clearer which packages are bundled with the +# Android operating system, and which are packaged with your app"s APK +# https://developer.android.com/topic/libraries/support-library/androidx-rn +android.useAndroidX=true +# Kotlin code style for this project: "official" or "obsolete": +kotlin.code.style=official \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..f6b961f Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..93b0342 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Sun May 30 13:56:54 EEST 2021 +distributionBase=GRADLE_USER_HOME +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip +distributionPath=wrapper/dists +zipStorePath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..cccdd3d --- /dev/null +++ b/gradlew @@ -0,0 +1,172 @@ +#!/usr/bin/env sh + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..f955316 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,84 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..ac8f3c9 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,2 @@ +rootProject.name = "weather_forecast" +include ':app'