private void setCarServicesIsError(boolean isError) { if (!isError) { prsScrollView.setVisibility(View.VISIBLE); llError.setVisibility(View.GONE); } else { prsScrollView.setVisibility(View.GONE); llError.setVisibility(View.VISIBLE); } }
/** 设置城市并获取服务 */ private void setCityAndFetchServices() { String cityName = mApplication.getCityName(); if (StringUtils.isEmpty(cityName)) { isFristLoc = true; tvLocation.setText("请选择"); setCarServicesIsError(true); llError.setAbnormalContent(AbnormalView.ERROR_POSITIONING); } else if (!TextUtils.isEmpty(cityName) && !tvLocation.getText().equals(cityName)) { isFristLoc = false; tvLocation.setText(cityName); request(); } }
@Override public void onReceive(Context context, Intent intent) { if (isFristLoc) { isFristLoc = false; } if (!StringUtils.isEmpty(mApplication.getCityName())) { // 定位成功 setCityAndFetchServices(); } else { if (!hasLocalCacheData) { // 如果没有城市缓存数据,设置定位失败 setCarServicesIsError(true); if (null != llError) { llError.setAbnormalContent(AbnormalView.ERROR_LOCATION_FAILED); } } } }
@Override protected void setListener() { ClickUtils.setNoFastClickListener(llLocation, this); llError.setAbormalViewCallback(this); }