Skip to content

Commit

Permalink
Merge pull request #11 from heweather/feature-niu
Browse files Browse the repository at this point in the history
Feature niu
  • Loading branch information
QWRDA committed Jul 10, 2020
2 parents 56e5cef + 2df71d4 commit ce20c30
Show file tree
Hide file tree
Showing 16 changed files with 242 additions and 233 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,5 @@ dependencies {
implementation files('libs/log4j-1.2.17.jar')
implementation 'com.google.code.gson:gson:2.8.0'
implementation files('libs/AMap_Location_V4.0.1_20180426.jar')
implementation files('libs/HeWeather_Android_Common_V3.2.jar')
implementation files('libs/HeWeather_sdk.jar')
}
Binary file removed app/libs/HeWeather_Android_Common_V3.2.jar
Binary file not shown.
Binary file added app/libs/HeWeather_sdk.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions app/src/main/java/com/heweather/owp/MyApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public void onCreate() {
instance = this;
//在主线程中new的handler就是主线程的handler
//初始化Handler
HeConfig.init(ContentUtil.APK_USERNAME, ContentUtil.APK_KEY);
HeConfig.switchToFreeServerNode();
HeConfig.init(ContentUtil.PUBLIC_ID, ContentUtil.APK_KEY);
HeConfig.switchToDevService();
configLog();

}
Expand Down
20 changes: 9 additions & 11 deletions app/src/main/java/com/heweather/owp/adapter/ForecastAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,21 @@
import android.widget.TextView;

import com.heweather.owp.R;
import com.heweather.owp.bean.CityBean;
import com.heweather.owp.utils.ContentUtil;
import com.heweather.owp.utils.IconUtils;
import com.heweather.owp.view.activity.ControlCityActivity;

import org.joda.time.DateTime;

import java.util.List;

import interfaces.heweather.com.interfacesmodule.bean.weather.forecast.ForecastBase;
import interfaces.heweather.com.interfacesmodule.bean.weather.WeatherDailyBean;

