diff --git a/app/build.gradle b/app/build.gradle index a1b7f3b..9ccd36c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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 */ diff --git a/app/src/main/java/com/maning/gankmm/bean/mob/MobHistoryTodayEntity.java b/app/src/main/java/com/maning/gankmm/bean/mob/MobHistoryTodayEntity.java index 1d2a77b..1934241 100644 --- a/app/src/main/java/com/maning/gankmm/bean/mob/MobHistoryTodayEntity.java +++ b/app/src/main/java/com/maning/gankmm/bean/mob/MobHistoryTodayEntity.java @@ -4,7 +4,7 @@ * Created by maning on 2017/5/12. * 历史上的今天 */ - +@Deprecated public class MobHistoryTodayEntity { diff --git a/app/src/main/java/com/maning/gankmm/bean/rolltools/HistoryTodayBean.java b/app/src/main/java/com/maning/gankmm/bean/rolltools/HistoryTodayBean.java new file mode 100644 index 0000000..bd3316b --- /dev/null +++ b/app/src/main/java/com/maning/gankmm/bean/rolltools/HistoryTodayBean.java @@ -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 data; + + public List getData() { + return data; + } + + public void setData(List 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; + } + } +} 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 index 6376e20..c362ec6 100644 --- a/app/src/main/java/com/maning/gankmm/http/rolltools/APIRolltoolsService.java +++ b/app/src/main/java/com/maning/gankmm/http/rolltools/APIRolltoolsService.java @@ -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; @@ -34,4 +35,11 @@ Call getCityWeatherFutureDays( @Path("cityName") String cityName ); + @Headers({ + "app_id:olkgphoyitdqikvi", + "app_secret:SFdTdFB5aGVoamlXU2dZblpPZTRjQT09" + }) + @GET("history/today?type=1") + Call getHistoryToday(); + } 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 index 979e502..9dd918d 100644 --- a/app/src/main/java/com/maning/gankmm/http/rolltools/RolltoolsApi.java +++ b/app/src/main/java/com/maning/gankmm/http/rolltools/RolltoolsApi.java @@ -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; @@ -32,5 +33,13 @@ public static void getCityWeatherFutureDays(String cityName, CommonHttpCallback< BuildApi.getRooltoolsAPIService().getCityWeatherFutureDays(cityName).enqueue(httpCallback); } + /** + * 历史上的今天 + * @param httpCallback + */ + public static void getHistoryToday(CommonHttpCallback httpCallback) { + BuildApi.getRooltoolsAPIService().getHistoryToday().enqueue(httpCallback); + } + } diff --git a/app/src/main/java/com/maning/gankmm/ui/activity/mob/HistoryTodayActivity.java b/app/src/main/java/com/maning/gankmm/ui/activity/mob/HistoryTodayActivity.java index eca8b48..5131ad2 100644 --- a/app/src/main/java/com/maning/gankmm/ui/activity/mob/HistoryTodayActivity.java +++ b/app/src/main/java/com/maning/gankmm/ui/activity/mob/HistoryTodayActivity.java @@ -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; @@ -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; /** * 历史上今天 @@ -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 mDatas; - - private Date currentDate = new Date(); - private SimpleDateFormat sdf = new SimpleDateFormat("MMdd"); - private SimpleDateFormat sdf2 = new SimpleDateFormat("MM月dd日"); + + private ArrayList mDatas; + private RecycleHistoryTodayAdapter recycleHistoryTodayAdapter; @Override @@ -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() { @Override - public void onSuccessList(int what, List results) { + public void onSuccess(HistoryTodayBean result) { dissmissProgressDialog(); - mDatas = (ArrayList) results; + mDatas = (ArrayList) 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() { @@ -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); - } - } diff --git a/app/src/main/java/com/maning/gankmm/ui/adapter/RecycleHealthAdapter.java b/app/src/main/java/com/maning/gankmm/ui/adapter/RecycleHealthAdapter.java index 5ecf3e1..b2f4516 100644 --- a/app/src/main/java/com/maning/gankmm/ui/adapter/RecycleHealthAdapter.java +++ b/app/src/main/java/com/maning/gankmm/ui/adapter/RecycleHealthAdapter.java @@ -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; @@ -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()); } } diff --git a/app/src/main/java/com/maning/gankmm/ui/adapter/RecycleHistoryTodayAdapter.java b/app/src/main/java/com/maning/gankmm/ui/adapter/RecycleHistoryTodayAdapter.java index be7fa99..da81378 100644 --- a/app/src/main/java/com/maning/gankmm/ui/adapter/RecycleHistoryTodayAdapter.java +++ b/app/src/main/java/com/maning/gankmm/ui/adapter/RecycleHistoryTodayAdapter.java @@ -2,20 +2,22 @@ import android.content.Context; import android.support.v7.widget.RecyclerView; +import android.text.TextUtils; import android.util.SparseBooleanArray; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.ImageView; import android.widget.TextView; +import com.bumptech.glide.Glide; +import com.bumptech.glide.request.RequestOptions; +import com.ctetin.expandabletextviewlibrary.ExpandableTextView; import com.maning.gankmm.R; -import com.maning.gankmm.bean.mob.MobHistoryTodayEntity; -import com.ms.square.android.expandabletextview.ExpandableTextView; +import com.maning.gankmm.bean.rolltools.HistoryTodayBean; -import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Date; import butterknife.Bind; import butterknife.ButterKnife; @@ -26,19 +28,16 @@ public class RecycleHistoryTodayAdapter extends RecyclerView.Adapter { private Context context; - private ArrayList mDatas; + private ArrayList mDatas; private LayoutInflater layoutInflater; - private SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); - private SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy年MM月dd日"); - - public RecycleHistoryTodayAdapter(Context context, ArrayList mDatas) { + public RecycleHistoryTodayAdapter(Context context, ArrayList mDatas) { this.context = context; this.mDatas = mDatas; layoutInflater = LayoutInflater.from(this.context); } - public void upddateDatas(ArrayList mDatas){ + public void upddateDatas(ArrayList mDatas) { this.mDatas = mDatas; notifyDataSetChanged(); } @@ -54,21 +53,27 @@ public void onBindViewHolder(final RecyclerView.ViewHolder viewHolder, final int if (viewHolder instanceof MyViewHolder) { MyViewHolder myViewHolder = (MyViewHolder) viewHolder; - MobHistoryTodayEntity mobHistoryTodayEntity = mDatas.get(position); + HistoryTodayBean.DataEntity dataEntity = mDatas.get(position); - myViewHolder.tv_title.setText(mobHistoryTodayEntity.getTitle()); + myViewHolder.tv_title.setText(dataEntity.getTitle()); - String date = mobHistoryTodayEntity.getDate(); - try { - Date parse = sdf.parse(date); - date = sdf2.format(parse); - } catch (ParseException e) { - e.printStackTrace(); - } - myViewHolder.tv_time.setText(date); + myViewHolder.tv_time.setText(dataEntity.getYear() + "-" + dataEntity.getMonth() + "-" + dataEntity.getDay()); + + myViewHolder.expand_text_view.setContent(dataEntity.getDetails()); - SparseBooleanArray mTogglePositions = new SparseBooleanArray(); - myViewHolder.expand_text_view.setText(mobHistoryTodayEntity.getEvent(), mTogglePositions, position); + if (TextUtils.isEmpty(dataEntity.getPicUrl())) { + myViewHolder.iv_show.setVisibility(View.GONE); + } else { + myViewHolder.iv_show.setVisibility(View.VISIBLE); + + RequestOptions options = new RequestOptions(); + options.fitCenter(); + options.placeholder(R.drawable.pic_gray_bg); + Glide.with(context) + .load(dataEntity.getPicUrl()) + .apply(options) + .into(myViewHolder.iv_show); + } } } @@ -83,6 +88,8 @@ class MyViewHolder extends RecyclerView.ViewHolder { TextView tv_title; @Bind(R.id.tv_time) TextView tv_time; + @Bind(R.id.iv_show) + ImageView iv_show; @Bind(R.id.expand_text_view) ExpandableTextView expand_text_view; diff --git a/app/src/main/res/layout/activity_history_today.xml b/app/src/main/res/layout/activity_history_today.xml index 2f70176..4eba74a 100644 --- a/app/src/main/res/layout/activity_history_today.xml +++ b/app/src/main/res/layout/activity_history_today.xml @@ -11,46 +11,11 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - - - - - - - - - diff --git a/app/src/main/res/layout/item_health.xml b/app/src/main/res/layout/item_health.xml index a8b2325..5057a65 100644 --- a/app/src/main/res/layout/item_health.xml +++ b/app/src/main/res/layout/item_health.xml @@ -1,5 +1,6 @@ - - - - - - - + android:lineSpacingExtra="4dp" + android:textSize="14sp" + app:ep_expand_text="展开" + app:ep_max_line="4" + app:ep_need_always_showright="true" + app:ep_need_animation="true" + app:ep_need_contract="true" + tools:text="1976年9月9日,中国人民的领袖,伟大的无产阶级革命家、战略家和理论家,中国共产党、中国人民解放军和中华人民共和国的主要缔造者和领导人毛泽东逝世,享年83岁。" /> diff --git a/app/src/main/res/layout/item_history_today.xml b/app/src/main/res/layout/item_history_today.xml index b950345..4bec565 100644 --- a/app/src/main/res/layout/item_history_today.xml +++ b/app/src/main/res/layout/item_history_today.xml @@ -1,5 +1,6 @@ + android:textSize="16sp" + android:textStyle="bold" /> - + + - - - - - - - + android:lineSpacingExtra="4dp" + android:textColor="@color/black_text3_color" + android:textSize="14sp" + app:ep_expand_text="展开" + app:ep_max_line="4" + app:ep_need_always_showright="true" + app:ep_need_animation="true" + app:ep_need_contract="true" + tools:text="1976年9月9日,中国人民的领袖,伟大的无产阶级革命家、战略家和理论家,中国共产党、中国人民解放军和中华人民共和国的主要缔造者和领导人毛泽东逝世,享年83岁。" /> + android:textColor="@color/black_text3_color" + android:textSize="12sp" + android:textStyle="bold" + tools:text="2020-01-01" /> diff --git a/build.gradle b/build.gradle index 467de62..e78fdae 100644 --- a/build.gradle +++ b/build.gradle @@ -6,6 +6,7 @@ buildscript { jcenter() mavenCentral() google() + maven { url 'https://jitpack.io' } } dependencies { classpath 'com.android.tools.build:gradle:3.2.0'