ItemElectronPapterLayoutManager.java
6.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
package com.wd.capability.layout.page;
import android.text.TextUtils;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import com.wd.capability.layout.R;
import com.wd.capability.layout.comp.layoutmanager.ItemContainerManager;
import com.wd.capability.layout.ui.paper.PaperContract;
import com.wd.capability.layout.ui.paper.PaperHelpFactory;
import com.wd.capability.layout.ui.paper.PaperHelper;
import com.wd.common.imageglide.ImageUtils;
import com.wd.common.viewclick.BaseClickListener;
import com.wd.foundation.bean.custom.MenuBean;
import com.wd.foundation.bean.paper.PaperPageBean;
import com.wd.foundation.bean.utils.TimeUtil;
import com.wd.foundation.wdkit.statusbar.StatusBarCompat;
import com.wd.foundation.wdkit.utils.ToastNightUtil;
import com.wd.foundation.wdkit.utils.ViewUtils;
/**
* @Description: 电子报
* @Author: Li Yubing
* @Email: liyubing@wondert.com.cn
* @CreateDate: 2023/7/13 14:51
* @Version: 1.0
*/
public class ItemElectronPapterLayoutManager extends ItemContainerManager<MenuBean> implements PaperContract.onSizeMeasureCallback {
// -------------- title bar --------------
public RelativeLayout rlTitle;
public ImageView imgBack;
public ImageView imgShare;
public TextView tvDate;
// -------------- content --------------
public TextView tvPageIndicator;
public ImageView imgPageIndicatorArrow, ivLoadingView, ivImageLayer;
public RecyclerView rvContentImage;
public LinearLayout llPageIndicatorContainer;
public FrameLayout flContent;
// -------------- bottom-------------
public RelativeLayout rlBottomLeft, llPaperTitleDate;
public TextView tvNewsNo;
public RelativeLayout rlBarBottom;
public LinearLayout llReadList;
public RelativeLayout rlTopLeft;
public ImageView ivBottom, ivPageLayer;
// -------------- help container --------------
public PaperHelpFactory helpFactory;
public String eleDate;
@Override
public int getItemViewType() {
return R.layout.page_item_layout_electro_paper;
}
@Override
public void prepareItem(View itemView, int position) {
}
@Override
public void onDestory() {
super.onDestory();
if (helpFactory != null) {
if (helpFactory.dateChoosePWHelp != null && helpFactory.dateChoosePWHelp.calendarView != null) {
helpFactory.dateChoosePWHelp.calendarView.clearData();
}
helpFactory.dateChoosePWHelp = null;
helpFactory.browseModeSwitchHelp = null;
helpFactory.paperPageModel = null;
helpFactory.paperPageChoosePWHelp = null;
helpFactory.pagePositionSyncHelp = null;
helpFactory.paperImageHelp = null;
}
}
@Override
public void bindItem(View itemView, int position, MenuBean data) {
rlTitle = ViewUtils.findViewById(itemView, R.id.rl_act_paper_bar_title);
imgBack = ViewUtils.findViewById(itemView, R.id.img_act_paper_bar_title_back);
imgBack.setOnClickListener(v -> getFragmentActivity().finish());
imgShare = ViewUtils.findViewById(itemView, R.id.img_act_paper_bar_title_share);
imgShare.setOnClickListener(new BaseClickListener() {
@Override
protected void onNoDoubleClick(View v) {
if (helpFactory != null) {
PaperPageBean currentPageBean = helpFactory.pagePositionSyncHelp.getCurrentPageBean();
if (currentPageBean != null) {
// CompentLogicUtil.shareElInfo(currentPageBean, imgShare.getContext());
} else {
ToastNightUtil.showShort("暂无数据");
}
}
}
});
llPaperTitleDate = ViewUtils.findViewById(itemView, R.id.ll_paper_title_date);
tvDate = ViewUtils.findViewById(itemView, R.id.tv_act_paper_bar_title_date);
tvPageIndicator = ViewUtils.findViewById(itemView, R.id.tv_act_paper_content_image_indicator);
llPageIndicatorContainer = ViewUtils.findViewById(itemView, R.id.ll_act_paper_content_image_indicator_container);
rvContentImage = ViewUtils.findViewById(itemView, R.id.rv_act_paper_content_image);
imgPageIndicatorArrow = ViewUtils.findViewById(itemView, R.id.img_act_paper_content_image_indicator_arrow);
flContent = ViewUtils.findViewById(itemView, R.id.flImageContent);
rlBottomLeft = ViewUtils.findViewById(itemView, R.id.rlBottomLeft);
tvNewsNo = ViewUtils.findViewById(itemView, R.id.tvNewsNo);
rlBarBottom = ViewUtils.findViewById(itemView, R.id.rl_act_paper_bar_bottom);
llReadList = ViewUtils.findViewById(itemView, R.id.llReadList);
ivPageLayer = ViewUtils.findViewById(itemView, R.id.ivPageLayer);
rlTopLeft = ViewUtils.findViewById(itemView, R.id.rlTopLeft);
ivBottom = ViewUtils.findViewById(itemView, R.id.ivBottom);
ivLoadingView = ViewUtils.findViewById(itemView, R.id.ivLoadingView);
ivImageLayer = ViewUtils.findViewById(itemView, R.id.ivImageLayer);
RelativeLayout.LayoutParams rlTitleLp = (RelativeLayout.LayoutParams) rlTitle.getLayoutParams();
rlTitleLp.topMargin = StatusBarCompat.getStatusBarHeight(getFragmentActivity());
rlTitle.setLayoutParams(rlTitleLp);
initHelp();
String imageUrl = data.getBackgroundUrl();
if (!TextUtils.isEmpty(imageUrl)) {
ImageUtils.getInstance().loadImage(ivLoadingView, imageUrl);
}
}
@Override
public void sizeMeasure(double w, double h) {
String data = TimeUtil.getCurrentDate();
setChoosePaperDate(data);
helpFactory.paperPageModel.setElWh(w + "x" + h);
helpFactory.paperPageModel.requestPaperTime(null);
}
/**
* 设置选择电子报日期
*
* @param date
*/
public void setChoosePaperDate(String date) {
eleDate = PaperHelper.format2YYYYMMDD(date);
tvDate.setText(PaperHelper.format2TitleStyle(date));
}
private void initHelp() {
helpFactory = PaperHelpFactory.create(this, getFragmentActivity());
helpFactory.injectView();
helpFactory.paperImageHelp.measurePaperImageCanvasSize(this);
}
public void setShareShow(PaperPageBean currentPageBean) {
if (currentPageBean != null && currentPageBean.getSharePagePic() != null
&& 1 == currentPageBean.getSharePagePic().getSharePosterOpen()) {
//判断分享显示或隐藏
imgShare.setVisibility(View.VISIBLE);
}
}
}