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

@ -5,9 +5,7 @@ import android.content.Context;
import android.graphics.Color;
import android.support.v4.content.ContextCompat;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.LinearLayout;
import android.widget.TextView;
@ -15,7 +13,7 @@ import android.widget.TextView;
import com.gh.gamecenter.CommentDetailActivity;
import com.gh.gamecenter.MessageDetailActivity;
import com.gh.gamecenter.R;
import com.gh.gamecenter.adapter.MessageDetailAdapter;
import com.gh.gamecenter.adapter.OnCommentCallBackListener;
import com.gh.gamecenter.db.CommentDao;
import com.gh.gamecenter.entity.CommentEntity;
@ -65,17 +63,17 @@ public class CommentUtils {
}
}
public static void showReportDialog(final CommentEntity commentEntity, final Context mContext
, final MessageDetailAdapter.OnCommentCallBackListener mCallBackListener, final String newsId) {
public static void showReportDialog(final CommentEntity commentEntity, final Context context,
final OnCommentCallBackListener listener, final String newsId) {
CommentDao commentDao = new CommentDao(mContext);
CommentDao commentDao = new CommentDao(context);
final Dialog dialog = new Dialog(mContext);
final Dialog dialog = new Dialog(context);
LinearLayout container = new LinearLayout(mContext);
LinearLayout container = new LinearLayout(context);
container.setOrientation(LinearLayout.VERTICAL);
container.setBackgroundColor(Color.WHITE);
container.setPadding(0, DisplayUtils.dip2px(mContext, 12), 0, DisplayUtils.dip2px(mContext, 12));
container.setPadding(0, DisplayUtils.dip2px(context, 12), 0, DisplayUtils.dip2px(context, 12));
List<String> dialogType = new ArrayList<>();
@ -91,16 +89,16 @@ public class CommentUtils {
}
for (String s : dialogType) {
final TextView reportTv = new TextView(mContext);
final TextView reportTv = new TextView(context);
reportTv.setText(s);
reportTv.setTextSize(17);
reportTv.setTextColor(ContextCompat.getColor(mContext, R.color.title));
reportTv.setTextColor(ContextCompat.getColor(context, R.color.title));
reportTv.setBackgroundResource(R.drawable.textview_white_style);
int widthPixels = mContext.getResources().getDisplayMetrics().widthPixels;
int widthPixels = context.getResources().getDisplayMetrics().widthPixels;
reportTv.setLayoutParams(new LinearLayout.LayoutParams((widthPixels * 9) / 10,
LinearLayout.LayoutParams.WRAP_CONTENT));
reportTv.setPadding(DisplayUtils.dip2px(mContext, 20), DisplayUtils.dip2px(mContext, 12),
0, DisplayUtils.dip2px(mContext, 12));
reportTv.setPadding(DisplayUtils.dip2px(context, 20), DisplayUtils.dip2px(context, 12),
0, DisplayUtils.dip2px(context, 12));
container.addView(reportTv);
reportTv.setOnClickListener(new View.OnClickListener() {
@ -109,23 +107,23 @@ public class CommentUtils {
dialog.cancel();
switch (reportTv.getText().toString()) {
case "回复":
if (mCallBackListener != null) {
mCallBackListener.showSoftInput(commentEntity);
if (listener != null) {
listener.onCommentCallback(commentEntity);
} else if (!TextUtils.isEmpty(newsId)) {
mContext.startActivity(MessageDetailActivity.getMessageDetailIntent(mContext, commentEntity, newsId));
context.startActivity(MessageDetailActivity.getMessageDetailIntent(context, commentEntity, newsId));
} else {
Utils.toast(mContext, "缺少关键属性");
Utils.toast(context, "缺少关键属性");
}
break;
case "复制":
LibaoUtils.copyLink(commentEntity.getContent(), mContext);
LibaoUtils.copyLink(commentEntity.getContent(), context);
break;
case "举报":
showReportTypeDialog(commentEntity, mContext);
showReportTypeDialog(commentEntity, context);
break;
case "查看对话":
mContext.startActivity(CommentDetailActivity.getCommentDetailIntent(mContext, commentEntity.getId()));
context.startActivity(CommentDetailActivity.getCommentDetailIntent(context, commentEntity.getId()));
break;
}
}