use of me.yluo.ruisiapp.myhttp.ResponseHandler in project Ruisi by freedom10086.
the class EditActivity method startPost.
private void startPost() {
String url = "forum.php?mod=post&action=edit&extra=&editsubmit=yes&mobile=2&handlekey=postform&inajax=1";
params.put("editsubmit", "yes");
if (typeId > 0) {
params.put("typeid", String.valueOf(typeId));
}
params.put("subject", edTitle.getText().toString());
params.put("message", edContent.getText().toString());
HttpUtil.post(url, params, new ResponseHandler() {
@Override
public void onSuccess(byte[] response) {
String res = new String(response);
Log.e("resoult", res);
if (res.contains("帖子编辑成功")) {
dialog.dismiss();
showToast("帖子编辑成功");
Intent i = new Intent();
if (edTitle.getVisibility() == View.VISIBLE) {
i.putExtra("TITLE", edTitle.getText().toString());
}
i.putExtra("CONTENT", edContent.getText().toString());
i.putExtra("PID", pid);
setResult(RESULT_OK, i);
EditActivity.this.finish();
} else 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);
postFail(reason);
} else {
postFail("编辑失败:我也不知道哪儿错了");
}
}
@Override
public void onFailure(Throwable e) {
super.onFailure(e);
dialog.dismiss();
showToast("网络错误");
}
});
}
use of me.yluo.ruisiapp.myhttp.ResponseHandler in project Ruisi by freedom10086.
the class FriendActivity method OnAddFriendOkClick.
@Override
public void OnAddFriendOkClick(String mes, String uid) {
final ProgressDialog dialog1 = new ProgressDialog(this);
dialog1.setTitle("正在发送请求");
dialog1.setMessage("请等待......");
Map<String, String> paras = new HashMap<>();
paras.put("addsubmit", "true");
paras.put("handlekey", "friend_" + uid);
paras.put("note", mes);
paras.put("gid", "1");
paras.put("addsubmit_btn", "true");
HttpUtil.post(UrlUtils.getAddFrirndUrl(uid), paras, new ResponseHandler() {
@Override
public void onSuccess(byte[] response) {
String res = new String(response);
if (res.contains("好友请求已")) {
Toast.makeText(getApplicationContext(), "请求已发送成功,正在请等待对方验证", Toast.LENGTH_SHORT).show();
} else if (res.contains("正在等待验证")) {
Toast.makeText(getApplicationContext(), "好友请求已经发送了,正在等待对方验证", Toast.LENGTH_SHORT).show();
} else if (res.contains("你们已成为好友")) {
Toast.makeText(getApplicationContext(), "你们已经是好友了不用添加了...", Toast.LENGTH_SHORT).show();
}
dialog1.dismiss();
}
@Override
public void onFailure(Throwable e) {
super.onFailure(e);
Toast.makeText(getApplicationContext(), "出错了,我也不知道哪儿错了...", Toast.LENGTH_SHORT).show();
dialog1.dismiss();
}
});
}
use of me.yluo.ruisiapp.myhttp.ResponseHandler in project Ruisi by freedom10086.
the class FriendActivity method removeFriend.
private void removeFriend(String uid, final int pos) {
// 操作成功
String url = "home.php?mod=spacecp&ac=friend&op=ignore&uid=" + uid + "&confirm=1";
if (App.ISLOGIN(this)) {
url = url + "&mobile=2";
}
HashMap<String, String> pa = new HashMap<>();
pa.put("friendsubmit", "true");
HttpUtil.post(url, pa, new ResponseHandler() {
@Override
public void onSuccess(byte[] response) {
String s = new String(response);
if (s.contains("操作成功")) {
removeRes(true, pos);
} else {
removeRes(false, pos);
}
}
@Override
public void onFailure(Throwable e) {
super.onFailure(e);
removeRes(false, pos);
}
});
}
use of me.yluo.ruisiapp.myhttp.ResponseHandler in project Ruisi by freedom10086.
the class HomeActivity method checkUpdate.
/**
* check update
*/
private void checkUpdate() {
PackageManager manager;
PackageInfo info = null;
manager = getPackageManager();
try {
info = manager.getPackageInfo(getPackageName(), 0);
} catch (Exception e) {
e.printStackTrace();
}
int version_code = 1;
if (info != null) {
version_code = info.versionCode;
}
final int finalVersion_code = version_code;
HttpUtil.get(App.CHECK_UPDATE_URL, new ResponseHandler() {
@Override
public void onSuccess(byte[] response) {
String res = new String(response);
int ih = res.indexOf("keywords");
int h_start = res.indexOf('\"', ih + 15);
int h_end = res.indexOf('\"', h_start + 1);
String title = res.substring(h_start + 1, h_end);
if (title.contains("code")) {
int st = title.indexOf("code");
int code = GetId.getNumber(title.substring(st));
if (code > finalVersion_code) {
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putLong(App.CHECK_UPDATE_KEY, System.currentTimeMillis());
editor.apply();
isNeedCheckUpdate = false;
new AlertDialog.Builder(HomeActivity.this).setTitle("检测到新版本").setMessage(title).setPositiveButton("查看", (dialog, which) -> PostActivity.open(HomeActivity.this, App.CHECK_UPDATE_URL, "谁用了FREEDOM")).setNegativeButton("取消", null).setCancelable(true).create().show();
}
}
}
});
}
use of me.yluo.ruisiapp.myhttp.ResponseHandler in project Ruisi by freedom10086.
the class NewPostActivity method switchFid.
private void switchFid(int fid) {
typeiddatas.clear();
typeId = 0;
String url = "forum.php?mod=post&action=newthread&fid=" + fid + "&mobile=2";
HttpUtil.get(url, new ResponseHandler() {
@Override
public void onSuccess(byte[] response) {
Document document = Jsoup.parse(new String(response));
Elements types = document.select("#typeid").select("option");
for (Element e : types) {
typeiddatas.add(new Forum(Integer.parseInt(e.attr("value")), e.text()));
}
if (typeiddatas.size() > 0) {
typeIdContainer.setVisibility(View.VISIBLE);
tvSelectType.setText(typeiddatas.get(0).name);
typeId = typeiddatas.get(0).fid;
} else {
typeIdContainer.setVisibility(View.GONE);
}
// 检查是否能上传图片
// uploadformdata:{uid:"252553", hash:"fe626ed21ff334263dfe552cd9a4c209"},
String res = new String(response);
int index = res.indexOf("uploadformdata:");
if (index > 0) {
int start = res.indexOf("hash", index) + 6;
int end = res.indexOf("\"", start + 5);
uploadHash = res.substring(start, end);
Log.v("===", "uploadhash:" + uploadHash);
}
}
});
}
Aggregations