Skip to content

Commit

Permalink
天气页面添加万年历信息
Browse files Browse the repository at this point in the history
  • Loading branch information
maning0303 committed Oct 15, 2020
1 parent b5b359c commit 9153657
Show file tree
Hide file tree
Showing 16 changed files with 351 additions and 78 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
/*网络监测*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* Created by maning on 2017/4/11.
*/

@Deprecated
public class CalendarInfoEntity {


Expand Down
152 changes: 152 additions & 0 deletions app/src/main/java/com/maning/gankmm/bean/rolltools/HolidayBean.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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;
}

}
Original file line number Diff line number Diff line change
@@ -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;
}
}
5 changes: 4 additions & 1 deletion app/src/main/java/com/maning/gankmm/constant/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
5 changes: 5 additions & 0 deletions app/src/main/java/com/maning/gankmm/http/BuildApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -28,28 +29,35 @@ public void onResponse(Call<T> call, Response<T> 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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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<HolidaySingleResultBean> getHolidaySingle(
@Path("date") String date
);

}
Original file line number Diff line number Diff line change
@@ -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<HolidaySingleResultBean> httpCallback) {
BuildApi.getRooltoolsAPIService().getHolidaySingle(date).enqueue(httpCallback);
}


}
Loading

0 comments on commit 9153657

Please sign in to comment.