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 b40c507 commit 0a964ed
Show file tree
Hide file tree
Showing 12 changed files with 191 additions and 181 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ dependencies {
/* 表格 */
implementation 'com.kelin.scrollablepanel:library:1.2.0'
/*显示更多文字*/
implementation 'com.ms-square:expandableTextView:0.1.4'
implementation 'com.github.MZCretin:ExpandableTextView:v1.6.1'
/* 拼音转换 */
implementation 'com.github.promeg:tinypinyin:2.0.3'
/* 背景可以移动的View */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Created by maning on 2017/5/12.
* 历史上的今天
*/

@Deprecated
public class MobHistoryTodayEntity {


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package com.maning.gankmm.bean.rolltools;

import java.util.List;

/**
* @author : maning
* @date : 2020-10-15
* @desc :
*/
public class HistoryTodayBean extends RollToolsBaseBean {


private List<DataEntity> data;

public List<DataEntity> getData() {
return data;
}

public void setData(List<DataEntity> data) {
this.data = data;
}

public static class DataEntity {
/**
* picUrl : http://www.todayonhistory.com/uploadfile/2016/0909/20160909104645350.jpg
* title : 毛泽东逝世40周年纪念日
* year : 2016
* month : 9
* day : 9
* details : 毛泽东
  1976年9月9日,中国人民的领袖,伟大的无产阶级革命家、战略家和理论家,中国共产党、中国人民解放军和中华人民共和国的主要缔造者和领导人毛泽东逝世,享年83岁。
  今天(2016年9月9日)是毛泽东逝世40周年纪念日,让我们一起回顾他的一生,缅怀这位伟人。
  ...
*/

private String picUrl;
private String title;
private String year;
private int month;
private int day;
private String details;

public String getPicUrl() {
return picUrl;
}

public void setPicUrl(String picUrl) {
this.picUrl = picUrl;
}

public String getTitle() {
return title;
}

public void setTitle(String title) {
this.title = title;
}

public String getYear() {
return year;
}

public void setYear(String year) {
this.year = year;
}

public int getMonth() {
return month;
}

public void setMonth(int month) {
this.month = month;
}

public int getDay() {
return day;
}

public void setDay(int day) {
this.day = day;
}

public String getDetails() {
return details;
}

public void setDetails(String details) {
this.details = details;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.maning.gankmm.http.rolltools;

import com.maning.gankmm.bean.rolltools.HistoryTodayBean;
import com.maning.gankmm.bean.rolltools.HolidaySingleResultBean;
import com.maning.gankmm.bean.rolltools.WeatherFuturedaysResultBean;

Expand Down Expand Up @@ -34,4 +35,11 @@ Call<WeatherFuturedaysResultBean> getCityWeatherFutureDays(
@Path("cityName") String cityName
);

@Headers({
"app_id:olkgphoyitdqikvi",
"app_secret:SFdTdFB5aGVoamlXU2dZblpPZTRjQT09"
})
@GET("history/today?type=1")
Call<HistoryTodayBean> getHistoryToday();

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.maning.gankmm.http.rolltools;

import com.maning.gankmm.bean.rolltools.HistoryTodayBean;
import com.maning.gankmm.bean.rolltools.HolidaySingleResultBean;
import com.maning.gankmm.bean.rolltools.WeatherFuturedaysResultBean;
import com.maning.gankmm.http.BuildApi;
Expand Down Expand Up @@ -32,5 +33,13 @@ public static void getCityWeatherFutureDays(String cityName, CommonHttpCallback<
BuildApi.getRooltoolsAPIService().getCityWeatherFutureDays(cityName).enqueue(httpCallback);
}

/**
* 历史上的今天
* @param httpCallback
*/
public static void getHistoryToday(CommonHttpCallback<HistoryTodayBean> httpCallback) {
BuildApi.getRooltoolsAPIService().getHistoryToday().enqueue(httpCallback);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,11 @@
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.maning.calendarlibrary.MNCalendar;
import com.maning.calendarlibrary.listeners.OnCalendarItemClickListener;
import com.maning.gankmm.R;
import com.maning.gankmm.bean.mob.MobHistoryTodayEntity;
import com.maning.gankmm.http.mob.MobApi;
import com.maning.gankmm.http.callback.MyCallBack;
import com.maning.gankmm.bean.rolltools.HistoryTodayBean;
import com.maning.gankmm.http.callback.CommonHttpCallback;
import com.maning.gankmm.http.rolltools.RolltoolsApi;
import com.maning.gankmm.skin.SkinManager;
import com.maning.gankmm.ui.adapter.RecycleHistoryTodayAdapter;
import com.maning.gankmm.ui.base.BaseActivity;
Expand All @@ -26,11 +21,9 @@
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
* 历史上今天
Expand All @@ -41,18 +34,9 @@ public class HistoryTodayActivity extends BaseActivity {
Toolbar toolbar;
@Bind(R.id.recyclerView)
RecyclerView recyclerView;
@Bind(R.id.tv_time)
TextView tvTime;
@Bind(R.id.mnCalendar)
MNCalendar mnCalendar;
@Bind(R.id.calendar_bg)
RelativeLayout CalendarBg;

private ArrayList<MobHistoryTodayEntity> mDatas;

private Date currentDate = new Date();
private SimpleDateFormat sdf = new SimpleDateFormat("MMdd");
private SimpleDateFormat sdf2 = new SimpleDateFormat("MM月dd日");

private ArrayList<HistoryTodayBean.DataEntity> mDatas;

private RecycleHistoryTodayAdapter recycleHistoryTodayAdapter;

@Override
Expand All @@ -65,55 +49,27 @@ protected void onCreate(Bundle savedInstanceState) {

initRecyclerView();

initCalendar();

queryData();

}

private void initCalendar() {
mnCalendar.setOnCalendarItemClickListener(new OnCalendarItemClickListener() {
@Override
public void onClick(Date date) {
currentDate = date;
CalendarBg.setVisibility(View.GONE);
queryData();
}

@Override
public void onLongClick(Date date) {

}
});
}

private void queryData() {
showProgressDialog("查询中...");

String timeString = sdf.format(currentDate);
String timeString2 = sdf2.format(currentDate);
tvTime.setText(timeString2);

MobApi.queryHistory(timeString, 0x001, new MyCallBack() {
@Override
public void onSuccess(int what, Object result) {

}

RolltoolsApi.getHistoryToday(new CommonHttpCallback<HistoryTodayBean>() {
@Override
public void onSuccessList(int what, List results) {
public void onSuccess(HistoryTodayBean result) {
dissmissProgressDialog();
mDatas = (ArrayList<MobHistoryTodayEntity>) results;
mDatas = (ArrayList<HistoryTodayBean.DataEntity>) result.getData();
initAdapter();
}

@Override
public void onFail(int what, String result) {
MySnackbar.makeSnackBarRed(toolbar, result);
public void onFail(int code, String message) {
MySnackbar.makeSnackBarRed(toolbar, message);
dissmissProgressDialog();
}
});

}

private void initAdapter() {
Expand Down Expand Up @@ -152,14 +108,4 @@ public boolean onOptionsItemSelected(MenuItem item) {
return super.onOptionsItemSelected(item);
}

@OnClick(R.id.tv_time)
public void tv_time() {
CalendarBg.setVisibility(View.VISIBLE);
}

@OnClick(R.id.calendar_bg)
public void calendar_bg() {
CalendarBg.setVisibility(View.GONE);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.SparseBooleanArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.ctetin.expandabletextviewlibrary.ExpandableTextView;
import com.maning.gankmm.R;
import com.maning.gankmm.bean.mob.MobHealthEntity;
import com.ms.square.android.expandabletextview.ExpandableTextView;

import java.util.ArrayList;

Expand Down Expand Up @@ -52,8 +51,7 @@ public void onBindViewHolder(final RecyclerView.ViewHolder viewHolder, final int

myViewHolder.tv_title.setText(mobHealth.getTitle());

SparseBooleanArray mTogglePositions = new SparseBooleanArray();
myViewHolder.expand_text_view.setText(mobHealth.getContent(), mTogglePositions, position);
myViewHolder.expand_text_view.setContent(mobHealth.getContent());
}
}

Expand Down
Loading

0 comments on commit 0a964ed

Please sign in to comment.