MultiContentDetailFragment.java
7.76 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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
package com.sunvote.xpadapp.fragment;
import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.github.barteksc.pdfviewer.PDFView;
import com.github.barteksc.pdfviewer.listener.OnRenderListener;
import com.sunvote.util.LogUtil;
import com.sunvote.xpadapp.R;
import com.sunvote.xpadapp.activity.PageManager;
import com.sunvote.xpadapp.bean.Bills;
import com.sunvote.xpadapp.db.DBManager;
import java.io.File;
/**
* Created by Elvis on 2017/11/30 15:07
* Email:Eluis@psunsky.com
* 版权所有:长沙中天电子设计开发有限公司
* Description: 人大通用版XPadAppRD重构
* 表决界面
*/
public class MultiContentDetailFragment extends BaseFragment {
private String TAG = "MultiContentDetailFr";
private Bills bill;
private TextView tvTitle;
private TextView tvTips;
private TextView ivReuslt;
private Button btnA;
private Button btnB;
private Button btnC;
private PDFView pdfView;
private Button btnLookPdf;
private RelativeLayout panelVote;
private RelativeLayout panelModify;
public String[] options;
private boolean showBackBtn;
//关闭当前Fragment
public boolean isClose = true;
//pdf 页码
public int pdfPageNum = 0;
private String filename;
//pdf延迟加载
private int pdfDelayLoadTime=500;
private int voteValue;
private RelativeLayout confirmLayout;
private TextView tvConfirmText;
public String[] voteOptions = new String[13];
public ContentVoteOnBack contentBackListener;
private String DATABASE_PATH = android.os.Environment.getExternalStorageDirectory().getAbsolutePath();
public interface ContentVoteOnBack {
void onBack();
}
public void setInfo(Bills billInfo, boolean isShowBack) {
bill = billInfo;
showBackBtn = isShowBack;
}
private void initOptions() {
voteOptions[0] = getString(R.string.zc_fd);
voteOptions[1] = getString(R.string.zc_fd_qq);
voteOptions[2] = getString(R.string.ty_fd_qq);
voteOptions[3] = getString(R.string.my_jbmy_bmy);
voteOptions[4] = getString(R.string.my_jbmy_bmy_blj);
voteOptions[5] = getString(R.string.my_jbmy_yb_bmy);
voteOptions[6] = getString(R.string.fcmy_my_blj_bmy_fcbmy);
voteOptions[7] = getString(R.string.fcty_ty_bqd_bty_fcbty);
voteOptions[8] = getString(R.string.yx_cz_bcz);
voteOptions[9] = getString(R.string.yx_cz_jbcz_bcz);
voteOptions[10] = getString(R.string.y_l_z_c);
voteOptions[11] = getString(R.string.my_bmy_fcbmy);
LogUtil.d(TAG, "options:" + options.toString());
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
LogUtil.d(TAG, "onCreateView");
View view = inflater.inflate(R.layout.fragment_multi_content_detail, container, false);
initOptions();
tvTitle = view.findViewById(R.id.content_detail_title);
pdfView = view.findViewById(R.id.content_detail_pdfview);
panelVote = view.findViewById(R.id.content_detail_pannal_vote);
panelModify = view.findViewById(R.id.content_detail_pannal_modify);
tvTips = view.findViewById(R.id.content_detail_tv_tips);
ivReuslt = view.findViewById(R.id.content_detail_tv_result);
btnLookPdf= view.findViewById(R.id.btn_look_pdf);
btnA = view.findViewById(R.id.content_detail_btnA);
btnB = view.findViewById(R.id.content_detail_btnB);
btnC = view.findViewById(R.id.content_detail_btnC);
ImageButton btnBack = view.findViewById(R.id.content_detail_btnback);
Button btnModify = view.findViewById(R.id.content_detail_btn_modify);
confirmLayout = view.findViewById(R.id.content_detail_confirm_panel);
tvConfirmText = view.findViewById(R.id.content_detail_confirm_textview);
Button btnConfirmCancel = view.findViewById(R.id.content_detail_btn_confirm_cancel);
Button btnConfirmOK = view.findViewById(R.id.content_detail_btn_confirm_ok);
if (bill != null && bill.getTitle() != null) {
tvTitle.setText(bill.getTitle());
}
filename = DATABASE_PATH + "/sunvote/" + DBManager.getInstance().getConfId() + "/" + bill.getBillFile();
ivReuslt.setVisibility(View.INVISIBLE);
new Handler().postDelayed(new Runnable(){
public void run() {
openPdfFile();
}
}, pdfDelayLoadTime);
btnBack.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
goBack();
}
});
if (!showBackBtn) {
btnBack.setVisibility(View.INVISIBLE);
}
btnModify.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
panelModify.setVisibility(View.GONE);
showVote();
ivReuslt.setVisibility(View.VISIBLE);
}
});
btnConfirmOK.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
hideConfirm();
doVoteWithIndex(voteValue);
}
});
btnConfirmCancel.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
hideConfirm();
}
});
return view;
}
private void showConfirmWithValue(int value) {
voteValue = value;
tvConfirmText.setText(
getString(R.string.you_selected) + options[value - 1] + getString(R.string.you_selected_confirm));
confirmLayout.setVisibility(View.VISIBLE);
btnA.setVisibility(View.INVISIBLE);
btnB.setVisibility(View.INVISIBLE);
btnC.setVisibility(View.INVISIBLE);
}
private void hideConfirm() {
confirmLayout.setVisibility(View.GONE);
btnA.setVisibility(View.VISIBLE);
if (options.length == 3) {
btnB.setVisibility(View.VISIBLE);
}
btnC.setVisibility(View.VISIBLE);
}
@Override
public void onResume() {
super.onResume();
// if (voteInfo != null) {
btnA.setVisibility(View.VISIBLE);
btnB.setVisibility(View.VISIBLE);
btnC.setVisibility(View.VISIBLE);
if (options.length == 2) {
btnA.setText(options[0]);
btnB.setVisibility(View.INVISIBLE);
btnC.setText(options[1]);
} else if (options.length == 3) {
btnA.setText(options[0]);
btnB.setText(options[1]);
btnC.setText(options[2]);
}
showVote();
showResult();
checkIsVoted();
// } else {
// hideVote();
// }
}
private void doVoteWithIndex(int index) {
}
// private int result;
private void showResult() {
}
private void goBack() {
PageManager.getInstance().popStack();
}
public void hideVote() {
panelVote.setVisibility(View.GONE);
panelModify.setVisibility(View.GONE);
}
public void showVote() {
panelVote.setVisibility(View.VISIBLE);
enableVote();
}
public void disableVote() {
btnA.setEnabled(false);
btnB.setEnabled(false);
btnC.setEnabled(false);
}
public void enableVote() {
btnA.setEnabled(true);
btnB.setEnabled(true);
btnC.setEnabled(true);
}
private void showModify() {
panelModify.setVisibility(View.VISIBLE);
tvTips.setText(getString(R.string.submited));
}
private void showModifyOrDisable(){
}
public void onVoteSubmitSuccess() {
tvTips.setText(getString(R.string.submited));
showModifyOrDisable();
saveVoteInfo();
}
private void saveVoteInfo(){
}
private void checkIsVoted(){
}
private void openPdfFile(){
File file=new File(filename);
if (file.exists()) {
pdfView.fromFile(file)
.enableSwipe(true) // allows to block changing pages using swipe
.swipeHorizontal(false)
.enableDoubletap(true)
.defaultPage(0)
.onRender(new OnRenderListener() {
@Override
public void onInitiallyRendered(int nbPages, float pageWidth, float pageHeight) {
pdfView.fitToWidth(pdfPageNum-1);
}
})
.enableAnnotationRendering(false)
.password(null)
.scrollHandle(null)
.enableAntialiasing(true)
.spacing(0)
.load();
}else {
Toast.makeText(getActivity(),"议案文件未找到",Toast.LENGTH_LONG).show();
}
}
}