mirror of
https://github.com/hmalik144/Weather-apps.git
synced 2026-03-18 07:26:04 +00:00
- Removal of kotlin synthetics
- Upgrade gradle to 8.0.0 - Change dependency versioning
This commit is contained in:
137
app/build.gradle
137
app/build.gradle
@@ -1,7 +1,6 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'com.android.application'
|
id 'com.android.application'
|
||||||
id 'org.jetbrains.kotlin.android'
|
id 'org.jetbrains.kotlin.android'
|
||||||
id 'kotlin-android-extensions'
|
|
||||||
id 'kotlin-kapt'
|
id 'kotlin-kapt'
|
||||||
id 'androidx.navigation.safeargs'
|
id 'androidx.navigation.safeargs'
|
||||||
}
|
}
|
||||||
@@ -13,14 +12,12 @@ def relKeyAlias = System.getenv("RELEASE_KEY_ALIAS")
|
|||||||
def keystorePath = System.getenv('PWD') + "/app/keystore.jks"
|
def keystorePath = System.getenv('PWD') + "/app/keystore.jks"
|
||||||
def keystore = file(keystorePath).exists() ? file(keystorePath) : null
|
def keystore = file(keystorePath).exists() ? file(keystorePath) : null
|
||||||
android {
|
android {
|
||||||
lintOptions {
|
namespace 'com.appttude.h_mal.atlas_weather'
|
||||||
abortOnError false
|
compileSdk 33
|
||||||
}
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "com.appttude.h_mal.atlas_weather"
|
applicationId "com.appttude.h_mal.atlas_weather"
|
||||||
compileSdk 33
|
minSdkVersion MIN_SDK_VERSION
|
||||||
minSdkVersion 26
|
targetSdkVersion TARGET_SDK_VERSION
|
||||||
targetSdkVersion 33
|
|
||||||
versionCode 5
|
versionCode 5
|
||||||
versionName "3.0"
|
versionName "3.0"
|
||||||
testInstrumentationRunner "com.appttude.h_mal.atlas_weather.application.TestRunner"
|
testInstrumentationRunner "com.appttude.h_mal.atlas_weather.application.TestRunner"
|
||||||
@@ -78,7 +75,7 @@ android {
|
|||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
jvmTarget = "1.8"
|
jvmTarget = "1.8"
|
||||||
freeCompilerArgs += [
|
freeCompilerArgs += [
|
||||||
'-Xjvm-default=enable'
|
'-Xjvm-default=all-compatibility'
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,7 +88,6 @@ android {
|
|||||||
}
|
}
|
||||||
monoWeather {
|
monoWeather {
|
||||||
applicationId "com.appttude.h_mal.monoWeather"
|
applicationId "com.appttude.h_mal.monoWeather"
|
||||||
|
|
||||||
versionCode 7
|
versionCode 7
|
||||||
versionName "4.2.0"
|
versionName "4.2.0"
|
||||||
}
|
}
|
||||||
@@ -108,105 +104,90 @@ android {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
lint {
|
||||||
|
abortOnError false
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
implementation 'androidx.appcompat:appcompat:1.6.1'
|
implementation "androidx.appcompat:appcompat:$MATERIAL_VERSION"
|
||||||
implementation 'com.google.android.material:material:1.2.1'
|
implementation "com.google.android.material:material:$MATERIAL_VERSION"
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
implementation "androidx.constraintlayout:constraintlayout:$CONSTR_LAYOUT_VERSION"
|
||||||
implementation 'androidx.fragment:fragment:1.2.0'
|
implementation "androidx.fragment:fragment:$FRAGMENT_VERSION"
|
||||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
implementation "androidx.legacy:legacy-support-v4:$LEGACY_SUPPORT_VERSION"
|
||||||
implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
|
|
||||||
implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
|
implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
|
||||||
implementation "com.google.android.gms:play-services-location:21.0.1"
|
implementation "com.google.android.gms:play-services-location:$GOOGLE_PLAY_SERVICE"
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$KOTLIN_VERSION"
|
||||||
implementation 'androidx.cardview:cardview:1.0.0'
|
implementation 'androidx.cardview:cardview:1.0.0'
|
||||||
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2'
|
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$KOTLINX_COROUTINES"
|
||||||
implementation 'androidx.preference:preference:1.2.1'
|
implementation "androidx.preference:preference:$PREFERENCES_VERSION"
|
||||||
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.1'
|
|
||||||
/ * Unit testing * /
|
/ * Unit testing * /
|
||||||
testImplementation 'junit:junit:4.13.2'
|
testImplementation "junit:junit:$JUNIT_VERSION"
|
||||||
androidTestImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
|
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$KOTLIN_VERSION"
|
||||||
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
|
implementation "org.jetbrains.kotlin:kotlin-test:$KOTLIN_VERSION"
|
||||||
implementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
|
androidTestImplementation "junit:junit:$JUNIT_VERSION"
|
||||||
|
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$KOTLINX_COROUTINES"
|
||||||
|
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$KOTLINX_COROUTINES"
|
||||||
/ * Fragment Navigation * /
|
/ * Fragment Navigation * /
|
||||||
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.2'
|
implementation "androidx.navigation:navigation-fragment-ktx:$NAVIGATION_VERSION"
|
||||||
implementation 'androidx.navigation:navigation-ui-ktx:2.3.2'
|
implementation "androidx.navigation:navigation-ui-ktx:$NAVIGATION_VERSION"
|
||||||
/ * android unit testing and espresso * /
|
/ * android unit testing and espresso * /
|
||||||
androidTestImplementation 'androidx.test:rules:1.5.0'
|
androidTestImplementation "androidx.test:rules:$TEST_KTX_VERSION"
|
||||||
androidTestImplementation "androidx.test:core:1.5.0"
|
androidTestImplementation 'androidx.test:core:1.5.0'
|
||||||
|
androidTestImplementation 'androidx.test:monitor:1.6.1'
|
||||||
/ * Android Espresso * /
|
androidTestImplementation "androidx.test.ext:junit:$TEST_JUNIT_VERSION"
|
||||||
def testJunitVersion = "1.1.5"
|
androidTestImplementation "org.jetbrains.kotlin:kotlin-test-junit:$KOTLIN_VERSION"
|
||||||
def testRunnerVersion = "1.5.2"
|
androidTestImplementation "androidx.test.espresso:espresso-core:$ESPRESSO_VERSION"
|
||||||
def espressoVersion = "3.5.1"
|
implementation "androidx.test.espresso:espresso-idling-resource:$ESPRESSO_VERSION"
|
||||||
androidTestImplementation "androidx.test.ext:junit:$testJunitVersion"
|
androidTestImplementation "androidx.test:runner:$TEST_RUNNER_VERSION"
|
||||||
androidTestImplementation "androidx.test.espresso:espresso-core:$espressoVersion"
|
androidTestImplementation "androidx.test.espresso:espresso-contrib:$ESPRESSO_VERSION"
|
||||||
androidTestImplementation "androidx.test.espresso.idling:idling-concurrent:$espressoVersion"
|
androidTestImplementation "androidx.test.espresso:espresso-intents:$ESPRESSO_VERSION"
|
||||||
implementation "androidx.test.espresso:espresso-idling-resource:$espressoVersion"
|
androidTestImplementation "org.hamcrest:hamcrest:$HAMCREST_VERSION"
|
||||||
androidTestImplementation "androidx.test:runner:$testRunnerVersion"
|
androidTestImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$KOTLINX_COROUTINES"
|
||||||
androidTestImplementation "androidx.test.espresso:espresso-contrib:$espressoVersion"
|
/ * Universal Image loader */
|
||||||
androidTestImplementation "androidx.test.espresso:espresso-intents:$espressoVersion"
|
implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
|
||||||
androidTestImplementation "org.hamcrest:hamcrest:2.2"
|
|
||||||
/ * mock websever for testing retrofit responses * /
|
/ * mock websever for testing retrofit responses * /
|
||||||
testImplementation "com.squareup.okhttp3:mockwebserver:4.6.0"
|
testImplementation "com.squareup.okhttp3:mockwebserver:4.6.0"
|
||||||
testImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0"
|
testImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0"
|
||||||
|
|
||||||
/ * mockito and livedata testing * /
|
/ * mockito and livedata testing * /
|
||||||
testImplementation 'org.mockito:mockito-inline:2.13.0'
|
testImplementation "org.mockito:mockito-inline:$MOKITO_INLINE_VERSION"
|
||||||
implementation 'androidx.arch.core:core-testing:2.2.0'
|
testImplementation "androidx.arch.core:core-testing:$CORE_TEST_VERSION"
|
||||||
|
testImplementation 'org.mockito:mockito-core:2.19.0'
|
||||||
|
androidTestImplementation 'org.mockito:mockito-core:2.19.0'
|
||||||
|
androidTestImplementation "androidx.arch.core:core-testing:$CORE_TEST_VERSION"
|
||||||
/ * MockK * /
|
/ * MockK * /
|
||||||
def mockk_ver = "1.10.5"
|
testImplementation "io.mockk:mockk:$MOCKK_VERSION"
|
||||||
testImplementation "io.mockk:mockk:$mockk_ver"
|
androidTestImplementation "io.mockk:mockk-android:$MOCKK_VERSION"
|
||||||
androidTestImplementation "io.mockk:mockk-android:$mockk_ver"
|
|
||||||
|
|
||||||
/ * Retrofit * /
|
/ * Retrofit * /
|
||||||
def retrofit_ver = "2.9.0"
|
def retrofit_ver = "2.9.0"
|
||||||
implementation "com.squareup.retrofit2:retrofit:$retrofit_ver"
|
implementation "com.squareup.retrofit2:retrofit:$retrofit_ver"
|
||||||
implementation "com.squareup.retrofit2:converter-gson:$retrofit_ver"
|
implementation "com.squareup.retrofit2:converter-gson:$retrofit_ver"
|
||||||
implementation "com.squareup.okhttp3:logging-interceptor:4.9.0"
|
implementation "com.squareup.okhttp3:logging-interceptor:4.9.0"
|
||||||
|
|
||||||
/ * Shared prefs * /
|
/ * Shared prefs * /
|
||||||
def prefs_ver = "1.2.0"
|
implementation "androidx.preference:preference-ktx:$PREFERENCES_VERSION"
|
||||||
implementation "androidx.preference:preference-ktx:$prefs_ver"
|
/ * Kodein Dependency Injection * /
|
||||||
|
implementation "org.kodein.di:kodein-di-generic-jvm:$KODEIN_VERSION"
|
||||||
/ *Kodein Dependency Injection * /
|
implementation "org.kodein.di:kodein-di-framework-android-x:$KODEIN_VERSION"
|
||||||
def kodein_version = "6.2.1"
|
|
||||||
implementation "org.kodein.di:kodein-di-generic-jvm:$kodein_version"
|
|
||||||
implementation "org.kodein.di:kodein-di-framework-android-x:$kodein_version"
|
|
||||||
|
|
||||||
/ * Room database * /
|
/ * Room database * /
|
||||||
def room_version = "2.4.3"
|
runtimeOnly "androidx.room:room-runtime:$ROOM_VERSION"
|
||||||
implementation "androidx.room:room-runtime:$room_version"
|
kapt "androidx.room:room-compiler:$ROOM_VERSION"
|
||||||
kapt "androidx.room:room-compiler:$room_version"
|
implementation "androidx.room:room-ktx:$ROOM_VERSION"
|
||||||
implementation "androidx.room:room-ktx:$room_version"
|
|
||||||
|
|
||||||
/ * Picasso * /
|
/ * Picasso * /
|
||||||
implementation 'com.squareup.picasso:picasso:2.71828'
|
implementation 'com.squareup.picasso:picasso:2.71828'
|
||||||
|
|
||||||
/ * coroutine * /
|
/ * coroutine * /
|
||||||
def coroutine_version = "1.3.9"
|
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$KOTLINX_COROUTINES"
|
||||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutine_version"
|
|
||||||
|
|
||||||
/ * tomtom search * /
|
/ * tomtom search * /
|
||||||
def tomtom_version = "2.4771"
|
implementation "com.tomtom.online:sdk-search:$TOMTOM_VERSION"
|
||||||
implementation "com.tomtom.online:sdk-search:$tomtom_version"
|
implementation "com.tomtom.online:sdk-maps:$TOMTOM_VERSION"
|
||||||
implementation "com.tomtom.online:sdk-maps:2.4807"
|
|
||||||
|
|
||||||
/ * coroutines support for firebase operations * /
|
/ * coroutines support for firebase operations * /
|
||||||
def coroutines_google_ver = "1.6.4"
|
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-play-services:$KOTLINX_COROUTINES"
|
||||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-play-services:$coroutines_google_ver"
|
|
||||||
|
|
||||||
/ * Picasso * /
|
/ * Picasso * /
|
||||||
implementation 'com.squareup.picasso:picasso:2.71828'
|
implementation 'com.squareup.picasso:picasso:2.71828'
|
||||||
|
|
||||||
/ * screenshot library * /
|
/ * screenshot library * /
|
||||||
androidTestImplementation 'tools.fastlane:screengrab:2.1.1'
|
androidTestImplementation 'tools.fastlane:screengrab:2.1.1'
|
||||||
/ * Permissions dispatcher * /
|
/ * Permissions dispatcher * /
|
||||||
def dispatcher_ver = "4.9.2"
|
implementation "com.github.permissions-dispatcher:permissionsdispatcher:$PERMISSIONS_DISPATCHER"
|
||||||
implementation "com.github.permissions-dispatcher:permissionsdispatcher:${dispatcher_ver}"
|
kapt "com.github.permissions-dispatcher:permissionsdispatcher-processor:$PERMISSIONS_DISPATCHER"
|
||||||
kapt "com.github.permissions-dispatcher:permissionsdispatcher-processor:${dispatcher_ver}"
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.appttude.h_mal.atlas_weather.application
|
package com.appttude.h_mal.atlas_weather.application
|
||||||
|
|
||||||
import MonoApp
|
|
||||||
import androidx.room.Room
|
import androidx.room.Room
|
||||||
import androidx.test.espresso.IdlingRegistry
|
import androidx.test.espresso.IdlingRegistry
|
||||||
import androidx.test.espresso.idling.CountingIdlingResource
|
import androidx.test.espresso.idling.CountingIdlingResource
|
||||||
|
|||||||
@@ -6,11 +6,12 @@ import android.view.View
|
|||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.appttude.h_mal.atlas_weather.R
|
import com.appttude.h_mal.atlas_weather.R
|
||||||
import com.appttude.h_mal.atlas_weather.model.forecast.WeatherDisplay
|
import com.appttude.h_mal.atlas_weather.model.forecast.WeatherDisplay
|
||||||
import com.appttude.h_mal.atlas_weather.ui.home.adapter.WeatherRecyclerAdapter
|
import com.appttude.h_mal.atlas_weather.ui.home.adapter.WeatherRecyclerAdapter
|
||||||
import com.appttude.h_mal.atlas_weather.utils.navigateTo
|
import com.appttude.h_mal.atlas_weather.utils.navigateTo
|
||||||
import kotlinx.android.synthetic.main.fragment_home.*
|
|
||||||
|
|
||||||
|
|
||||||
class WorldItemFragment : Fragment() {
|
class WorldItemFragment : Fragment() {
|
||||||
@@ -40,7 +41,7 @@ class WorldItemFragment : Fragment() {
|
|||||||
|
|
||||||
param1?.let { recyclerAdapter.addCurrent(it) }
|
param1?.let { recyclerAdapter.addCurrent(it) }
|
||||||
|
|
||||||
forecast_listview.apply {
|
view.findViewById<RecyclerView>(R.id.forecast_listview).apply {
|
||||||
layoutManager = LinearLayoutManager(context)
|
layoutManager = LinearLayoutManager(context)
|
||||||
adapter = recyclerAdapter
|
adapter = recyclerAdapter
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,10 +4,11 @@ import android.os.Bundle
|
|||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import android.widget.TextView
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import com.appttude.h_mal.atlas_weather.R
|
import com.appttude.h_mal.atlas_weather.R
|
||||||
import com.appttude.h_mal.atlas_weather.model.forecast.Forecast
|
import com.appttude.h_mal.atlas_weather.model.forecast.Forecast
|
||||||
import kotlinx.android.synthetic.main.activity_further_info.*
|
|
||||||
|
|
||||||
|
|
||||||
private const val WEATHER = "param1"
|
private const val WEATHER = "param1"
|
||||||
@@ -36,14 +37,12 @@ class FurtherInfoFragment : Fragment() {
|
|||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
maxtemp.text = param1?.mainTemp
|
view.findViewById<TextView>(R.id.maxtemp).text = param1?.mainTemp
|
||||||
averagetemp.text = param1?.averageTemp
|
view.findViewById<TextView>(R.id.averagetemp).text = param1?.averageTemp
|
||||||
minimumtemp.text = param1?.minorTemp
|
view.findViewById<TextView>(R.id.minimumtemp).text = param1?.minorTemp
|
||||||
windtext.text = param1?.windText
|
view.findViewById<TextView>(R.id.windtext).text = param1?.windText
|
||||||
preciptext.text = param1?.precipitation
|
view.findViewById<TextView>(R.id.preciptext).text = param1?.precipitation
|
||||||
humiditytext.text = param1?.humidity
|
view.findViewById<TextView>(R.id.sunrisetext).text = param1?.sunrise
|
||||||
uvtext.text = param1?.uvi
|
view.findViewById<TextView>(R.id.sunsettext).text = param1?.sunset
|
||||||
sunrisetext.text = param1?.sunrise
|
|
||||||
sunsettext.text = param1?.sunset
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,6 +12,8 @@ import android.view.View
|
|||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.navigation.Navigation.findNavController
|
import androidx.navigation.Navigation.findNavController
|
||||||
import androidx.navigation.ui.onNavDestinationSelected
|
import androidx.navigation.ui.onNavDestinationSelected
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||||
import com.appttude.h_mal.atlas_weather.R
|
import com.appttude.h_mal.atlas_weather.R
|
||||||
import com.appttude.h_mal.atlas_weather.application.AtlasApp
|
import com.appttude.h_mal.atlas_weather.application.AtlasApp
|
||||||
import com.appttude.h_mal.atlas_weather.base.BaseFragment
|
import com.appttude.h_mal.atlas_weather.base.BaseFragment
|
||||||
@@ -22,7 +24,7 @@ import com.appttude.h_mal.atlas_weather.ui.home.adapter.WeatherRecyclerAdapter
|
|||||||
import com.appttude.h_mal.atlas_weather.utils.displayToast
|
import com.appttude.h_mal.atlas_weather.utils.displayToast
|
||||||
import com.appttude.h_mal.atlas_weather.utils.navigateTo
|
import com.appttude.h_mal.atlas_weather.utils.navigateTo
|
||||||
import com.appttude.h_mal.atlas_weather.viewmodel.MainViewModel
|
import com.appttude.h_mal.atlas_weather.viewmodel.MainViewModel
|
||||||
import kotlinx.android.synthetic.main.fragment_home.*
|
|
||||||
import permissions.dispatcher.NeedsPermission
|
import permissions.dispatcher.NeedsPermission
|
||||||
import permissions.dispatcher.OnNeverAskAgain
|
import permissions.dispatcher.OnNeverAskAgain
|
||||||
import permissions.dispatcher.OnPermissionDenied
|
import permissions.dispatcher.OnPermissionDenied
|
||||||
@@ -38,14 +40,15 @@ import permissions.dispatcher.RuntimePermissions
|
|||||||
@RuntimePermissions
|
@RuntimePermissions
|
||||||
class HomeFragment : BaseFragment<MainViewModel>(R.layout.fragment_home) {
|
class HomeFragment : BaseFragment<MainViewModel>(R.layout.fragment_home) {
|
||||||
|
|
||||||
lateinit var recyclerAdapter: WeatherRecyclerAdapter
|
private lateinit var recyclerAdapter: WeatherRecyclerAdapter
|
||||||
|
private lateinit var swipeRefresh: SwipeRefreshLayout
|
||||||
|
|
||||||
@SuppressLint("MissingPermission")
|
@SuppressLint("MissingPermission")
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
setHasOptionsMenu(true)
|
setHasOptionsMenu(true)
|
||||||
|
|
||||||
swipe_refresh.apply {
|
swipeRefresh = view.findViewById<SwipeRefreshLayout>(R.id.swipe_refresh).apply {
|
||||||
setOnRefreshListener {
|
setOnRefreshListener {
|
||||||
showLocationWithPermissionCheck()
|
showLocationWithPermissionCheck()
|
||||||
isRefreshing = true
|
isRefreshing = true
|
||||||
@@ -56,7 +59,7 @@ class HomeFragment : BaseFragment<MainViewModel>(R.layout.fragment_home) {
|
|||||||
navigateToFurtherDetails(it)
|
navigateToFurtherDetails(it)
|
||||||
})
|
})
|
||||||
|
|
||||||
forecast_listview.adapter = recyclerAdapter
|
view.findViewById<RecyclerView>(R.id.forecast_listview).adapter = recyclerAdapter
|
||||||
|
|
||||||
scheduleNotification()
|
scheduleNotification()
|
||||||
}
|
}
|
||||||
@@ -69,7 +72,7 @@ class HomeFragment : BaseFragment<MainViewModel>(R.layout.fragment_home) {
|
|||||||
|
|
||||||
override fun onSuccess(data: Any?) {
|
override fun onSuccess(data: Any?) {
|
||||||
super.onSuccess(data)
|
super.onSuccess(data)
|
||||||
swipe_refresh.isRefreshing = false
|
swipeRefresh.isRefreshing = false
|
||||||
|
|
||||||
if (data is WeatherDisplay) {
|
if (data is WeatherDisplay) {
|
||||||
recyclerAdapter.addCurrent(data)
|
recyclerAdapter.addCurrent(data)
|
||||||
@@ -78,7 +81,7 @@ class HomeFragment : BaseFragment<MainViewModel>(R.layout.fragment_home) {
|
|||||||
|
|
||||||
override fun onFailure(error: Any?) {
|
override fun onFailure(error: Any?) {
|
||||||
super.onFailure(error)
|
super.onFailure(error)
|
||||||
swipe_refresh.isRefreshing = false
|
swipeRefresh.isRefreshing = false
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun navigateToFurtherDetails(forecast: Forecast) {
|
private fun navigateToFurtherDetails(forecast: Forecast) {
|
||||||
@@ -96,6 +99,7 @@ class HomeFragment : BaseFragment<MainViewModel>(R.layout.fragment_home) {
|
|||||||
return item.onNavDestinationSelected(navController) || super.onOptionsItemSelected(item)
|
return item.onNavDestinationSelected(navController) || super.onOptionsItemSelected(item)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated("Deprecated in Java")
|
||||||
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
|
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
|
||||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
|
||||||
// NOTE: delegate the permission handling to generated method
|
// NOTE: delegate the permission handling to generated method
|
||||||
|
|||||||
@@ -2,13 +2,13 @@ package com.appttude.h_mal.atlas_weather.ui.world
|
|||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import android.widget.Button
|
||||||
|
import android.widget.TextView
|
||||||
import com.appttude.h_mal.atlas_weather.R
|
import com.appttude.h_mal.atlas_weather.R
|
||||||
import com.appttude.h_mal.atlas_weather.base.BaseFragment
|
import com.appttude.h_mal.atlas_weather.base.BaseFragment
|
||||||
import com.appttude.h_mal.atlas_weather.utils.displayToast
|
import com.appttude.h_mal.atlas_weather.utils.displayToast
|
||||||
import com.appttude.h_mal.atlas_weather.utils.goBack
|
import com.appttude.h_mal.atlas_weather.utils.goBack
|
||||||
import com.appttude.h_mal.atlas_weather.viewmodel.WorldViewModel
|
import com.appttude.h_mal.atlas_weather.viewmodel.WorldViewModel
|
||||||
import kotlinx.android.synthetic.main.activity_add_forecast.location_name_tv
|
|
||||||
import kotlinx.android.synthetic.main.activity_add_forecast.submit
|
|
||||||
|
|
||||||
|
|
||||||
class AddLocationFragment : BaseFragment<WorldViewModel>(R.layout.activity_add_forecast) {
|
class AddLocationFragment : BaseFragment<WorldViewModel>(R.layout.activity_add_forecast) {
|
||||||
@@ -16,8 +16,11 @@ class AddLocationFragment : BaseFragment<WorldViewModel>(R.layout.activity_add_f
|
|||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
|
val submit = view.findViewById<Button>(R.id.submit)
|
||||||
|
|
||||||
submit.setOnClickListener {
|
submit.setOnClickListener {
|
||||||
val locationName = location_name_tv.text?.trim()?.toString()
|
val locationName =
|
||||||
|
view.findViewById<TextView>(R.id.location_name_tv).text?.trim()?.toString()
|
||||||
if (locationName.isNullOrBlank()) {
|
if (locationName.isNullOrBlank()) {
|
||||||
submit.error = "Location cannot be blank"
|
submit.error = "Location cannot be blank"
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
|
|||||||
@@ -4,13 +4,13 @@ import android.os.Bundle
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.appttude.h_mal.atlas_weather.R
|
import com.appttude.h_mal.atlas_weather.R
|
||||||
import com.appttude.h_mal.atlas_weather.base.BaseFragment
|
import com.appttude.h_mal.atlas_weather.base.BaseFragment
|
||||||
import com.appttude.h_mal.atlas_weather.model.forecast.WeatherDisplay
|
import com.appttude.h_mal.atlas_weather.model.forecast.WeatherDisplay
|
||||||
import com.appttude.h_mal.atlas_weather.utils.navigateTo
|
import com.appttude.h_mal.atlas_weather.utils.navigateTo
|
||||||
import com.appttude.h_mal.atlas_weather.viewmodel.WorldViewModel
|
import com.appttude.h_mal.atlas_weather.viewmodel.WorldViewModel
|
||||||
import kotlinx.android.synthetic.atlasWeather.fragment_add_location.floatingActionButton
|
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
import kotlinx.android.synthetic.atlasWeather.fragment_add_location.world_recycler
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -29,12 +29,12 @@ class WorldFragment : BaseFragment<WorldViewModel>(R.layout.fragment_add_locatio
|
|||||||
navigateTo(direction)
|
navigateTo(direction)
|
||||||
}
|
}
|
||||||
|
|
||||||
world_recycler.apply {
|
view.findViewById<RecyclerView>(R.id.world_recycler).apply {
|
||||||
layoutManager = LinearLayoutManager(context)
|
layoutManager = LinearLayoutManager(context)
|
||||||
adapter = recyclerAdapter
|
adapter = recyclerAdapter
|
||||||
}
|
}
|
||||||
|
|
||||||
floatingActionButton.setOnClickListener {
|
view.findViewById<FloatingActionButton>(R.id.floatingActionButton).setOnClickListener {
|
||||||
navigateTo(R.id.action_worldFragment_to_addLocationFragment)
|
navigateTo(R.id.action_worldFragment_to_addLocationFragment)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
package="com.appttude.h_mal.atlas_weather">
|
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ abstract class BaseActivity : AppCompatActivity(), KodeinAware {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Deprecated("Deprecated in Java")
|
||||||
override fun onBackPressed() {
|
override fun onBackPressed() {
|
||||||
loadingView?.hide()
|
loadingView?.hide()
|
||||||
super.onBackPressed()
|
super.onBackPressed()
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import androidx.navigation.ui.setupWithNavController
|
|||||||
import com.appttude.h_mal.atlas_weather.R
|
import com.appttude.h_mal.atlas_weather.R
|
||||||
import com.appttude.h_mal.atlas_weather.base.BaseActivity
|
import com.appttude.h_mal.atlas_weather.base.BaseActivity
|
||||||
import com.google.android.material.bottomnavigation.BottomNavigationView
|
import com.google.android.material.bottomnavigation.BottomNavigationView
|
||||||
import kotlinx.android.synthetic.main.activity_main_navigation.toolbar
|
|
||||||
|
|
||||||
class MainActivity : BaseActivity() {
|
class MainActivity : BaseActivity() {
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ class MainActivity : BaseActivity() {
|
|||||||
setContentView(R.layout.activity_main_navigation)
|
setContentView(R.layout.activity_main_navigation)
|
||||||
|
|
||||||
val navView: BottomNavigationView = findViewById(R.id.nav_view)
|
val navView: BottomNavigationView = findViewById(R.id.nav_view)
|
||||||
setSupportActionBar(toolbar)
|
setSupportActionBar(findViewById(R.id.toolbar))
|
||||||
|
|
||||||
navHost = supportFragmentManager
|
navHost = supportFragmentManager
|
||||||
.findFragmentById(R.id.container) as NavHostFragment
|
.findFragmentById(R.id.container) as NavHostFragment
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.appttude.h_mal.atlas_weather.utils
|
|||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.util.Log
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
@@ -11,7 +12,12 @@ import android.view.inputmethod.InputMethodManager
|
|||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.annotation.AnimRes
|
import androidx.annotation.AnimRes
|
||||||
|
import androidx.annotation.IdRes
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
|
import androidx.lifecycle.Lifecycle
|
||||||
|
import androidx.lifecycle.LifecycleObserver
|
||||||
|
import androidx.lifecycle.OnLifecycleEvent
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.appttude.h_mal.atlas_weather.R
|
import com.appttude.h_mal.atlas_weather.R
|
||||||
import com.squareup.picasso.Picasso
|
import com.squareup.picasso.Picasso
|
||||||
|
|
||||||
@@ -56,3 +62,62 @@ fun View.triggerAnimation(@AnimRes id: Int, complete: (View) -> Unit) {
|
|||||||
})
|
})
|
||||||
startAnimation(animation)
|
startAnimation(animation)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class BindViewDelegate<T>(
|
||||||
|
private val createView: () -> T,
|
||||||
|
private val getLifecycle: () -> Lifecycle
|
||||||
|
) : Lazy<T>, LifecycleObserver {
|
||||||
|
|
||||||
|
private var view: T? = null
|
||||||
|
|
||||||
|
private val lifecycle: Lifecycle?
|
||||||
|
get() = try {
|
||||||
|
getLifecycle()
|
||||||
|
} catch (e: IllegalStateException) {
|
||||||
|
e.message?.let { Log.e("BindViewDelegate", it) }
|
||||||
|
null
|
||||||
|
}
|
||||||
|
|
||||||
|
override val value: T
|
||||||
|
get() {
|
||||||
|
if (view == null) {
|
||||||
|
lifecycle?.removeObserver(this)
|
||||||
|
view = createView()
|
||||||
|
lifecycle?.addObserver(this)
|
||||||
|
}
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
return view as T
|
||||||
|
}
|
||||||
|
|
||||||
|
@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
|
||||||
|
fun onDestroy() {
|
||||||
|
reset()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun reset() {
|
||||||
|
lifecycle?.removeObserver(this)
|
||||||
|
view = null
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun isInitialized(): Boolean = view != null
|
||||||
|
}
|
||||||
|
|
||||||
|
fun <T : View> Fragment.bindView(@IdRes resource: Int): Lazy<T> = BindViewDelegate(
|
||||||
|
createView = { requireView().findViewById<T>(resource) },
|
||||||
|
getLifecycle = { viewLifecycleOwner.lifecycle }
|
||||||
|
)
|
||||||
|
|
||||||
|
fun <T : View> Activity.bindView(@IdRes res: Int): Lazy<T> {
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
return lazy(LazyThreadSafetyMode.NONE) { findViewById<T>(res) }
|
||||||
|
}
|
||||||
|
|
||||||
|
fun <T : View> View.bindView(@IdRes res: Int): Lazy<T> {
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
return lazy(LazyThreadSafetyMode.NONE) { findViewById<T>(res) }
|
||||||
|
}
|
||||||
|
|
||||||
|
fun <T : View> RecyclerView.ViewHolder.bindView(@IdRes res: Int): Lazy<T> {
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
return lazy(LazyThreadSafetyMode.NONE) { itemView.findViewById<T>(res) }
|
||||||
|
}
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
import com.appttude.h_mal.atlas_weather.application.AppClass
|
package com.appttude.h_mal.atlas_weather.application
|
||||||
import com.appttude.h_mal.atlas_weather.application.ApplicationViewModelFactory
|
|
||||||
import org.kodein.di.generic.bind
|
import org.kodein.di.generic.bind
|
||||||
import org.kodein.di.generic.instance
|
import org.kodein.di.generic.instance
|
||||||
import org.kodein.di.generic.provider
|
import org.kodein.di.generic.provider
|
||||||
import org.kodein.di.generic.singleton
|
|
||||||
|
|
||||||
open class MonoApp : AppClass() {
|
open class MonoApp : AppClass() {
|
||||||
|
|
||||||
|
|||||||
@@ -4,14 +4,16 @@ package com.appttude.h_mal.monoWeather.ui
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||||
import com.appttude.h_mal.atlas_weather.R
|
import com.appttude.h_mal.atlas_weather.R
|
||||||
import com.appttude.h_mal.atlas_weather.model.forecast.WeatherDisplay
|
import com.appttude.h_mal.atlas_weather.model.forecast.WeatherDisplay
|
||||||
import com.appttude.h_mal.atlas_weather.base.BaseFragment
|
import com.appttude.h_mal.atlas_weather.base.BaseFragment
|
||||||
import com.appttude.h_mal.atlas_weather.utils.navigateTo
|
import com.appttude.h_mal.atlas_weather.utils.navigateTo
|
||||||
import com.appttude.h_mal.atlas_weather.viewmodel.WorldViewModel
|
import com.appttude.h_mal.atlas_weather.viewmodel.WorldViewModel
|
||||||
import com.appttude.h_mal.monoWeather.ui.home.adapter.WeatherRecyclerAdapter
|
import com.appttude.h_mal.monoWeather.ui.home.adapter.WeatherRecyclerAdapter
|
||||||
import kotlinx.android.synthetic.main.fragment_home.forecast_listview
|
|
||||||
import kotlinx.android.synthetic.main.fragment_home.swipe_refresh
|
|
||||||
|
|
||||||
|
|
||||||
class WorldItemFragment : BaseFragment<WorldViewModel>(R.layout.fragment_home) {
|
class WorldItemFragment : BaseFragment<WorldViewModel>(R.layout.fragment_home) {
|
||||||
@@ -19,6 +21,7 @@ class WorldItemFragment : BaseFragment<WorldViewModel>(R.layout.fragment_home) {
|
|||||||
private var retrievedLocationName: String? = null
|
private var retrievedLocationName: String? = null
|
||||||
|
|
||||||
private lateinit var recyclerAdapter: WeatherRecyclerAdapter
|
private lateinit var recyclerAdapter: WeatherRecyclerAdapter
|
||||||
|
private lateinit var swipeRefresh: SwipeRefreshLayout
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
@@ -35,12 +38,12 @@ class WorldItemFragment : BaseFragment<WorldViewModel>(R.layout.fragment_home) {
|
|||||||
navigateTo(directions)
|
navigateTo(directions)
|
||||||
}
|
}
|
||||||
|
|
||||||
forecast_listview.apply {
|
view.findViewById<RecyclerView>(R.id.forecast_listview).apply {
|
||||||
layoutManager = LinearLayoutManager(context)
|
layoutManager = LinearLayoutManager(context)
|
||||||
adapter = recyclerAdapter
|
adapter = recyclerAdapter
|
||||||
}
|
}
|
||||||
|
|
||||||
swipe_refresh.apply {
|
swipeRefresh = view.findViewById<SwipeRefreshLayout>(R.id.swipe_refresh).apply {
|
||||||
setOnRefreshListener {
|
setOnRefreshListener {
|
||||||
retrievedLocationName?.let {
|
retrievedLocationName?.let {
|
||||||
viewModel.fetchDataForSingleLocation(it)
|
viewModel.fetchDataForSingleLocation(it)
|
||||||
@@ -57,11 +60,11 @@ class WorldItemFragment : BaseFragment<WorldViewModel>(R.layout.fragment_home) {
|
|||||||
recyclerAdapter.addCurrent(data)
|
recyclerAdapter.addCurrent(data)
|
||||||
}
|
}
|
||||||
super.onSuccess(data)
|
super.onSuccess(data)
|
||||||
swipe_refresh.isRefreshing = false
|
swipeRefresh.isRefreshing = false
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onFailure(error: Any?) {
|
override fun onFailure(error: Any?) {
|
||||||
super.onFailure(error)
|
super.onFailure(error)
|
||||||
swipe_refresh.isRefreshing = false
|
swipeRefresh.isRefreshing = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,9 +5,9 @@ import android.view.LayoutInflater
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
|
import android.widget.TextView
|
||||||
import com.appttude.h_mal.atlas_weather.R
|
import com.appttude.h_mal.atlas_weather.R
|
||||||
import com.appttude.h_mal.atlas_weather.model.forecast.Forecast
|
import com.appttude.h_mal.atlas_weather.model.forecast.Forecast
|
||||||
import kotlinx.android.synthetic.main.activity_further_info.*
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -34,18 +34,18 @@ class FurtherInfoFragment : Fragment() {
|
|||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
maxtemp.text = param1?.mainTemp.appendWith(requireContext().getString(R.string.degrees))
|
view.findViewById<TextView>(R.id.maxtemp).text = param1?.mainTemp.appendWith(requireContext().getString(R.string.degrees))
|
||||||
averagetemp.text =
|
view.findViewById<TextView>(R.id.averagetemp).text =
|
||||||
param1?.averageTemp.appendWith(requireContext().getString(R.string.degrees))
|
param1?.averageTemp.appendWith(requireContext().getString(R.string.degrees))
|
||||||
minimumtemp.text =
|
view.findViewById<TextView>(R.id.minimumtemp).text =
|
||||||
param1?.minorTemp.appendWith(requireContext().getString(R.string.degrees))
|
param1?.minorTemp.appendWith(requireContext().getString(R.string.degrees))
|
||||||
windtext.text = param1?.windText.appendWith(" km")
|
view.findViewById<TextView>(R.id.windtext).text = param1?.windText.appendWith(" km")
|
||||||
preciptext.text = param1?.precipitation.appendWith(" %")
|
view.findViewById<TextView>(R.id.preciptext).text = param1?.precipitation.appendWith(" %")
|
||||||
cloudtext.text = param1?.cloud.appendWith(" %")
|
view.findViewById<TextView>(R.id.cloudtext).text = param1?.cloud.appendWith(" %")
|
||||||
humiditytext.text = param1?.humidity.appendWith(" %")
|
view.findViewById<TextView>(R.id.humiditytext).text = param1?.humidity.appendWith(" %")
|
||||||
uvtext.text = param1?.uvi
|
view.findViewById<TextView>(R.id.uvtext).text = param1?.uvi
|
||||||
sunrisetext.text = param1?.sunrise
|
view.findViewById<TextView>(R.id.sunrisetext).text = param1?.sunrise
|
||||||
sunsettext.text = param1?.sunset
|
view.findViewById<TextView>(R.id.sunsettext).text = param1?.sunset
|
||||||
}
|
}
|
||||||
|
|
||||||
fun String?.appendWith(suffix: String): String? {
|
fun String?.appendWith(suffix: String): String? {
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ import android.view.View
|
|||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.navigation.Navigation.findNavController
|
import androidx.navigation.Navigation.findNavController
|
||||||
import androidx.navigation.ui.onNavDestinationSelected
|
import androidx.navigation.ui.onNavDestinationSelected
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||||
import com.appttude.h_mal.atlas_weather.R
|
import com.appttude.h_mal.atlas_weather.R
|
||||||
import com.appttude.h_mal.atlas_weather.base.BaseFragment
|
import com.appttude.h_mal.atlas_weather.base.BaseFragment
|
||||||
import com.appttude.h_mal.atlas_weather.model.forecast.Forecast
|
import com.appttude.h_mal.atlas_weather.model.forecast.Forecast
|
||||||
@@ -19,7 +21,7 @@ import com.appttude.h_mal.atlas_weather.utils.navigateTo
|
|||||||
import com.appttude.h_mal.atlas_weather.viewmodel.MainViewModel
|
import com.appttude.h_mal.atlas_weather.viewmodel.MainViewModel
|
||||||
import com.appttude.h_mal.monoWeather.dialog.PermissionsDeclarationDialog
|
import com.appttude.h_mal.monoWeather.dialog.PermissionsDeclarationDialog
|
||||||
import com.appttude.h_mal.monoWeather.ui.home.adapter.WeatherRecyclerAdapter
|
import com.appttude.h_mal.monoWeather.ui.home.adapter.WeatherRecyclerAdapter
|
||||||
import kotlinx.android.synthetic.main.fragment_home.*
|
|
||||||
import permissions.dispatcher.NeedsPermission
|
import permissions.dispatcher.NeedsPermission
|
||||||
import permissions.dispatcher.OnNeverAskAgain
|
import permissions.dispatcher.OnNeverAskAgain
|
||||||
import permissions.dispatcher.OnPermissionDenied
|
import permissions.dispatcher.OnPermissionDenied
|
||||||
@@ -36,13 +38,14 @@ import permissions.dispatcher.RuntimePermissions
|
|||||||
class HomeFragment : BaseFragment<MainViewModel>(R.layout.fragment_home) {
|
class HomeFragment : BaseFragment<MainViewModel>(R.layout.fragment_home) {
|
||||||
|
|
||||||
lateinit var recyclerAdapter: WeatherRecyclerAdapter
|
lateinit var recyclerAdapter: WeatherRecyclerAdapter
|
||||||
|
lateinit var swipeRefresh: SwipeRefreshLayout
|
||||||
|
|
||||||
@SuppressLint("MissingPermission")
|
@SuppressLint("MissingPermission")
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
setHasOptionsMenu(true)
|
setHasOptionsMenu(true)
|
||||||
|
|
||||||
swipe_refresh.apply {
|
swipeRefresh = view.findViewById<SwipeRefreshLayout>(R.id.swipe_refresh).apply {
|
||||||
setOnRefreshListener {
|
setOnRefreshListener {
|
||||||
showLocationWithPermissionCheck()
|
showLocationWithPermissionCheck()
|
||||||
isRefreshing = true
|
isRefreshing = true
|
||||||
@@ -53,7 +56,7 @@ class HomeFragment : BaseFragment<MainViewModel>(R.layout.fragment_home) {
|
|||||||
navigateToFurtherDetails(it)
|
navigateToFurtherDetails(it)
|
||||||
})
|
})
|
||||||
|
|
||||||
forecast_listview.adapter = recyclerAdapter
|
view.findViewById<RecyclerView>(R.id.forecast_listview).adapter = recyclerAdapter
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("MissingPermission")
|
@SuppressLint("MissingPermission")
|
||||||
@@ -64,7 +67,7 @@ class HomeFragment : BaseFragment<MainViewModel>(R.layout.fragment_home) {
|
|||||||
|
|
||||||
override fun onSuccess(data: Any?) {
|
override fun onSuccess(data: Any?) {
|
||||||
super.onSuccess(data)
|
super.onSuccess(data)
|
||||||
swipe_refresh.isRefreshing = false
|
swipeRefresh.isRefreshing = false
|
||||||
|
|
||||||
if (data is WeatherDisplay) {
|
if (data is WeatherDisplay) {
|
||||||
recyclerAdapter.addCurrent(data)
|
recyclerAdapter.addCurrent(data)
|
||||||
@@ -73,7 +76,7 @@ class HomeFragment : BaseFragment<MainViewModel>(R.layout.fragment_home) {
|
|||||||
|
|
||||||
override fun onFailure(error: Any?) {
|
override fun onFailure(error: Any?) {
|
||||||
super.onFailure(error)
|
super.onFailure(error)
|
||||||
swipe_refresh.isRefreshing = false
|
swipeRefresh.isRefreshing = false
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun navigateToFurtherDetails(forecast: Forecast) {
|
private fun navigateToFurtherDetails(forecast: Forecast) {
|
||||||
|
|||||||
@@ -4,10 +4,12 @@ import android.content.Context
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.ArrayAdapter
|
import android.widget.ArrayAdapter
|
||||||
|
import android.widget.ImageView
|
||||||
|
import android.widget.TextView
|
||||||
import com.appttude.h_mal.atlas_weather.R
|
import com.appttude.h_mal.atlas_weather.R
|
||||||
import com.appttude.h_mal.atlas_weather.utils.generateView
|
import com.appttude.h_mal.atlas_weather.utils.generateView
|
||||||
import kotlinx.android.synthetic.monoWeather.mono_item_two_cell.view.mono_item_cell
|
|
||||||
import kotlinx.android.synthetic.monoWeather.mono_item_two_cell.view.mono_text_cell
|
|
||||||
|
|
||||||
|
|
||||||
class GridAdapter(
|
class GridAdapter(
|
||||||
@@ -20,8 +22,8 @@ class GridAdapter(
|
|||||||
val item = getItem(position)
|
val item = getItem(position)
|
||||||
|
|
||||||
return view.apply {
|
return view.apply {
|
||||||
mono_item_cell.setImageResource(item!!.first)
|
findViewById<ImageView>(R.id.mono_item_cell).setImageResource(item!!.first)
|
||||||
mono_text_cell.text = item.second
|
findViewById<TextView>(R.id.mono_text_cell).text = item.second
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,6 +11,7 @@ import android.content.Intent
|
|||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.text.method.LinkMovementMethod
|
import android.text.method.LinkMovementMethod
|
||||||
|
import android.widget.Button
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.annotation.RequiresApi
|
import androidx.annotation.RequiresApi
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
@@ -18,8 +19,8 @@ import com.appttude.h_mal.atlas_weather.R
|
|||||||
import com.appttude.h_mal.atlas_weather.utils.displayToast
|
import com.appttude.h_mal.atlas_weather.utils.displayToast
|
||||||
import com.appttude.h_mal.monoWeather.dialog.DeclarationBuilder
|
import com.appttude.h_mal.monoWeather.dialog.DeclarationBuilder
|
||||||
import com.appttude.h_mal.monoWeather.dialog.PermissionsDeclarationDialog
|
import com.appttude.h_mal.monoWeather.dialog.PermissionsDeclarationDialog
|
||||||
import kotlinx.android.synthetic.monoWeather.permissions_declaration_dialog.cancel
|
|
||||||
import kotlinx.android.synthetic.monoWeather.permissions_declaration_dialog.submit
|
|
||||||
import permissions.dispatcher.NeedsPermission
|
import permissions.dispatcher.NeedsPermission
|
||||||
import permissions.dispatcher.OnNeverAskAgain
|
import permissions.dispatcher.OnNeverAskAgain
|
||||||
import permissions.dispatcher.OnPermissionDenied
|
import permissions.dispatcher.OnPermissionDenied
|
||||||
@@ -60,7 +61,7 @@ class WidgetLocationPermissionActivity : AppCompatActivity(), DeclarationBuilder
|
|||||||
movementMethod = LinkMovementMethod.getInstance()
|
movementMethod = LinkMovementMethod.getInstance()
|
||||||
}
|
}
|
||||||
|
|
||||||
submit.setOnClickListener {
|
findViewById<Button>(R.id.submit).setOnClickListener {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||||
showBackgroundLocationWithPermissionCheck()
|
showBackgroundLocationWithPermissionCheck()
|
||||||
} else {
|
} else {
|
||||||
@@ -68,7 +69,7 @@ class WidgetLocationPermissionActivity : AppCompatActivity(), DeclarationBuilder
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cancel.setOnClickListener { finish() }
|
findViewById<Button>(R.id.cancel).setOnClickListener { finish() }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun submitWidget() {
|
private fun submitWidget() {
|
||||||
|
|||||||
@@ -2,14 +2,16 @@ package com.appttude.h_mal.monoWeather.ui.world
|
|||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import android.widget.Button
|
||||||
|
import android.widget.TextView
|
||||||
import com.appttude.h_mal.atlas_weather.R
|
import com.appttude.h_mal.atlas_weather.R
|
||||||
import com.appttude.h_mal.atlas_weather.base.BaseFragment
|
import com.appttude.h_mal.atlas_weather.base.BaseFragment
|
||||||
import com.appttude.h_mal.atlas_weather.utils.displayToast
|
import com.appttude.h_mal.atlas_weather.utils.displayToast
|
||||||
import com.appttude.h_mal.atlas_weather.utils.goBack
|
import com.appttude.h_mal.atlas_weather.utils.goBack
|
||||||
import com.appttude.h_mal.atlas_weather.utils.hideKeyboard
|
import com.appttude.h_mal.atlas_weather.utils.hideKeyboard
|
||||||
import com.appttude.h_mal.atlas_weather.viewmodel.WorldViewModel
|
import com.appttude.h_mal.atlas_weather.viewmodel.WorldViewModel
|
||||||
import kotlinx.android.synthetic.main.activity_add_forecast.location_name_tv
|
|
||||||
import kotlinx.android.synthetic.main.activity_add_forecast.submit
|
|
||||||
|
|
||||||
|
|
||||||
class AddLocationFragment : BaseFragment<WorldViewModel>(R.layout.activity_add_forecast) {
|
class AddLocationFragment : BaseFragment<WorldViewModel>(R.layout.activity_add_forecast) {
|
||||||
@@ -17,10 +19,11 @@ class AddLocationFragment : BaseFragment<WorldViewModel>(R.layout.activity_add_f
|
|||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
submit.setOnClickListener {
|
view.findViewById<Button>(R.id.submit).setOnClickListener {
|
||||||
val locationName = location_name_tv.text?.trim()?.toString()
|
val locationNameView = view.findViewById<TextView>(R.id.location_name_tv)
|
||||||
|
val locationName = locationNameView.text?.trim()?.toString()
|
||||||
if (locationName.isNullOrBlank()) {
|
if (locationName.isNullOrBlank()) {
|
||||||
location_name_tv.error = "Location cannot be blank"
|
locationNameView.error = "Location cannot be blank"
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
}
|
}
|
||||||
viewModel.fetchDataForSingleLocationSearch(locationName)
|
viewModel.fetchDataForSingleLocationSearch(locationName)
|
||||||
|
|||||||
@@ -2,17 +2,18 @@ package com.appttude.h_mal.monoWeather.ui.world
|
|||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import android.widget.Button
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.appttude.h_mal.atlas_weather.R
|
import com.appttude.h_mal.atlas_weather.R
|
||||||
import com.appttude.h_mal.atlas_weather.model.forecast.WeatherDisplay
|
|
||||||
import com.appttude.h_mal.atlas_weather.base.BaseFragment
|
import com.appttude.h_mal.atlas_weather.base.BaseFragment
|
||||||
|
import com.appttude.h_mal.atlas_weather.model.forecast.WeatherDisplay
|
||||||
import com.appttude.h_mal.atlas_weather.utils.navigateTo
|
import com.appttude.h_mal.atlas_weather.utils.navigateTo
|
||||||
import com.appttude.h_mal.atlas_weather.viewmodel.WorldViewModel
|
import com.appttude.h_mal.atlas_weather.viewmodel.WorldViewModel
|
||||||
import com.appttude.h_mal.monoWeather.ui.world.WorldFragmentDirections.actionWorldFragmentToWorldItemFragment
|
import com.appttude.h_mal.monoWeather.ui.world.WorldFragmentDirections.actionWorldFragmentToWorldItemFragment
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
import kotlinx.android.synthetic.monoWeather.fragment__two.floatingActionButton
|
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
import kotlinx.android.synthetic.monoWeather.fragment__two.world_recycler
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -47,12 +48,12 @@ class WorldFragment : BaseFragment<WorldViewModel>(R.layout.fragment__two) {
|
|||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
world_recycler.apply {
|
view.findViewById<RecyclerView>(R.id.world_recycler).apply {
|
||||||
layoutManager = LinearLayoutManager(context)
|
layoutManager = LinearLayoutManager(context)
|
||||||
adapter = recyclerAdapter
|
adapter = recyclerAdapter
|
||||||
}
|
}
|
||||||
|
|
||||||
floatingActionButton.setOnClickListener {
|
view.findViewById<FloatingActionButton>(R.id.floatingActionButton).setOnClickListener {
|
||||||
navigateTo(R.id.action_worldFragment_to_addLocationFragment)
|
navigateTo(R.id.action_worldFragment_to_addLocationFragment)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
19
build.gradle
19
build.gradle
@@ -1,24 +1,21 @@
|
|||||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
buildscript {
|
buildscript {
|
||||||
ext {
|
|
||||||
kotlin_version = '1.5.20'
|
|
||||||
}
|
|
||||||
repositories {
|
repositories {
|
||||||
maven { url "https://www.jitpack.io" }
|
maven { url "https://www.jitpack.io" }
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath("androidx.navigation:navigation-safe-args-gradle-plugin:2.4.1")
|
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$NAVIGATION_VERSION"
|
||||||
classpath ('com.android.tools.build:gradle:7.2.2')
|
classpath "com.android.tools.build:gradle:$GRADLE_PLUGIN_VERSION"
|
||||||
classpath ("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20")
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$KOTLIN_GRADLE_PLUGIN"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id 'com.android.application' version '7.2.2' apply false
|
id 'com.android.application' version "$ANDROID_APPLICATION" apply false
|
||||||
id 'com.android.library' version '7.2.2' apply false
|
id 'com.android.library' version "$ANDROID_LIBRARY" apply false
|
||||||
id 'com.google.gms.google-services' version '4.3.15' apply false
|
id 'com.google.gms.google-services' version "$GOOGLE_SERVICES" apply false
|
||||||
id 'androidx.navigation.safeargs.kotlin' version '2.4.0' apply false
|
id 'org.jetbrains.kotlin.android' version "$KOTLIN_VERSION" apply false
|
||||||
id 'org.jetbrains.kotlin.android' version "$kotlin_version" apply false
|
id 'com.autonomousapps.dependency-analysis' version "$GRADLE_ANALYZE_VERSION"
|
||||||
}
|
}
|
||||||
|
|
||||||
task clean(type: Delete) {
|
task clean(type: Delete) {
|
||||||
|
|||||||
@@ -9,11 +9,54 @@
|
|||||||
|
|
||||||
# Specifies the JVM arguments used for the daemon process.
|
# Specifies the JVM arguments used for the daemon process.
|
||||||
# The setting is particularly useful for tweaking memory settings.
|
# The setting is particularly useful for tweaking memory settings.
|
||||||
android.enableJetifier=true
|
|
||||||
android.useAndroidX=true
|
|
||||||
org.gradle.jvmargs=-Xmx1536m
|
|
||||||
kotlin.code.style=official
|
kotlin.code.style=official
|
||||||
|
android.defaults.buildfeatures.buildconfig=true
|
||||||
|
android.nonTransitiveRClass=false
|
||||||
|
android.nonFinalResIds=false
|
||||||
# When configured, Gradle will run in incubating parallel mode.
|
# When configured, Gradle will run in incubating parallel mode.
|
||||||
# This option should only be used with decoupled projects. More details, visit
|
# 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
|
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||||
# org.gradle.parallel=true
|
# org.gradle.parallel=true
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Plugin versions
|
||||||
|
LEGACY_SUPPORT_VERSION = 1.0.0
|
||||||
|
FRAGMENT_VERSION = 1.4.0
|
||||||
|
MATERIAL_VERSION = 1.0.0
|
||||||
|
CONSTR_LAYOUT_VERSION = 1.1.3
|
||||||
|
PERMISSIONS_DISPATCHER = 4.9.2
|
||||||
|
TOMTOM_VERSION = 2.4771
|
||||||
|
NAVIGATION_VERSION = 2.5.0
|
||||||
|
PREFERENCES_VERSION = 1.2.1
|
||||||
|
MOKITO_INLINE_VERSION = 2.13.0
|
||||||
|
CORE_TEST_VERSION = 2.1.0
|
||||||
|
MOCKK_VERSION = 1.10.5
|
||||||
|
TEST_JUNIT_VERSION = 1.1.5
|
||||||
|
TEST_RUNNER_VERSION = 1.5.2
|
||||||
|
ESPRESSO_VERSION = 3.5.1
|
||||||
|
HAMCREST_VERSION = 2.2
|
||||||
|
JUNIT_VERSION = 4.13.2
|
||||||
|
KODEIN_VERSION = 6.2.1
|
||||||
|
ROOM_VERSION = 2.4.3
|
||||||
|
KOTLINX_COROUTINES = 1.6.1
|
||||||
|
TEST_KTX_VERSION = 1.4.0
|
||||||
|
GOOGLE_PLAY_SERVICE = 21.3.0
|
||||||
|
GOOGLE_SERVICES = 4.3.15
|
||||||
|
ANDROID_LIBRARY = 8.0.0
|
||||||
|
ANDROID_APPLICATION = 8.0.0
|
||||||
|
GRADLE_PLUGIN_VERSION = 8.0.0
|
||||||
|
KOTLIN_VERSION = 1.9.0
|
||||||
|
KOTLIN_GRADLE_PLUGIN = 1.6.21
|
||||||
|
GRADLE_ANALYZE_VERSION = 1.20.0
|
||||||
|
|
||||||
|
# Android configuration
|
||||||
|
TARGET_SDK_VERSION = 33
|
||||||
|
MIN_SDK_VERSION = 26
|
||||||
|
|
||||||
|
# Gradle parameters
|
||||||
|
org.gradle.jvmargs = -Xmx1536m
|
||||||
|
|
||||||
|
# AndroidX
|
||||||
|
android.useAndroidX = true
|
||||||
|
android.enableJetifier = true
|
||||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,6 @@
|
|||||||
#Wed Jul 26 10:14:37 BST 2023
|
#Wed Jul 26 10:14:37 BST 2023
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
Reference in New Issue
Block a user