Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

取消按钮点击闪退,自带返回键无问题 #31

Closed
diguasange opened this issue Mar 9, 2018 · 7 comments
Closed

取消按钮点击闪退,自带返回键无问题 #31

diguasange opened this issue Mar 9, 2018 · 7 comments

Comments

@diguasange
Copy link

在Fragment中添加定位,按您的方法调用如下
image
其中,cityLocated,province,cityCode是调用initLocation( )后得到的定位数据。
问题:

  1. 第一次进入时,定位城市无显示;第二次及以后进入时正常。如下图所示为首次进入:
    image
  2. 点击取消按钮程序闪退,系统自带返回键不会出现这个问题,报错如下:
    java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.zaaach.citypicker.model.City.getName()' on a null object reference
    错误地方如下图标注(同图一)
    image
@zaaach
Copy link
Owner

zaaach commented Mar 9, 2018

@diguasange 你的initLocation()方法是异步请求定位的话,第一次打开定位城市可能为空;点击取消按钮返回的data是null,先判断下。

@zaaach zaaach closed this as completed Mar 12, 2018
@diguasange
Copy link
Author

intiLocation()方法如下:
image
请问怎么解决初次定位城市为空的问题?

@zaaach
Copy link
Owner

zaaach commented Mar 29, 2018

初次定位为空,打开CityPicker后默认就是定位失败

@diguasange
Copy link
Author

没有显示定位失败,定位城市按钮无显示

@diguasange
Copy link
Author

在onClick()方法中的onLocate()方法,在点击时似乎并未被调用,因为在onLocate()方法内添加Log输出定位城市数据,点击时并无log输出

@zaaach
Copy link
Owner

zaaach commented Mar 30, 2018

你的cityLocated默认为空的吧,因为你传了LocatedCity,就是已经定位了城市所以点击没反应。还不明白的话加QQ交流群601783167

@diguasange
Copy link
Author

谢谢作者!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants