复制代码
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
mGradeFlowTagLayout.setOnTagSelectListener(new OnTagSelectListener() {
@Override
public void onItemSelect(FlowTagLayout parent, List<Integer> selectedList) {
if (selectedList != null && selectedList.size() > 0) {
for (int i : selectedList) {
switch (i) {
case 0:
PadGrade(index_0+ "", true);
mStartStatus=index_0;
break;
case 1:
PadGrade(index_1+ "", true);
mStartStatus=index_1;
break;
case 2:
PadGrade(index_2+ "", true);
mStartStatus=index_2;
break;
case 3:
PadGrade(index_3+ "", true);
mStartStatus=index_3;
break;
case 4:
PadGrade(index_4+ "", true);
mStartStatus=index_4;
break;
}
}
} else {
Toast.makeText(getActivity(), "没有选择标签", Toast.LENGTH_SHORT).show();
PadGrade(null, true);
}
}
});
netWorkHelper.obtainStoreScoreInfoComment(mContext, new NetWorkListener.ObtainStoreScoreInfoCommentListener() {
@Override
public void onFinish(int score, int pointCount, int starFive, int starFour, int starThree, int starTwo, int starOne) {
star1 = starOne;
star2 = starTwo;
star3 = starThree;
star4 = starFour;
star5 = starFive;
List<String> dataSource1 = new ArrayList<>();
int i = 0;
if (star5 != 0) {
dataSource1.add("5星评价" + "n" + " " + star5);
i++;
index_0 = 5;
}
if (star4 != 0) {
dataSource1.add("4星评价" + "n" + " " + star4);
if (i == 0) {
index_0 = 4;
}else {
index_1 = 4;
}
i++;
}
if (star3 != 0) {
dataSource1.add("3星评价" + "n" + " " + star3);
switch (i) {
case 0:
index_0 = 3;
break;
case 1:
index_1 = 3;
break;
case 2:
index_2 = 3;
break;
}
i++;
}
if (star2 != 0) {
dataSource1.add("2星评价" + "n" + " " + star2);
switch (i) {
case 0:
index_0 = 2;
break;
case 1:
index_1 = 2;
break;
case 2:
index_2 = 2;
break;
case 3:
index_3 = 2;
break;
}
i++;
}
if (star1 != 0) {
dataSource1.add("1星评价" + "n" + " " + star1);
switch (i) {
case 0:
index_0 = 1;
break;
case 1:
index_1 = 1;
break;
case 2:
index_2 = 1;
break;
case 3:
index_3 = 1;
break;
case 4:
index_4 = 1;
break;
}
i++;
}
mGradeTagAdapter.onlyAddAll(dataSource1);
}
@Override
public void onError(String errorDesc) {
Toast.makeText(mContext, "网络错误", Toast.LENGTH_SHORT).show();
}
});
复制代码
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
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
package com.mine.project.function.home;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.mine.project.R;
import com.mine.project.flowlibrary.FlowTagLayout;
import com.mine.project.flowlibrary.OnTagSelectListener;
import com.mine.project.function.activity.UserComplainActivity;
import com.mine.project.function.adapter.PadComplainAdapter;
import com.mine.project.function.adapter.PadGradeAdpter;
import com.mine.project.function.adapter.TagAdapter;
import com.mine.project.function.domain.CommentInfo;
import com.mine.project.function.domain.ComplainInfo;
import com.mine.project.function.domain.PageInfo;
import com.mine.project.home.ui.BaseFragment;
import com.mine.project.network.control.NetWorkListener;
import java.util.ArrayList;
import java.util.List;
/**
* A simple {@link Fragment} subclass.
*/
public class TabLayoutFragment extends BaseFragment {
public static String TABLAYOUT_FRAGMENT = "tab_fragment";
private TextView mTextView;
private int type;
private ListView mLvShopGrade;
private LinearLayout mLlShapgrade;
private ListView mLvShopgrade;
private RecyclerView mRv;
List<String> mData;
private FlowTagLayout mGradeFlowTagLayout;
private CheckBox mChCommentShopgrade;
private TagAdapter<String> mGradeTagAdapter;
private FragmentManager manager;
private FragmentTransaction transaction;
private String padGradeTime;
private int star1;
private int star2;
private int star3;
private int star4;
private int star5;
private int index_0;
private int index_1;
private int index_2;
private int index_3;
private int index_4;
private int mStartStatus;
private boolean mIsChecked=true;
private PadComplainAdapter mPadComplainAdapter;
public static TabLayoutFragment newInstance(int type) {
TabLayoutFragment fragment = new TabLayoutFragment();
Bundle bundle = new Bundle();
bundle.putSerializable(TABLAYOUT_FRAGMENT, type);
fragment.setArguments(bundle);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments() != null) {
type = (int) getArguments().getSerializable(TABLAYOUT_FRAGMENT);
}
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_tab_layout, container, false);
initView(view);
initData();
initSizeData();
return view;
}
private void initData() {
mChCommentShopgrade.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
PadGrade(mStartStatus+"", true);
Toast.makeText(getActivity(), "只看有内容评论", Toast.LENGTH_SHORT).show();
} else {
PadGrade(mStartStatus+"", false);
Toast.makeText(getActivity(), "查看全部评论", Toast.LENGTH_SHORT).show();
}
}
});
}
protected void initView(View view) {
mChCommentShopgrade = (CheckBox) view.findViewById(R.id.ch_comment_shopgrade);
mGradeFlowTagLayout = (FlowTagLayout) view.findViewById(R.id.size_flow_layout);
mRv = (RecyclerView) view.findViewById(R.id.rv);
// mLvShopgrade = (ListView)view.findViewById(R.id.lv_shopgrade);
mLlShapgrade = (LinearLayout) view.findViewById(R.id.ll_shapgrade);
switch (type) {
case 1:
//flase显示所有评论,默认显示有内容评论
PadGrade(null, true);
break;
case 2:
PadComplain(1);
mLlShapgrade.setVisibility(View.GONE);
break;
}
}
private void initSizeData() {
//评价动态标签流式布局显示
mGradeTagAdapter = new TagAdapter<>(getActivity());
mGradeFlowTagLayout.setTagCheckedMode(FlowTagLayout.FLOW_TAG_CHECKED_SINGLE);
mGradeFlowTagLayout.setAdapter(mGradeTagAdapter);
mGradeFlowTagLayout.setOnTagSelectListener(new OnTagSelectListener() {
@Override
public void onItemSelect(FlowTagLayout parent, List<Integer> selectedList) {
if (selectedList != null && selectedList.size() > 0) {
for (int i : selectedList) {
switch (i) {
case 0:
PadGrade(index_0+ "", true);
mStartStatus=index_0;
break;
case 1:
PadGrade(index_1+ "", true);
mStartStatus=index_1;
break;
case 2:
PadGrade(index_2+ "", true);
mStartStatus=index_2;
break;
case 3:
PadGrade(index_3+ "", true);
mStartStatus=index_3;
break;
case 4:
PadGrade(index_4+ "", true);
mStartStatus=index_4;
break;
}
}
} else {
Toast.makeText(getActivity(), "没有选择标签", Toast.LENGTH_SHORT).show();
PadGrade(null, true);
}
}
});
netWorkHelper.obtainStoreScoreInfoComment(mContext, new NetWorkListener.ObtainStoreScoreInfoCommentListener() {
@Override
public void onFinish(int score, int pointCount, int starFive, int starFour, int starThree, int starTwo, int starOne) {
star1 = starOne;
star2 = starTwo;
star3 = starThree;
star4 = starFour;
star5 = starFive;
List<String> dataSource1 = new ArrayList<>();
int i = 0;
if (star5 != 0) {
dataSource1.add("5星评价" + "n" + " " + star5);
i++;
index_0 = 5;
}
if (star4 != 0) {
dataSource1.add("4星评价" + "n" + " " + star4);
if (i == 0) {
index_0 = 4;
}else {
index_1 = 4;
}
i++;
}
if (star3 != 0) {
dataSource1.add("3星评价" + "n" + " " + star3);
switch (i) {
case 0:
index_0 = 3;
break;
case 1:
index_1 = 3;
break;
case 2:
index_2 = 3;
break;
}
i++;
}
if (star2 != 0) {
dataSource1.add("2星评价" + "n" + " " + star2);
switch (i) {
case 0:
index_0 = 2;
break;
case 1:
index_1 = 2;
break;
case 2:
index_2 = 2;
break;
case 3:
index_3 = 2;
break;
}
i++;
}
if (star1 != 0) {
dataSource1.add("1星评价" + "n" + " " + star1);
switch (i) {
case 0:
index_0 = 1;
break;
case 1:
index_1 = 1;
break;
case 2:
index_2 = 1;
break;
case 3:
index_3 = 1;
break;
case 4:
index_4 = 1;
break;
}
i++;
}
mGradeTagAdapter.onlyAddAll(dataSource1);
}
@Override
public void onError(String errorDesc) {
Toast.makeText(mContext, "网络错误", Toast.LENGTH_SHORT).show();
}
});
// List<StarEntity> dataSource = new ArrayList<>();
// StarEntity mStarEntity1 = new StarEntity("1星评价",1);
// dataSource.add(mStarEntity1);
}
private void PadGrade(String mLevel, boolean isShowNoComment) {
netWorkHelper.obtainStoreScoreComment(mContext, mLevel, 1, isShowNoComment, new NetWorkListener.ObtainStoreScoreCommentListener() {
@Override
public void onFinish(ArrayList<CommentInfo> list, PageInfo pageInfo) {
// mLvShopgrade.setAdapter(new ItemPadgradeAdapter(mContext,list));
mRv.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
mRv.setItemAnimator(new DefaultItemAnimator());
mRv.setAdapter(new PadGradeAdpter(mContext, list));
}
@Override
public void onError(String errorDesc) {
Toast.makeText(mContext, "网络错误", Toast.LENGTH_SHORT).show();
}
});
}
private void PadComplain(int mCurPage) {
netWorkHelper.obtainStoreScoreComplain(mContext, mCurPage, new NetWorkListener.ObtainStoreScoreComplainListener() {
@Override
public void onFinish(ArrayList<ComplainInfo> list, PageInfo pageInfo) {
mRv.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
mRv.setItemAnimator(new DefaultItemAnimator());
mPadComplainAdapter = new PadComplainAdapter(mContext, list);
mRv.setAdapter(mPadComplainAdapter);
mPadComplainAdapter.setOnItemClickListener(new PadComplainAdapter.OnItemClickListener() {
@Override
public void onClick(PadComplainAdapter.ViewHolder holder, View view, int position) {
switch (position) {
case 1:
startActvity(UserComplainActivity.class);
break;
default:
startActvity(UserComplainActivity.class);
break;
}
}
});
}
@Override
public void onError(String errorDesc) {
Toast.makeText(mContext, "联网失败", Toast.LENGTH_SHORT).show();
}
});
}
}
最后
以上就是淡淡学姐最近收集整理的关于来段牛逼的代码的全部内容,更多相关来段牛逼内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复