From 062ff08956278b0369bba67808c2211739f845fe Mon Sep 17 00:00:00 2001 From: yiwei Date: Sun, 3 Jan 2016 14:30:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=82=B9=E8=B5=9E=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E4=B8=AD=E5=9B=BE=E6=A0=87=E7=9A=84=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yiw/circledemo/adapter/CircleAdapter.java | 25 +++++++++++-------- .../circledemo/adapter/CommentAdapter.java | 7 +++--- .../FavortListAdapter.java | 19 ++++++++------ .../contral/CirclePublicCommentContral.java | 6 ++--- .../mvp/presenter/CirclePresenter.java | 6 ++--- ...teListener.java => ICircleViewUpdate.java} | 2 +- .../circledemo/widgets/FavortListView.java | 1 + .../main/res/layout/adapter_circle_item.xml | 2 -- 8 files changed, 37 insertions(+), 31 deletions(-) rename CircleDemo/app/src/main/java/com/yiw/circledemo/{widgets => adapter}/FavortListAdapter.java (80%) rename CircleDemo/app/src/main/java/com/yiw/circledemo/mvp/view/{ICircleViewUpdateListener.java => ICircleViewUpdate.java} (94%) diff --git a/CircleDemo/app/src/main/java/com/yiw/circledemo/adapter/CircleAdapter.java b/CircleDemo/app/src/main/java/com/yiw/circledemo/adapter/CircleAdapter.java index be10832..19a1b8d 100644 --- a/CircleDemo/app/src/main/java/com/yiw/circledemo/adapter/CircleAdapter.java +++ b/CircleDemo/app/src/main/java/com/yiw/circledemo/adapter/CircleAdapter.java @@ -25,12 +25,11 @@ import com.yiw.circledemo.bean.User; import com.yiw.circledemo.contral.CirclePublicCommentContral; import com.yiw.circledemo.mvp.presenter.CirclePresenter; -import com.yiw.circledemo.mvp.view.ICircleViewUpdateListener; +import com.yiw.circledemo.mvp.view.ICircleViewUpdate; import com.yiw.circledemo.spannable.ISpanClick; import com.yiw.circledemo.utils.DatasUtil; import com.yiw.circledemo.widgets.AppNoScrollerListView; import com.yiw.circledemo.widgets.CircularImage; -import com.yiw.circledemo.widgets.FavortListAdapter; import com.yiw.circledemo.widgets.FavortListView; import com.yiw.circledemo.widgets.MultiImageView; import com.yiw.circledemo.widgets.SnsPopupWindow; @@ -46,7 +45,7 @@ * @date 2015-12-28 上午09:37:23 * */ -public class CircleAdapter extends BaseAdapter implements ICircleViewUpdateListener{ +public class CircleAdapter extends BaseAdapter implements ICircleViewUpdate { private static final int ITEM_VIEW_TYPE_DEFAULT = 0; private static final int ITEM_VIEW_TYPE_URL = 1; private static final int ITEM_VIEW_TYPE_IMAGE = 2; @@ -60,7 +59,7 @@ public class CircleAdapter extends BaseAdapter implements ICircleViewUpdateListe private CirclePresenter mPresenter; private CirclePublicCommentContral mCirclePublicCommentContral; private List datas = new ArrayList(); - + public void setmCirclePublicCommentContral( CirclePublicCommentContral mCirclePublicCommentContral) { this.mCirclePublicCommentContral = mCirclePublicCommentContral; @@ -186,6 +185,8 @@ public View getView(final int position, View convertView, ViewGroup parent) { holder.nameTv.setText(name); holder.timeTv.setText(createTime); holder.contentTv.setText(content); + holder.contentTv.setVisibility(TextUtils.isEmpty(content) ? View.GONE : View.VISIBLE); + if(DatasUtil.curUser.getId().equals(circleItem.getUser().getId())){ holder.deleteBtn.setVisibility(View.VISIBLE); }else{ @@ -219,11 +220,14 @@ public void onClick(int position) { holder.bbsAdapter.setCommentClickListener(new ICommentItemClickListener() { @Override public void onItemClick(int commentPosition) { + CommentItem commentItem = commentsDatas.get(commentPosition); if(DatasUtil.curUser.getId().equals(commentItem.getUser().getId())){//复制或者删除自己的评论 + CommentDialog dialog = new CommentDialog(mContext, mPresenter, commentItem, position); dialog.show(); }else{//回复别人的评论 + if(mCirclePublicCommentContral!=null){ mCirclePublicCommentContral.editTextBodyVisible(View.VISIBLE, mPresenter, position, TYPE_REPLY_COMMENT, commentItem.getUser(), commentPosition); } @@ -236,6 +240,7 @@ public void onItemClick(int commentPosition) { holder.commentList.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView arg0, View view, final int commentPosition, long id) { + //长按进行复制或者删除 CommentItem commentItem = commentsDatas.get(commentPosition); CommentDialog dialog = new CommentDialog(mContext, mPresenter, commentItem, position); @@ -244,18 +249,16 @@ public boolean onItemLongClick(AdapterView arg0, View view, final int comment } }); }else { + holder.commentList.setVisibility(View.GONE); } holder.digCommentBody.setVisibility(View.VISIBLE); }else{ holder.digCommentBody.setVisibility(View.GONE); } - if(hasFavort && hasComment){ - holder.digLine.setVisibility(View.VISIBLE); - }else{ - holder.digLine.setVisibility(View.GONE); - } - + + holder.digLine.setVisibility(hasFavort && hasComment ? View.VISIBLE : View.GONE); + final SnsPopupWindow snsPopupWindow = holder.snsPopupWindow; //判断是否已点赞 String curUserFavortId = circleItem.getCurUserFavortId(DatasUtil.curUser.getId()); @@ -335,11 +338,13 @@ private class PopupItemClickListener implements SnsPopupWindow.OnItemClickListen private int mCirclePosition; private long mLasttime = 0; private CircleItem mCircleItem; + public PopupItemClickListener(int circlePosition, CircleItem circleItem, String favorId){ this.mFavorId = favorId; this.mCirclePosition = circlePosition; this.mCircleItem = circleItem; } + @Override public void onItemClick(ActionItem actionitem, int position) { switch (position) { diff --git a/CircleDemo/app/src/main/java/com/yiw/circledemo/adapter/CommentAdapter.java b/CircleDemo/app/src/main/java/com/yiw/circledemo/adapter/CommentAdapter.java index 20b3425..93e3198 100644 --- a/CircleDemo/app/src/main/java/com/yiw/circledemo/adapter/CommentAdapter.java +++ b/CircleDemo/app/src/main/java/com/yiw/circledemo/adapter/CommentAdapter.java @@ -92,13 +92,12 @@ public View getView(final int position, View convertView, ViewGroup parent) { } SpannableStringBuilder builder = new SpannableStringBuilder(); - builder.append(getSpannableString(name, 0)); + builder.append(setClickableSpan(name, 0)); if (!TextUtils.isEmpty(toReplyName)) { builder.append(" 回复 "); - - builder.append(getSpannableString(toReplyName, 1)); + builder.append(setClickableSpan(toReplyName, 1)); } builder.append(": "); //转换表情字符 @@ -122,7 +121,7 @@ public void onClick(View v) { } @NonNull - private SpannableString getSpannableString(String textStr, int position) { + private SpannableString setClickableSpan(String textStr, int position) { SpannableString subjectSpanText = new SpannableString(textStr); subjectSpanText.setSpan(new NameClickable(new NameClickListener( subjectSpanText, ""), position), 0, subjectSpanText.length(), diff --git a/CircleDemo/app/src/main/java/com/yiw/circledemo/widgets/FavortListAdapter.java b/CircleDemo/app/src/main/java/com/yiw/circledemo/adapter/FavortListAdapter.java similarity index 80% rename from CircleDemo/app/src/main/java/com/yiw/circledemo/widgets/FavortListAdapter.java rename to CircleDemo/app/src/main/java/com/yiw/circledemo/adapter/FavortListAdapter.java index 733a9df..2d8bc29 100644 --- a/CircleDemo/app/src/main/java/com/yiw/circledemo/widgets/FavortListAdapter.java +++ b/CircleDemo/app/src/main/java/com/yiw/circledemo/adapter/FavortListAdapter.java @@ -1,9 +1,10 @@ -package com.yiw.circledemo.widgets; +package com.yiw.circledemo.adapter; import android.support.annotation.NonNull; import android.text.Spannable; import android.text.SpannableString; import android.text.SpannableStringBuilder; +import android.text.style.DynamicDrawableSpan; import android.text.style.ImageSpan; import com.yiw.circledemo.MyApplication; @@ -11,6 +12,7 @@ import com.yiw.circledemo.bean.FavortItem; import com.yiw.circledemo.spannable.CircleMovementMethod; import com.yiw.circledemo.spannable.NameClickable; +import com.yiw.circledemo.widgets.FavortListView; import java.util.List; @@ -60,12 +62,13 @@ public void notifyDataSetChanged(){ SpannableStringBuilder builder = new SpannableStringBuilder(); if(datas != null && datas.size() > 0){ //添加点赞图标 - //builder.append(setImgSpannable()); + builder.append(setImageSpan()); + //builder.append(" "); FavortItem item = null; for (int i=0; i