use of me.yluo.ruisiapp.myhttp.ResponseHandler in project Ruisi by freedom10086.
the class NewPostActivity method beginPost.
// 开始发帖
private void beginPost() {
String url = UrlUtils.getPostUrl(fid);
Map<String, String> params = new HashMap<>();
params.put("topicsubmit", "yes");
if (typeId > 0) {
params.put("typeid", String.valueOf(typeId));
}
params.put("subject", edTitle.getText().toString());
params.put("message", edContent.getText().toString());
if (haveValid) {
// 是否有验证码
params.put("seccodehash", seccodehash);
params.put("seccodeverify", validValue);
}
// params["attachnew[\(aid)]"] = ""
List<String> aids = handler.getImagesAids();
for (String aid : aids) {
params.put("attachnew[" + aid + "]", "");
}
HttpUtil.post(url, params, new ResponseHandler() {
@Override
public void onSuccess(byte[] response) {
String res = new String(response);
// Log.e("==========", res);
if (res.contains("class=\"jump_c\"")) {
int start = res.indexOf("<p>", res.indexOf("class=\"jump_c\"")) + 3;
int end = res.indexOf("</p>", start);
String reason = res.substring(start, end);
if ("抱歉,验证码填写错误".equals(reason)) {
showInputValidDialog();
reason = "抱歉,验证码填写错误";
}
postFail(reason);
} else {
postSuccess();
}
}
@Override
public void onFailure(Throwable e) {
postFail("发帖失败:" + e.getMessage());
}
@Override
public void onFinish() {
super.onFinish();
postDialog.dismiss();
}
});
}
use of me.yluo.ruisiapp.myhttp.ResponseHandler in project Ruisi by freedom10086.
the class PostActivity method starTask.
/**
* 收藏帖子
*/
private void starTask(final View v) {
final String url = UrlUtils.getStarUrl(tid);
Map<String, String> params = new HashMap<>();
params.put("favoritesubmit", "true");
HttpUtil.post(url, params, new ResponseHandler() {
@Override
public void onSuccess(byte[] response) {
String res = new String(response);
if (res.contains("成功") || res.contains("您已收藏")) {
showToast("收藏成功");
if (v != null) {
final ImageView mv = (ImageView) v;
mv.postDelayed(() -> mv.setImageResource(R.drawable.ic_star_32dp_yes), 300);
}
}
}
});
}
use of me.yluo.ruisiapp.myhttp.ResponseHandler in project Ruisi by freedom10086.
the class PostActivity method replyLz.
// 回复楼主
private void replyLz(String url) {
if (!(isLogin() && checkTime() && checkInput())) {
return;
}
ProgressDialog dialog = new ProgressDialog(this);
dialog.setTitle("回复中");
dialog.setMessage("请稍后......");
dialog.show();
String s = getPreparedReply(this, input.getText().toString());
Map<String, String> params = new HashMap<>();
params.put("message", s);
HttpUtil.post(url + "&handlekey=fastpost&loc=1&inajax=1", params, new ResponseHandler() {
@Override
public void onSuccess(byte[] response) {
String res = new String(response);
handleReply(true, res);
}
@Override
public void onFailure(Throwable e) {
handleReply(false, "");
}
@Override
public void onFinish() {
super.onFinish();
dialog.dismiss();
}
});
}
use of me.yluo.ruisiapp.myhttp.ResponseHandler in project Ruisi by freedom10086.
the class PostActivity method startDelete.
private void startDelete(int position) {
if (App.IS_SCHOOL_NET) {
params = new HashMap<>();
params.put("fid", fid);
params.put("handlekey", "mods");
if (datas.get(position).type == SingleType.CONTENT) {
// 主题
params.put("moderate[]", tid);
params.put("operations[]", "delete");
} else {
// 评论
params.put("topiclist[]", datas.get(position).pid);
params.put("tid", tid);
params.put("page", (1 + position / 10) + "");
}
} else {
String url;
// 以下仅仅针对手机版做了测试
if (datas.get(position).type == SingleType.CONTENT) {
// 删除整个帖子
url = "forum.php?mod=topicadmin&action=moderate&fid=" + fid + "&moderate[]=" + tid + "&operation=delete&optgroup=3&from=" + tid + "&mobile=2&inajax=1";
} else {
// 删除评论
url = "forum.php?mod=topicadmin&action=delpost&fid=" + fid + "&tid=" + tid + "&operation=&optgroup=&page=&topiclist[]=" + datas.get(position).pid + "&mobile=2&inajax=1";
}
params = null;
HttpUtil.get(url, new ResponseHandler() {
@Override
public void onSuccess(byte[] response) {
Document document = RuisUtils.getManageContent(response);
if (datas.get(position).type == SingleType.CONTENT) {
params = RuisUtils.getForms(document, "moderateform");
} else {
params = RuisUtils.getForms(document, "topicadminform");
}
}
@Override
public void onFailure(Throwable e) {
super.onFailure(e);
showToast("网络错误!");
}
});
}
}
use of me.yluo.ruisiapp.myhttp.ResponseHandler in project Ruisi by freedom10086.
the class PostActivity method startClose.
private void startClose() {
String url = "";
if (App.IS_SCHOOL_NET) {
url = "forum.php?mod=topicadmin&action=moderate&fid=" + fid + "&moderate[]=" + tid + "&handlekey=mods" + "&infloat=yes&nopost=yes&from=" + tid + "&inajax=1";
} else {
url = "forum.php?mod=topicadmin&action=moderate&fid=" + fid + "&moderate[]=" + tid + "&from=" + tid + "&optgroup=4&mobile=2";
}
params = null;
HttpUtil.get(url, new ResponseHandler() {
@Override
public void onSuccess(byte[] response) {
Document document = RuisUtils.getManageContent(response);
params = RuisUtils.getForms(document, "moderateform");
params.put("redirect", "");
}
@Override
public void onFailure(Throwable e) {
super.onFailure(e);
showToast("网络错误!请重试");
}
});
}
Aggregations