Skip to content

Commit 3fa2651

Browse files
committed
Client:adt版删除不需要的ShowUtil和UserViewLayout;与studio版同步(CommentAdapter.ItemView改为CommentItemView),test工程一个ArrayList声明嵌入类型
1 parent 111838f commit 3fa2651

10 files changed

Lines changed: 239 additions & 387 deletions

File tree

APIJSON(Android)/APIJSON(ADT)/APIJSONApp/APIJSONApp/src/apijson/demo/client/activity_fragment/MomentActivity.java

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,6 @@
1414

1515
package apijson.demo.client.activity_fragment;
1616

17-
import java.util.List;
18-
19-
import zuo.biao.apijson.JSON;
20-
import zuo.biao.apijson.JSONResponse;
21-
import zuo.biao.library.base.BaseHttpListActivity;
22-
import zuo.biao.library.base.BaseView.OnDataChangedListener;
23-
import zuo.biao.library.interfaces.AdapterCallBack;
24-
import zuo.biao.library.interfaces.CacheCallBack;
25-
import zuo.biao.library.interfaces.OnBottomDragListener;
26-
import zuo.biao.library.manager.CacheManager;
27-
import zuo.biao.library.manager.HttpManager.OnHttpResponseListener;
28-
import zuo.biao.library.ui.AlertDialog;
29-
import zuo.biao.library.ui.AlertDialog.OnDialogButtonClickListener;
30-
import zuo.biao.library.ui.EditTextManager;
31-
import zuo.biao.library.util.CommonUtil;
32-
import zuo.biao.library.util.Log;
33-
import zuo.biao.library.util.SettingUtil;
34-
import zuo.biao.library.util.StringUtil;
3517
import android.app.Activity;
3618
import android.content.Context;
3719
import android.content.Intent;
@@ -43,9 +25,11 @@
4325
import android.widget.AdapterView.OnItemClickListener;
4426
import android.widget.AdapterView.OnItemLongClickListener;
4527
import android.widget.EditText;
28+
29+
import java.util.List;
30+
4631
import apijson.demo.client.R;
4732
import apijson.demo.client.adapter.CommentAdapter;
48-
import apijson.demo.client.adapter.CommentAdapter.ItemView.OnCommentClickListener;
4933
import apijson.demo.client.application.APIJSONApplication;
5034
import apijson.demo.client.manager.HttpManager;
5135
import apijson.demo.client.model.Comment;
@@ -54,7 +38,24 @@
5438
import apijson.demo.client.model.User;
5539
import apijson.demo.client.util.CommentUtil;
5640
import apijson.demo.client.util.HttpRequest;
41+
import apijson.demo.client.view.CommentItemView.OnCommentClickListener;
5742
import apijson.demo.client.view.MomentView;
43+
import zuo.biao.apijson.JSON;
44+
import zuo.biao.apijson.JSONResponse;
45+
import zuo.biao.library.base.BaseHttpListActivity;
46+
import zuo.biao.library.base.BaseView.OnDataChangedListener;
47+
import zuo.biao.library.interfaces.AdapterCallBack;
48+
import zuo.biao.library.interfaces.CacheCallBack;
49+
import zuo.biao.library.interfaces.OnBottomDragListener;
50+
import zuo.biao.library.manager.CacheManager;
51+
import zuo.biao.library.manager.HttpManager.OnHttpResponseListener;
52+
import zuo.biao.library.ui.AlertDialog;
53+
import zuo.biao.library.ui.AlertDialog.OnDialogButtonClickListener;
54+
import zuo.biao.library.ui.EditTextManager;
55+
import zuo.biao.library.util.CommonUtil;
56+
import zuo.biao.library.util.Log;
57+
import zuo.biao.library.util.SettingUtil;
58+
import zuo.biao.library.util.StringUtil;
5859

