├── .idea ├── .name ├── .gitignore ├── caches │ └── build_file_checksums.ser ├── codeStyles │ ├── codeStyleConfig.xml │ └── Project.xml ├── compiler.xml ├── vcs.xml ├── misc.xml ├── libraries │ ├── Gradle__com_google_code_findbugs_jsr305_2_0_1.xml │ ├── Gradle__androidx_constraintlayout_constraintlayout_solver_2_0_4.xml │ ├── Gradle__androidx_collection_collection_1_1_0.xml │ ├── Gradle__androidx_arch_core_core_common_2_1_0.xml │ ├── Gradle__androidx_collection_collection_ktx_1_1_0.xml │ ├── Gradle__androidx_lifecycle_lifecycle_common_2_2_0.xml │ ├── Gradle__junit_junit_4_12.xml │ ├── Gradle__androidx_constraintlayout_constraintlayout_2_0_4_aar.xml │ ├── Gradle__junit_junit_4_13_2.xml │ ├── Gradle__javax_inject_javax_inject_1.xml │ ├── Gradle__com_squareup_okio_okio_1_17_2.xml │ ├── Gradle__com_google_code_gson_gson_2_6_1.xml │ ├── Gradle__com_squareup_moshi_moshi_1_9_3.xml │ ├── Gradle__com_squareup_javawriter_2_1_1.xml │ ├── Gradle__org_hamcrest_hamcrest_core_1_3.xml │ ├── Gradle__org_jetbrains_annotations_13_0.xml │ ├── Gradle__com_squareup_okhttp3_okhttp_3_14_9.xml │ ├── Gradle__com_squareup_picasso_picasso_2_5_2.xml │ ├── Gradle__com_squareup_retrofit2_retrofit_2_9_0.xml │ ├── Gradle__org_hamcrest_hamcrest_library_1_3.xml │ ├── Gradle__androidx_annotation_annotation_1_1_0.xml │ ├── Gradle__com_google_android_gms_play_services_places_placereport_17_0_0_aar.xml │ ├── Gradle__androidx_loader_loader_1_0_0_aar.xml │ ├── Gradle__org_hamcrest_hamcrest_integration_1_3.xml │ ├── Gradle__org_jetbrains_kotlin_kotlin_stdlib_1_3_72.xml │ ├── Gradle__androidx_cardview_cardview_1_0_0_aar.xml │ ├── Gradle__com_squareup_retrofit2_converter_gson_2_0_0.xml │ ├── Gradle__androidx_viewpager_viewpager_1_0_0_aar.xml │ ├── Gradle__androidx_core_core_ktx_1_3_2_aar.xml │ ├── Gradle__androidx_customview_customview_1_1_0_aar.xml │ ├── Gradle__androidx_activity_activity_1_1_0_aar.xml │ ├── Gradle__androidx_arch_core_core_runtime_2_1_0_aar.xml │ ├── Gradle__androidx_documentfile_documentfile_1_0_0_aar.xml │ ├── Gradle__androidx_interpolator_interpolator_1_0_0_aar.xml │ ├── Gradle__androidx_navigation_navigation_ui_2_3_5_aar.xml │ ├── Gradle__androidx_cursoradapter_cursoradapter_1_0_0_aar.xml │ ├── Gradle__androidx_savedstate_savedstate_1_0_0_aar.xml │ ├── Gradle__androidx_activity_activity_ktx_1_1_0_aar.xml │ ├── Gradle__androidx_fragment_fragment_ktx_1_2_4_aar.xml │ ├── Gradle__androidx_databinding_viewbinding_4_1_2_aar.xml │ ├── Gradle__androidx_legacy_legacy_support_v4_1_0_0_aar.xml │ ├── Gradle__androidx_vectordrawable_vectordrawable_1_1_0_aar.xml │ ├── Gradle__androidx_lifecycle_lifecycle_runtime_2_2_0_aar.xml │ ├── Gradle__androidx_navigation_navigation_common_2_3_5_aar.xml │ ├── Gradle__androidx_navigation_navigation_ui_ktx_2_3_5_aar.xml │ ├── Gradle__org_jetbrains_kotlin_kotlin_stdlib_common_1_3_72.xml │ ├── Gradle__org_jetbrains_kotlinx_kotlinx_coroutines_core_1_3_0.xml │ ├── Gradle__androidx_lifecycle_lifecycle_livedata_2_0_0_aar.xml │ ├── Gradle__androidx_navigation_navigation_runtime_2_3_5_aar.xml │ ├── Gradle__androidx_dynamicanimation_dynamicanimation_1_0_0_aar.xml │ ├── Gradle__androidx_lifecycle_lifecycle_viewmodel_2_2_0_aar.xml │ ├── Gradle__androidx_navigation_navigation_fragment_2_3_5_aar.xml │ ├── Gradle__androidx_slidingpanelayout_slidingpanelayout_1_0_0_aar.xml │ ├── Gradle__androidx_legacy_legacy_support_core_ui_1_0_0_aar.xml │ ├── Gradle__org_jetbrains_kotlinx_kotlinx_coroutines_android_1_3_0.xml │ ├── Gradle__androidx_navigation_navigation_common_ktx_2_3_5_aar.xml │ ├── Gradle__androidx_navigation_navigation_runtime_ktx_2_3_5_aar.xml │ ├── Gradle__androidx_appcompat_appcompat_resources_1_2_0_aar.xml │ ├── Gradle__androidx_asynclayoutinflater_asynclayoutinflater_1_0_0_aar.xml │ ├── Gradle__androidx_lifecycle_lifecycle_livedata_core_2_2_0_aar.xml │ ├── Gradle__androidx_navigation_navigation_fragment_ktx_2_3_5_aar.xml │ ├── Gradle__androidx_versionedparcelable_versionedparcelable_1_1_0_aar.xml │ ├── Gradle__androidx_legacy_legacy_support_core_utils_1_0_0_aar.xml │ ├── Gradle__androidx_lifecycle_lifecycle_runtime_ktx_2_2_0_aar.xml │ ├── Gradle__com_google_android_gms_play_services_base_17_3_0_aar.xml │ ├── Gradle__androidx_vectordrawable_vectordrawable_animated_1_1_0_aar.xml │ ├── Gradle__com_google_android_gms_play_services_tasks_17_1_0_aar.xml │ ├── Gradle__androidx_localbroadcastmanager_localbroadcastmanager_1_0_0_aar.xml │ ├── Gradle__androidx_lifecycle_lifecycle_viewmodel_ktx_2_2_0_aar.xml │ ├── Gradle__androidx_annotation_annotation_experimental_1_0_0_aar.xml │ ├── Gradle__androidx_core_core_1_3_2_aar.xml │ ├── Gradle__com_google_android_gms_play_services_basement_17_3_0_aar.xml │ ├── Gradle__com_google_android_gms_play_services_location_17_1_0_aar.xml │ ├── Gradle__androidx_lifecycle_lifecycle_livedata_core_ktx_2_2_0_aar.xml │ ├── Gradle__androidx_media_media_1_0_0_aar.xml │ ├── Gradle__androidx_print_print_1_0_0_aar.xml │ ├── Gradle__androidx_test_runner_1_3_0_aar.xml │ ├── Gradle__androidx_test_core_1_3_0_aar.xml │ ├── Gradle__androidx_test_monitor_1_3_0_aar.xml │ ├── Gradle__androidx_lifecycle_lifecycle_viewmodel_savedstate_2_2_0_aar.xml │ ├── Gradle__androidx_fragment_fragment_1_2_4_aar.xml │ ├── Gradle__androidx_test_ext_junit_1_1_2_aar.xml │ ├── Gradle__androidx_appcompat_appcompat_1_2_0_aar.xml │ ├── Gradle__androidx_transition_transition_1_3_0_aar.xml │ ├── Gradle__androidx_transition_transition_1_2_0_aar.xml │ ├── Gradle__com_google_android_material_material_1_3_0_aar.xml │ ├── Gradle__androidx_drawerlayout_drawerlayout_1_1_1_aar.xml │ ├── Gradle__androidx_recyclerview_recyclerview_1_1_0_aar.xml │ ├── Gradle__androidx_viewpager2_viewpager2_1_0_0_aar.xml │ ├── Gradle__androidx_test_espresso_espresso_core_3_3_0_aar.xml │ ├── Gradle__androidx_coordinatorlayout_coordinatorlayout_1_1_0_aar.xml │ ├── Gradle__androidx_swiperefreshlayout_swiperefreshlayout_1_0_0_aar.xml │ └── Gradle__androidx_test_espresso_espresso_idling_resource_3_3_0_aar.xml ├── modules.xml ├── gradle.xml ├── modules │ └── Weather_App.iml ├── jarRepositories.xml └── navEditor.xml ├── app ├── .gitignore ├── src │ ├── main │ │ ├── ic_launcher-playstore.png │ │ ├── res │ │ │ ├── drawable-hdpi │ │ │ │ └── illutration.png │ │ │ ├── drawable-ldpi │ │ │ │ └── illutration.png │ │ │ ├── drawable-mdpi │ │ │ │ └── illutration.png │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── drawable-xhdpi │ │ │ │ └── illutration.png │ │ │ ├── drawable-xxhdpi │ │ │ │ └── illutration.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── drawable-xxxhdpi │ │ │ │ └── illutration.png │ │ │ ├── values │ │ │ │ ├── preloaded_fonts.xml │ │ │ │ ├── themes.xml │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ ├── style.xml │ │ │ │ └── font_certs.xml │ │ │ ├── drawable │ │ │ │ ├── card_background.xml │ │ │ │ ├── card_item_bg.xml │ │ │ │ ├── card_item_bg_first.xml │ │ │ │ ├── ic_arrow_back_24px.xml │ │ │ │ ├── card_with_box_shadow.xml │ │ │ │ └── ic_launcher_background.xml │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ ├── values-night │ │ │ │ └── themes.xml │ │ │ ├── font │ │ │ │ └── roboto_medium.xml │ │ │ ├── layout │ │ │ │ ├── activity_main.xml │ │ │ │ ├── card_item.xml │ │ │ │ ├── fragment_virtual.xml │ │ │ │ ├── card_detail.xml │ │ │ │ └── fragment_detail.xml │ │ │ ├── navigation │ │ │ │ └── nav_graph.xml │ │ │ └── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── weatherapp │ │ │ │ ├── model │ │ │ │ ├── WeatherForecast.kt │ │ │ │ ├── SevenDayForecast.kt │ │ │ │ └── Weather.kt │ │ │ │ ├── DayWeather.kt │ │ │ │ ├── CardDetail.kt │ │ │ │ ├── Util.kt │ │ │ │ ├── fragment │ │ │ │ ├── VirtualFragment.kt │ │ │ │ ├── DetailFragment.kt │ │ │ │ └── HomeFragment.kt │ │ │ │ ├── adapter │ │ │ │ ├── DetailAdapter.kt │ │ │ │ └── CardAdapter.kt │ │ │ │ ├── api │ │ │ │ └── WeatherServiceApi.kt │ │ │ │ ├── viewmodel │ │ │ │ ├── DetailViewModel.kt │ │ │ │ └── HomeViewModel.kt │ │ │ │ └── MainActivity.kt │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── example │ │ │ └── weatherapp │ │ │ └── ExampleUnitTest.kt │ └── androidTest │ │ └── java │ │ └── com │ │ └── example │ │ └── weatherapp │ │ └── ExampleInstrumentedTest.kt ├── proguard-rules.pro └── build.gradle ├── .gradle ├── 6.5 │ ├── gc.properties │ ├── fileChanges │ │ └── last-build.bin │ ├── fileHashes │ │ ├── fileHashes.bin │ │ ├── fileHashes.lock │ │ └── resourceHashesCache.bin │ ├── fileContent │ │ └── fileContent.lock │ ├── javaCompile │ │ ├── classAnalysis.bin │ │ ├── jarAnalysis.bin │ │ ├── javaCompile.lock │ │ └── taskHistory.bin │ └── executionHistory │ │ ├── executionHistory.bin │ │ └── executionHistory.lock ├── vcs-1 │ └── gc.properties ├── buildOutputCleanup │ ├── cache.properties │ ├── outputFiles.bin │ └── buildOutputCleanup.lock └── checksums │ ├── checksums.lock │ ├── md5-checksums.bin │ └── sha1-checksums.bin ├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── README.md ├── local.properties ├── gradle.properties ├── gradlew.bat └── gradlew /.idea/.name: -------------------------------------------------------------------------------- 1 | Weather App -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /.gradle/6.5/gc.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gradle/vcs-1/gc.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gradle/6.5/fileChanges/last-build.bin: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | rootProject.name = "Weather App" -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /.gradle/buildOutputCleanup/cache.properties: -------------------------------------------------------------------------------- 1 | #Thu Mar 18 00:47:40 ICT 2021 2 | gradle.version=6.5 3 | -------------------------------------------------------------------------------- /.gradle/checksums/checksums.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingo213/Weather-Android-App-Kotlin/HEAD/.gradle/checksums/checksums.lock -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingo213/Weather-Android-App-Kotlin/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /.gradle/checksums/md5-checksums.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingo213/Weather-Android-App-Kotlin/HEAD/.gradle/checksums/md5-checksums.bin -------------------------------------------------------------------------------- /.gradle/checksums/sha1-checksums.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingo213/Weather-Android-App-Kotlin/HEAD/.gradle/checksums/sha1-checksums.bin -------------------------------------------------------------------------------- /.gradle/6.5/fileHashes/fileHashes.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingo213/Weather-Android-App-Kotlin/HEAD/.gradle/6.5/fileHashes/fileHashes.bin -------------------------------------------------------------------------------- /.gradle/6.5/fileHashes/fileHashes.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingo213/Weather-Android-App-Kotlin/HEAD/.gradle/6.5/fileHashes/fileHashes.lock -------------------------------------------------------------------------------- /.idea/caches/build_file_checksums.ser: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingo213/Weather-Android-App-Kotlin/HEAD/.idea/caches/build_file_checksums.ser -------------------------------------------------------------------------------- /app/src/main/ic_launcher-playstore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingo213/Weather-Android-App-Kotlin/HEAD/app/src/main/ic_launcher-playstore.png -------------------------------------------------------------------------------- /.gradle/6.5/fileContent/fileContent.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingo213/Weather-Android-App-Kotlin/HEAD/.gradle/6.5/fileContent/fileContent.lock -------------------------------------------------------------------------------- /.gradle/6.5/javaCompile/classAnalysis.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingo213/Weather-Android-App-Kotlin/HEAD/.gradle/6.5/javaCompile/classAnalysis.bin -------------------------------------------------------------------------------- /.gradle/6.5/javaCompile/jarAnalysis.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingo213/Weather-Android-App-Kotlin/HEAD/.gradle/6.5/javaCompile/jarAnalysis.bin -------------------------------------------------------------------------------- /.gradle/6.5/javaCompile/javaCompile.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingo213/Weather-Android-App-Kotlin/HEAD/.gradle/6.5/javaCompile/javaCompile.lock -------------------------------------------------------------------------------- /.gradle/6.5/javaCompile/taskHistory.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingo213/Weather-Android-App-Kotlin/HEAD/.gradle/6.5/javaCompile/taskHistory.bin -------------------------------------------------------------------------------- /.gradle/buildOutputCleanup/outputFiles.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingo213/Weather-Android-App-Kotlin/HEAD/.gradle/buildOutputCleanup/outputFiles.bin -------------------------------------------------------------------------------- /.gradle/6.5/fileHashes/resourceHashesCache.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingo213/Weather-Android-App-Kotlin/HEAD/.gradle/6.5/fileHashes/resourceHashesCache.bin -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/illutration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingo213/Weather-Android-App-Kotlin/HEAD/app/src/main/res/drawable-hdpi/illutration.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-ldpi/illutration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingo213/Weather-Android-App-Kotlin/HEAD/app/src/main/res/drawable-ldpi/illutration.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/illutration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingo213/Weather-Android-App-Kotlin/HEAD/app/src/main/res/drawable-mdpi/illutration.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingo213/Weather-Android-App-Kotlin/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingo213/Weather-Android-App-Kotlin/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingo213/Weather-Android-App-Kotlin/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingo213/Weather-Android-App-Kotlin/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/illutration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingo213/Weather-Android-App-Kotlin/HEAD/app/src/main/res/drawable-xhdpi/illutration.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/illutration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingo213/Weather-Android-App-Kotlin/HEAD/app/src/main/res/drawable-xxhdpi/illutration.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingo213/Weather-Android-App-Kotlin/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /.gradle/6.5/executionHistory/executionHistory.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingo213/Weather-Android-App-Kotlin/HEAD/.gradle/6.5/executionHistory/executionHistory.bin -------------------------------------------------------------------------------- /.gradle/6.5/executionHistory/executionHistory.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingo213/Weather-Android-App-Kotlin/HEAD/.gradle/6.5/executionHistory/executionHistory.lock -------------------------------------------------------------------------------- /.gradle/buildOutputCleanup/buildOutputCleanup.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingo213/Weather-Android-App-Kotlin/HEAD/.gradle/buildOutputCleanup/buildOutputCleanup.lock -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/illutration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingo213/Weather-Android-App-Kotlin/HEAD/app/src/main/res/drawable-xxxhdpi/illutration.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingo213/Weather-Android-App-Kotlin/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingo213/Weather-Android-App-Kotlin/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingo213/Weather-Android-App-Kotlin/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingo213/Weather-Android-App-Kotlin/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bingo213/Weather-Android-App-Kotlin/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/java/com/example/weatherapp/model/WeatherForecast.kt: -------------------------------------------------------------------------------- 1 | package com.example.weatherapp.model 2 | 3 | class WeatherForecast { 4 | var list = ArrayList() 5 | } 6 | 7 | -------------------------------------------------------------------------------- /.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Weather-Android-App-Kotlin 2 | Simple weather app using Kotlin 3 | 4 | 5 | https://user-images.githubusercontent.com/56663780/128003655-f0616215-a8df-481f-8035-6cf244ead1c6.mp4 6 | 7 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/weatherapp/DayWeather.kt: -------------------------------------------------------------------------------- 1 | package com.example.weatherapp 2 | 3 | data class DayWeather( 4 | val day: String, 5 | val hour: String, 6 | val tempo: Int, 7 | val icon: String 8 | ) -------------------------------------------------------------------------------- /app/src/main/res/values/preloaded_fonts.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | @font/roboto_medium 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/card_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/card_item_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/weatherapp/CardDetail.kt: -------------------------------------------------------------------------------- 1 | package com.example.weatherapp 2 | 3 | data class CardDetail( 4 | // val weatherIcon: Int, 5 | val tempMax: Int, 6 | val tempMin: Int, 7 | val icon: String, 8 | val dateTime: String 9 | ) -------------------------------------------------------------------------------- /app/src/main/res/drawable/card_item_bg_first.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/values-night/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu Mar 18 00:47:22 ICT 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-6.5-bin.zip 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Weather App 3 | A girl next to her car, is waiting for someone\'s message 4 | Hello blank fragment 5 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/weatherapp/Util.kt: -------------------------------------------------------------------------------- 1 | package com.example.weatherapp 2 | 3 | val KELVIN_TO_CELSIUS = 273.15 4 | val METER_PER_SECOND_TO_KILOMETER_PER_HOUR = 3.6 5 | val BASE_URL = "https://api.openweathermap.org" 6 | val APPID = "1db025ac283a13fd0f776ff93a691693" 7 | val HOUR_FORECAST = intArrayOf(0, 3, 6, 9, 12, 15, 18, 21) 8 | 9 | var LATITUDE = 0.0 10 | var LONGITUDE = 0.0 -------------------------------------------------------------------------------- /app/src/main/java/com/example/weatherapp/model/SevenDayForecast.kt: -------------------------------------------------------------------------------- 1 | package com.example.weatherapp.model 2 | 3 | class DailyForecast { 4 | var daily = ArrayList() 5 | } 6 | 7 | class Temp { 8 | val max = 0f 9 | val min = 0f 10 | } 11 | 12 | class DailyWeather { 13 | val temp: Temp? = null 14 | val weather = ArrayList() 15 | } 16 | 17 | 18 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/font/roboto_medium.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_arrow_back_24px.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__com_google_code_findbugs_jsr305_2_0_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/test/java/com/example/weatherapp/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.example.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 | } -------------------------------------------------------------------------------- /local.properties: -------------------------------------------------------------------------------- 1 | ## This file is automatically generated by Android Studio. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file should *NOT* be checked into Version Control Systems, 5 | # as it contains information specific to your local configuration. 6 | # 7 | # Location of the SDK. This is only used by Gradle. 8 | # For customization when using a Version Control System, please read the 9 | # header note. 10 | sdk.dir=C\:\\Users\\Hp\\AppData\\Local\\Android\\Sdk -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_constraintlayout_constraintlayout_solver_2_0_4.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #1F3F9C 4 | #586994 5 | #59586994 6 | #353535 7 | #848484 8 | #5472BC 9 | #475D93 10 | #F6F7F9 11 | #DFDDDD 12 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_collection_collection_1_1_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_arch_core_core_common_2_1_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_collection_collection_ktx_1_1_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_lifecycle_lifecycle_common_2_2_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__junit_junit_4_12.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_constraintlayout_constraintlayout_2_0_4_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__junit_junit_4_13_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/weatherapp/model/Weather.kt: -------------------------------------------------------------------------------- 1 | package com.example.weatherapp.model 2 | 3 | class Weather { 4 | var weather = ArrayList() 5 | var main: Main? = null 6 | var wind: Wind? = null 7 | var clouds: Clouds? = null 8 | var name: String? = null 9 | var dt_txt: String?=null 10 | 11 | override fun toString(): String { 12 | return main?.temp.toString() 13 | } 14 | } 15 | 16 | class Wind { 17 | var speed = 0f 18 | } 19 | 20 | class Clouds { 21 | var all = 0f 22 | } 23 | 24 | class Main { 25 | var temp = 0f 26 | var feels_like = 0f 27 | var humidity = 0f 28 | } 29 | 30 | class WeatherMain { 31 | var main: String? = null 32 | var icon: String? = null 33 | var description: String? = null 34 | } -------------------------------------------------------------------------------- /.idea/libraries/Gradle__javax_inject_javax_inject_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__com_squareup_okio_okio_1_17_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__com_google_code_gson_gson_2_6_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__com_squareup_moshi_moshi_1_9_3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__com_squareup_javawriter_2_1_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__org_hamcrest_hamcrest_core_1_3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__org_jetbrains_annotations_13_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__com_squareup_okhttp3_okhttp_3_14_9.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__com_squareup_picasso_picasso_2_5_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/example/weatherapp/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.example.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.example.weatherapp", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /.idea/libraries/Gradle__com_squareup_retrofit2_retrofit_2_9_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__org_hamcrest_hamcrest_library_1_3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /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 -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_annotation_annotation_1_1_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__com_google_android_gms_play_services_places_placereport_17_0_0_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_loader_loader_1_0_0_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__org_hamcrest_hamcrest_integration_1_3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_1_3_72.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_cardview_cardview_1_0_0_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 17 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__com_squareup_retrofit2_converter_gson_2_0_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_viewpager_viewpager_1_0_0_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_core_core_ktx_1_3_2_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_customview_customview_1_1_0_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_activity_activity_1_1_0_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_arch_core_core_runtime_2_1_0_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_documentfile_documentfile_1_0_0_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_interpolator_interpolator_1_0_0_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_navigation_navigation_ui_2_3_5_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_cursoradapter_cursoradapter_1_0_0_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_savedstate_savedstate_1_0_0_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_activity_activity_ktx_1_1_0_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_fragment_fragment_ktx_1_2_4_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_databinding_viewbinding_4_1_2_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_legacy_legacy_support_v4_1_0_0_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_vectordrawable_vectordrawable_1_1_0_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_lifecycle_lifecycle_runtime_2_2_0_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_navigation_navigation_common_2_3_5_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_navigation_navigation_ui_ktx_2_3_5_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_common_1_3_72.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__org_jetbrains_kotlinx_kotlinx_coroutines_core_1_3_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_2_0_0_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_navigation_navigation_runtime_2_3_5_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_dynamicanimation_dynamicanimation_1_0_0_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_lifecycle_lifecycle_viewmodel_2_2_0_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_navigation_navigation_fragment_2_3_5_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_slidingpanelayout_slidingpanelayout_1_0_0_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_legacy_legacy_support_core_ui_1_0_0_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__org_jetbrains_kotlinx_kotlinx_coroutines_android_1_3_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_navigation_navigation_common_ktx_2_3_5_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_navigation_navigation_runtime_ktx_2_3_5_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_appcompat_appcompat_resources_1_2_0_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_asynclayoutinflater_asynclayoutinflater_1_0_0_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_core_2_2_0_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_navigation_navigation_fragment_ktx_2_3_5_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_versionedparcelable_versionedparcelable_1_1_0_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_legacy_legacy_support_core_utils_1_0_0_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_lifecycle_lifecycle_runtime_ktx_2_2_0_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__com_google_android_gms_play_services_base_17_3_0_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_vectordrawable_vectordrawable_animated_1_1_0_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__com_google_android_gms_play_services_tasks_17_1_0_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_localbroadcastmanager_localbroadcastmanager_1_0_0_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_lifecycle_lifecycle_viewmodel_ktx_2_2_0_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_annotation_annotation_experimental_1_0_0_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_core_core_1_3_2_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__com_google_android_gms_play_services_basement_17_3_0_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__com_google_android_gms_play_services_location_17_1_0_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 22 | 23 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_core_ktx_2_2_0_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_media_media_1_0_0_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_print_print_1_0_0_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_test_runner_1_3_0_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_test_core_1_3_0_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_test_monitor_1_3_0_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_lifecycle_lifecycle_viewmodel_savedstate_2_2_0_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_fragment_fragment_1_2_4_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_test_ext_junit_1_1_2_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_appcompat_appcompat_1_2_0_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_transition_transition_1_3_0_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_transition_transition_1_2_0_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /.idea/modules/Weather_App.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__com_google_android_material_material_1_3_0_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_drawerlayout_drawerlayout_1_1_1_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_recyclerview_recyclerview_1_1_0_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_viewpager2_viewpager2_1_0_0_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_test_espresso_espresso_core_3_3_0_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | 24 | 25 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_coordinatorlayout_coordinatorlayout_1_1_0_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_swiperefreshlayout_swiperefreshlayout_1_0_0_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /.idea/libraries/Gradle__androidx_test_espresso_espresso_idling_resource_3_3_0_aar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /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 -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 17 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /app/src/main/res/navigation/nav_graph.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 14 | 17 | 18 | 23 | 26 | 27 | 32 | 36 | 37 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/weatherapp/fragment/VirtualFragment.kt: -------------------------------------------------------------------------------- 1 | package com.example.weatherapp.fragment 2 | 3 | import android.os.Bundle 4 | import androidx.fragment.app.Fragment 5 | import android.view.LayoutInflater 6 | import android.view.View 7 | import android.view.ViewGroup 8 | import com.example.weatherapp.MainActivity 9 | import com.example.weatherapp.R 10 | import com.example.weatherapp.databinding.FragmentHomeBinding 11 | import com.example.weatherapp.databinding.FragmentVirtualBinding 12 | import com.example.weatherapp.model.Main 13 | 14 | // TODO: Rename parameter arguments, choose names that match 15 | // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER 16 | private const val ARG_PARAM1 = "param1" 17 | private const val ARG_PARAM2 = "param2" 18 | 19 | /** 20 | * A simple [Fragment] subclass. 21 | * Use the [VirtualFragment.newInstance] factory method to 22 | * create an instance of this fragment. 23 | */ 24 | class VirtualFragment : Fragment() { 25 | private lateinit var binding : FragmentVirtualBinding 26 | 27 | override fun onCreateView( 28 | inflater: LayoutInflater, container: ViewGroup?, 29 | savedInstanceState: Bundle? 30 | ): View? { 31 | binding = FragmentVirtualBinding.inflate(inflater) 32 | 33 | binding.next.setOnClickListener { 34 | val homeFragment = HomeFragment() 35 | (activity as MainActivity).loadFragment(homeFragment) 36 | } 37 | 38 | if((activity as MainActivity).permissions == 1){ 39 | binding.next.visibility = View.GONE 40 | } 41 | else{ 42 | binding.next.visibility = View.VISIBLE 43 | } 44 | 45 | return binding.root 46 | } 47 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/card_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 20 | 21 | 28 | 29 | 37 | 38 | 44 | 45 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/weatherapp/adapter/DetailAdapter.kt: -------------------------------------------------------------------------------- 1 | package com.example.weatherapp.adapter 2 | 3 | import android.view.LayoutInflater 4 | import android.view.View 5 | import android.view.ViewGroup 6 | import android.widget.ImageView 7 | import android.widget.TextView 8 | import androidx.recyclerview.widget.RecyclerView 9 | import com.example.weatherapp.CardDetail 10 | import com.example.weatherapp.R 11 | import com.squareup.picasso.Picasso 12 | 13 | class DetailAdapter(private val listCard: ArrayList) : RecyclerView.Adapter(){ 14 | class DetailHolder(view: View) : RecyclerView.ViewHolder(view) { 15 | val weatherIcon: ImageView = view.findViewById(R.id.weatherIcon) 16 | val dayInfo: TextView = view.findViewById(R.id.dayInfo) 17 | val tempMax: TextView = view.findViewById(R.id.tempMax) 18 | val tempMin: TextView = view.findViewById(R.id.tempMin) 19 | } 20 | 21 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): DetailHolder { 22 | val view = LayoutInflater.from(parent.context).inflate(R.layout.card_detail, parent, false) 23 | return DetailHolder(view) 24 | } 25 | 26 | override fun getItemCount(): Int { 27 | return listCard.size 28 | } 29 | 30 | override fun onBindViewHolder(holder: DetailHolder, position: Int) { 31 | val currentCard = listCard[position] 32 | 33 | // holder.weatherIcon.setImageResource(currentCard.weatherIcon) 34 | holder.dayInfo.text = currentCard.dateTime 35 | holder.tempMax.text = currentCard.tempMax.toString() 36 | holder.tempMin.text = currentCard.tempMin.toString() 37 | Picasso.with(holder.dayInfo.context).load(currentCard.icon).resize(100, 100).into(holder.weatherIcon) 38 | } 39 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/weatherapp/adapter/CardAdapter.kt: -------------------------------------------------------------------------------- 1 | package com.example.weatherapp.adapter 2 | 3 | import android.annotation.SuppressLint 4 | import android.view.LayoutInflater 5 | import android.view.View 6 | import android.view.ViewGroup 7 | import android.widget.ImageView 8 | import android.widget.TextView 9 | import androidx.recyclerview.widget.RecyclerView 10 | import com.example.weatherapp.DayWeather 11 | import com.example.weatherapp.R 12 | import com.squareup.picasso.Picasso 13 | 14 | class CardAdapter(private val listDay: ArrayList) : 15 | RecyclerView.Adapter() { 16 | class CardHolder(view: View) : RecyclerView.ViewHolder(view) { 17 | val day: TextView = view.findViewById(R.id.day) 18 | val hour: TextView = view.findViewById(R.id.hour) 19 | val tempo: TextView = view.findViewById(R.id.tempo) 20 | val icon: ImageView = view.findViewById(R.id.iconInCard) 21 | } 22 | 23 | // private lateinit var context: Context 24 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CardHolder { 25 | // context = parent.context 26 | return CardHolder( 27 | LayoutInflater.from(parent.context).inflate(R.layout.card_item, parent, false) 28 | ) 29 | } 30 | 31 | override fun getItemCount(): Int { 32 | return listDay.size 33 | } 34 | 35 | @SuppressLint("SetTextI18n") 36 | override fun onBindViewHolder(holder: CardHolder, position: Int) { 37 | val currentItem = listDay[position] 38 | 39 | holder.day.text = currentItem.day 40 | holder.hour.text = currentItem.hour 41 | holder.tempo.text = currentItem.tempo.toString() + "°C" 42 | Picasso.with(holder.day.context).load(currentItem.icon).resize(100, 100).into(holder.icon) 43 | } 44 | } -------------------------------------------------------------------------------- /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/layout/fragment_virtual.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 19 | 20 | 32 | 33 | 42 | 43 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/weatherapp/api/WeatherServiceApi.kt: -------------------------------------------------------------------------------- 1 | package com.example.weatherapp.api 2 | 3 | import com.example.weatherapp.BASE_URL 4 | import com.example.weatherapp.model.DailyForecast 5 | import com.example.weatherapp.model.Weather 6 | import com.example.weatherapp.model.WeatherForecast 7 | import kotlinx.coroutines.Deferred 8 | import retrofit2.Call 9 | import retrofit2.Response 10 | import retrofit2.Retrofit 11 | import retrofit2.converter.gson.GsonConverterFactory 12 | import retrofit2.create 13 | import retrofit2.http.GET 14 | import retrofit2.http.Path 15 | import retrofit2.http.Query 16 | 17 | private val retrofit = Retrofit.Builder() 18 | .addConverterFactory(GsonConverterFactory.create()) 19 | .baseUrl(BASE_URL) 20 | .build() 21 | 22 | interface WeatherService { 23 | @GET("data/2.5/weather?") 24 | suspend fun getCurrentWeatherData( 25 | @Query("lat") lat: Double, 26 | @Query("lon") lon: Double, 27 | @Query("appid") appid: String 28 | // @Query("q") city: String, 29 | // @Query("appid") app_id: String 30 | ) : Weather 31 | } 32 | 33 | object WeatherApi{ 34 | val retrofitService : WeatherService by lazy { 35 | retrofit.create(WeatherService::class.java) 36 | } 37 | } 38 | 39 | interface WeatherForecastService{ 40 | @GET("data/2.5/forecast?") 41 | suspend fun getWeatherForecast(@Query("lat") lat: Double, 42 | @Query("lon") lon: Double, 43 | @Query("appid") appid: String) : WeatherForecast 44 | } 45 | 46 | object WeatherForecastApi{ 47 | val weatherForecastService : WeatherForecastService by lazy { 48 | retrofit.create(WeatherForecastService::class.java) 49 | } 50 | } 51 | 52 | interface DailyForecastService { 53 | @GET("data/2.5/onecall?") 54 | suspend fun getDailyForecast(@Query("lat") lat: Double, 55 | @Query("lon") lon: Double, 56 | @Query("appid") appid: String) : DailyForecast 57 | } 58 | 59 | object DailyForecastApi{ 60 | val dailyForecastService : DailyForecastService by lazy { 61 | retrofit.create(DailyForecastService::class.java) 62 | } 63 | } 64 | 65 | -------------------------------------------------------------------------------- /app/src/main/res/layout/card_detail.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 21 | 22 | 31 | 32 | 42 | 43 | 54 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.application' 3 | id 'kotlin-android' 4 | } 5 | 6 | android { 7 | compileSdkVersion 30 8 | buildToolsVersion "30.0.3" 9 | 10 | buildFeatures{ 11 | viewBinding true 12 | } 13 | 14 | defaultConfig { 15 | applicationId "com.example.weatherapp" 16 | minSdkVersion 19 17 | targetSdkVersion 30 18 | versionCode 1 19 | versionName "1.0" 20 | // multiDexEnabled true 21 | 22 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 23 | } 24 | 25 | buildTypes { 26 | release { 27 | minifyEnabled false 28 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 29 | } 30 | } 31 | compileOptions { 32 | sourceCompatibility JavaVersion.VERSION_1_8 33 | targetCompatibility JavaVersion.VERSION_1_8 34 | } 35 | kotlinOptions { 36 | jvmTarget = '1.8' 37 | } 38 | } 39 | 40 | dependencies { 41 | 42 | implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" 43 | implementation 'androidx.core:core-ktx:1.3.2' 44 | implementation 'androidx.appcompat:appcompat:1.2.0' 45 | implementation 'com.google.android.material:material:1.3.0' 46 | implementation 'androidx.constraintlayout:constraintlayout:2.0.4' 47 | implementation 'androidx.legacy:legacy-support-v4:1.0.0' 48 | implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5' 49 | implementation 'androidx.navigation:navigation-ui-ktx:2.3.5' 50 | testImplementation 'junit:junit:4.+' 51 | androidTestImplementation 'androidx.test.ext:junit:1.1.2' 52 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' 53 | 54 | implementation "com.squareup.moshi:moshi:$version_moshi" 55 | // implementation "com.squareup.moshi:moshi-kotlin:$version_moshi" 56 | 57 | implementation "com.squareup.retrofit2:retrofit:$version_retrofit" 58 | 59 | implementation 'com.squareup.retrofit2:converter-gson:2.0.0' 60 | 61 | implementation "android.arch.navigation:navigation-fragment-ktx:$version_navigation" 62 | implementation "android.arch.navigation:navigation-ui-ktx:$version_navigation" 63 | 64 | implementation "com.google.android.gms:play-services-location:17.1.0" 65 | 66 | implementation 'com.squareup.picasso:picasso:2.5.2' 67 | } -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/card_with_box_shadow.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /app/src/main/res/values/style.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 12 | 13 | 17 | 18 | 24 | 25 | 31 | 32 | 35 | 36 | 43 | 44 | 51 | 52 | 57 | 58 | 63 | 64 | 69 | 74 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/weatherapp/fragment/DetailFragment.kt: -------------------------------------------------------------------------------- 1 | package com.example.weatherapp.fragment 2 | 3 | import android.annotation.SuppressLint 4 | import android.os.Bundle 5 | import androidx.fragment.app.Fragment 6 | import android.view.LayoutInflater 7 | import android.view.View 8 | import android.view.ViewGroup 9 | import androidx.lifecycle.Observer 10 | import androidx.lifecycle.ViewModelProvider 11 | import androidx.recyclerview.widget.LinearLayoutManager 12 | import androidx.recyclerview.widget.RecyclerView 13 | import com.example.weatherapp.BASE_URL 14 | import com.example.weatherapp.KELVIN_TO_CELSIUS 15 | import com.example.weatherapp.METER_PER_SECOND_TO_KILOMETER_PER_HOUR 16 | import com.example.weatherapp.MainActivity 17 | import com.example.weatherapp.R.id.homeFragment 18 | import com.example.weatherapp.adapter.DetailAdapter 19 | import com.example.weatherapp.databinding.FragmentDetailBinding 20 | import com.example.weatherapp.viewmodel.DetailViewModel 21 | import com.squareup.picasso.Picasso 22 | import java.text.DateFormat 23 | import java.util.* 24 | import kotlin.math.roundToInt 25 | 26 | class DetailFragment : Fragment() { 27 | private lateinit var detailAdapter: DetailAdapter 28 | private lateinit var detailRecyclerView: RecyclerView 29 | 30 | private lateinit var binding: FragmentDetailBinding 31 | 32 | @SuppressLint("SetTextI18n") 33 | override fun onCreateView( 34 | inflater: LayoutInflater, container: ViewGroup?, 35 | savedInstanceState: Bundle? 36 | ): View? { 37 | binding = FragmentDetailBinding.inflate(inflater) 38 | val detailViewModel = ViewModelProvider(this).get(DetailViewModel::class.java) 39 | 40 | binding.backBtn.setOnClickListener { view : View -> 41 | (activity as MainActivity).removeFragment(this) 42 | } 43 | 44 | detailRecyclerView = binding.listCard 45 | detailViewModel.listDailyWeather.observe(viewLifecycleOwner, Observer {cardDetail -> 46 | detailAdapter = DetailAdapter(cardDetail) 47 | detailRecyclerView.adapter = detailAdapter 48 | }) 49 | detailRecyclerView.apply { 50 | setHasFixedSize(true) 51 | layoutManager = LinearLayoutManager(activity) 52 | } 53 | 54 | detailViewModel.weather.observe(viewLifecycleOwner, Observer {weather -> 55 | binding.cloudness.text = weather.clouds?.all?.roundToInt()?.toString() + "%" 56 | binding.temp.text = weather.main?.temp?.minus(KELVIN_TO_CELSIUS)?.roundToInt().toString() + "°C" 57 | 58 | binding.date.text = DateFormat.getDateInstance(DateFormat.FULL, Locale.US) 59 | .format(Calendar.getInstance().time).toString() 60 | 61 | binding.humidity.text = weather.main?.humidity?.roundToInt()?.toString() + "%" 62 | 63 | binding.realFeel.text = weather.main?.feels_like?.minus(KELVIN_TO_CELSIUS)?.roundToInt().toString() + "°C" 64 | 65 | binding.wind.text = 66 | weather.wind?.speed?.times(METER_PER_SECOND_TO_KILOMETER_PER_HOUR)?.roundToInt() 67 | ?.toString() + " km/h" 68 | 69 | binding.main.text = weather.weather[0].main 70 | val iconUrl = BASE_URL + "/img/w/" + weather.weather[0].icon + ".png" 71 | Picasso.with(activity).load(iconUrl).resize(200, 200).into(binding.icon) 72 | }) 73 | 74 | return binding.root 75 | } 76 | 77 | } -------------------------------------------------------------------------------- /.idea/navEditor.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 81 | 82 | -------------------------------------------------------------------------------- /app/src/main/res/values/font_certs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | @array/com_google_android_gms_fonts_certs_dev 5 | @array/com_google_android_gms_fonts_certs_prod 6 | 7 | 8 | 9 | MIIEqDCCA5CgAwIBAgIJANWFuGx90071MA0GCSqGSIb3DQEBBAUAMIGUMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTAeFw0wODA0MTUyMzM2NTZaFw0zNTA5MDEyMzM2NTZaMIGUMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTCCASAwDQYJKoZIhvcNAQEBBQADggENADCCAQgCggEBANbOLggKv+IxTdGNs8/TGFy0PTP6DHThvbbR24kT9ixcOd9W+EaBPWW+wPPKQmsHxajtWjmQwWfna8mZuSeJS48LIgAZlKkpFeVyxW0qMBujb8X8ETrWy550NaFtI6t9+u7hZeTfHwqNvacKhp1RbE6dBRGWynwMVX8XW8N1+UjFaq6GCJukT4qmpN2afb8sCjUigq0GuMwYXrFVee74bQgLHWGJwPmvmLHC69EH6kWr22ijx4OKXlSIx2xT1AsSHee70w5iDBiK4aph27yH3TxkXy9V89TDdexAcKk/cVHYNnDBapcavl7y0RiQ4biu8ymM8Ga/nmzhRKya6G0cGw8CAQOjgfwwgfkwHQYDVR0OBBYEFI0cxb6VTEM8YYY6FbBMvAPyT+CyMIHJBgNVHSMEgcEwgb6AFI0cxb6VTEM8YYY6FbBMvAPyT+CyoYGapIGXMIGUMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbYIJANWFuGx90071MAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEEBQADggEBABnTDPEF+3iSP0wNfdIjIz1AlnrPzgAIHVvXxunW7SBrDhEglQZBbKJEk5kT0mtKoOD1JMrSu1xuTKEBahWRbqHsXclaXjoBADb0kkjVEJu/Lh5hgYZnOjvlba8Ld7HCKePCVePoTJBdI4fvugnL8TsgK05aIskyY0hKI9L8KfqfGTl1lzOv2KoWD0KWwtAWPoGChZxmQ+nBli+gwYMzM1vAkP+aayLe0a1EQimlOalO762r0GXO0ks+UeXde2Z4e+8S/pf7pITEI/tP+MxJTALw9QUWEv9lKTk+jkbqxbsh8nfBUapfKqYn0eidpwq2AzVp3juYl7//fKnaPhJD9gs= 10 | 11 | 12 | 13 | 14 | MIIEQzCCAyugAwIBAgIJAMLgh0ZkSjCNMA0GCSqGSIb3DQEBBAUAMHQxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtHb29nbGUgSW5jLjEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDAeFw0wODA4MjEyMzEzMzRaFw0zNjAxMDcyMzEzMzRaMHQxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtHb29nbGUgSW5jLjEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDCCASAwDQYJKoZIhvcNAQEBBQADggENADCCAQgCggEBAKtWLgDYO6IIrgqWbxJOKdoR8qtW0I9Y4sypEwPpt1TTcvZApxsdyxMJZ2JORland2qSGT2y5b+3JKkedxiLDmpHpDsz2WCbdxgxRczfey5YZnTJ4VZbH0xqWVW/8lGmPav5xVwnIiJS6HXk+BVKZF+JcWjAsb/GEuq/eFdpuzSqeYTcfi6idkyugwfYwXFU1+5fZKUaRKYCwkkFQVfcAs1fXA5V+++FGfvjJ/CxURaSxaBvGdGDhfXE28LWuT9ozCl5xw4Yq5OGazvV24mZVSoOO0yZ31j7kYvtwYK6NeADwbSxDdJEqO4k//0zOHKrUiGYXtqw/A0LFFtqoZKFjnkCAQOjgdkwgdYwHQYDVR0OBBYEFMd9jMIhF1Ylmn/Tgt9r45jk14alMIGmBgNVHSMEgZ4wgZuAFMd9jMIhF1Ylmn/Tgt9r45jk14aloXikdjB0MQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEUMBIGA1UEChMLR29vZ2xlIEluYy4xEDAOBgNVBAsTB0FuZHJvaWQxEDAOBgNVBAMTB0FuZHJvaWSCCQDC4IdGZEowjTAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBAUAA4IBAQBt0lLO74UwLDYKqs6Tm8/yzKkEu116FmH4rkaymUIE0P9KaMftGlMexFlaYjzmB2OxZyl6euNXEsQH8gjwyxCUKRJNexBiGcCEyj6z+a1fuHHvkiaai+KL8W1EyNmgjmyy8AW7P+LLlkR+ho5zEHatRbM/YAnqGcFh5iZBqpknHf1SKMXFh4dd239FJ1jWYfbMDMy3NS5CTMQ2XFI1MvcyUTdZPErjQfTbQe3aDQsQcafEQPD+nqActifKZ0Np0IS9L9kR/wbNvyz6ENwPiTrjV2KRkEjH78ZMcUQXg0L3BYHJ3lc69Vs5Ddf9uUGGMYldX3WfMBEmh/9iFBDAaTCK 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 119 | 120 | 122 | 123 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/weatherapp/viewmodel/DetailViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.example.weatherapp.viewmodel 2 | 3 | import android.os.Build 4 | import android.util.Log 5 | import androidx.annotation.RequiresApi 6 | import androidx.lifecycle.* 7 | import com.example.weatherapp.* 8 | import com.example.weatherapp.api.DailyForecastApi 9 | import com.example.weatherapp.api.WeatherApi 10 | import com.example.weatherapp.api.WeatherForecastApi 11 | import com.example.weatherapp.model.DailyForecast 12 | import com.example.weatherapp.model.Weather 13 | import com.example.weatherapp.model.WeatherForecast 14 | import kotlinx.coroutines.launch 15 | import java.text.DateFormat 16 | import java.text.SimpleDateFormat 17 | import java.time.Instant 18 | import java.time.ZoneId 19 | import java.util.* 20 | import kotlin.collections.ArrayList 21 | import kotlin.math.roundToInt 22 | 23 | class DetailViewModel : ViewModel() { 24 | private val _response = MutableLiveData() 25 | val response: LiveData 26 | get() = _response 27 | 28 | private var _weather = MutableLiveData() 29 | val weather: LiveData 30 | get() = _weather 31 | 32 | private var list: ArrayList = ArrayList() 33 | 34 | private var _listDailyWeather = MutableLiveData>() 35 | .apply { postValue(ArrayList()) } 36 | val listDailyWeather: LiveData> 37 | get() = _listDailyWeather 38 | 39 | init { 40 | getDailyForecast() 41 | getWeather() 42 | Log.i("Detail VM", "init detail VM") 43 | } 44 | 45 | private fun getDailyForecast() { 46 | viewModelScope.launch { 47 | try { 48 | Log.i("Debug", "Long: ${LONGITUDE}, Lat: ${LATITUDE}") 49 | val result = DailyForecastApi.dailyForecastService.getDailyForecast( 50 | LATITUDE, 51 | LONGITUDE, 52 | APPID 53 | ) 54 | // _weatherForecast.value = result 55 | for (i: Int in 1 until result.daily.size) { 56 | val iconUrl = BASE_URL + "/img/w/" + result.daily[i].weather[0].icon + ".png" 57 | result.daily[i]?.temp?.max?.minus(KELVIN_TO_CELSIUS)?.roundToInt() 58 | ?.let { tempMax -> 59 | result.daily[i]?.temp?.min?.minus(KELVIN_TO_CELSIUS)?.roundToInt() 60 | ?.let { tempMin -> 61 | CardDetail(tempMax, tempMin, iconUrl, getDateTime(i)) 62 | } 63 | }?.let { _listDailyWeather.value?.add(it) } 64 | } 65 | _listDailyWeather.value = _listDailyWeather.value 66 | _response.value = "Success!!!" 67 | Log.i("Detail VM", "list size: ${list.size}") 68 | Log.i("Detail VM", "forecastFiveDay size: ${_listDailyWeather.value?.size}") 69 | Log.i("Detail VM", _response.value!!) 70 | } catch (e: Exception) { 71 | _response.value = "Failure: ${e.message}" 72 | Log.i("Detail VM", e.toString()) 73 | } 74 | } 75 | } 76 | 77 | private fun getWeather() { 78 | viewModelScope.launch { 79 | try { 80 | val result = 81 | WeatherApi.retrofitService.getCurrentWeatherData(LATITUDE, LONGITUDE, APPID) 82 | _weather.value = result 83 | _response.value = "Success!!!" 84 | } catch (e: Exception) { 85 | _response.value = "Failure: ${e.message}" 86 | Log.i("VM", e.toString()) 87 | } 88 | } 89 | } 90 | 91 | private fun getDateTime(i: Int): String { 92 | var date = Date() 93 | val calendar = Calendar.getInstance() 94 | calendar.time = date 95 | calendar.add(Calendar.DATE, i) 96 | date = calendar.time 97 | return DateFormat.getDateInstance( 98 | DateFormat.SHORT 99 | ) 100 | .format(date).toString() 101 | } 102 | 103 | } 104 | 105 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/weatherapp/fragment/HomeFragment.kt: -------------------------------------------------------------------------------- 1 | package com.example.weatherapp.fragment 2 | 3 | import android.annotation.SuppressLint 4 | import android.os.Bundle 5 | import android.util.Log 6 | import androidx.fragment.app.Fragment 7 | import android.view.LayoutInflater 8 | import android.view.View 9 | import android.view.ViewGroup 10 | import androidx.lifecycle.Observer 11 | import androidx.lifecycle.ViewModelProvider 12 | import androidx.recyclerview.widget.LinearLayoutManager 13 | import androidx.recyclerview.widget.RecyclerView 14 | import com.example.weatherapp.* 15 | import com.example.weatherapp.adapter.CardAdapter 16 | import com.example.weatherapp.databinding.FragmentHomeBinding 17 | import com.example.weatherapp.viewmodel.HomeViewModel 18 | import com.example.weatherapp.viewmodel.DetailViewModel 19 | import com.squareup.picasso.Picasso 20 | import java.text.DateFormat 21 | import java.util.* 22 | import kotlin.collections.ArrayList 23 | import kotlin.math.roundToInt 24 | 25 | class HomeFragment : Fragment() { 26 | private lateinit var dayAdapter: CardAdapter 27 | private lateinit var dayRecyclerView: RecyclerView 28 | private var listDayWeather : ArrayList = ArrayList() 29 | 30 | private lateinit var binding: FragmentHomeBinding 31 | 32 | @SuppressLint("SetTextI18n") 33 | override fun onCreateView( 34 | inflater: LayoutInflater, container: ViewGroup?, 35 | savedInstanceState: Bundle? 36 | ): View? { 37 | Log.i("HomeFragment", "createView") 38 | binding = FragmentHomeBinding.inflate(inflater) 39 | 40 | binding.seeMore.setOnClickListener { view: View -> 41 | val detailFragment = DetailFragment() 42 | (activity as MainActivity).loadFragment(detailFragment) 43 | } 44 | 45 | val homeViewModel = ViewModelProvider(this).get(HomeViewModel::class.java) 46 | 47 | homeViewModel.weather.observe(viewLifecycleOwner, Observer { weather -> 48 | binding.tempo.text = weather.main?.temp?.let { convertKelvinToCelsius(it) } 49 | 50 | binding.mainWeather.text = weather.weather[0].main 51 | binding.description.text = weather.weather[0].description 52 | binding.dateTime.text = DateFormat.getDateInstance(DateFormat.FULL, Locale.US) 53 | .format(Calendar.getInstance().time).toString() 54 | binding.address.text = weather.name 55 | 56 | binding.humidity.text = weather.main?.humidity?.roundToInt()?.toString() + "%" 57 | binding.progressHumidity.progress = weather.main?.humidity?.roundToInt()!! 58 | 59 | binding.realFeel.text = weather.main?.feels_like?.let { convertKelvinToCelsius(it) } 60 | binding.progressRealFeel.progress = 61 | weather.main?.feels_like?.minus(KELVIN_TO_CELSIUS)?.roundToInt()!! 62 | 63 | binding.wind.text = 64 | weather.wind?.speed?.times(METER_PER_SECOND_TO_KILOMETER_PER_HOUR)?.roundToInt() 65 | ?.toString() + " km/h" 66 | binding.progressWind.progress = weather.wind?.speed?.times( 67 | METER_PER_SECOND_TO_KILOMETER_PER_HOUR 68 | )?.roundToInt()!! 69 | 70 | binding.cloudness.text = weather.clouds?.all?.roundToInt()?.toString() + "%" 71 | binding.progressCloudness.progress = weather.clouds?.all?.roundToInt()!! 72 | 73 | val iconUrl = BASE_URL + "/img/w/" + weather.weather[0].icon + ".png" 74 | Picasso.with(activity).load(iconUrl).resize(200, 200).into(binding.icon) 75 | }) 76 | 77 | dayRecyclerView = binding.bottom 78 | homeViewModel.listDayWeather.observe(viewLifecycleOwner, Observer { 79 | dayAdapter = CardAdapter(it) 80 | dayRecyclerView.adapter = dayAdapter 81 | }) 82 | 83 | dayRecyclerView.apply { 84 | setHasFixedSize(true) 85 | layoutManager = LinearLayoutManager(activity, LinearLayoutManager.HORIZONTAL, false) 86 | } 87 | 88 | return binding.root 89 | } 90 | 91 | private fun convertKelvinToCelsius(temp: Float): String { 92 | return (temp.minus(KELVIN_TO_CELSIUS)).roundToInt().toString() + "°C" 93 | } 94 | 95 | // override fun onStop() { 96 | // super.onStop() 97 | // Log.i("HomeFragment", "Stop") 98 | // } 99 | // 100 | // override fun onDestroy() { 101 | // super.onDestroy() 102 | // Log.i("HomeFragment", "Destroy") 103 | // } 104 | 105 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/weatherapp/viewmodel/HomeViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.example.weatherapp.viewmodel 2 | 3 | import android.annotation.SuppressLint 4 | import android.os.Build 5 | import android.util.Log 6 | import androidx.annotation.RequiresApi 7 | import androidx.lifecycle.LiveData 8 | import androidx.lifecycle.MutableLiveData 9 | import androidx.lifecycle.ViewModel 10 | import androidx.lifecycle.viewModelScope 11 | import com.example.weatherapp.* 12 | import com.example.weatherapp.api.WeatherApi 13 | import com.example.weatherapp.api.WeatherForecastApi 14 | import com.example.weatherapp.model.Weather 15 | import com.google.android.material.timepicker.TimeFormat 16 | import kotlinx.coroutines.launch 17 | import java.text.DateFormat 18 | import java.text.SimpleDateFormat 19 | import java.time.LocalDate 20 | import java.time.LocalDateTime 21 | import java.time.format.DateTimeFormatter 22 | import java.util.* 23 | import kotlin.collections.ArrayList 24 | import kotlin.math.roundToInt 25 | 26 | class HomeViewModel : ViewModel() { 27 | private val _response = MutableLiveData() 28 | val response: LiveData 29 | get() = _response 30 | 31 | private var _weather = MutableLiveData() 32 | val weather: LiveData 33 | get() = _weather 34 | 35 | private var _listDayWeather = MutableLiveData>() 36 | .apply { postValue(ArrayList()) } 37 | val listDayWeather: LiveData> 38 | get() = _listDayWeather 39 | 40 | init { 41 | getWeather() 42 | getWeatherForecast() 43 | } 44 | 45 | private fun getWeather() { 46 | viewModelScope.launch { 47 | try { 48 | val result = 49 | WeatherApi.retrofitService.getCurrentWeatherData(LATITUDE, LONGITUDE, APPID) 50 | _weather.value = result 51 | 52 | _response.value = "Success!!!" 53 | } catch (e: Exception) { 54 | _response.value = "Failure: ${e.message}" 55 | Log.i("VM", e.toString()) 56 | } 57 | } 58 | } 59 | 60 | private fun getWeatherForecast() { 61 | viewModelScope.launch { 62 | try { 63 | Log.i("Debug", "Long: ${LONGITUDE}, Lat: ${LATITUDE}") 64 | val result = WeatherForecastApi.weatherForecastService.getWeatherForecast( 65 | LATITUDE, 66 | LONGITUDE, 67 | APPID 68 | ) 69 | // _weatherForecast.value = result 70 | for (i: Int in HOUR_FORECAST.indices) { 71 | val iconUrl = BASE_URL + "/img/w/" + result.list[i].weather[0].icon + ".png" 72 | result.list[i].main?.temp?.minus(KELVIN_TO_CELSIUS)?.roundToInt()?.let { temp -> 73 | result.list[i].dt_txt?.let { dateTime -> 74 | DayWeather( 75 | dateTime.toDate().formatTo("dd/MM"), 76 | dateTime.toDate().formatTo("HH")+"h", 77 | temp, 78 | iconUrl 79 | ) 80 | } 81 | }?.let { _listDayWeather.value?.add(it) } 82 | 83 | _listDayWeather.value = _listDayWeather.value 84 | } 85 | _response.value = "Success!!!" 86 | Log.i("Home VM", "listDayWeather size: ${_listDayWeather.value?.size}") 87 | Log.i("VM", _response.value!!) 88 | } catch (e: Exception) { 89 | _response.value = "Failure: ${e.message}" 90 | Log.i("VM", e.toString()) 91 | } 92 | } 93 | } 94 | 95 | private fun getDate(dateTime: String): String { 96 | val strArr = dateTime.split(" ")[0].split("-") 97 | return strArr[2] + "/" + strArr[1] 98 | } 99 | 100 | private fun getTime(dateTime: String): String { 101 | return dateTime.split(" ")[1].split(":")[0] + "h" 102 | } 103 | 104 | 105 | private fun String.toDate( 106 | dateFormat: String = "yyyy-MM-dd HH:mm:ss", 107 | timeZone: TimeZone = TimeZone.getTimeZone("UTC") 108 | ): Date { 109 | val parser = SimpleDateFormat(dateFormat, Locale.TAIWAN) 110 | parser.timeZone = timeZone 111 | return parser.parse(this) 112 | } 113 | 114 | private fun Date.formatTo( 115 | dateFormat: String, timeZone: TimeZone = TimeZone.getDefault() 116 | ): String { 117 | val formatter = SimpleDateFormat(dateFormat, Locale.TAIWAN) 118 | formatter.timeZone = timeZone 119 | return formatter.format(this) 120 | } 121 | } 122 | 123 | 124 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 9 | 11 | 13 | 15 | 17 | 19 | 21 | 23 | 25 | 27 | 29 | 31 | 33 | 35 | 37 | 39 | 41 | 43 | 45 | 47 | 49 | 51 | 53 | 55 | 57 | 59 | 61 | 63 | 65 | 67 | 69 | 71 | 73 | 74 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/weatherapp/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.weatherapp 2 | 3 | import android.Manifest 4 | import com.example.weatherapp.databinding.ActivityMainBinding 5 | import com.example.weatherapp.databinding.FragmentHomeBinding 6 | import java.util.* 7 | 8 | import android.content.Context 9 | import android.content.Intent 10 | import android.content.pm.PackageManager 11 | import android.location.Geocoder 12 | import android.location.Location 13 | import android.location.LocationManager 14 | import android.os.Build 15 | import androidx.appcompat.app.AppCompatActivity 16 | import android.os.Bundle 17 | import android.os.Looper 18 | import android.util.Log 19 | import android.view.View 20 | import android.widget.TextView 21 | import android.widget.Toast 22 | import androidx.core.app.ActivityCompat 23 | import androidx.fragment.app.Fragment 24 | import androidx.fragment.app.FragmentManager 25 | import androidx.fragment.app.FragmentTransaction 26 | import androidx.lifecycle.LiveData 27 | import androidx.lifecycle.MutableLiveData 28 | import androidx.navigation.NavController 29 | import androidx.navigation.NavGraph 30 | import androidx.navigation.Navigation 31 | import androidx.navigation.findNavController 32 | import com.example.weatherapp.fragment.HomeFragment 33 | import com.example.weatherapp.fragment.VirtualFragment 34 | import com.example.weatherapp.model.Main 35 | import com.google.android.gms.location.* 36 | 37 | 38 | class MainActivity : AppCompatActivity() { 39 | private lateinit var binding: ActivityMainBinding 40 | private val homeFragment = HomeFragment() 41 | 42 | var permissions = 0 43 | 44 | // Declaring the needed Variables 45 | lateinit var fusedLocationProviderClient: FusedLocationProviderClient 46 | lateinit var locationRequest: LocationRequest 47 | private val PERMISSION_ID = 21 48 | 49 | override fun onCreate(savedInstanceState: Bundle?) { 50 | super.onCreate(savedInstanceState) 51 | binding = ActivityMainBinding.inflate(layoutInflater) 52 | setContentView(binding.root) 53 | 54 | // virtualFragment.hideNextBtn() 55 | 56 | fusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(this) 57 | 58 | RequestPermission() 59 | getLastLocation() 60 | 61 | Log.i("MainActivity", "it catch here") 62 | Log.d("Debug:", "permission " + checkPermission().toString()) 63 | Log.d("Debug:", "location is enable " + isLocationEnabled().toString()) 64 | } 65 | 66 | 67 | fun getLastLocation() { 68 | if (checkPermission()) { 69 | if (isLocationEnabled()) { 70 | fusedLocationProviderClient.lastLocation.addOnCompleteListener { task -> 71 | var location: Location? = task.result 72 | if (location == null) { 73 | NewLocationData() 74 | Log.d("Debug", "location null") 75 | } else { 76 | Log.d( 77 | "Debug:", 78 | "Your Location: Longtitude: " + location.longitude + "Latitude: " + location.latitude 79 | ) 80 | LATITUDE = location.latitude 81 | LONGITUDE = location.longitude 82 | // virtualFragment.displayNextBtn() 83 | loadFragment(homeFragment) 84 | } 85 | } 86 | 87 | } else { 88 | Toast.makeText(this, "Please Turn on Your device Location", Toast.LENGTH_SHORT) 89 | .show() 90 | } 91 | } else { 92 | RequestPermission() 93 | } 94 | } 95 | 96 | 97 | fun NewLocationData() { 98 | locationRequest = LocationRequest() 99 | locationRequest.priority = LocationRequest.PRIORITY_HIGH_ACCURACY 100 | locationRequest.interval = 0 101 | locationRequest.fastestInterval = 0 102 | locationRequest.numUpdates = 1 103 | fusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(this) 104 | checkPermission() 105 | fusedLocationProviderClient.requestLocationUpdates( 106 | locationRequest, locationCallback, Looper.myLooper() 107 | ) 108 | } 109 | 110 | 111 | private val locationCallback = object : LocationCallback() { 112 | override fun onLocationResult(locationResult: LocationResult) { 113 | var lastLocation: Location = locationResult.lastLocation 114 | LATITUDE = lastLocation.latitude 115 | LONGITUDE = lastLocation.longitude 116 | Log.d("Debug:", "your last last location: " + lastLocation.longitude.toString()) 117 | } 118 | } 119 | 120 | fun checkPermission(): Boolean { 121 | //this function will return a boolean 122 | //true: if we have permission 123 | //false if not 124 | if ( 125 | ActivityCompat.checkSelfPermission( 126 | this, 127 | android.Manifest.permission.ACCESS_COARSE_LOCATION 128 | ) == PackageManager.PERMISSION_GRANTED || 129 | ActivityCompat.checkSelfPermission( 130 | this, 131 | android.Manifest.permission.ACCESS_FINE_LOCATION 132 | ) == PackageManager.PERMISSION_GRANTED 133 | ) { 134 | return true 135 | } 136 | 137 | return false 138 | 139 | } 140 | public fun loadFragment(fragment: Fragment){ 141 | supportFragmentManager 142 | .beginTransaction() 143 | .replace(R.id.nav_host_fragment, fragment) 144 | .setCustomAnimations(R.anim.design_bottom_sheet_slide_in, R.anim.design_bottom_sheet_slide_out) 145 | .addToBackStack(null) 146 | .commit() 147 | } 148 | 149 | fun RequestPermission() { 150 | //this function will allows us to tell the user to requesut the necessary permsiion if they are not garented 151 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { 152 | requestPermissions( 153 | arrayOf( 154 | android.Manifest.permission.ACCESS_COARSE_LOCATION, 155 | android.Manifest.permission.ACCESS_FINE_LOCATION 156 | ), 157 | PERMISSION_ID 158 | ) 159 | } 160 | } 161 | 162 | fun isLocationEnabled(): Boolean { 163 | //this function will return to us the state of the location service 164 | //if the gps or the network provider is enabled then it will return true otherwise it will return false 165 | var locationManager = getSystemService(Context.LOCATION_SERVICE) as LocationManager 166 | return locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER) || locationManager.isProviderEnabled( 167 | LocationManager.NETWORK_PROVIDER 168 | ) 169 | } 170 | 171 | 172 | override fun onRequestPermissionsResult( 173 | requestCode: Int, 174 | permissions: Array, 175 | grantResults: IntArray 176 | ) { 177 | if (requestCode == PERMISSION_ID) { 178 | if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) { 179 | // Log.d("Debug:", "You have the Permission") 180 | getLastLocation() 181 | } 182 | } 183 | else 184 | setPermission() 185 | } 186 | 187 | private fun setPermission(){ 188 | permissions = 1 189 | } 190 | 191 | fun removeFragment(fragment: Fragment){ 192 | val manager : FragmentManager = this.supportFragmentManager 193 | val fragTransaction : FragmentTransaction = manager.beginTransaction() 194 | fragTransaction.remove(fragment) 195 | fragTransaction.commit() 196 | manager.popBackStack() 197 | } 198 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_detail.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 18 | 19 | 29 | 30 | 42 | 43 | 44 | 45 | 61 | 62 | 73 | 74 | 81 | 82 | 93 | 94 | 103 | 104 | 115 | 116 | 125 | 126 | 139 | 140 | 149 | 150 | 162 | 163 | 172 | 173 | 184 | 185 | 194 | 195 | 196 | 197 | 208 | 209 | --------------------------------------------------------------------------------