package com.electric.chargingpile.activity; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.os.Handler; import android.text.SpannableString; import android.text.Spanned; import android.text.TextUtils; import android.text.style.ForegroundColorSpan; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.animation.AnimationUtils; import android.view.inputmethod.InputMethodManager; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ListView; import android.widget.RelativeLayout; import android.widget.ScrollView; import android.widget.TextView; import android.widget.Toast; import com.bumptech.glide.Glide; import com.electric.chargingpile.R; import com.electric.chargingpile.adapter.ZhanSCommentsAdapter; import com.electric.chargingpile.application.MainApplication; import com.electric.chargingpile.data.MyOtto; import com.electric.chargingpile.data.RankinglistRefreshEvent; import com.electric.chargingpile.fragment.ZhanCommentFragment; import com.electric.chargingpile.util.BarColorUtil; import com.electric.chargingpile.util.CarTypeUtil; import com.electric.chargingpile.util.DES3; import com.electric.chargingpile.util.JsonUtils; import com.electric.chargingpile.util.LoadingDialog; import com.electric.chargingpile.util.NetUtil; import com.electric.chargingpile.util.ToastUtil; import com.electric.chargingpile.util.Util; import com.electric.chargingpile.view.CircleImageView; import com.electric.chargingpile.view.ContainsEmojiEditText; import com.electric.chargingpile.view.CustomScrollView; import com.google.gson.Gson; import com.squareup.otto.Subscribe; import com.squareup.picasso.Picasso; import com.zhy.http.okhttp.OkHttpUtils; import com.zhy.http.okhttp.callback.StringCallback; import com.zhy.view.flowlayout.FlowLayout; import com.zhy.view.flowlayout.TagAdapter; import com.zhy.view.flowlayout.TagFlowLayout; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import org.w3c.dom.Text; import java.net.URLEncoder; import java.util.ArrayList; import java.util.regex.Matcher; import java.util.regex.Pattern; import okhttp3.Call; public class SingleCommentActivity extends Activity implements View.OnClickListener { private ImageView iv_back, iv_commentPic, iv_pgrade, iv_pzan, iv_level_img,imgVideo,imgStart,imgTwo,imgThree; private ListView lv_scomment; private CircleImageView iv_picon; private CustomScrollView scrollView; private String name0, name1; private TextView tv_pname, tv_ptime, tv_pcontext, tv_pcar, tv_preply, tv_pzan, tv_submit, tv_pdelete; private TagFlowLayout fl_ptag; private LinearLayout ll_parent, ll_pzan; public static LinearLayout ll_comment; public static ContainsEmojiEditText et_commet; private String nn, telphone, zan; public static String id, zhanid, userid; public static String pid; private InputMethodManager imm = null; private LoadingDialog dialog; private TextView tv_point; private RelativeLayout rl_point; private android.view.animation.Animation animation; private ImageView certified_icon; private RelativeLayout imgLayout; private Gson mGson = new Gson(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_single_comment); BarColorUtil.initStatusBarColor(SingleCommentActivity.this); MyOtto.getInstance().register(this); getIntentData(); initViews(); dialog = new LoadingDialog(this); dialog.setCanceledOnTouchOutside(false); if (null == imm) { imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); } } private void initViews() { iv_level_img = (ImageView) findViewById(R.id.iv_level_img); iv_back = (ImageView) findViewById(R.id.iv_back); iv_back.setOnClickListener(this); lv_scomment = (ListView) findViewById(R.id.lv_scomment); iv_picon = (CircleImageView) findViewById(R.id.iv_picon); scrollView = (CustomScrollView) findViewById(R.id.scrollView); tv_pname = (TextView) findViewById(R.id.tv_pname); tv_pdelete = (TextView) findViewById(R.id.tv_pdelete); tv_submit = (TextView) findViewById(R.id.tv_submit); tv_submit.setOnClickListener(this); tv_ptime = (TextView) findViewById(R.id.tv_ptime); tv_pcontext = (TextView) findViewById(R.id.tv_pcontext); tv_pzan = (TextView) findViewById(R.id.tv_pzan); tv_pzan.setOnClickListener(this); tv_preply = (TextView) findViewById(R.id.tv_preply); tv_preply.setOnClickListener(this); tv_pcar = (TextView) findViewById(R.id.tv_pcar); certified_icon = (ImageView)findViewById(R.id.certified_icon); fl_ptag = (TagFlowLayout) findViewById(R.id.fl_ptag); iv_commentPic = (ImageView) findViewById(R.id.iv_commentPic); imgTwo = (ImageView) findViewById(R.id.imgTwo); imgThree = (ImageView) findViewById(R.id.imgThree); imgVideo = (ImageView) findViewById(R.id.imgVideo); imgStart = (ImageView) findViewById(R.id.imgStart); imgLayout = findViewById(R.id.imgLayout); iv_pgrade = (ImageView) findViewById(R.id.iv_pgrade); iv_pzan = (ImageView) findViewById(R.id.iv_pzan); et_commet = (ContainsEmojiEditText) findViewById(R.id.et_commet); ll_comment = (LinearLayout) findViewById(R.id.ll_comment); ll_pzan = (LinearLayout) findViewById(R.id.ll_pzan); ll_pzan.setOnClickListener(this); ll_parent = (LinearLayout) findViewById(R.id.ll_parent); ll_parent.setOnClickListener(this); rl_point = (RelativeLayout) findViewById(R.id.rl_point); tv_point = (TextView) findViewById(R.id.tv_point); animation = AnimationUtils.loadAnimation(SingleCommentActivity.this, R.anim.nn); } private void getIntentData() { pid = getIntent().getStringExtra("id"); Log.e("pid==", pid); if (null != pid && !pid.equals("")) { getCommentData(null); } } @Subscribe public void getCommentData(RankinglistRefreshEvent rankinglistRefreshEvent) { // String url = "http://59.110.68.162/zhannew/basic/web/index.php/tpappcomments/get-sub-comments?id="+pid; String url = MainApplication.url + "/zhannew/basic/web/index.php/tpappcomments/get-sub-comments?id=" + pid; // Log.e("getCommentData_url=", url); OkHttpUtils.get().url(url).build().execute(new StringCallback() { @Override public void onError(Call call, Exception e) { } @Override public void onResponse(String response) { Log.e("respone==", response); setPUi(response); String rtnCode = JsonUtils.getKeyResult(response, "rtnCode"); if (null != rtnCode && rtnCode.equals("01")) { try { JSONObject jsonObj = new JSONObject(response); String commentData = jsonObj.getString("data"); Log.e("commentBean==", commentData); JSONObject obj = new JSONObject(commentData); JSONArray jsonArray = obj.getJSONArray("subcomments"); ArrayList datas = new ArrayList(); datas.clear(); for (int j = 0; j < jsonArray.length(); j++) { JSONObject jsonObject = (JSONObject) jsonArray.opt(j); datas.add(jsonObject); } Log.e("single==", "dealData: size=" + datas.size()); lv_scomment.setAdapter(new ZhanSCommentsAdapter(datas, SingleCommentActivity.this, getApplicationContext(), "2", "")); new Handler().post(()-> { scrollView.fullScroll(ScrollView.FOCUS_UP); } ); } catch (JSONException e) { e.printStackTrace(); } } else { // Log.e(TAG,"error"); } } }); } private void setPUi(String s) { String data = JsonUtils.getKeyResult(s, "data"); id = JsonUtils.getKeyResult(data, "id"); zhanid = JsonUtils.getKeyResult(data, "zhanid"); userid = JsonUtils.getKeyResult(data, "userid"); String title = JsonUtils.getKeyResult(data, "title"); if (title != null) { if (title.equals("")) { iv_level_img.setVisibility(View.GONE); } else if (title.equals("V0")) { iv_level_img.setVisibility(View.GONE); // holder.iv_level_img.setImageResource(R.drawable.icon_level_putong); } else if (title.equals("V1")) { iv_level_img.setVisibility(View.VISIBLE); iv_level_img.setImageResource(R.drawable.icon_qingtong); } else if (title.equals("V2")) { iv_level_img.setVisibility(View.VISIBLE); iv_level_img.setImageResource(R.drawable.icon_baiyin); } else if (title.equals("V3")) { iv_level_img.setVisibility(View.VISIBLE); iv_level_img.setImageResource(R.drawable.icon_huangjin); } else if (title.equals("V4")) { iv_level_img.setVisibility(View.VISIBLE); iv_level_img.setImageResource(R.drawable.icon_bojin); } else if (title.equals("V5")) { iv_level_img.setVisibility(View.VISIBLE); iv_level_img.setImageResource(R.drawable.icon_zuanshi); } } //设置头像 String userpic = JsonUtils.getKeyResult(data, "userpic"); Picasso.with(MainApplication.context) .load(MainApplication.url + "/zhannew/uploadfile/" + userpic) .placeholder(R.drawable.icon_user1118) .error(R.drawable.icon_user1118) .into(iv_picon); //设置名称 String nickname = JsonUtils.getKeyResult(data, "nickname"); String tel = JsonUtils.getKeyResult(data, "tel"); nn = nickname; telphone = tel; if (!nickname.equals("") && !nickname.equals("null")) { tv_pname.setText(nickname); } else { tv_pname.setText(Util.handlePhoneComment(tel)); } //设置时间 String addtime = JsonUtils.getKeyResult(data, "addtime"); addtime= TextUtils.isEmpty(addtime)?"0":addtime; tv_ptime.setText(TimeStamp2Date(addtime, "yyyy-MM-dd")); //设置内容 String content = JsonUtils.getKeyResult(data, "content"); String theme= JsonUtils.getKeyResult(data,"theme"); if (!TextUtils.isEmpty(theme.trim())){ content= "#"+theme+"#"+content; } if (content.equals("") || content.equals(" ")) { tv_pcontext.setVisibility(View.GONE); } else { tv_pcontext.setVisibility(View.VISIBLE); SpannableString ss = new SpannableString(content); Pattern pattern = Pattern.compile("#[0-9a-zA-Z,\\u4e00-\\u9fa5]+#"); Matcher matcher = pattern.matcher(ss); while (matcher.find()) { int start = matcher.start(); int end = matcher.end(); ss.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.topic_green)), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } tv_pcontext.setText(ss); } //设置车型 String hascar = JsonUtils.getKeyResult(data, "hascar"); tv_pcar.setText(CarTypeUtil.getCarType(hascar)); String isCertifiedOwner = JsonUtils.getKeyResult(data, "is_certified_owner"); if ("1".equals(isCertifiedOwner)) { certified_icon.setVisibility(View.VISIBLE); } else { certified_icon.setVisibility(View.GONE); } //设置标签 String tag = JsonUtils.getKeyResult(data, "tag"); if (tag != null) { if (tag.equals("")) { fl_ptag.setVisibility(View.GONE); } else { fl_ptag.setVisibility(View.VISIBLE); final LayoutInflater mInflater = LayoutInflater.from(getApplicationContext()); String[] stringArr = tag.split(","); fl_ptag.setClickable(false); fl_ptag.setEnabled(false); fl_ptag.setAdapter(new TagAdapter(stringArr) { @Override public View getView(FlowLayout parent, int position, String s) { TextView tv = (TextView) mInflater.inflate(R.layout.tv_comment, fl_ptag, false); tv.setText(s); return tv; } }); } } //设置图片 String fileUrl = JsonUtils.getKeyResult(data, "fileUrl"); fileUrl=fileUrl==null?"":fileUrl; String file2Url = JsonUtils.getKeyResult(data, "file2Url"); file2Url=file2Url==null?"":file2Url; String file3Url = JsonUtils.getKeyResult(data, "file3Url"); file3Url=file3Url==null?"":file3Url; String type = JsonUtils.getKeyResult(data, "type")==null?"":JsonUtils.getKeyResult(data, "type"); //23 视频,24 图片 if (type.equals("23")){ imgVideo.setVisibility(View.VISIBLE); imgStart.setVisibility(View.VISIBLE); imgLayout.setVisibility(View.VISIBLE); iv_commentPic.setVisibility(View.GONE); imgTwo.setVisibility(View.GONE); imgThree.setVisibility(View.GONE); String thumUrl = JsonUtils.getKeyResult(data, "thumUrl"); if (!TextUtils.isEmpty(thumUrl) && !TextUtils.isEmpty(fileUrl)){ Glide.with(this) .load(MainApplication.CDN +thumUrl) .into(imgVideo); imgVideo.setOnClickListener(v->{ CommentVideoDetailActivity.actioinStart(this,pid); }); } }else { imgVideo.setVisibility(View.GONE); imgStart.setVisibility(View.GONE); if (!fileUrl.equals("")) { iv_commentPic.setVisibility(View.VISIBLE); imgLayout.setVisibility(View.VISIBLE); Picasso.with(this) .load(MainApplication.url + "/zhannew/uploadfile/"+fileUrl) .into(iv_commentPic); } else { iv_commentPic.setVisibility(View.GONE); imgLayout.setVisibility(View.GONE); } if (!file2Url.equals("")) { imgTwo.setVisibility(View.VISIBLE); Picasso.with(this) .load(MainApplication.url + "/zhannew/uploadfile/"+file2Url) .into(imgTwo); } else { imgTwo.setVisibility(View.GONE); } if (!file3Url.equals("")) { imgThree.setVisibility(View.VISIBLE); Picasso.with(this) .load(MainApplication.url + "/zhannew/uploadfile/"+file3Url) .into(imgThree); } else { imgThree.setVisibility(View.GONE); } String[] fileUrlArray = null; if (!TextUtils.isEmpty(fileUrl) && !TextUtils.isEmpty(file2Url) &&!TextUtils.isEmpty(file3Url)){ fileUrlArray =new String[]{ MainApplication.url + "/zhannew/uploadfile/"+fileUrl, MainApplication.url + "/zhannew/uploadfile/"+file2Url, MainApplication.url + "/zhannew/uploadfile/"+file3Url }; }else if (!TextUtils.isEmpty(fileUrl) && !TextUtils.isEmpty(file2Url)){ fileUrlArray =new String[]{ MainApplication.url + "/zhannew/uploadfile/"+fileUrl, MainApplication.url + "/zhannew/uploadfile/"+file2Url }; }else if (!TextUtils.isEmpty(fileUrl)){ fileUrlArray =new String[]{ MainApplication.url + "/zhannew/uploadfile/"+fileUrl}; } String[] finalFileUrlArray = fileUrlArray; iv_commentPic.setOnClickListener(v->{ startImagePager(finalFileUrlArray, 0); }); imgTwo.setOnClickListener(v->{ startImagePager(finalFileUrlArray, 1); }); imgThree.setOnClickListener(v->{ startImagePager(finalFileUrlArray, 2); }); } //设置评分 String grade = JsonUtils.getKeyResult(data, "star_level"); if (grade != null) { if (grade.equals("")) { iv_pgrade.setVisibility(View.GONE); } else { double d = Double.parseDouble(grade); if (d == 0) { iv_pgrade.setVisibility(View.GONE); } else { if (d > 0 && d < 1) { iv_pgrade.setImageResource(R.drawable.icon_05xing); iv_pgrade.setVisibility(View.VISIBLE); } else if (d >= 1 && d < 1.5) { iv_pgrade.setVisibility(View.VISIBLE); iv_pgrade.setImageResource(R.drawable.icon_1xing); } else if (d >= 1.5 && d < 2) { iv_pgrade.setVisibility(View.VISIBLE); iv_pgrade.setImageResource(R.drawable.icon_15xing); } else if (d >= 2 && d < 2.5) { iv_pgrade.setVisibility(View.VISIBLE); iv_pgrade.setImageResource(R.drawable.icon_2xing); } else if (d >= 2.5 && d < 3) { iv_pgrade.setVisibility(View.VISIBLE); iv_pgrade.setImageResource(R.drawable.icon_25xing); } else if (d >= 3 && d < 3.5) { iv_pgrade.setVisibility(View.VISIBLE); iv_pgrade.setImageResource(R.drawable.icon_3xing); } else if (d >= 3.5 && d < 4) { iv_pgrade.setVisibility(View.VISIBLE); iv_pgrade.setImageResource(R.drawable.icon_35xing); } else if (d >= 4 && d < 4.5) { iv_pgrade.setVisibility(View.VISIBLE); iv_pgrade.setImageResource(R.drawable.icon_4xing); } else if (d >= 4.5 && d < 5) { iv_pgrade.setVisibility(View.VISIBLE); iv_pgrade.setImageResource(R.drawable.icon_45xing); } else { iv_pgrade.setVisibility(View.VISIBLE); iv_pgrade.setImageResource(R.drawable.icon_5xing); } } } } //设置赞数 String agree_num = JsonUtils.getKeyResult(data, "agree_num"); zan = agree_num; if (agree_num.equals("0")) { tv_pzan.setText("赞"); } else { tv_pzan.setText(agree_num); } //设置删除 String userid = JsonUtils.getKeyResult(data, "userid"); final String id = JsonUtils.getKeyResult(data, "id"); Log.e("eeee", userid); tv_pdelete.setVisibility(View.GONE); if (!MainApplication.isLogin()) { tv_pdelete.setVisibility(View.GONE); } else { if (MainApplication.userId.equals(userid)) { tv_pdelete.setVisibility(View.VISIBLE); tv_pdelete.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { new com.electric.chargingpile.view.AlertDialog(SingleCommentActivity.this).builder() .setMsg("是否删除该评论?") .setPositiveButton("删除", new View.OnClickListener() { @Override public void onClick(View v) { // String url = "http://59.110.68.162/zhannew/basic/web/index.php/tpappcomments/delete-comments?id="+id+"&phone="+MainApplication.userPhone+"&password="+MainApplication.userPassword; String url = MainApplication.url + "/zhannew/basic/web/index.php/tpappcomments/delete-comments?id=" + id + "&phone=" + MainApplication.userPhone + "&password=" + MainApplication.userPassword; Log.e("eeeee", url); OkHttpUtils.get().url(url).build().execute(new StringCallback() { @Override public void onError(Call call, Exception e) { } @Override public void onResponse(String response) { Log.e("eeee", response); String rtnCode = JsonUtils.getKeyResult(response, "rtnCode"); String rtnMsg = JsonUtils.getKeyResult(response, "rtnMsg"); if (rtnCode.equals("01")) { Toast.makeText(getApplicationContext(), "删除成功", Toast.LENGTH_SHORT).show(); MyOtto.getInstance().post(new RankinglistRefreshEvent()); finish(); // getCommentData(pid); } else { ToastUtil.showToast(getApplicationContext(), rtnMsg, Toast.LENGTH_SHORT); } } }); } }).setNegativeButton("取消", new View.OnClickListener() { @Override public void onClick(View v) { } }).show(); // String url = MainApplication.url+"/zhannew/basic/web/index.php/tpappcomments/delete-comments?id=23068&phone="+MainApplication.userPhone+"&password="+MainApplication.userPassword; } }); } } } private void startImagePager(String[] finalFileUrlArray, int i) { Intent intent = new Intent(SingleCommentActivity.this, ImagePagerActivity.class); // 图片url,为了演示这里使用常量,一般从数据库中或网络中获取 intent.putExtra(ImagePagerActivity.EXTRA_IMAGE_URLS, finalFileUrlArray); intent.putExtra(ImagePagerActivity.EXTRA_IMAGE_INDEX, i); startActivity(intent); } @Override public void onClick(View v) { switch (v.getId()) { case R.id.tv_submit: imm.hideSoftInputFromWindow(et_commet.getWindowToken(), 0); if (!NetUtil.CheckNetwork(this)) { Toast.makeText(this, "请检查网络是否可用", Toast.LENGTH_SHORT).show(); } else if (!MainApplication.isLogin()) { Toast.makeText(getApplication(), "请先登录", Toast.LENGTH_SHORT).show(); startActivity(new Intent(getApplication(), LoginActivity.class)); } else if (et_commet.getText().toString().equals("")) { Toast.makeText(this, "评论不能为空", Toast.LENGTH_SHORT).show(); } else if (replaceBlank(et_commet.getText().toString()).equals("")) { Toast.makeText(this, "评论不能为空", Toast.LENGTH_SHORT).show(); } else if (MainApplication.isLogin() && et_commet.getText().toString() != "") { dialog.show(); new Thread(new Runnable() { @Override public void run() { try { addComment("", ""); } catch (Exception e) { e.printStackTrace(); } } }).start(); } break; case R.id.iv_back: imm.hideSoftInputFromWindow(et_commet.getWindowToken(), 0); finish(); break; case R.id.tv_preply: et_commet.setFocusable(true); et_commet.setFocusableInTouchMode(true); et_commet.requestFocus(); if (!nn.equals("")) { et_commet.setHint("回复:" + nn); } else { et_commet.setHint("回复:" + Util.handlePhoneComment(telphone)); } imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(et_commet, InputMethodManager.SHOW_FORCED); ll_comment.setVisibility(View.VISIBLE); break; case R.id.ll_parent: if (imm.isActive()) { imm.hideSoftInputFromWindow(v.getWindowToken(), 0); ll_comment.setVisibility(View.GONE); } break; case R.id.ll_pzan: final int[] i = {Integer.parseInt(zan)}; if (MainApplication.isLogin()) { long appTime1 = System.currentTimeMillis() / 1000; long updatetime = appTime1 - MainMapActivity.cha - 2; String token = String.valueOf(updatetime); String url = null; try { url = MainApplication.url + "/zhannew/basic/web/index.php/commentzhan/add?user_id=" + MainApplication.userId + "&comment_id=" + id + "&token=" + URLEncoder.encode(DES3.encode(token)); } catch (Exception e) { e.printStackTrace(); } Log.e("zan_url", url); OkHttpUtils.get() .url(url) .build() .execute(new StringCallback() { @Override public void onError(Call call, Exception e) { } @Override public void onResponse(String response) { Log.e("zan_response", response); String rtnCode = JsonUtils.getKeyResult(response, "rtnCode"); String rtnMsg = JsonUtils.getKeyResult(response, "rtnMsg"); if (rtnCode.equals("01")) { i[0]++; tv_pzan.setText(String.valueOf(i[0])); iv_pzan.setImageResource(R.drawable.icon_zan_lv); } else { ToastUtil.showToast(getApplicationContext(), rtnMsg, Toast.LENGTH_SHORT); } } }); } else { Toast.makeText(getApplicationContext(), "请先登录", Toast.LENGTH_SHORT).show(); startActivity(new Intent(getApplicationContext(), LoginActivity.class)); } break; } } public String TimeStamp2Date(String timestampString, String formats) { Long timestamp = Long.parseLong(timestampString) * 1000; String date = new java.text.SimpleDateFormat(formats).format(new java.util.Date(timestamp)); return date; } public static String replaceBlank(String str) { String dest = ""; if (str != null) { Pattern p = Pattern.compile("\\s*|\t|\r|\n"); Matcher m = p.matcher(str); dest = m.replaceAll(""); } return dest; } private void addComment(String content, String parentid) throws Exception { long appTime1 = System.currentTimeMillis() / 1000; long updatetime = appTime1 - MainMapActivity.cha - 2; String token = String.valueOf(updatetime); String childCommentUrl = ""; if (null != id && null != userid) { childCommentUrl = "&parentid=" + id + "&puserid=" + userid; } String url = ""; url = MainApplication.url + "/zhannew/basic/web/index.php/tpappcomments/add?userid=" + MainApplication.userId + "&zhanid=" + zhanid + "&comment=" + URLEncoder.encode(et_commet.getText().toString()) + "&tel=" + MainApplication.userPhone + "&token=" + URLEncoder.encode(DES3.encode(token)) + childCommentUrl; // url = "http://59.110.68.162/zhannew/basic/web/index.php/tpappcomments/add?userid=" + MainApplication.userId + "&zhanid=" + zhanid + "&comment=" + URLEncoder.encode(et_commet.getText().toString()) + "&tel=" + MainApplication.userPhone + "&token=" + URLEncoder.encode(DES3.encode(token)) + childCommentUrl; Log.d("url!!!", url); OkHttpUtils.get() .url(url) .build() .connTimeOut(10000) .readTimeOut(10000) .execute(new StringCallback() { @Override public void onError(Call call, Exception e) { Toast.makeText(getApplicationContext(), "网络不给力", Toast.LENGTH_SHORT).show(); dialog.cancel(); } @Override public void onResponse(String response) { // Toast.makeText(getApplicationContext(),response,Toast.LENGTH_SHORT).show(); InputMethodManager imm = (InputMethodManager) getSystemService( Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(et_commet.getWindowToken(), 0); dialog.cancel(); try { JSONObject jsonObjadd = new JSONObject(response); String rtnCode = jsonObjadd.getString("rtnCode"); String rtnMsg = jsonObjadd.getString("rtnMsg"); String plusScore = jsonObjadd.getString("plusScore"); if (rtnCode.equals("01")) { et_commet.setText(""); getCommentData(null); ll_comment.setVisibility(View.GONE); // String plusScore = JsonUtils.getKeyResult(response,"plusScore"); if (!plusScore.equals("")) { tv_point.setText(plusScore); rl_point.setVisibility(View.VISIBLE); rl_point.startAnimation(animation); new Handler().postDelayed(new Runnable() { public void run() { rl_point.setVisibility(View.GONE); } }, 1000); // new Handler().postDelayed(new Runnable() { // public void run() { // finish(); // } // }, 1500); } else { ToastUtil.showToast(getApplicationContext(), "回复成功", Toast.LENGTH_SHORT); } // SingleCommentActivity.relativeLayout.setVisibility(View.VISIBLE); // SingleCommentActivity.textView.setVisibility(View.VISIBLE); // SingleCommentActivity.textView.startAnimation(SingleCommentActivity.animation); // new Handler().postDelayed(new Runnable() { // public void run() { // SingleCommentActivity.textView.setVisibility(View.GONE); // } // }, 2000); ZhanCommentFragment.index = 1; MyOtto.getInstance().post(new RankinglistRefreshEvent()); // Toast.makeText(getApplicationContext(), "评论成功", Toast.LENGTH_SHORT).show(); new Handler().postDelayed(new Runnable() { @Override public void run() { scrollView.fullScroll(ScrollView.FOCUS_DOWN); } }, 500); } else { ToastUtil.showToast(getApplicationContext(), rtnMsg, Toast.LENGTH_SHORT); } } catch (Exception e) { e.printStackTrace(); } } }); } @Override protected void onDestroy() { super.onDestroy(); MyOtto.getInstance().unregister(this); } }