use of me.yluo.ruisiapp.myhttp.ResponseHandler in project Ruisi by freedom10086.
the class UserDetailActivity method loadData.
private void loadData(String url) {
adapter.changeLoadMoreState(BaseAdapter.STATE_LOADING);
HttpUtil.get(url, new ResponseHandler() {
@Override
public void onSuccess(byte[] response) {
new GetUserInfoTask().execute(new String(response));
}
@Override
public void onFailure(Throwable e) {
Toast.makeText(getApplicationContext(), "网络错误!!", Toast.LENGTH_SHORT).show();
adapter.changeLoadMoreState(BaseAdapter.STATE_LOAD_FAIL);
}
});
}
use of me.yluo.ruisiapp.myhttp.ResponseHandler in project Ruisi by freedom10086.
the class UserDetailActivity 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 ViewImgActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_view_img);
datas = new ArrayList<>();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().setStatusBarColor(Color.rgb(138, 145, 151));
}
pager = findViewById(R.id.pager);
index = findViewById(R.id.index);
findViewById(R.id.nav_back).setOnClickListener(v -> finish());
pager.addOnPageChangeListener(this);
adapter = new MyAdapter();
pager.setAdapter(adapter);
Bundle b = getIntent().getExtras();
String url = b.getString("url");
final String tid = GetId.getId("tid=", url);
aid = GetId.getId("aid=", url);
String urll = "forum.php?mod=viewthread&tid=" + tid + "&aid=" + aid + "&from=album&mobile=2";
HttpUtil.get(urll, new ResponseHandler() {
@Override
public void onSuccess(byte[] response) {
String res = new String(response);
Document doc = Jsoup.parse(res);
int ih = doc.head().html().indexOf("keywords");
if (ih > 0) {
int h_start = doc.head().html().indexOf('\"', ih + 15);
int h_end = doc.head().html().indexOf('\"', h_start + 1);
String title = doc.head().html().substring(h_start + 1, h_end);
TextView v = findViewById(R.id.title);
v.setText(title);
}
Elements elements = doc.select("ul.postalbum_c").select("li");
int i = 0;
for (Element e : elements) {
String zsrc = e.select("img").attr("zsrc");
if (zsrc.contains(aid)) {
position = i;
}
String src = e.select("img").attr("orig");
if (TextUtils.isEmpty("src")) {
continue;
}
if (src.startsWith("./")) {
src = src.substring(2);
}
if (!src.startsWith("http")) {
src = App.getBaseUrl() + src;
}
i++;
datas.add(src);
}
adapter.notifyDataSetChanged();
changeIndex(position);
pager.setCurrentItem(position);
}
});
}
use of me.yluo.ruisiapp.myhttp.ResponseHandler in project Ruisi by freedom10086.
the class FrageHotsNews method getData.
private void getData() {
isEnableLoadMore = false;
adapter.changeLoadMoreState(BaseAdapter.STATE_LOADING);
if (App.IS_SCHOOL_NET) {
new GetGalleryTask().execute();
}
String type = (currentType == TYPE_HOT) ? "hot" : "new";
String url = "forum.php?mod=guide&view=" + type + "&page=" + CurrentPage + "&mobile=2";
HttpUtil.get(url, new ResponseHandler() {
@Override
public void onSuccess(byte[] response) {
new GetNewArticleListTaskMe().execute(new String(response));
}
@Override
public void onFailure(Throwable e) {
refreshLayout.postDelayed(() -> refreshLayout.setRefreshing(false), 300);
adapter.changeLoadMoreState(BaseAdapter.STATE_LOAD_FAIL);
}
});
}
use of me.yluo.ruisiapp.myhttp.ResponseHandler in project Ruisi by freedom10086.
the class FrageMessage method getData.
private void getData(boolean needRefresh) {
lastLoginState = App.ISLOGIN(getActivity());
// 记录上次已读消息游标
if (!App.ISLOGIN(getActivity())) {
adapter.changeLoadMoreState(BaseAdapter.STATE_NEED_LOGIN);
refreshLayout.setRefreshing(false);
return;
}
if (needRefresh) {
datas.clear();
adapter.notifyDataSetChanged();
totalPage = 1;
currentPage = 1;
refreshLayout.setRefreshing(true);
}
lastReplyId = getContext().getSharedPreferences(App.MY_SHP_NAME, Activity.MODE_PRIVATE).getInt(App.NOTICE_MESSAGE_REPLY_KEY, 0);
currReplyId = lastReplyId;
lastAtId = getContext().getSharedPreferences(App.MY_SHP_NAME, Activity.MODE_PRIVATE).getInt(App.NOTICE_MESSAGE_AT_KEY, 0);
currAtId = lastAtId;
// reply
String url;
if (index == 0) {
// reply
url = "home.php?mod=space&do=notice&mobile=2&page=" + currentPage;
} else if (index == 1) {
// pm
url = "home.php?mod=space&do=pm&mobile=2&page=" + currentPage;
} else {
// @wo
url = "home.php?mod=space&do=notice&view=mypost&type=at&mobile=2&page=" + currentPage;
}
HttpUtil.get(url, new ResponseHandler() {
@Override
public void onSuccess(byte[] response) {
String res = new String(response);
if (index == 1) {
new GetUserPmTask().execute(res);
} else {
new GetMessageTask(index).execute(res);
}
}
@Override
public void onFailure(Throwable e) {
e.printStackTrace();
refreshLayout.postDelayed(() -> refreshLayout.setRefreshing(false), 500);
adapter.changeLoadMoreState(BaseAdapter.STATE_LOAD_FAIL);
}
});
}
Aggregations