解决天气类型无法获取导致的npe

This commit is contained in:
wangcongtao
2020-09-11 14:43:05 +08:00
parent 766e84b66f
commit b7a024f0fc

View File

@@ -71,9 +71,12 @@ public class EntrancePresenter extends Presenter<EntranceView> implements Weathe
if ( weatherInfo == null ) {
return;
}
String temp = getContext().getResources().getString( R.string.module_ext_str_weather_temp_format, weatherInfo.getTemperature() );
Phenomena phenomena = Phenomena.getById( weatherInfo.getPhenomena() );
String desc = phenomena == null ? "" : phenomena.nameCn;
if ( phenomena == null ) {
return;
}
String temp = getContext().getResources().getString( R.string.module_ext_str_weather_temp_format, weatherInfo.getTemperature() );
String desc = phenomena.nameCn;
int resId = phenomena.resId;
mView.renderWeatherInfo( temp, desc, resId );
}