diff --git a/app/build.gradle b/app/build.gradle index bf31c8a..a1b7f3b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -126,15 +126,15 @@ dependencies { /*ViewPager指示器*/ implementation 'com.ogaclejapan.smarttablayout:library:1.6.1@aar' /*Umeng统计*/ - implementation 'com.umeng.sdk:common:latest.integration' - implementation 'com.umeng.sdk:analytics:latest.integration' + implementation 'com.umeng.sdk:common:1.5.3' + implementation 'com.umeng.sdk:analytics:7.5.3' /*极光推送*/ implementation files('libs/jcore-android_v1.1.2.jar') implementation files('libs/jpush-android_v3.0.5.jar') /*菜单*/ implementation 'io.github.yavski:fab-speed-dial:1.0.4' /*高德地图*/ - implementation 'com.amap.api:location:latest.integration' + implementation 'com.amap.api:location:5.2.0' /* 模糊 */ implementation 'jp.wasabeef:blurry:2.1.1' /*网络监测*/ diff --git a/app/src/main/java/com/maning/gankmm/bean/mob/CalendarInfoEntity.java b/app/src/main/java/com/maning/gankmm/bean/mob/CalendarInfoEntity.java index e3a7bcd..3a2bdb5 100644 --- a/app/src/main/java/com/maning/gankmm/bean/mob/CalendarInfoEntity.java +++ b/app/src/main/java/com/maning/gankmm/bean/mob/CalendarInfoEntity.java @@ -3,7 +3,7 @@ /** * Created by maning on 2017/4/11. */ - +@Deprecated public class CalendarInfoEntity { diff --git a/app/src/main/java/com/maning/gankmm/bean/rolltools/HolidayBean.java b/app/src/main/java/com/maning/gankmm/bean/rolltools/HolidayBean.java new file mode 100644 index 0000000..5742d9f --- /dev/null +++ b/app/src/main/java/com/maning/gankmm/bean/rolltools/HolidayBean.java @@ -0,0 +1,152 @@ +package com.maning.gankmm.bean.rolltools; + +/** + * @author : maning + * @date : 2020-10-15 + * @desc : + */ +public class HolidayBean { + /** + * date : 2018-11-21 + * weekDay : 3 + * yearTips : 戊戌 + * type : 0 + * typeDes : 工作日 + * chineseZodiac : 狗 + * solarTerms : 立冬后 + * avoid : 嫁娶.安葬 + * lunarCalendar : 十月十四 + * suit : 破屋.坏垣.祭祀.余事勿取 + * dayOfYear : 325 + * weekOfYear : 47 + * constellation : 天蝎座 + * indexWorkDayOfMonth : 1 + */ + + private String date; + private int weekDay; + private String yearTips; + private int type; + private String typeDes; + private String chineseZodiac; + private String solarTerms; + private String avoid; + private String lunarCalendar; + private String suit; + private int dayOfYear; + private int weekOfYear; + private String constellation; + private int indexWorkDayOfMonth; + + public String getDate() { + return date; + } + + public void setDate(String date) { + this.date = date; + } + + public int getWeekDay() { + return weekDay; + } + + public void setWeekDay(int weekDay) { + this.weekDay = weekDay; + } + + public String getYearTips() { + return yearTips; + } + + public void setYearTips(String yearTips) { + this.yearTips = yearTips; + } + + public int getType() { + return type; + } + + public void setType(int type) { + this.type = type; + } + + public String getTypeDes() { + return typeDes; + } + + public void setTypeDes(String typeDes) { + this.typeDes = typeDes; + } + + public String getChineseZodiac() { + return chineseZodiac; + } + + public void setChineseZodiac(String chineseZodiac) { + this.chineseZodiac = chineseZodiac; + } + + public String getSolarTerms() { + return solarTerms; + } + + public void setSolarTerms(String solarTerms) { + this.solarTerms = solarTerms; + } + + public String getAvoid() { + return avoid; + } + + public void setAvoid(String avoid) { + this.avoid = avoid; + } + + public String getLunarCalendar() { + return lunarCalendar; + } + + public void setLunarCalendar(String lunarCalendar) { + this.lunarCalendar = lunarCalendar; + } + + public String getSuit() { + return suit; + } + + public void setSuit(String suit) { + this.suit = suit; + } + + public int getDayOfYear() { + return dayOfYear; + } + + public void setDayOfYear(int dayOfYear) { + this.dayOfYear = dayOfYear; + } + + public int getWeekOfYear() { + return weekOfYear; + } + + public void setWeekOfYear(int weekOfYear) { + this.weekOfYear = weekOfYear; + } + + public String getConstellation() { + return constellation; + } + + public void setConstellation(String constellation) { + this.constellation = constellation; + } + + public int getIndexWorkDayOfMonth() { + return indexWorkDayOfMonth; + } + + public void setIndexWorkDayOfMonth(int indexWorkDayOfMonth) { + this.indexWorkDayOfMonth = indexWorkDayOfMonth; + } +} diff --git a/app/src/main/java/com/maning/gankmm/bean/rolltools/HolidaySingleResultBean.java b/app/src/main/java/com/maning/gankmm/bean/rolltools/HolidaySingleResultBean.java new file mode 100644 index 0000000..2773ffd --- /dev/null +++ b/app/src/main/java/com/maning/gankmm/bean/rolltools/HolidaySingleResultBean.java @@ -0,0 +1,24 @@ +package com.maning.gankmm.bean.rolltools; + +/** + * @author : maning + * @date : 2020-10-15 + * @desc : + */ +public class HolidaySingleResultBean extends RollToolsBaseBean { + + /** + * data : {"date":"2018-11-21","weekDay":3,"yearTips":"戊戌","type":0,"typeDes":"工作日","chineseZodiac":"狗","solarTerms":"立冬后","avoid":"嫁娶.安葬","lunarCalendar":"十月十四","suit":"破屋.坏垣.祭祀.余事勿取","dayOfYear":325,"weekOfYear":47,"constellation":"天蝎座","indexWorkDayOfMonth":1} + */ + + private HolidayBean data; + + public HolidayBean getData() { + return data; + } + + public void setData(HolidayBean data) { + this.data = data; + } + +} diff --git a/app/src/main/java/com/maning/gankmm/bean/rolltools/RollToolsBaseBean.java b/app/src/main/java/com/maning/gankmm/bean/rolltools/RollToolsBaseBean.java new file mode 100644 index 0000000..b746a1a --- /dev/null +++ b/app/src/main/java/com/maning/gankmm/bean/rolltools/RollToolsBaseBean.java @@ -0,0 +1,33 @@ +package com.maning.gankmm.bean.rolltools; + +/** + * @author : maning + * @date : 2020-10-15 + * @desc : + */ +public class RollToolsBaseBean { + + /** + * code : 1 + * msg : 数据返回成功 + */ + + private int code; + private String msg; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } +} diff --git a/app/src/main/java/com/maning/gankmm/constant/Constants.java b/app/src/main/java/com/maning/gankmm/constant/Constants.java index 4badada..48f0c73 100644 --- a/app/src/main/java/com/maning/gankmm/constant/Constants.java +++ b/app/src/main/java/com/maning/gankmm/constant/Constants.java @@ -17,9 +17,12 @@ public class Constants { public static final String FIR_BASEURL = "http://api.fir.im/"; - //https://api.seniverse.com/v3/weather/now.json?key=SkAwmmz_N361lNLX3&location=beijing&language=zh-Hans&unit=c + //知心API public static final String BASEURL_WEATHER = "https://api.seniverse.com/v3/"; + //开源API:https://github.com/MZCretin/RollToolsApi + public static final String BASEURL_ROLL_TOOLS = "https://www.mxnzp.com/api/"; + //干活历史日期 public static final String URL_HistoryDate = "http://gank.io/api/day/history"; diff --git a/app/src/main/java/com/maning/gankmm/http/BuildApi.java b/app/src/main/java/com/maning/gankmm/http/BuildApi.java index 44ec606..6299188 100644 --- a/app/src/main/java/com/maning/gankmm/http/BuildApi.java +++ b/app/src/main/java/com/maning/gankmm/http/BuildApi.java @@ -5,6 +5,7 @@ import com.maning.gankmm.http.gank.APIGankService; import com.maning.gankmm.http.gank2.APIGank2Service; import com.maning.gankmm.http.mob.APIMobService; +import com.maning.gankmm.http.rolltools.APIRolltoolsService; import com.maning.gankmm.http.update.APIUpdateService; import com.maning.gankmm.http.weather.APIWeatherService; @@ -60,4 +61,8 @@ public static APIWeatherService getWeatherAPIService() { return getInterface(Constants.BASEURL_WEATHER, APIWeatherService.class); } + public static APIRolltoolsService getRooltoolsAPIService() { + return getInterface(Constants.BASEURL_ROLL_TOOLS, APIRolltoolsService.class); + } + } diff --git a/app/src/main/java/com/maning/gankmm/http/callback/CommonHttpCallback.java b/app/src/main/java/com/maning/gankmm/http/callback/CommonHttpCallback.java index 2030415..8a21cac 100644 --- a/app/src/main/java/com/maning/gankmm/http/callback/CommonHttpCallback.java +++ b/app/src/main/java/com/maning/gankmm/http/callback/CommonHttpCallback.java @@ -3,6 +3,7 @@ import android.text.TextUtils; import com.maning.gankmm.bean.gank2.Gank2BaseBean; +import com.maning.gankmm.bean.rolltools.RollToolsBaseBean; import com.maning.gankmm.bean.weather.caiyun.CaiyunWeatherBaseBean; import com.maning.gankmm.bean.weather.zhixin.ZhixinBaseBean; @@ -28,28 +29,35 @@ public void onResponse(Call call, Response response) { T body = response.body(); if (body instanceof Gank2BaseBean) { //gankio - Gank2BaseBean gank2BaseBean = (Gank2BaseBean) response.body(); - if (gank2BaseBean.getStatus() == 100) { + Gank2BaseBean baseBean = (Gank2BaseBean) response.body(); + if (baseBean.getStatus() == 100) { onSuccess(response.body()); } else { - onFail(gank2BaseBean.getStatus(), gank2BaseBean.getMsg()); + onFail(baseBean.getStatus(), baseBean.getMsg()); } } else if (body instanceof CaiyunWeatherBaseBean) { //彩云天气 - CaiyunWeatherBaseBean caiyunWeather = (CaiyunWeatherBaseBean) response.body(); - String status = caiyunWeather.getStatus(); - String api_status = caiyunWeather.getApi_status(); + CaiyunWeatherBaseBean baseBean = (CaiyunWeatherBaseBean) response.body(); + String status = baseBean.getStatus(); + String api_status = baseBean.getApi_status(); if ("ok".equals(status) && "active".equals(api_status)) { onSuccess(response.body()); } else { onFail(1000, "彩云天气接口出错啦~~~"); } } else if (body instanceof ZhixinBaseBean) { - ZhixinBaseBean zhixinBaseBean = (ZhixinBaseBean) response.body(); - if (TextUtils.isEmpty(zhixinBaseBean.getStatus())) { + ZhixinBaseBean baseBean = (ZhixinBaseBean) response.body(); + if (TextUtils.isEmpty(baseBean.getStatus())) { onSuccess(response.body()); } else { - onFail(1000, zhixinBaseBean.getStatus()); + onFail(1000, baseBean.getStatus()); + } + } else if (body instanceof RollToolsBaseBean) { + RollToolsBaseBean baseBean = (RollToolsBaseBean) response.body(); + if (baseBean.getCode() == 1) { + onSuccess(response.body()); + } else { + onFail(baseBean.getCode(), baseBean.getMsg()); } } else { onSuccess(body); diff --git a/app/src/main/java/com/maning/gankmm/http/rolltools/APIRolltoolsService.java b/app/src/main/java/com/maning/gankmm/http/rolltools/APIRolltoolsService.java new file mode 100644 index 0000000..e3c1d3d --- /dev/null +++ b/app/src/main/java/com/maning/gankmm/http/rolltools/APIRolltoolsService.java @@ -0,0 +1,26 @@ +package com.maning.gankmm.http.rolltools; + +import com.maning.gankmm.bean.rolltools.HolidaySingleResultBean; + +import retrofit2.Call; +import retrofit2.http.GET; +import retrofit2.http.Headers; +import retrofit2.http.Path; + + +/** + * 接口调用的工具类 + */ +public interface APIRolltoolsService { + + + @Headers({ + "app_id:olkgphoyitdqikvi", + "app_secret:SFdTdFB5aGVoamlXU2dZblpPZTRjQT09" + }) + @GET("holiday/single/{date}") + Call getHolidaySingle( + @Path("date") String date + ); + +} diff --git a/app/src/main/java/com/maning/gankmm/http/rolltools/RolltoolsApi.java b/app/src/main/java/com/maning/gankmm/http/rolltools/RolltoolsApi.java new file mode 100644 index 0000000..7b4593d --- /dev/null +++ b/app/src/main/java/com/maning/gankmm/http/rolltools/RolltoolsApi.java @@ -0,0 +1,25 @@ +package com.maning.gankmm.http.rolltools; + +import com.maning.gankmm.bean.rolltools.HolidaySingleResultBean; +import com.maning.gankmm.http.BuildApi; +import com.maning.gankmm.http.callback.CommonHttpCallback; + +/** + * @author : maning + * @date : 2020-09-29 + * @desc : + */ +public class RolltoolsApi { + + + /** + * 获取指定日期的节假日及万年历信息 + * + * @param date yyyyMMdd + */ + public static void getHolidaySingle(String date, CommonHttpCallback httpCallback) { + BuildApi.getRooltoolsAPIService().getHolidaySingle(date).enqueue(httpCallback); + } + + +} diff --git a/app/src/main/java/com/maning/gankmm/ui/activity/WeatherActivity.java b/app/src/main/java/com/maning/gankmm/ui/activity/WeatherActivity.java index 23bf8ab..1ce176d 100644 --- a/app/src/main/java/com/maning/gankmm/ui/activity/WeatherActivity.java +++ b/app/src/main/java/com/maning/gankmm/ui/activity/WeatherActivity.java @@ -20,6 +20,7 @@ import com.maning.gankmm.R; import com.maning.gankmm.bean.mob.CalendarInfoEntity; import com.maning.gankmm.bean.gank2.GankEntity; +import com.maning.gankmm.bean.rolltools.HolidayBean; import com.maning.gankmm.bean.weather.WeatherInfoBean; import com.maning.gankmm.bean.weather.zhixin.ZhixinSuggestionEntity; import com.maning.gankmm.ui.adapter.WeatherAdapter; @@ -65,7 +66,7 @@ public class WeatherActivity extends BaseActivity implements OnRefreshListener, @Bind(R.id.swipeToLoadLayout) SwipeToLoadLayout swipeToLoadLayout; - private CalendarInfoEntity calendarInfoEntity; + private HolidayBean holidayBean; private WeatherInfoBean weatherInfoBean; private ZhixinSuggestionEntity lifeSuggestionBean; private WeatherAdapter weatherAdapter; @@ -201,10 +202,10 @@ public void backBtn() { private void initAdapter() { if (weatherAdapter == null) { - weatherAdapter = new WeatherAdapter(this, weatherInfoBean, calendarInfoEntity, lifeSuggestionBean); + weatherAdapter = new WeatherAdapter(this, weatherInfoBean, holidayBean, lifeSuggestionBean); swipeTarget.setAdapter(weatherAdapter); } else { - weatherAdapter.updateDatas(weatherInfoBean, calendarInfoEntity, lifeSuggestionBean); + weatherAdapter.updateDatas(weatherInfoBean, holidayBean, lifeSuggestionBean); } } @@ -241,8 +242,8 @@ public void overRefresh() { } @Override - public void updateCalendarInfo(CalendarInfoEntity calendarInfoEntity) { - this.calendarInfoEntity = calendarInfoEntity; + public void updateCalendarInfo(HolidayBean holidayBean) { + this.holidayBean = holidayBean; initAdapter(); } diff --git a/app/src/main/java/com/maning/gankmm/ui/adapter/WeatherAdapter.java b/app/src/main/java/com/maning/gankmm/ui/adapter/WeatherAdapter.java index bfcf169..dff0316 100644 --- a/app/src/main/java/com/maning/gankmm/ui/adapter/WeatherAdapter.java +++ b/app/src/main/java/com/maning/gankmm/ui/adapter/WeatherAdapter.java @@ -12,6 +12,7 @@ import com.maning.gankmm.R; import com.maning.gankmm.bean.mob.CalendarInfoEntity; import com.maning.gankmm.bean.mob.WeatherBeseEntity; +import com.maning.gankmm.bean.rolltools.HolidayBean; import com.maning.gankmm.bean.weather.WeatherInfoBean; import com.maning.gankmm.bean.weather.zhixin.ZhixinSuggestionEntity; import com.maning.gankmm.ui.view.ArcProgressView; @@ -28,22 +29,22 @@ public class WeatherAdapter extends RecyclerView.Adapter implem private Context context; - private MyCallBack httpCallBack = new MyCallBack() { - @Override - public void onSuccessList(int what, List results) { - mView.overRefresh(); - } - - @Override - public void onSuccess(int what, Object result) { - if (mView == null) { - return; - } - if (result == null) { - return; - } - switch (what) { - case 0x001: - CalendarInfoEntity calendarInfoEntity = (CalendarInfoEntity) result; - //刷新界面 - mView.updateCalendarInfo(calendarInfoEntity); - break; - } - } - - @Override - public void onFail(int what, String result) { - if (mView == null) { - return; - } - mView.overRefresh(); - if (!TextUtils.isEmpty(result)) { - mView.showToast(result); - } - } - }; - public WeatherPresenterImpl(Context context, IWeatherView iWeatherView) { this.context = context; attachView(iWeatherView); @@ -86,9 +50,21 @@ public void onFail(String msg) { @Override public void getCalendarInfo() { //获取当天日期 - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - String date = sdf.format(new java.util.Date()); - MobApi.getCalendarInfo(date, 0x001, httpCallBack); + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); + String date = sdf.format(new Date()); + RolltoolsApi.getHolidaySingle(date, new CommonHttpCallback() { + @Override + public void onSuccess(HolidaySingleResultBean result) { + HolidayBean holidayBean = result.getData(); + mView.updateCalendarInfo(holidayBean); + + } + + @Override + public void onFail(int code, String message) { + mView.showToast(message); + } + }); } @Override diff --git a/app/src/main/res/layout/item_weather_calendar.xml b/app/src/main/res/layout/item_weather_calendar.xml index 751071e..eada13f 100644 --- a/app/src/main/res/layout/item_weather_calendar.xml +++ b/app/src/main/res/layout/item_weather_calendar.xml @@ -1,6 +1,7 @@ @@ -15,6 +16,7 @@ android:gravity="center_vertical" android:paddingLeft="16dp" android:text="万年历" + android:textStyle="bold" android:textColor="@color/white" /> + + @@ -54,10 +67,11 @@ android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:layout_marginTop="20dp" - android:text="乙未 (羊) 星期五" + tools:text="乙未 (羊) 星期五" android:textColor="#FFFFFF" android:textSize="14sp" /> +