5960
/**用户列表界面fragment
6061
* @author Lemon
@@ -173,7 +174,7 @@ public void initView() {//必须调用
173174

174175
private MomentItem momentItem;
175176
/**
176-
* @param momentItem
177+
* @param momentItem_
177178
*/
178179
private void setHead(MomentItem momentItem_) {
179180
this.momentItem = momentItem_;
@@ -222,7 +223,7 @@ public void refreshAdapter() {
222223
// adapter.setShowAll(true);
223224
adapter.refresh(list_);
224225
}
225-
});
226+
});
226227
}
227228
});
228229
}
@@ -231,14 +232,14 @@ public void refreshAdapter() {
231232

232233

233234
/**显示输入评论
234-
* @param toCommentItem
235+
* @param toCommentItem_
235236
*/
236237
public void showInput(CommentItem toCommentItem_) {
237238
showInput(toCommentItem_, -1, -1);
238239
}
239240
/**显示输入评论
240-
* @param toCommentItem
241-
* @param position
241+
* @param toCommentItem_
242+
* @param position
242243
*/
243244
public void showInput(CommentItem toCommentItem_, final int position, final int index) {
244245
this.toCommentItem = toCommentItem_;
@@ -341,7 +342,7 @@ public void sendComment() {
341342

342343

343344
/**删除评论
344-
* @param comment
345+
* @param commentItem
345346
*/
346347
private void deleteComment(CommentItem commentItem) {
347348
long id = commentItem == null ? 0 : commentItem.getId();
@@ -483,7 +484,7 @@ public void onCommentClick(CommentItem item, int position, int index, boolean is
483484
new AlertDialog(context, null, "删除这条评论?", true, DIALOG_DELETE_COMMENT, MomentActivity.this).show();
484485
} else {
485486
showInput(item, position, index);
486-
}
487+
}
487488
}
488489

489490
private static final int DIALOG_DELETE_COMMENT = 1;

APIJSON(Android)/APIJSON(ADT)/APIJSONApp/APIJSONApp/src/apijson/demo/client/activity_fragment/ScanActivity.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import android.content.Context;
2121
import android.content.Intent;
2222
import android.os.Bundle;
23-
import android.view.SurfaceHolder.Callback;
2423
import android.view.SurfaceView;
2524
import android.view.View;
2625
import android.view.View.OnClickListener;
@@ -34,7 +33,7 @@
3433
* @author Lemon
3534
* @use toActivity(ScanActivity.createIntent(...));
3635
*/
37-
public class ScanActivity extends CaptureActivity implements Callback, ActivityPresenter, OnClickListener {
36+
public class ScanActivity extends CaptureActivity implements ActivityPresenter, OnClickListener {
3837
public static final String TAG = "ScanActivity";
3938

4039
//启动方法<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

APIJSON(Android)/APIJSON(ADT)/APIJSONApp/APIJSONApp/src/apijson/demo/client/adapter/CommentAdapter.java

Lines changed: 24 additions & 189 deletions
Original file line numberDiff line numberDiff line change
@@ -14,43 +14,28 @@
1414

1515
package apijson.demo.client.adapter;
1616

17+
import android.app.Activity;
18+
import android.view.ViewGroup;
19+
1720
import java.util.HashMap;
1821
import java.util.List;
1922
import java.util.Map;
2023

21-
import zuo.biao.library.base.BaseView;
22-
import zuo.biao.library.base.BaseViewAdapter;
23-
import zuo.biao.library.util.ImageLoaderUtil;
24-
import zuo.biao.library.util.StringUtil;
25-
import zuo.biao.library.util.TimeUtil;
26-
import android.annotation.SuppressLint;
27-
import android.app.Activity;
28-
import android.content.res.Resources;
29-
import android.text.Html;
30-
import android.view.LayoutInflater;
31-
import android.view.View;
32-
import android.view.View.OnClickListener;
33-
import android.view.View.OnLongClickListener;
34-
import android.view.ViewGroup;
35-
import android.widget.ImageView;
36-
import android.widget.LinearLayout;
37-
import android.widget.TextView;
38-
import apijson.demo.client.R;
39-
import apijson.demo.client.activity_fragment.UserActivity;
40-
import apijson.demo.client.adapter.CommentAdapter.ItemView;
41-
import apijson.demo.client.adapter.CommentAdapter.ItemView.OnCommentClickListener;
42-
import apijson.demo.client.adapter.CommentAdapter.ItemView.OnShowAllListener;
4324
import apijson.demo.client.model.CommentItem;
44-
import apijson.demo.client.view.CommentContainerView;
25+
import apijson.demo.client.view.CommentItemView;
26+
import apijson.demo.client.view.CommentItemView.OnCommentClickListener;
27+
import apijson.demo.client.view.CommentItemView.OnShowAllListener;
28+
import zuo.biao.library.base.BaseViewAdapter;
4529

4630
/**评论列表
4731
* @author Lemon
4832
*/
49-
public class CommentAdapter extends BaseViewAdapter<CommentItem, ItemView> {
33+
public class CommentAdapter extends BaseViewAdapter<CommentItem, CommentItemView> {
5034

5135

5236
private OnCommentClickListener onCommentClickListener;
53-
public CommentAdapter(Activity context, OnCommentClickListener onCommentClickListener) {
37+
38+
public CommentAdapter(Activity context, OnCommentClickListener onCommentClickListener) {
5439
super(context);
5540
this.onCommentClickListener = onCommentClickListener;
5641
}
@@ -61,6 +46,7 @@ public long getItemId(int position) {
6146
}
6247

6348
private boolean showAll = false;
49+
6450
public void setShowAll(boolean showAll) {
6551
this.showAll = showAll;
6652
}
@@ -72,176 +58,25 @@ public synchronized void refresh(List<CommentItem> list) {
7258
}
7359

7460
@Override
75-
public ItemView createView(int position, ViewGroup parent) {
76-
return new ItemView(context, resources)
77-
.setOnCommentClickListener(onCommentClickListener)
78-
.setOnShowAllListener(new OnShowAllListener() {
79-
@Override
80-
public void onShowAll(int position, ItemView bv, boolean show) {
81-
showAllMap.put(position, show);
82-
bindView(position, bv);
83-
}
84-
});
61+
public CommentItemView createView(int position, ViewGroup parent) {
62+
return new CommentItemView(context, resources)
63+
.setOnCommentClickListener(onCommentClickListener)
64+
.setOnShowAllListener(new OnShowAllListener() {
65+
@Override
66+
public void onShowAll(int position, CommentItemView bv, boolean show) {
67+
showAllMap.put(position, show);
68+
bindView(position, bv);
69+
}
70+
});
8571
}
8672

8773
private Map<Integer, Boolean> showAllMap = new HashMap<>();
74+
8875
@Override
89-
public void bindView(int position, ItemView bv) {
76+
public void bindView(int position, CommentItemView bv) {
9077
//true : showAllMap.get(position)怎么搞都崩溃
9178
bv.setShowAll(showAll ? Boolean.valueOf(true) : showAllMap.get(position));
9279
super.bindView(position, bv);
9380
}
9481

95-
96-
public static class ItemView extends BaseView<CommentItem> implements OnClickListener {
97-
98-
/**点击评论监听回调
99-
*/
100-
public interface OnCommentClickListener {
101-
void onCommentClick(CommentItem item, int position, int index, boolean isLong);
102-
}
103-
104-
/**显示更多监听回调
105-
* @author Lemon
106-
*/
107-
public interface OnShowAllListener {
108-
public void onShowAll(int position, ItemView bv, boolean show);
109-
}
110-
111-
private OnCommentClickListener onCommentClickListener;
112-
public ItemView setOnCommentClickListener(OnCommentClickListener onCommentClickListener) {
113-
this.onCommentClickListener = onCommentClickListener;
114-
return this;
115-
}
116-
117-
private OnShowAllListener onShowAllListener;
118-
public ItemView setOnShowAllListener(OnShowAllListener onShowAllListener) {
119-
this.onShowAllListener = onShowAllListener;
120-
return this;
121-
}
122-
123-
124-
125-
public ItemView(Activity context, Resources resources) {
126-
super(context, resources);
127-
}
128-
129-
private LayoutInflater inflater;
130-
131-
public ImageView ivCommentHead;
132-
public TextView tvCommentName;
133-
public TextView tvCommentContent;
134-
public TextView tvCommentTime;
135-
136-
137-
public LinearLayout llCommentContainer;
138-
139-
@SuppressLint("InflateParams")
140-
@Override
141-
public View createView(LayoutInflater inflater) {
142-
this.inflater = inflater;
143-
convertView = inflater.inflate(R.layout.comment_main_item, null);
144-
145-
ivCommentHead = findViewById(R.id.ivCommentHead, this);
146-
147-
tvCommentName = (TextView) findViewById(R.id.tvCommentName, this);
148-
tvCommentContent = (TextView) findViewById(R.id.tvCommentContent);
149-
tvCommentTime = (TextView) findViewById(R.id.tvCommentTime);
150-
151-
llCommentContainer = findViewById(R.id.llCommentContainer);
152-
153-
return convertView;
154-
}
155-
156-
157-
private boolean showAll = false;
158-
public void setShowAll(Boolean showAll) {
159-
this.showAll = showAll == null ? false : showAll;
160-
}
161-
162-
@Override
163-
public void bindView(CommentItem data){
164-
this.data = data;
165-
166-
String name = StringUtil.getTrimedString(data.getUser().getName());
167-
String content = StringUtil.getTrimedString(data.getComment().getContent());
168-
169-
tvCommentName.setText("" + name);
170-
tvCommentContent.setText("" + content);
171-
tvCommentTime.setText("" + TimeUtil.getSmartDate(data.getDate()));
172-
ImageLoaderUtil.loadImage(ivCommentHead, data.getUser().getHead(), ImageLoaderUtil.TYPE_OVAL);
173-
174-
setChildComment();
175-
}
176-
177-
178-
@Override
179-
public void onClick(View v) {
180-
switch (v.getId()) {
181-
case R.id.ivCommentHead:
182-
case R.id.tvCommentName:
183-
toActivity(UserActivity.createIntent(context, data.getUser().getId()));
184-
break;
185-
case R.id.tvCommentContainerViewMore:
186-
if (onShowAllListener != null) {
187-
onShowAllListener.onShowAll(position, this, true);
188-
}
189-
break;
190-
default:
191-
break;
192-
}
193-
}
194-
195-
public CommentContainerView commentContainerView;
196-
/**显示子评论
197-
* @param data
198-
*/
199-
@SuppressLint("InflateParams")
200-
public void setChildComment() {
201-
if (commentContainerView == null) {
202-
commentContainerView = new CommentContainerView(context, resources);
203-
llCommentContainer.removeAllViews();
204-
llCommentContainer.addView(commentContainerView.createView(inflater));
205-
206-
commentContainerView.setOnCommentClickListener(onCommentClickListener);
207-
commentContainerView.tvCommentContainerViewMore.setOnClickListener(this);
208-
}
209-
210-
commentContainerView.setMaxShowCount(showAll ? 0 : 3);
211-
commentContainerView.bindView(data.getChildList());
212-
213-
// for (int i = 0; i < downList.size(); i++) {
214-
// final int index = i;
215-
//
216-
// TextView childComment = (TextView) inflater.inflate(R.layout.comment_down_item, null);
217-
//
218-
// final CommentItem data = downList.get(i);
219-
// String name = StringUtil.getTrimedString(data.getUser().getName());
220-
// String content = StringUtil.getTrimedString(data.getComment().getContent());
221-
// childComment.setText(Html.fromHtml("<font color=\"#009ed3\">" + StringUtil.getString(name) + "</font>"
222-
// + " 回复 " + "<font color=\"#009ed3\">" + StringUtil.getString(data.getToUser().getName())
223-
// + "</font>" + " : " + content));
224-
//
225-
// childComment.setOnClickListener(new OnClickListener() {
226-
// @Override
227-
// public void onClick(View v) {
228-
// onCommentClick(data, position, index, false);
229-
// }
230-
// });
231-
// childComment.setOnLongClickListener(new OnLongClickListener() {
232-
//
233-
// @Override
234-
// public boolean onLongClick(View v) {
235-
// onCommentClick(data, position, index, true);
236-
// return true;
237-
// }
238-
// });
239-
//
240-
// llCommentContainer.addView(childComment);
241-
// }
242-
243-
}
244-
245-
}
246-
247-
}
82+
}

0 commit comments

Comments
 (0)