Skip to content

Location Name won't show in Toolbar #18

@Mr-ARBN

Description

@Mr-ARBN

Hello and thanks for the awesome tutorials.
I got a problem with the weather app.
while we use GPS (i meaning the setting in the app), the location's name won't show up in the toolbar.
but if we turn it off, and use custom location, it will be set in the toolbar.

I found the problem here:
weatherLocation.observe(this@CurrentWeatherFragment, Observer { location -> if (location == null) { return@Observer } else { updateLocation(location.name) } })

while we're using GPS, the location.name will be (empty: "") also there are other empty fields too.
looks like there is nothing...

here you see the debug mode:

GPS off:
WeatherLocation(country=United States of America, lat=40.71, localtime=2019-08-24 2:54, localtimeEpoch=1566629689, lon=-74.01, name=New York, region=New York, tzId=America/New_York)

GPS on:
WeatherLocation(country=, lat=35.75, localtime=2019-08-24 11:25, localtimeEpoch=1566629736, lon=51.39, name=, region=, tzId=Asia/Tehran)

How to fix it?

also sometimes we won't get answers from the server and it will return 404 to us.
I don't know how but we get crash when we receive 404. while I remember you handle it
when it happens, logcat will show us the error on (ConnectivityInterceptorImpl) on the if statement

override fun intercept(chain: Interceptor.Chain): Response { if (!isOnline()) { throw NoConnectivityException() } return chain.proceed(chain.request()) }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions