1、处理viewholder

2、处理adapter
3、
This commit is contained in:
CsHeng
2017-06-16 15:39:45 +08:00
parent 079c160268
commit b3d63c5698
152 changed files with 666 additions and 1022 deletions

View File

@ -4,7 +4,6 @@ import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.ViewHolder;
@ -14,7 +13,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import com.gh.base.BaseRecyclerAdapter;
import com.gh.base.adapter.BaseRecyclerAdapter;
import com.gh.common.constant.Config;
import com.gh.common.util.CommentUtils;
import com.gh.common.util.ConcernContentUtils;
@ -31,7 +30,6 @@ import com.gh.common.util.Utils;
import com.gh.gamecenter.MessageDetailActivity;
import com.gh.gamecenter.NewsDetailActivity;
import com.gh.gamecenter.R;
import com.gh.gamecenter.ShareCardActivity;
import com.gh.gamecenter.ShareCardPicActivity;
import com.gh.gamecenter.WebActivity;
import com.gh.gamecenter.adapter.viewholder.CommentHeadViewHolder;
@ -78,7 +76,7 @@ public class MessageDetailAdapter extends BaseRecyclerAdapter<ViewHolder> {
boolean isGetRvHeight = true; // 防止评论时弹出软键盘 影响RecyclerView高度
int rvHeight;
private ConcernEntity mConcernEntity;
private OnCommentCallBackListener mCallBackListener;
private OnCommentCallBackListener mOnCommentCallBackListener;
private RecyclerView mRecyclerView;
private List<CommentEntity> mHotCommentList;
private List<CommentEntity> mNormalCommentList;
@ -87,18 +85,18 @@ public class MessageDetailAdapter extends BaseRecyclerAdapter<ViewHolder> {
private SharedPreferences sp;
private String userName; //用户名
private String userIcon; //用户icon
private String entrance;
private String mEntrance;
private boolean isOver;
private boolean isLoading;
private boolean isNetworkError;
private boolean isRefreshPosition;
public MessageDetailAdapter(MessageDetailActivity context, CommentDao commentDao, RecyclerView messageDetailRv,
ConcernEntity concernEntity, String entrance) {
public MessageDetailAdapter(MessageDetailActivity context, OnCommentCallBackListener listener, CommentDao commentDao,
RecyclerView messageDetailRv, ConcernEntity concernEntity, String entrance) {
super(context);
this.mRecyclerView = messageDetailRv;
this.entrance = entrance;
mCallBackListener = context;
mRecyclerView = messageDetailRv;
mEntrance = entrance;
mOnCommentCallBackListener = listener;
mVoteDao = new VoteDao(context);
mCommentDao = commentDao;
@ -123,7 +121,9 @@ public class MessageDetailAdapter extends BaseRecyclerAdapter<ViewHolder> {
} else if (mConcernEntity != null) {
isOver = true;
notifyItemChanged(getItemCount() - 1);
mCallBackListener.showSoftInput(null);
if (mOnCommentCallBackListener != null) {
mOnCommentCallBackListener.onCommentCallback(null);
}
}
}
@ -291,7 +291,7 @@ public class MessageDetailAdapter extends BaseRecyclerAdapter<ViewHolder> {
viewHolder.imgLayout.setVisibility(View.VISIBLE);
viewHolder.imgLayout.removeAllViews();
ConcernContentUtils.addContentPic(mContext, viewHolder.imgLayout, mConcernEntity.getImg(),
StringUtils.buildString(entrance, "+(消息详情[", mConcernEntity.getGameName(), "])"),
StringUtils.buildString(mEntrance, "+(消息详情[", mConcernEntity.getGameName(), "])"),
mContext.getResources().getDisplayMetrics().widthPixels - DisplayUtils.dip2px(mContext, 34));
}
@ -303,38 +303,7 @@ public class MessageDetailAdapter extends BaseRecyclerAdapter<ViewHolder> {
viewHolder.share.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String shareContent;
if (mConcernEntity.getBrief() != null) {
shareContent = mConcernEntity.getBrief();
} else {
shareContent = mConcernEntity.getContent();
}
if (mConcernEntity.getImg() != null && mConcernEntity.getImg().size() > 0) {
Intent intent = new Intent(mContext, ShareCardPicActivity.class);
Bundle bundle = new Bundle();
bundle.putString("gameName", mConcernEntity.getGameName());
bundle.putString("gameIconUrl", mConcernEntity.getGameIcon());
bundle.putString("shareContent", shareContent);
if (mConcernEntity.getLink() == null) {
bundle.putString("newsId", mConcernEntity.getId());
}
bundle.putStringArrayList("shareArrImg", (ArrayList<String>) mConcernEntity.getImg());
intent.putExtras(bundle);
intent.putExtra(EntranceUtils.KEY_ENTRANCE, StringUtils.buildString(entrance, "+(消息详情[", mConcernEntity.getGameName(), "])"));
mContext.startActivity(intent);
} else {
Intent intent = new Intent(mContext, ShareCardActivity.class);
Bundle bundle = new Bundle();
bundle.putString("gameName", mConcernEntity.getGameName());
bundle.putString("gameIconUrl", mConcernEntity.getGameIcon());
bundle.putString("shareContent", shareContent);
if (mConcernEntity.getLink() == null) {
bundle.putString("newsId", mConcernEntity.getId());
}
intent.putExtras(bundle);
intent.putExtra(EntranceUtils.KEY_ENTRANCE, StringUtils.buildString(entrance, "+(消息详情[", mConcernEntity.getGameName(), "])"));
mContext.startActivity(intent);
}
ShareCardPicActivity.startShareCardPicActivity(mContext, mConcernEntity, mEntrance);
}
});
@ -355,12 +324,12 @@ public class MessageDetailAdapter extends BaseRecyclerAdapter<ViewHolder> {
intent.putExtra("url", mConcernEntity.getLink());
intent.putExtra("gameName", mConcernEntity.getGameName());
intent.putExtra("newsId", mConcernEntity.getId());
intent.putExtra(EntranceUtils.KEY_ENTRANCE, StringUtils.buildString(entrance, "+(消息详情[", mConcernEntity.getGameName(), "])"));
intent.putExtra(EntranceUtils.KEY_ENTRANCE, StringUtils.buildString(mEntrance, "+(消息详情[", mConcernEntity.getGameName(), "])"));
mContext.startActivity(intent);
} else {
Intent intent = new Intent(mContext, NewsDetailActivity.class);
intent.putExtra("newsId", mConcernEntity.getId());
intent.putExtra(EntranceUtils.KEY_ENTRANCE, StringUtils.buildString(entrance, "+(消息详情[", mConcernEntity.getGameName(), "])"));
intent.putExtra(EntranceUtils.KEY_ENTRANCE, StringUtils.buildString(mEntrance, "+(消息详情[", mConcernEntity.getGameName(), "])"));
mContext.startActivity(intent);
}
}
@ -369,7 +338,9 @@ public class MessageDetailAdapter extends BaseRecyclerAdapter<ViewHolder> {
viewHolder.comment.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mCallBackListener.showSoftInput(null);
if (mOnCommentCallBackListener != null) {
mOnCommentCallBackListener.onCommentCallback(null);
}
}
});
@ -533,7 +504,7 @@ public class MessageDetailAdapter extends BaseRecyclerAdapter<ViewHolder> {
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
CommentUtils.showReportDialog(finalCommentEntity, mContext, mCallBackListener, null);
CommentUtils.showReportDialog(finalCommentEntity, mContext, mOnCommentCallBackListener, null);
}
});
}
@ -677,7 +648,4 @@ public class MessageDetailAdapter extends BaseRecyclerAdapter<ViewHolder> {
return isOver;
}
public interface OnCommentCallBackListener {
void showSoftInput(CommentEntity entity);
}
}