public class ForecastAdapter extends Adapter<ForecastAdapter.MyViewHolder> {

private List<ForecastBase> datas;
private List<WeatherDailyBean.DailyBean> datas;
private Context context;

public ForecastAdapter(Context context, List<ForecastBase> datas) {
public ForecastAdapter(Context context, List<WeatherDailyBean.DailyBean> datas) {
this.datas = datas;
this.context = context;
}
Expand All @@ -40,7 +38,7 @@ public MyViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
return new MyViewHolder(view);
}

public void refreshData(Context context, List<ForecastBase> datas) {
public void refreshData(Context context, List<WeatherDailyBean.DailyBean> datas) {
this.datas = datas;
this.context = context;
notifyDataSetChanged();
Expand All @@ -49,11 +47,11 @@ public void refreshData(Context context, List<ForecastBase> datas) {
@SuppressLint("SetTextI18n")
@Override
public void onBindViewHolder(@NonNull MyViewHolder myViewHolder, @SuppressLint("RecyclerView") final int i) {
ForecastBase forecastBase = datas.get(i);
String condCodeD = forecastBase.getCond_code_d();
String condCodeN = forecastBase.getCond_code_n();
String tmpMin = forecastBase.getTmp_min();
String tmpMax = forecastBase.getTmp_max();
WeatherDailyBean.DailyBean forecastBase = datas.get(i);
String condCodeD = forecastBase.getIconDay();
String condCodeN = forecastBase.getIconNight();
String tmpMin = forecastBase.getTempMin();
String tmpMax = forecastBase.getTempMax();
myViewHolder.tvMax.setText(tmpMax + "°");
myViewHolder.tvMin.setText(tmpMin + "°");
myViewHolder.ivDay.setImageResource(IconUtils.getDayIconDark(condCodeD));
Expand Down
40 changes: 21 additions & 19 deletions app/src/main/java/com/heweather/owp/adapter/SearchAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,22 @@
import android.view.ViewGroup;
import android.widget.TextView;

import com.heweather.owp.dataInterface.DataUtil;
import com.heweather.owp.R;
import com.heweather.owp.bean.CityBean;
import com.heweather.owp.bean.CityBeanList;
import com.heweather.owp.dataInterface.DataUtil;
import com.heweather.owp.utils.ContentUtil;
import com.heweather.owp.utils.SpUtils;
import com.heweather.owp.view.activity.SearchActivity;

import java.util.ArrayList;
import java.util.List;

import interfaces.heweather.com.interfacesmodule.bean.Lang;
import interfaces.heweather.com.interfacesmodule.bean.basic.Basic;
import interfaces.heweather.com.interfacesmodule.bean.search.Search;
import interfaces.heweather.com.interfacesmodule.bean.base.Code;
import interfaces.heweather.com.interfacesmodule.bean.base.Lang;
import interfaces.heweather.com.interfacesmodule.bean.base.Mode;
import interfaces.heweather.com.interfacesmodule.bean.base.Range;
import interfaces.heweather.com.interfacesmodule.bean.geo.GeoBean;
import interfaces.heweather.com.interfacesmodule.view.HeWeather;

/**
Expand All @@ -53,9 +55,9 @@ public SearchAdapter(SearchActivity activity, List<CityBean> data, String search
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
if (ContentUtil.APP_SETTING_LANG.equals("en") || ContentUtil.APP_SETTING_LANG.equals("sys") && ContentUtil.SYS_LANG.equals("en")) {
lang = Lang.ENGLISH;
lang = Lang.EN;
} else {
lang = Lang.CHINESE_SIMPLIFIED;
lang = Lang.ZH_HANS;
}
View view;
if (isSearching) {
Expand Down Expand Up @@ -95,11 +97,11 @@ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder myViewHolder, @Sup
@Override
public void onClick(View view) {
final String cid = data.get(i).getCityId();
if (lang.equals(Lang.CHINESE_SIMPLIFIED)) {
saveData(Lang.ENGLISH, "cityBeanEn", cid);
if (lang.equals(Lang.ZH_HANS)) {
saveData(Lang.EN, "cityBeanEn", cid);
saveBean("cityBean", cid, i);
} else {
saveData(Lang.CHINESE_SIMPLIFIED, "cityBean", cid);
saveData(Lang.ZH_HANS, "cityBean", cid);
saveBean("cityBeanEn", cid, i);
}
activity.onBackPressed();
Expand Down Expand Up @@ -130,31 +132,31 @@ private void saveBean(final String key, String cid, int x) {
}

private void saveData(Lang lang, final String key, final String cid) {
HeWeather.getSearch(activity, cid, "cn,overseas", 1, lang, new HeWeather.OnResultSearchBeansListener() {
HeWeather.getGeoCityLookup(activity, cid, Mode.FUZZY, Range.WORLD, 1, lang, new HeWeather.OnResultGeoListener() {
@Override
public void onError(Throwable throwable) {
Log.i("sky", "onError: ");
activity.onBackPressed();
}

@Override
public void onSuccess(Search search) {
public void onSuccess(GeoBean search) {
List<CityBean> citys = new ArrayList<>();
if (!search.getStatus().equals("unknown city") && !search.getStatus().equals("noData")) {
List<Basic> basic = search.getBasic();
Basic basicData = basic.get(0);
String parentCity = basicData.getParent_city();
String adminArea = basicData.getAdmin_area();
String cnty = basicData.getCnty();
if (search.getStatus().equals(Code.OK.getCode())) {
List<GeoBean.LocationBean> basic = search.getLocationBean();
GeoBean.LocationBean basicData = basic.get(0);
String parentCity = basicData.getAdm2();
String adminArea = basicData.getAdm1();
String cnty = basicData.getCountry();
if (TextUtils.isEmpty(parentCity)) {
parentCity = adminArea;
}
if (TextUtils.isEmpty(adminArea)) {
parentCity = cnty;
}
CityBean cityBean = new CityBean();
cityBean.setCityName(parentCity + " - " + basicData.getLocation());
cityBean.setCityId(basicData.getCid());
cityBean.setCityName(parentCity + " - " + basicData.getName());
cityBean.setCityId(basicData.getId());
cityBean.setCnty(cnty);
cityBean.setAdminArea(adminArea);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package com.heweather.owp.presenters;

import interfaces.heweather.com.interfacesmodule.bean.air.forecast.AirForecast;
import interfaces.heweather.com.interfacesmodule.bean.air.now.AirNow;
import interfaces.heweather.com.interfacesmodule.bean.alarm.Alarm;
import interfaces.heweather.com.interfacesmodule.bean.weather.Weather;
import interfaces.heweather.com.interfacesmodule.bean.weather.forecast.Forecast;
import interfaces.heweather.com.interfacesmodule.bean.weather.hourly.Hourly;
import interfaces.heweather.com.interfacesmodule.bean.weather.now.Now;
import interfaces.heweather.com.interfacesmodule.bean.WarningBean;
import interfaces.heweather.com.interfacesmodule.bean.air.AirNowBean;
import interfaces.heweather.com.interfacesmodule.bean.weather.WeatherBean;
import interfaces.heweather.com.interfacesmodule.bean.weather.WeatherDailyBean;
import interfaces.heweather.com.interfacesmodule.bean.weather.WeatherHourlyBean;
import interfaces.heweather.com.interfacesmodule.bean.weather.WeatherNowBean;

/**
* Created by niuchong on 2018/5/17.
Expand All @@ -16,32 +15,32 @@ public interface WeatherInterface {
/**
* 实况天气
*/
void getWeatherNow(Now bean);
void getWeatherNow(WeatherNowBean bean);

/**
* 3-7天天气预报
*/
void getWeatherForecast(Forecast bean);
void getWeatherForecast(WeatherDailyBean bean);

/**
* 灾害天气预警
*/
void getAlarm(Alarm bean);
void getWarning(WarningBean.WarningBeanBase bean);

/**
* 空气实况
*/
void getAirNow(AirNow bean);
void getAirNow(AirNowBean bean);

/**
* 空气预报
*/
void getAirForecast(AirForecast bean);
// void getAirForecast(AirForecast bean);


/**
* 逐小时预报
*/
void getWeatherHourly(Hourly bean);
void getWeatherHourly(WeatherHourlyBean bean);

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public interface WeatherPresenters {
/**
* 灾害天气预警
*/
void getAlarm(String location);
void getWarning(String location);

/**
* 空气实况
Expand Down
Loading

0 comments on commit ce20c30

Please sign in to comment.