use of me.yluo.ruisiapp.myhttp.ResponseHandler in project Ruisi by freedom10086.
the class PostActivity method removeItem.
// 删除帖子或者回复
private void removeItem(final int pos, String reason) {
params.put("redirect", "");
params.put("reason", reason);
HttpUtil.post(UrlUtils.getDeleteReplyUrl(datas.get(pos).type), params, new ResponseHandler() {
@Override
public void onSuccess(byte[] response) {
String res = new String(response);
Log.e("result", res);
if (res.contains("成功")) {
if (datas.get(pos).type == SingleType.CONTENT) {
showToast("主题删除成功");
finish();
} else {
showToast("回复删除成功");
datas.remove(pos);
adapter.notifyItemRemoved(pos);
}
} else {
int start = res.indexOf("<p>");
int end = res.indexOf("<", start + 5);
String ss = res.substring(start + 3, end);
showToast(ss);
}
}
@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 onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_post);
initToolBar(true, "加载中......");
input = findViewById(R.id.ed_comment);
showPlainText = App.showPlainText(this);
initCommentList();
initEmotionInput();
Bundle b = getIntent().getExtras();
String url = b.getString("url");
authorName = b.getString("author");
tid = GetId.getId("tid=", url);
if (url != null && url.contains("redirect")) {
redirectPid = GetId.getId("pid=", url);
if (!App.IS_SCHOOL_NET) {
url = url + "&mobile=2";
}
HttpUtil.head(url, null, new ResponseHandler() {
@Override
public void onSuccess(byte[] response) {
int page = GetId.getPage(new String(response));
firstGetData(page);
}
});
} else {
firstGetData(1);
}
initSpinner();
}
use of me.yluo.ruisiapp.myhttp.ResponseHandler in project Ruisi by freedom10086.
the class ReplyCzActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_reply_cz);
boolean isLz = false;
String title = getString(R.string.app_name);
Bundle b = getIntent().getExtras();
if (b != null) {
data = b.getParcelable("data");
isLz = b.getBoolean("islz", false);
title = "回复" + data.index + ": " + data.username;
}
initToolBar(true, title);
input = findViewById(R.id.ed_comment);
MyFriendPicker.attach(this, input);
findViewById(R.id.btn_more).setVisibility(View.GONE);
findViewById(R.id.bt_lable_lz).setVisibility(isLz ? View.VISIBLE : View.GONE);
rootView = findViewById(R.id.root);
View btnSend = findViewById(R.id.btn_send);
View smileyBtn = findViewById(R.id.btn_emotion);
rootView.initSmiley(input, smileyBtn, btnSend);
findViewById(R.id.content).setOnTouchListener((view, motionEvent) -> {
if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
KeyboardUtil.hideKeyboard(input);
rootView.hideSmileyContainer();
}
return false;
});
findViewById(R.id.btn_reply_cz).setOnClickListener(view -> {
KeyboardUtil.showKeyboard(input);
});
if (data == null) {
showToast("加载失败......");
return;
} else {
ImageView imageView = findViewById(R.id.article_user_image);
String img_url = UrlUtils.getAvaterurlm(data.getImg());
Picasso.with(this).load(img_url).placeholder(R.drawable.image_placeholder).into(imageView);
((TextView) findViewById(R.id.replay_author)).setText(data.username);
((TextView) findViewById(R.id.replay_index)).setText(data.index);
((TextView) findViewById(R.id.replay_time)).setText(data.postTime);
TextView t = findViewById(R.id.html_text);
HtmlView.parseHtml(data.content).into(t);
input.setHint("回复: " + data.username);
imageView.setOnClickListener(v -> UserDetailActivity.openWithAnimation(this, data.username, imageView, data.uid));
}
HttpUtil.get(data.replyUrlTitle, new ResponseHandler() {
@Override
public void onSuccess(byte[] response) {
Document document = Jsoup.parse(new String(response));
Elements els = document.select("#postform");
params.put("formhash", els.select("input[name=formhash]").attr("value"));
params.put("posttime", els.select("input[name=posttime]").attr("value"));
params.put("noticeauthor", els.select("input[name=noticeauthor]").attr("value"));
params.put("noticetrimstr", els.select("input[name=noticetrimstr]").attr("value"));
params.put("reppid", els.select("input[name=reppid]").attr("value"));
params.put("reppost", els.select("input[name=reppost]").attr("value"));
params.put("noticeauthormsg", els.select("input[name=noticeauthormsg]").attr("value"));
params.put("replysubmit", "yes");
postUrl = els.attr("action");
}
@Override
public void onFailure(Throwable e) {
super.onFailure(e);
}
});
btnSend.setOnClickListener(view -> {
if (isLogin() && !TextUtils.isEmpty(input.getText())) {
dialog = new ProgressDialog(ReplyCzActivity.this);
dialog.setTitle("回复中");
dialog.setMessage("请稍后......");
dialog.show();
replyCz(postUrl);
}
});
}
use of me.yluo.ruisiapp.myhttp.ResponseHandler in project Ruisi by freedom10086.
the class SearchActivity method getSomePageData.
private void getSomePageData(int page) {
String str = searchInput.getText().toString();
String url = "search.php?mod=forum&searchid=" + searchid + "&orderby=lastpost&ascdesc=desc&searchsubmit=yes&kw=" + str + "&page=" + page + "&mobile=2";
HttpUtil.get(url, new ResponseHandler() {
@Override
public void onSuccess(byte[] response) {
new GetResultListTaskMe().execute(new String(response));
}
@Override
public void onFailure(Throwable e) {
e.printStackTrace();
getDataFail(null);
}
});
}
use of me.yluo.ruisiapp.myhttp.ResponseHandler in project Ruisi by freedom10086.
the class SearchActivity method getData.
private void getData(String str) {
adapter.changeLoadMoreState(BaseAdapter.STATE_LOADING);
String url = "search.php?mod=forum&mobile=2";
Map<String, String> paras = new HashMap<>();
paras.put("searchsubmit", "yes");
paras.put("srchtxt", str);
HttpUtil.post(url, paras, new ResponseHandler() {
@Override
public void onSuccess(byte[] response) {
String res = new String(response);
if (res.contains("秒内只能进行一次搜索")) {
getDataFail("抱歉,您在 15 秒内只能进行一次搜索");
} else if (res.contains("没有找到匹配结果")) {
getDataFail("对不起,没有找到匹配结果。");
} else {
new GetResultListTaskMe().execute(new String(response));
}
}
@Override
public void onFailure(Throwable e) {
e.printStackTrace();
getDataFail(null);
}
});
}
Aggregations