游戏求版本功能(未对接接口), 文章详情优化(文章内容跳转未做),消息中心(未接接口),首页资讯改版,跳转意见反馈规则汇总
This commit is contained in:
@ -1,10 +1,30 @@
|
||||
package com.gh.common.util;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gh.base.AppController;
|
||||
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.entity.CommentEntity;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
@ -42,4 +62,138 @@ public class CommentUtils {
|
||||
textView.setText(format.format(time * 1000));
|
||||
}
|
||||
}
|
||||
|
||||
public static void showReportDialog(final CommentEntity commentEntity, final Context mContext
|
||||
, final MessageDetailAdapter.OnCommentCallBackListener mCallBackListener, final String newsId) {
|
||||
|
||||
final Dialog dialog = new Dialog(mContext);
|
||||
|
||||
LinearLayout container = new LinearLayout(mContext);
|
||||
container.setOrientation(LinearLayout.VERTICAL);
|
||||
container.setBackgroundColor(Color.WHITE);
|
||||
container.setPadding(0, DisplayUtils.dip2px(mContext, 12), 0, DisplayUtils.dip2px(mContext, 12));
|
||||
|
||||
List<String> dialogType = new ArrayList<>();
|
||||
dialogType.add("回复");
|
||||
dialogType.add("复制");
|
||||
dialogType.add("举报");
|
||||
|
||||
if (commentEntity.getParent() != null) {
|
||||
dialogType.add("查看对话");
|
||||
}
|
||||
|
||||
for (String s : dialogType) {
|
||||
final TextView reportTv = new TextView(mContext);
|
||||
reportTv.setPadding(DisplayUtils.dip2px(mContext, 20), DisplayUtils.dip2px(mContext, 12),
|
||||
0, DisplayUtils.dip2px(mContext, 12));
|
||||
reportTv.setText(s);
|
||||
reportTv.setTextSize(17);
|
||||
reportTv.setTextColor(mContext.getResources().getColor(R.color.title));
|
||||
reportTv.setBackgroundResource(R.drawable.textview_white_style);
|
||||
int widthPixels = mContext.getResources().getDisplayMetrics().widthPixels;
|
||||
reportTv.setLayoutParams(new LinearLayout.LayoutParams((widthPixels * 9)/10,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT));
|
||||
container.addView(reportTv);
|
||||
|
||||
reportTv.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dialog.cancel();
|
||||
switch (reportTv.getText().toString()) {
|
||||
case "回复":
|
||||
if (mCallBackListener != null) {
|
||||
mCallBackListener.showSoftInput(commentEntity);
|
||||
} else if (!TextUtils.isEmpty(newsId)){
|
||||
Intent intent = new Intent(mContext, MessageDetailActivity.class);
|
||||
AppController.put("CommentEntity", commentEntity);
|
||||
intent.putExtra("commentNum", -1);
|
||||
intent.putExtra("newsId", newsId);
|
||||
intent.putExtra("openSoftInput", true);
|
||||
mContext.startActivity(intent);
|
||||
} else {
|
||||
Utils.toast(mContext, "缺少关键属性");
|
||||
}
|
||||
|
||||
break;
|
||||
case "复制":
|
||||
LibaoUtils.copyLink(commentEntity.getContent(), mContext);
|
||||
break;
|
||||
case "举报":
|
||||
showReportTypeDialog(commentEntity, mContext);
|
||||
break;
|
||||
case "查看对话":
|
||||
Intent intent = new Intent(mContext, CommentDetailActivity.class);
|
||||
intent.putExtra("commentId", commentEntity.getId());
|
||||
mContext.startActivity(intent);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(container);
|
||||
dialog.show();
|
||||
|
||||
}
|
||||
|
||||
private static void showReportTypeDialog(final CommentEntity commentEntity, final Context mContext) {
|
||||
final String[] arrReportType = new String[]{"垃圾广告营销", "恶意攻击谩骂", "淫秽色情信息",
|
||||
"违法有害信息", "其它"};
|
||||
int widthPixels = mContext.getResources().getDisplayMetrics().widthPixels;
|
||||
|
||||
final Dialog reportTypeDialog = new Dialog(mContext);
|
||||
LinearLayout container = new LinearLayout(mContext);
|
||||
container.setOrientation(LinearLayout.VERTICAL);
|
||||
container.setPadding(0, DisplayUtils.dip2px(mContext, 12), 0, DisplayUtils.dip2px(mContext, 12));
|
||||
container.setBackgroundColor(Color.WHITE);
|
||||
|
||||
for (final String s : arrReportType) {
|
||||
TextView reportTypeTv = new TextView(mContext);
|
||||
reportTypeTv.setText(s);
|
||||
reportTypeTv.setTextSize(17);
|
||||
reportTypeTv.setTextColor(mContext.getResources().getColor(R.color.title));
|
||||
reportTypeTv.setBackgroundResource(R.drawable.textview_white_style);
|
||||
reportTypeTv.setLayoutParams(new LinearLayout.LayoutParams((widthPixels * 9)/10,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT));
|
||||
reportTypeTv.setPadding(DisplayUtils.dip2px(mContext, 20), DisplayUtils.dip2px(mContext, 12),
|
||||
0, DisplayUtils.dip2px(mContext, 12));
|
||||
container.addView(reportTypeTv);
|
||||
|
||||
reportTypeTv.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
try {
|
||||
jsonObject.put("comment_id", commentEntity.getId());
|
||||
jsonObject.put("reason", s);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
PostCommentUtils.addReportData(mContext, jsonObject.toString(), true,
|
||||
new PostCommentUtils.PostCommentListener() {
|
||||
@Override
|
||||
public void postSucced(JSONObject response) {
|
||||
Utils.toast(mContext, "感谢您的举报");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postFailed(Throwable error) {
|
||||
Utils.toast(mContext, "举报失败,请检查网络设置");
|
||||
}
|
||||
});
|
||||
reportTypeDialog.cancel();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
reportTypeDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
reportTypeDialog.setContentView(container);
|
||||
reportTypeDialog.show();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user