8 |
9 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # WeatherApp-Android
2 | ⛈ Weather app with OpenWeatherMap API. Here i demonstrate the use of Modern Android development tools - (Kotlin, Architecture Components, MVVM, LiveData, Material Components)
3 |
4 | 
5 | 
6 | 
7 | 
8 | 
9 |
10 |
11 | ## Screenshots
12 |
13 | **Please click the image below to enlarge.**
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | ## Built With 🛠
22 | - [Kotlin](https://kotlinlang.org/) - First class and official programming language for Android development.
23 | - [Coroutines](https://kotlinlang.org/docs/reference/coroutines-overview.html) - For asynchronous and more..
24 | - [Android Architecture Components](https://developer.android.com/topic/libraries/architecture) - Collection of libraries that help you design robust, testable, and maintainable apps.
25 | - [LiveData](https://developer.android.com/topic/libraries/architecture/livedata) - Data objects that notify views when the underlying database changes.
26 | - [ViewModel](https://developer.android.com/topic/libraries/architecture/viewmodel) - Stores UI-related data that isn't destroyed on UI changes.
27 | - [ViewBinding](https://developer.android.com/topic/libraries/view-binding) - Generates a binding class for each XML layout file present in that module and allows you to more easily write code that interacts with views.
28 | - [Koin](https://insert-koin.io) - Dependency Injection Framework
29 | - [Retrofit](https://square.github.io/retrofit/) - A type-safe HTTP client for Android and Java.
30 | - [GSON](https://github.com/google/gson) - A Java serialization/deserialization library to convert Java Objects into JSON and back.
31 | - [GSON Converter](https://github.com/square/retrofit/tree/master/retrofit-converters/gson) - A Converter which uses Gson for serialization to and from JSON.
32 | - [OkHttp3](https://github.com/square/okhttp) - For implementing interceptor, logging and mocking web server.
33 | - [Glide](https://github.com/bumptech/glide) - An image loading and caching library for Android focused on smooth scrolling.
34 | - [Material Components for Android](https://github.com/material-components/material-components-android) - Modular and customizable Material Design UI components for Android.
35 |
36 |
37 | ## Architecture
38 | This app uses [***MVVM (Model View View-Model)***](https://developer.android.com/jetpack/docs/guide#recommended-app-arch) architecture.
39 |
40 | 
41 |
42 |
43 | ## Contributing
44 |
45 | Please fork this repository and contribute back using
46 | [pull requests](https://github.com/Shashank02051997/WeatherApp-Android/pulls).
47 |
48 | Any contributions, large or small, major features, bug fixes, are welcomed and appreciated
49 | but will be thoroughly reviewed .
50 |
51 | ### Contact - Let's become friend
52 | - [Twitter](https://twitter.com/shashank020597)
53 | - [Github](https://github.com/Shashank02051997)
54 | - [Linkedin](https://www.linkedin.com/in/shashank-singhal-a87729b5/)
55 | - [Facebook](https://www.facebook.com/shashanksinghal02)
56 |
57 |
58 | Don't forget to star ⭐ the repo it motivates me to share more open source
59 |
60 |
61 | ## Donation
62 | If this project help you reduce time to develop, you can give me a cup of coffee :)
63 |
64 |
65 |
66 | ## License
67 |
68 | ```
69 | MIT License
70 |
71 | Copyright (c) 2021 Shashank Singhal
72 |
73 | Permission is hereby granted, free of charge, to any person obtaining a copy
74 | of this software and associated documentation files (the "Software"), to deal
75 | in the Software without restriction, including without limitation the rights
76 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
77 | copies of the Software, and to permit persons to whom the Software is
78 | furnished to do so, subject to the following conditions:
79 |
80 | The above copyright notice and this permission notice shall be included in all
81 | copies or substantial portions of the Software.
82 |
83 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
84 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
85 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
86 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
87 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
88 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
89 | SOFTWARE.```
90 |
--------------------------------------------------------------------------------
/Screenshot/Screenshot_20210428-050132.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Shashank02051997/WeatherApp-Android/44bfe589c76c528a4158ecdb1bbb77041ed71053/Screenshot/Screenshot_20210428-050132.png
--------------------------------------------------------------------------------
/Screenshot/Screenshot_20210428-050143.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Shashank02051997/WeatherApp-Android/44bfe589c76c528a4158ecdb1bbb77041ed71053/Screenshot/Screenshot_20210428-050143.png
--------------------------------------------------------------------------------
/Screenshot/Screenshot_20210428-055501.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Shashank02051997/WeatherApp-Android/44bfe589c76c528a4158ecdb1bbb77041ed71053/Screenshot/Screenshot_20210428-055501.png
--------------------------------------------------------------------------------
/Screenshot/Screenshot_20210428-055510.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Shashank02051997/WeatherApp-Android/44bfe589c76c528a4158ecdb1bbb77041ed71053/Screenshot/Screenshot_20210428-055510.png
--------------------------------------------------------------------------------
/app-DEV-debug.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Shashank02051997/WeatherApp-Android/44bfe589c76c528a4158ecdb1bbb77041ed71053/app-DEV-debug.apk
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.application'
3 | id 'kotlin-android'
4 | id 'kotlin-android-extensions'
5 | id 'kotlin-kapt'
6 | }
7 |
8 | android {
9 | compileSdkVersion 30
10 | buildToolsVersion "30.0.3"
11 |
12 | defaultConfig {
13 | applicationId "com.shashank.weatherapp"
14 | minSdkVersion 21
15 | targetSdkVersion 30
16 | versionCode 1
17 | versionName "1.0"
18 |
19 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
20 |
21 | buildConfigField "String", "weather_api_key", '"094aa776d64c50d5b9e9043edd4ffd00"'
22 |
23 | }
24 |
25 | flavorDimensions 'mode'
26 | productFlavors {
27 | DEV {
28 | applicationId "com.shashank.weatherapp.dev"
29 | dimension = 'mode'
30 | resValue "string", "app_name", "Weather App Dev"
31 | resValue "string", "package_name", applicationId
32 | buildConfigField "String", "end_point", '"http://api.openweathermap.org/data/2.5/"'
33 | }
34 | PROD {
35 | applicationId "com.shashank.weatherapp"
36 | dimension = 'mode'
37 | resValue "string", "app_name", "Weather App"
38 | resValue "string", "package_name", applicationId
39 | buildConfigField "String", "end_point", '"http://api.openweathermap.org/data/2.5/"'
40 | }
41 |
42 | }
43 | buildTypes {
44 | debug {
45 | minifyEnabled false
46 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
47 | }
48 | release {
49 | minifyEnabled false
50 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
51 | }
52 | }
53 | compileOptions {
54 | sourceCompatibility JavaVersion.VERSION_1_8
55 | targetCompatibility JavaVersion.VERSION_1_8
56 | }
57 | kotlinOptions {
58 | jvmTarget = '1.8'
59 | }
60 | buildFeatures {
61 | dataBinding true
62 | }
63 | }
64 |
65 | dependencies {
66 |
67 | implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
68 | implementation 'androidx.core:core-ktx:1.6.0'
69 | implementation 'androidx.appcompat:appcompat:1.3.1'
70 | implementation 'com.google.android.material:material:1.4.0'
71 | implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
72 |
73 | // Coroutines
74 | implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0'
75 |
76 | // Retrofit
77 | implementation 'com.squareup.retrofit2:retrofit:2.9.0'
78 | implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
79 | implementation 'com.squareup.okhttp3:logging-interceptor:4.9.0'
80 |
81 | def lifecycle_version = "2.3.1"
82 | // ViewModel and LiveData
83 | implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
84 | implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
85 |
86 |
87 | def kodein_version = '6.3.1'
88 | //Kodein Dependency Injection
89 | implementation "org.kodein.di:kodein-di-generic-jvm:$kodein_version"
90 | implementation "org.kodein.di:kodein-di-framework-android-x:$kodein_version"
91 |
92 | def room_version = '2.3.0'
93 | //Room
94 | implementation "androidx.room:room-runtime:$room_version"
95 | implementation "androidx.room:room-ktx:$room_version"
96 | kapt "androidx.room:room-compiler:$room_version"
97 |
98 | //For Image Loading
99 | implementation 'com.github.bumptech.glide:glide:4.12.0'
100 | implementation 'androidx.legacy:legacy-support-v4:1.0.0'
101 |
102 | testImplementation 'junit:junit:4.13.2'
103 | androidTestImplementation 'androidx.test.ext:junit:1.1.3'
104 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
105 | }
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/shashank/weatherapp/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.shashank.weatherapp
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("com.shashank.weatherapp", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
19 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/app/src/main/java/com/shashank/weatherapp/WeatherApplication.kt:
--------------------------------------------------------------------------------
1 | package com.shashank.weatherapp
2 |
3 | import android.app.Application
4 | import com.shashank.weatherapp.data.local.WeatherDatabase
5 | import com.shashank.weatherapp.data.network.ApiInterface
6 | import com.shashank.weatherapp.data.network.NetworkConnectionInterceptor
7 | import com.shashank.weatherapp.data.repositories.WeatherRepository
8 | import com.shashank.weatherapp.ui.viewmodelfactory.WeatherViewModelFactory
9 | import org.kodein.di.Kodein
10 | import org.kodein.di.KodeinAware
11 | import org.kodein.di.android.x.androidXModule
12 | import org.kodein.di.generic.bind
13 | import org.kodein.di.generic.instance
14 | import org.kodein.di.generic.provider
15 | import org.kodein.di.generic.singleton
16 |
17 | class WeatherApplication : Application(), KodeinAware {
18 |
19 | override val kodein = Kodein.lazy {
20 | import(androidXModule(this@WeatherApplication))
21 |
22 | bind() from singleton { NetworkConnectionInterceptor(instance()) }
23 | bind() from singleton { ApiInterface(instance()) }
24 | bind() from singleton { WeatherRepository(instance(), instance()) }
25 | bind() from provider { WeatherViewModelFactory(instance()) }
26 | bind() from provider { WeatherDatabase(instance()) }
27 | }
28 |
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/app/src/main/java/com/shashank/weatherapp/data/local/WeatherDatabase.kt:
--------------------------------------------------------------------------------
1 | package com.shashank.weatherapp.data.local
2 |
3 | import android.content.Context
4 | import androidx.room.Database
5 | import androidx.room.Room
6 | import androidx.room.RoomDatabase
7 | import com.shashank.weatherapp.data.local.dao.WeatherDetailDao
8 | import com.shashank.weatherapp.data.model.WeatherDetail
9 |
10 | @Database(
11 | entities = [WeatherDetail::class],
12 | version = 1
13 | )
14 | abstract class WeatherDatabase : RoomDatabase() {
15 |
16 | abstract fun getWeatherDao(): WeatherDetailDao
17 |
18 | companion object {
19 | const val DB_NAME = "weather_database"
20 |
21 | @Volatile
22 | private var INSTANCE: WeatherDatabase? = null
23 |
24 | operator fun invoke(context: Context) = INSTANCE ?: synchronized(this) {
25 | INSTANCE ?: buildDatabase(context).also {
26 | INSTANCE = it
27 | }
28 | }
29 |
30 | private fun buildDatabase(context: Context) =
31 | Room.databaseBuilder(
32 | context.applicationContext,
33 | WeatherDatabase::class.java,
34 | DB_NAME
35 | ).build()
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/app/src/main/java/com/shashank/weatherapp/data/local/dao/WeatherDetailDao.kt:
--------------------------------------------------------------------------------
1 | package com.shashank.weatherapp.data.local.dao
2 |
3 | import androidx.room.Dao
4 | import androidx.room.Insert
5 | import androidx.room.OnConflictStrategy
6 | import androidx.room.Query
7 | import com.shashank.weatherapp.data.model.WeatherDetail
8 |
9 | @Dao
10 | interface WeatherDetailDao {
11 |
12 | /**
13 | * Duplicate values are replaced in the table.
14 | */
15 | @Insert(onConflict = OnConflictStrategy.REPLACE)
16 | suspend fun addWeather(weatherDetail: WeatherDetail)
17 |
18 | @Query("SELECT * FROM ${WeatherDetail.TABLE_NAME} WHERE cityName = :cityName")
19 | suspend fun fetchWeatherByCity(cityName: String): WeatherDetail?
20 |
21 | @Query("SELECT * FROM ${WeatherDetail.TABLE_NAME}")
22 | suspend fun fetchAllWeatherDetails(): List
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/app/src/main/java/com/shashank/weatherapp/data/model/WeatherDataResponse.kt:
--------------------------------------------------------------------------------
1 | package com.shashank.weatherapp.data.model
2 |
3 |
4 | import androidx.annotation.Keep
5 | import com.google.gson.annotations.SerializedName
6 |
7 | @Keep
8 | data class WeatherDataResponse(
9 | @SerializedName("base")
10 | val base: String,
11 | @SerializedName("clouds")
12 | val clouds: Clouds,
13 | @SerializedName("cod")
14 | val cod: Int,
15 | @SerializedName("coord")
16 | val coord: Coord,
17 | @SerializedName("dt")
18 | val dt: Int,
19 | @SerializedName("id")
20 | val id: Int,
21 | @SerializedName("main")
22 | val main: Main,
23 | @SerializedName("name")
24 | val name: String,
25 | @SerializedName("sys")
26 | val sys: Sys,
27 | @SerializedName("timezone")
28 | val timezone: Int,
29 | @SerializedName("visibility")
30 | val visibility: Int,
31 | @SerializedName("weather")
32 | val weather: List,
33 | @SerializedName("wind")
34 | val wind: Wind
35 | ) {
36 | @Keep
37 | data class Clouds(
38 | @SerializedName("all")
39 | val all: Int
40 | )
41 |
42 | @Keep
43 | data class Coord(
44 | @SerializedName("lat")
45 | val lat: Double,
46 | @SerializedName("lon")
47 | val lon: Double
48 | )
49 |
50 | @Keep
51 | data class Main(
52 | @SerializedName("feels_like")
53 | val feelsLike: Double,
54 | @SerializedName("grnd_level")
55 | val grndLevel: Int,
56 | @SerializedName("humidity")
57 | val humidity: Int,
58 | @SerializedName("pressure")
59 | val pressure: Int,
60 | @SerializedName("sea_level")
61 | val seaLevel: Int,
62 | @SerializedName("temp")
63 | val temp: Double,
64 | @SerializedName("temp_max")
65 | val tempMax: Double,
66 | @SerializedName("temp_min")
67 | val tempMin: Double
68 | )
69 |
70 | @Keep
71 | data class Sys(
72 | @SerializedName("country")
73 | val country: String,
74 | @SerializedName("sunrise")
75 | val sunrise: Int,
76 | @SerializedName("sunset")
77 | val sunset: Int
78 | )
79 |
80 | @Keep
81 | data class Weather(
82 | @SerializedName("description")
83 | val description: String,
84 | @SerializedName("icon")
85 | val icon: String,
86 | @SerializedName("id")
87 | val id: Int,
88 | @SerializedName("main")
89 | val main: String
90 | )
91 |
92 | @Keep
93 | data class Wind(
94 | @SerializedName("deg")
95 | val deg: Int,
96 | @SerializedName("gust")
97 | val gust: Double,
98 | @SerializedName("speed")
99 | val speed: Double
100 | )
101 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/shashank/weatherapp/data/model/WeatherDetail.kt:
--------------------------------------------------------------------------------
1 | package com.shashank.weatherapp.data.model
2 |
3 | import androidx.room.Entity
4 | import androidx.room.PrimaryKey
5 | import com.shashank.weatherapp.data.model.WeatherDetail.Companion.TABLE_NAME
6 |
7 | /**
8 | * Data class for Database entity and Serialization.
9 | */
10 | @Entity(tableName = TABLE_NAME)
11 | data class WeatherDetail(
12 |
13 | @PrimaryKey
14 | var id: Int? = 0,
15 | var temp: Double? = null,
16 | var icon: String? = null,
17 | var cityName: String? = null,
18 | var countryName: String? = null,
19 | var dateTime: String? = null
20 | ) {
21 | companion object {
22 | const val TABLE_NAME = "weather_detail"
23 | }
24 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/shashank/weatherapp/data/network/ApiInterface.kt:
--------------------------------------------------------------------------------
1 | package com.shashank.weatherapp.data.network
2 |
3 | import com.shashank.weatherapp.BuildConfig
4 | import com.shashank.weatherapp.data.model.WeatherDataResponse
5 | import com.shashank.weatherapp.util.AppConstants
6 | import okhttp3.OkHttpClient
7 | import okhttp3.logging.HttpLoggingInterceptor
8 | import retrofit2.Response
9 | import retrofit2.Retrofit
10 | import retrofit2.converter.gson.GsonConverterFactory
11 | import retrofit2.http.GET
12 | import retrofit2.http.Query
13 | import java.util.concurrent.TimeUnit
14 |
15 | interface ApiInterface {
16 |
17 | //
18 |
19 | @GET("weather")
20 | suspend fun findCityWeatherData(
21 | @Query("q") q: String,
22 | @Query("units") units: String = AppConstants.WEATHER_UNIT,
23 | @Query("appid") appid: String = BuildConfig.weather_api_key
24 | ): Response
25 |
26 | //
27 |
28 | companion object {
29 | operator fun invoke(
30 | networkConnectionInterceptor: NetworkConnectionInterceptor
31 | ): ApiInterface {
32 |
33 | val WS_SERVER_URL = BuildConfig.end_point
34 | val okkHttpclient = OkHttpClient.Builder()
35 | .addInterceptor(networkConnectionInterceptor)
36 | .addInterceptor(HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY))
37 | .connectTimeout(1, TimeUnit.MINUTES)
38 | .readTimeout(60, TimeUnit.SECONDS)
39 | .writeTimeout(60, TimeUnit.SECONDS)
40 | .build()
41 |
42 | return Retrofit.Builder()
43 | .client(okkHttpclient)
44 | .baseUrl(WS_SERVER_URL)
45 | .addConverterFactory(GsonConverterFactory.create())
46 | .build()
47 | .create(ApiInterface::class.java)
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/app/src/main/java/com/shashank/weatherapp/data/network/NetworkConnectionInterceptor.kt:
--------------------------------------------------------------------------------
1 | package com.shashank.weatherapp.data.network
2 |
3 | import android.annotation.SuppressLint
4 | import android.content.Context
5 | import android.net.ConnectivityManager
6 | import android.net.NetworkCapabilities
7 | import android.os.Build
8 | import androidx.annotation.RequiresApi
9 | import com.shashank.weatherapp.util.NoInternetException
10 | import okhttp3.Interceptor
11 | import okhttp3.Response
12 |
13 | class NetworkConnectionInterceptor(
14 | context: Context
15 | ) : Interceptor {
16 |
17 | private val applicationContext = context.applicationContext
18 |
19 | @RequiresApi(Build.VERSION_CODES.M)
20 | override fun intercept(chain: Interceptor.Chain): Response {
21 | if (!isInternetAvailable())
22 | throw NoInternetException("Make sure you have an active data connection")
23 | return chain.proceed(chain.request())
24 | }
25 |
26 | @SuppressLint("MissingPermission")
27 | @RequiresApi(Build.VERSION_CODES.M)
28 | private fun isInternetAvailable(): Boolean {
29 | var result = false
30 | val connectivityManager =
31 | applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager?
32 | connectivityManager?.let {
33 | it.getNetworkCapabilities(connectivityManager.activeNetwork)?.apply {
34 | result = when {
35 | hasTransport(NetworkCapabilities.TRANSPORT_WIFI) -> true
36 | hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) -> true
37 | else -> false
38 | }
39 | }
40 | }
41 | return result
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/app/src/main/java/com/shashank/weatherapp/data/network/SafeApiRequest.kt:
--------------------------------------------------------------------------------
1 | package com.shashank.weatherapp.data.network
2 |
3 | import com.shashank.weatherapp.util.ApiException
4 | import org.json.JSONException
5 | import org.json.JSONObject
6 | import retrofit2.Response
7 |
8 | abstract class SafeApiRequest {
9 |
10 | suspend fun apiRequest(call: suspend () -> Response): T {
11 | val response = call.invoke()
12 | if (response.isSuccessful && response.body() != null) {
13 | return response.body()!!
14 | } else {
15 | val error = response.errorBody()?.string()
16 |
17 | val message = StringBuilder()
18 | error?.let {
19 | try {
20 | message.append(JSONObject(it).getString("message"))
21 | } catch (e: JSONException) {
22 | }
23 | }
24 | throw ApiException(message.toString())
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/main/java/com/shashank/weatherapp/data/repositories/WeatherRepository.kt:
--------------------------------------------------------------------------------
1 | package com.shashank.weatherapp.data.repositories
2 |
3 | import com.shashank.weatherapp.data.local.WeatherDatabase
4 | import com.shashank.weatherapp.data.model.WeatherDataResponse
5 | import com.shashank.weatherapp.data.model.WeatherDetail
6 | import com.shashank.weatherapp.data.network.ApiInterface
7 | import com.shashank.weatherapp.data.network.SafeApiRequest
8 |
9 | class WeatherRepository(
10 | private val api: ApiInterface,
11 | private val db: WeatherDatabase
12 | ) : SafeApiRequest() {
13 |
14 | suspend fun findCityWeather(cityName: String): WeatherDataResponse = apiRequest {
15 | api.findCityWeatherData(cityName)
16 | }
17 |
18 | suspend fun addWeather(weatherDetail: WeatherDetail) {
19 | db.getWeatherDao().addWeather(weatherDetail)
20 | }
21 |
22 | suspend fun fetchWeatherDetail(cityName: String): WeatherDetail? =
23 | db.getWeatherDao().fetchWeatherByCity(cityName)
24 |
25 | suspend fun fetchAllWeatherDetails(): List =
26 | db.getWeatherDao().fetchAllWeatherDetails()
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/main/java/com/shashank/weatherapp/ui/activities/WeatherActivity.kt:
--------------------------------------------------------------------------------
1 | package com.shashank.weatherapp.ui.activities
2 |
3 | import android.annotation.SuppressLint
4 | import android.os.Bundle
5 | import android.view.inputmethod.EditorInfo
6 | import android.widget.EditText
7 | import androidx.appcompat.app.AppCompatActivity
8 | import androidx.databinding.DataBindingUtil
9 | import androidx.lifecycle.ViewModelProvider
10 | import androidx.recyclerview.widget.DefaultItemAnimator
11 | import androidx.recyclerview.widget.LinearLayoutManager
12 | import com.shashank.weatherapp.R
13 | import com.shashank.weatherapp.databinding.ActivityWeatherBinding
14 | import com.shashank.weatherapp.ui.adapters.CustomAdapterSearchedCityTemperature
15 | import com.shashank.weatherapp.ui.viewmodel.WeatherViewModel
16 | import com.shashank.weatherapp.ui.viewmodelfactory.WeatherViewModelFactory
17 | import com.shashank.weatherapp.util.*
18 | import org.kodein.di.KodeinAware
19 | import org.kodein.di.android.closestKodein
20 | import org.kodein.di.generic.instance
21 |
22 | class WeatherActivity : AppCompatActivity(), KodeinAware {
23 |
24 | override val kodein by closestKodein()
25 | private lateinit var dataBind: ActivityWeatherBinding
26 | private val factory: WeatherViewModelFactory by instance()
27 | private val viewModel: WeatherViewModel by lazy {
28 | ViewModelProvider(this, factory).get(WeatherViewModel::class.java)
29 | }
30 | private lateinit var customAdapterSearchedCityTemperature: CustomAdapterSearchedCityTemperature
31 |
32 | override fun onCreate(savedInstanceState: Bundle?) {
33 | super.onCreate(savedInstanceState)
34 | dataBind = DataBindingUtil.setContentView(this, R.layout.activity_weather)
35 | setupUI()
36 | observeAPICall()
37 | }
38 |
39 | private fun setupUI() {
40 | initializeRecyclerView()
41 | dataBind.inputFindCityWeather.setOnEditorActionListener { view, actionId, event ->
42 | if (actionId == EditorInfo.IME_ACTION_DONE) {
43 | viewModel.fetchWeatherDetailFromDb((view as EditText).text.toString())
44 | viewModel.fetchAllWeatherDetailsFromDb()
45 | }
46 | false
47 | }
48 | }
49 |
50 | private fun initializeRecyclerView() {
51 | customAdapterSearchedCityTemperature = CustomAdapterSearchedCityTemperature()
52 | val mLayoutManager = LinearLayoutManager(
53 | this,
54 | LinearLayoutManager.HORIZONTAL,
55 | false
56 | )
57 | dataBind.recyclerViewSearchedCityTemperature.apply {
58 | layoutManager = mLayoutManager
59 | itemAnimator = DefaultItemAnimator()
60 | adapter = customAdapterSearchedCityTemperature
61 | }
62 | }
63 |
64 | @SuppressLint("SetTextI18n")
65 | private fun observeAPICall() {
66 | viewModel.weatherLiveData.observe(this, EventObserver { state ->
67 | when (state) {
68 | is State.Loading -> {
69 | }
70 | is State.Success -> {
71 | dataBind.textLabelSearchForCity.hide()
72 | dataBind.imageCity.hide()
73 | dataBind.constraintLayoutShowingTemp.show()
74 | dataBind.inputFindCityWeather.text?.clear()
75 | state.data.let { weatherDetail ->
76 | val iconCode = weatherDetail.icon?.replace("n", "d")
77 | AppUtils.setGlideImage(
78 | dataBind.imageWeatherSymbol,
79 | AppConstants.WEATHER_API_IMAGE_ENDPOINT + "${iconCode}@4x.png"
80 | )
81 | changeBgAccToTemp(iconCode)
82 | dataBind.textTodaysDate.text =
83 | AppUtils.getCurrentDateTime(AppConstants.DATE_FORMAT)
84 | dataBind.textTemperature.text = weatherDetail.temp.toString()
85 | dataBind.textCityName.text =
86 | "${weatherDetail.cityName?.capitalize()}, ${weatherDetail.countryName}"
87 | }
88 |
89 | }
90 | is State.Error -> {
91 | showToast(state.message)
92 | }
93 | }
94 | })
95 |
96 | viewModel.weatherDetailListLiveData.observe(this, EventObserver { state ->
97 | when (state) {
98 | is State.Loading -> {
99 | }
100 | is State.Success -> {
101 | if (state.data.isEmpty()) {
102 | dataBind.recyclerViewSearchedCityTemperature.hide()
103 | } else {
104 | dataBind.recyclerViewSearchedCityTemperature.show()
105 | customAdapterSearchedCityTemperature.setData(state.data)
106 | }
107 | }
108 | is State.Error -> {
109 | showToast(state.message)
110 | }
111 | }
112 | })
113 | }
114 |
115 | private fun changeBgAccToTemp(iconCode: String?) {
116 | when (iconCode) {
117 | "01d", "02d", "03d" -> dataBind.imageWeatherHumanReaction.setImageResource(R.drawable.sunny_day)
118 | "04d", "09d", "10d", "11d" -> dataBind.imageWeatherHumanReaction.setImageResource(R.drawable.raining)
119 | "13d", "50d" -> dataBind.imageWeatherHumanReaction.setImageResource(R.drawable.snowfalling)
120 | }
121 | }
122 |
123 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/shashank/weatherapp/ui/adapters/CustomAdapterSearchedCityTemperature.kt:
--------------------------------------------------------------------------------
1 | package com.shashank.weatherapp.ui.adapters
2 |
3 | import android.annotation.SuppressLint
4 | import android.view.LayoutInflater
5 | import android.view.ViewGroup
6 | import androidx.databinding.DataBindingUtil
7 | import androidx.recyclerview.widget.RecyclerView
8 | import com.shashank.weatherapp.R
9 | import com.shashank.weatherapp.data.model.WeatherDetail
10 | import com.shashank.weatherapp.databinding.ListItemSearchedCityTemperatureBinding
11 | import com.shashank.weatherapp.util.AppConstants
12 | import com.shashank.weatherapp.util.AppUtils
13 |
14 | class CustomAdapterSearchedCityTemperature :
15 | RecyclerView.Adapter() {
16 |
17 | private val weatherDetailList = ArrayList()
18 |
19 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
20 | val binding: ListItemSearchedCityTemperatureBinding = DataBindingUtil.inflate(
21 | LayoutInflater.from(parent.context),
22 | R.layout.list_item_searched_city_temperature,
23 | parent,
24 | false
25 | )
26 | return ViewHolder(binding)
27 | }
28 |
29 | override fun onBindViewHolder(holder: ViewHolder, position: Int) {
30 | holder.bindItems(weatherDetailList[position])
31 | }
32 |
33 | override fun getItemCount(): Int = weatherDetailList.size
34 |
35 | fun setData(
36 | newWeatherDetail: List
37 | ) {
38 | weatherDetailList.clear()
39 | weatherDetailList.addAll(newWeatherDetail)
40 | notifyDataSetChanged()
41 | }
42 |
43 | inner class ViewHolder(private val binding: ListItemSearchedCityTemperatureBinding) :
44 | RecyclerView.ViewHolder(binding.root) {
45 |
46 | @SuppressLint("SetTextI18n")
47 | fun bindItems(weatherDetail: WeatherDetail) {
48 | binding.apply {
49 | val iconCode = weatherDetail.icon?.replace("n", "d")
50 | AppUtils.setGlideImage(
51 | imageWeatherSymbol,
52 | AppConstants.WEATHER_API_IMAGE_ENDPOINT + "${iconCode}@4x.png"
53 | )
54 | textCityName.text =
55 | "${weatherDetail.cityName?.capitalize()}, ${weatherDetail.countryName}"
56 | textTemperature.text = weatherDetail.temp.toString()
57 | textDateTime.text = weatherDetail.dateTime
58 | }
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/app/src/main/java/com/shashank/weatherapp/ui/viewmodel/WeatherViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.shashank.weatherapp.ui.viewmodel
2 |
3 | import androidx.lifecycle.LiveData
4 | import androidx.lifecycle.MutableLiveData
5 | import androidx.lifecycle.ViewModel
6 | import androidx.lifecycle.viewModelScope
7 | import com.shashank.weatherapp.data.model.WeatherDataResponse
8 | import com.shashank.weatherapp.data.model.WeatherDetail
9 | import com.shashank.weatherapp.data.repositories.WeatherRepository
10 | import com.shashank.weatherapp.util.*
11 | import kotlinx.coroutines.Dispatchers
12 | import kotlinx.coroutines.launch
13 | import kotlinx.coroutines.withContext
14 |
15 | class WeatherViewModel(private val repository: WeatherRepository) :
16 | ViewModel() {
17 |
18 | private val _weatherLiveData =
19 | MutableLiveData>>()
20 | val weatherLiveData: LiveData>>
21 | get() = _weatherLiveData
22 |
23 | private val _weatherDetailListLiveData =
24 | MutableLiveData>>>()
25 | val weatherDetailListLiveData: LiveData>>>
26 | get() = _weatherDetailListLiveData
27 |
28 | private lateinit var weatherResponse: WeatherDataResponse
29 |
30 | private fun findCityWeather(cityName: String) {
31 | _weatherLiveData.postValue(Event(State.loading()))
32 | viewModelScope.launch(Dispatchers.IO) {
33 | try {
34 | weatherResponse =
35 | repository.findCityWeather(cityName)
36 | addWeatherDetailIntoDb(weatherResponse)
37 | withContext(Dispatchers.Main) {
38 | val weatherDetail = WeatherDetail()
39 | weatherDetail.icon = weatherResponse.weather.first().icon
40 | weatherDetail.cityName = weatherResponse.name
41 | weatherDetail.countryName = weatherResponse.sys.country
42 | weatherDetail.temp = weatherResponse.main.temp
43 | _weatherLiveData.postValue(
44 | Event(
45 | State.success(
46 | weatherDetail
47 | )
48 | )
49 | )
50 | }
51 | } catch (e: ApiException) {
52 | withContext(Dispatchers.Main) {
53 | _weatherLiveData.postValue(Event(State.error(e.message ?: "")))
54 | }
55 | } catch (e: NoInternetException) {
56 | withContext(Dispatchers.Main) {
57 | _weatherLiveData.postValue(Event(State.error(e.message ?: "")))
58 | }
59 | } catch (e: Exception) {
60 | withContext(Dispatchers.Main) {
61 | _weatherLiveData.postValue(
62 | Event(
63 | State.error(
64 | e.message ?: ""
65 | )
66 | )
67 | )
68 | }
69 | }
70 | }
71 | }
72 |
73 | private suspend fun addWeatherDetailIntoDb(weatherResponse: WeatherDataResponse) {
74 | val weatherDetail = WeatherDetail()
75 | weatherDetail.id = weatherResponse.id
76 | weatherDetail.icon = weatherResponse.weather.first().icon
77 | weatherDetail.cityName = weatherResponse.name.toLowerCase()
78 | weatherDetail.countryName = weatherResponse.sys.country
79 | weatherDetail.temp = weatherResponse.main.temp
80 | weatherDetail.dateTime = AppUtils.getCurrentDateTime(AppConstants.DATE_FORMAT_1)
81 | repository.addWeather(weatherDetail)
82 | }
83 |
84 | fun fetchWeatherDetailFromDb(cityName: String) {
85 | viewModelScope.launch(Dispatchers.IO) {
86 | val weatherDetail = repository.fetchWeatherDetail(cityName.toLowerCase())
87 | withContext(Dispatchers.Main) {
88 | if (weatherDetail != null) {
89 | // Return true of current date and time is greater then the saved date and time of weather searched
90 | if (AppUtils.isTimeExpired(weatherDetail.dateTime)) {
91 | findCityWeather(cityName)
92 | } else {
93 | _weatherLiveData.postValue(
94 | Event(
95 | State.success(
96 | weatherDetail
97 | )
98 | )
99 | )
100 | }
101 |
102 | } else {
103 | findCityWeather(cityName)
104 | }
105 |
106 | }
107 | }
108 | }
109 |
110 | fun fetchAllWeatherDetailsFromDb() {
111 | viewModelScope.launch(Dispatchers.IO) {
112 | val weatherDetailList = repository.fetchAllWeatherDetails()
113 | withContext(Dispatchers.Main) {
114 | _weatherDetailListLiveData.postValue(
115 | Event(
116 | State.success(weatherDetailList)
117 | )
118 | )
119 | }
120 | }
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/app/src/main/java/com/shashank/weatherapp/ui/viewmodelfactory/WeatherViewModelFactory.kt:
--------------------------------------------------------------------------------
1 | package com.shashank.weatherapp.ui.viewmodelfactory
2 |
3 | import androidx.lifecycle.ViewModel
4 | import androidx.lifecycle.ViewModelProvider
5 | import com.shashank.weatherapp.data.repositories.WeatherRepository
6 | import com.shashank.weatherapp.ui.viewmodel.WeatherViewModel
7 |
8 | @Suppress("UNCHECKED_CAST")
9 | class WeatherViewModelFactory(
10 | private val repository: WeatherRepository
11 | ) : ViewModelProvider.NewInstanceFactory() {
12 |
13 | override fun create(modelClass: Class): T {
14 | return WeatherViewModel(repository) as T
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/app/src/main/java/com/shashank/weatherapp/util/AppConstants.kt:
--------------------------------------------------------------------------------
1 | package com.shashank.weatherapp.util
2 |
3 | object AppConstants {
4 |
5 | const val DATE_FORMAT = "E, d MMM yyyy"
6 | const val DATE_FORMAT_1 = "E, d MMM yyyy HH:mm:ss"
7 | const val WEATHER_UNIT = "metric"
8 | const val WEATHER_API_IMAGE_ENDPOINT = "http://openweathermap.org/img/wn/"
9 | }
10 |
--------------------------------------------------------------------------------
/app/src/main/java/com/shashank/weatherapp/util/AppUtils.kt:
--------------------------------------------------------------------------------
1 | package com.shashank.weatherapp.util
2 |
3 | import android.annotation.SuppressLint
4 | import android.content.Context
5 | import android.widget.ImageView
6 | import com.bumptech.glide.Glide
7 | import java.text.SimpleDateFormat
8 | import java.util.*
9 |
10 | object AppUtils {
11 |
12 | fun showProgressBar(requireContext: Context) {
13 | if (!ProgressBar.getInstance().isDialogShowing()) {
14 | ProgressBar.getInstance().showProgress(requireContext, false)
15 | }
16 | }
17 |
18 | fun hideProgressBar() {
19 | ProgressBar.getInstance().dismissProgress()
20 | }
21 |
22 | fun setGlideImage(image: ImageView, url: String) {
23 |
24 | Glide.with(image).load(url)
25 | .thumbnail(0.5f)
26 | .into(image)
27 |
28 | }
29 |
30 | @SuppressLint("SimpleDateFormat")
31 | fun getCurrentDateTime(dateFormat: String): String =
32 | SimpleDateFormat(dateFormat).format(Date())
33 |
34 | @SuppressLint("SimpleDateFormat")
35 | fun isTimeExpired(dateTimeSavedWeather: String?): Boolean {
36 | dateTimeSavedWeather?.let {
37 | val currentDateTime = Date()
38 | val savedWeatherDateTime =
39 | SimpleDateFormat(AppConstants.DATE_FORMAT_1).parse(it)
40 | val diff: Long = currentDateTime.time - savedWeatherDateTime.time
41 | val seconds = diff / 1000
42 | val minutes = seconds / 60
43 | if (minutes > 10)
44 | return true
45 | }
46 | return false
47 | }
48 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/shashank/weatherapp/util/CommonExtensions.kt:
--------------------------------------------------------------------------------
1 | package com.shashank.weatherapp.util
2 |
3 | import android.app.Activity
4 | import android.content.Context
5 | import android.content.Intent
6 | import android.util.DisplayMetrics
7 | import android.view.View
8 | import android.widget.Toast
9 | import androidx.core.content.ContextCompat
10 | import com.google.android.material.snackbar.Snackbar
11 |
12 |
13 | // used for simple start activity without Intent parameters
14 | fun Activity.goToActivity(newActivity: Class<*>) {
15 | val intent = Intent(this, newActivity)
16 | startActivity(intent)
17 | }
18 |
19 | // used for show a toast message in the UI Thread
20 | fun Context.showToast(message: String) {
21 | Toast.makeText(this, message, Toast.LENGTH_LONG).show()
22 | }
23 |
24 |
25 | fun Activity.screenWidth(): Int {
26 | val metrics: DisplayMetrics = DisplayMetrics()
27 | windowManager.defaultDisplay.getMetrics(metrics)
28 | return metrics.widthPixels
29 | }
30 |
31 | fun Activity.screenHeight(): Int {
32 | val metrics: DisplayMetrics = DisplayMetrics()
33 | windowManager.defaultDisplay.getMetrics(metrics)
34 | return metrics.heightPixels
35 | }
36 |
37 | fun Activity.color(resId: Int): Int {
38 | return ContextCompat.getColor(this, resId)
39 | }
40 |
41 | fun View.snackbar(message: String) {
42 | Snackbar.make(this, message, Snackbar.LENGTH_LONG).also { snackbar ->
43 | snackbar.setAction("Ok") {
44 | snackbar.dismiss()
45 | }
46 | }.show()
47 | }
48 |
49 |
50 | fun View.show() {
51 | visibility = View.VISIBLE
52 | }
53 |
54 | fun View.invisible() {
55 | visibility = View.INVISIBLE
56 | }
57 |
58 | fun View.hide() {
59 | visibility = View.GONE
60 | }
61 |
--------------------------------------------------------------------------------
/app/src/main/java/com/shashank/weatherapp/util/Event.kt:
--------------------------------------------------------------------------------
1 | package com.shashank.weatherapp.util
2 |
3 | open class Event(private val content: T) {
4 |
5 | var consumed = false
6 | private set // Allow external read but not write
7 |
8 | /**
9 | * Consumes the content if it's not been consumed yet.
10 | * @return The unconsumed content or `null` if it was consumed already.
11 | */
12 | fun consume(): T? {
13 | return if (consumed) {
14 | null
15 | } else {
16 | consumed = true
17 | content
18 | }
19 | }
20 |
21 | /**
22 | * @return The content whether it's been handled or not.
23 | */
24 | fun peek(): T = content
25 |
26 | override fun equals(other: Any?): Boolean {
27 | if (this === other) return true
28 | if (javaClass != other?.javaClass) return false
29 |
30 | other as Event<*>
31 |
32 | if (content != other.content) return false
33 | if (consumed != other.consumed) return false
34 |
35 | return true
36 | }
37 |
38 | override fun hashCode(): Int {
39 | var result = content?.hashCode() ?: 0
40 | result = 31 * result + consumed.hashCode()
41 | return result
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/app/src/main/java/com/shashank/weatherapp/util/EventObserver.kt:
--------------------------------------------------------------------------------
1 | package com.shashank.weatherapp.util
2 |
3 | import androidx.lifecycle.Observer
4 |
5 | /**
6 | * An [Observer] for [Event]s, simplifying the pattern of checking if the [Event]'s content has
7 | * already been consumed.
8 | *
9 | * [onEventUnconsumedContent] is *only* called if the [Event]'s contents has not been consumed.
10 | */
11 | class EventObserver(private val onEventUnconsumedContent: (T) -> Unit) : Observer> {
12 | override fun onChanged(event: Event?) {
13 | event?.consume()?.run(onEventUnconsumedContent)
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/app/src/main/java/com/shashank/weatherapp/util/Exceptions.kt:
--------------------------------------------------------------------------------
1 | package com.shashank.weatherapp.util
2 |
3 | import java.io.IOException
4 |
5 | class ApiException(message: String) : IOException(message)
6 | class NoInternetException(message: String) : IOException(message)
7 |
--------------------------------------------------------------------------------
/app/src/main/java/com/shashank/weatherapp/util/ProgressBar.kt:
--------------------------------------------------------------------------------
1 | package com.shashank.weatherapp.util
2 |
3 | import android.annotation.SuppressLint
4 | import android.app.Dialog
5 | import android.content.Context
6 | import android.view.Window
7 | import android.view.WindowManager
8 | import com.shashank.weatherapp.R
9 |
10 | class ProgressBar {
11 | private var dialog: Dialog? = null
12 |
13 | companion object {
14 |
15 | @SuppressLint("StaticFieldLeak")
16 | private var gifProgress: ProgressBar? = null
17 |
18 | fun getInstance(): ProgressBar {
19 | if (gifProgress == null) {
20 | gifProgress = ProgressBar()
21 | }
22 | return gifProgress as ProgressBar
23 | }
24 | }
25 |
26 | fun showProgress(context: Context, cancelable: Boolean) {
27 | dialog = Dialog(context)
28 |
29 | dialog?.requestWindowFeature(Window.FEATURE_NO_TITLE)
30 | dialog?.setContentView(R.layout.dialog_progress_bar)
31 |
32 | val layoutParams = WindowManager.LayoutParams()
33 | layoutParams.copyFrom(dialog?.window?.attributes)
34 | layoutParams.width = (context.resources.displayMetrics.widthPixels * 0.85).toInt()
35 | layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT
36 |
37 | dialog?.window?.setBackgroundDrawableResource(android.R.color.transparent)
38 | dialog?.window?.setLayout(layoutParams.width, layoutParams.height)
39 |
40 | dialog?.setCancelable(cancelable)
41 | dialog?.setCanceledOnTouchOutside(cancelable)
42 | if (dialog?.isShowing == false) {
43 | dialog?.show()
44 | }
45 | }
46 |
47 | fun dismissProgress() {
48 | if (dialog != null && isDialogShowing()) {
49 | dialog?.dismiss()
50 | dialog = null
51 | }
52 | }
53 |
54 | fun isDialogShowing(): Boolean {
55 | if (dialog != null) {
56 | return dialog!!.isShowing
57 | }
58 | return false
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/app/src/main/java/com/shashank/weatherapp/util/State.kt:
--------------------------------------------------------------------------------
1 | package com.shashank.weatherapp.util
2 |
3 | sealed class State {
4 | class Loading : State()
5 |
6 | data class Success(val data: T) : State()
7 |
8 | data class Error(val message: String) : State()
9 |
10 | companion object {
11 | fun loading() = Loading()
12 | fun success(data: T) = Success(data)
13 | fun error(message: String) = Error(message)
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/black_outline_square_rounded_shape_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/city_bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Shashank02051997/WeatherApp-Android/44bfe589c76c528a4158ecdb1bbb77041ed71053/app/src/main/res/drawable/city_bg.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_search.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/light_blue_square_rounded_shape_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Shashank02051997/WeatherApp-Android/44bfe589c76c528a4158ecdb1bbb77041ed71053/app/src/main/res/drawable/logo.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/raining.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Shashank02051997/WeatherApp-Android/44bfe589c76c528a4158ecdb1bbb77041ed71053/app/src/main/res/drawable/raining.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/snowfalling.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Shashank02051997/WeatherApp-Android/44bfe589c76c528a4158ecdb1bbb77041ed71053/app/src/main/res/drawable/snowfalling.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/sunny_day.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Shashank02051997/WeatherApp-Android/44bfe589c76c528a4158ecdb1bbb77041ed71053/app/src/main/res/drawable/sunny_day.png
--------------------------------------------------------------------------------
/app/src/main/res/font/calibri.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Shashank02051997/WeatherApp-Android/44bfe589c76c528a4158ecdb1bbb77041ed71053/app/src/main/res/font/calibri.ttf
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_weather.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
21 |
22 |
29 |
30 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
57 |
58 |
69 |
70 |
77 |
78 |
84 |
85 |
96 |
97 |
105 |
106 |
117 |
118 |
128 |
129 |
140 |
141 |
151 |
152 |
163 |
164 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_progress_bar.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/list_item_searched_city_temperature.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
12 |
13 |
20 |
21 |
31 |
32 |
46 |
47 |
48 |
59 |
60 |
69 |
70 |
71 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Shashank02051997/WeatherApp-Android/44bfe589c76c528a4158ecdb1bbb77041ed71053/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Shashank02051997/WeatherApp-Android/44bfe589c76c528a4158ecdb1bbb77041ed71053/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Shashank02051997/WeatherApp-Android/44bfe589c76c528a4158ecdb1bbb77041ed71053/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Shashank02051997/WeatherApp-Android/44bfe589c76c528a4158ecdb1bbb77041ed71053/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Shashank02051997/WeatherApp-Android/44bfe589c76c528a4158ecdb1bbb77041ed71053/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Shashank02051997/WeatherApp-Android/44bfe589c76c528a4158ecdb1bbb77041ed71053/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Shashank02051997/WeatherApp-Android/44bfe589c76c528a4158ecdb1bbb77041ed71053/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Shashank02051997/WeatherApp-Android/44bfe589c76c528a4158ecdb1bbb77041ed71053/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Shashank02051997/WeatherApp-Android/44bfe589c76c528a4158ecdb1bbb77041ed71053/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Shashank02051997/WeatherApp-Android/44bfe589c76c528a4158ecdb1bbb77041ed71053/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #10ADE2
4 | #10ADE2
5 | #000000
6 | #FFFFFF
7 | #000000
8 | #2D2D2D
9 | #5F5F5F
10 | #999999
11 | #E8E9F1
12 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Search
4 | Today
5 | Search City Weather
6 | Search for a city
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
13 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | // Text View
28 |
29 |
33 |
34 |
38 |
39 |
43 |
44 | // Toolbar Search View
45 |
46 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/network_security_config.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/test/java/com/shashank/weatherapp/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.shashank.weatherapp
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | ext.kotlin_version = "1.5.21"
3 | repositories {
4 | google()
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:7.0.0'
9 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
10 | }
11 | }
12 |
13 | allprojects {
14 | repositories {
15 | google()
16 | jcenter()
17 | maven { url 'https://jitpack.io' }
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app"s APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
20 | # Kotlin code style for this project: "official" or "obsolete":
21 | kotlin.code.style=official
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Shashank02051997/WeatherApp-Android/44bfe589c76c528a4158ecdb1bbb77041ed71053/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Apr 28 00:40:25 IST 2021
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 | rootProject.name = "Weather App"
--------------------------------------------------------------------------------