diff --git a/.gitignore b/.gitignore index ebab689..426a199 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,5 @@ .DS_Store /build /captures -.externalNativeBuild \ No newline at end of file +.externalNativeBuild +.cxx \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..0d15693 --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,134 @@ + + + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+
+
\ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..a55e7a1 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..61a9130 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/dictionaries/Admin.xml b/.idea/dictionaries/Admin.xml new file mode 100644 index 0000000..99898b7 --- /dev/null +++ b/.idea/dictionaries/Admin.xml @@ -0,0 +1,7 @@ + + + + upsert + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..15a15b2 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..9bba60d --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,21 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..b27f7b2 --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml new file mode 100644 index 0000000..0dd4b35 --- /dev/null +++ b/.idea/kotlinc.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..d5d35ec --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/hoc/weatherapp/App.kt b/app/src/main/java/com/hoc/weatherapp/App.kt index adc29e9..39a1ada 100644 --- a/app/src/main/java/com/hoc/weatherapp/App.kt +++ b/app/src/main/java/com/hoc/weatherapp/App.kt @@ -5,6 +5,7 @@ import android.app.NotificationChannel import android.app.NotificationManager import android.os.Build import androidx.work.WorkManager +import com.google.android.libraries.places.api.Places import com.hoc.weatherapp.koin.dataSourceModule import com.hoc.weatherapp.koin.presenterModule import com.hoc.weatherapp.koin.retrofitModule @@ -27,10 +28,15 @@ class App : Application() { AndroidThreeTen.init(this) RxJavaPlugins.setErrorHandler { debug("RxJava error: $it", "RXJAVA_ERROR", it) } startKoin() + setupPlaceApi() createNotificationChannel() observeWorkInfo() } + private fun setupPlaceApi() { + Places.initialize(this, BuildConfig.PLACE_API_KEY) + } + private fun startKoin() { startKoin { androidLogger( diff --git a/app/src/main/java/com/hoc/weatherapp/ui/addcity/AddCityActivity.kt b/app/src/main/java/com/hoc/weatherapp/ui/addcity/AddCityActivity.kt index 6591816..4bdabf2 100644 --- a/app/src/main/java/com/hoc/weatherapp/ui/addcity/AddCityActivity.kt +++ b/app/src/main/java/com/hoc/weatherapp/ui/addcity/AddCityActivity.kt @@ -14,9 +14,10 @@ import androidx.transition.TransitionManager import androidx.transition.TransitionSet import com.google.android.gms.common.api.ResolvableApiException import com.google.android.gms.common.api.Status -import com.google.android.gms.location.places.Place -import com.google.android.gms.location.places.ui.PlaceSelectionListener -import com.google.android.gms.location.places.ui.SupportPlaceAutocompleteFragment +import com.google.android.libraries.places.api.model.Place +import com.google.android.libraries.places.api.model.Place.Field +import com.google.android.libraries.places.widget.AutocompleteSupportFragment +import com.google.android.libraries.places.widget.listener.PlaceSelectionListener import com.hoc.weatherapp.R import com.hoc.weatherapp.ui.BaseMviActivity import com.hoc.weatherapp.utils.debug @@ -93,11 +94,14 @@ class AddCityActivity : BaseMviActivity( } private fun setupAutoCompletePlace() { - (supportFragmentManager.findFragmentById(R.id.place_autocomplete_fragment) as SupportPlaceAutocompleteFragment).run { + (supportFragmentManager.findFragmentById(R.id.place_autocomplete_fragment) as AutocompleteSupportFragment).run { setHint("Search city ...") + + setPlaceFields(listOf(Field.LAT_LNG)) + setOnPlaceSelectedListener(object : PlaceSelectionListener { - override fun onPlaceSelected(place: Place?) { - val latitude = place?.latLng?.latitude ?: return + override fun onPlaceSelected(place: Place) { + val latitude = place.latLng?.latitude ?: return val longitude = place.latLng?.longitude ?: return publishSubjectAutoCompletePlace.onNext(latitude to longitude) } diff --git a/app/src/main/res/layout/activity_add_city.xml b/app/src/main/res/layout/activity_add_city.xml index d0f8e5b..73f78c5 100644 --- a/app/src/main/res/layout/activity_add_city.xml +++ b/app/src/main/res/layout/activity_add_city.xml @@ -27,7 +27,7 @@ NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega