use of cn.liuyin.manhua.data.bean.SearchBean in project Manhua by ag2s20150909.
the class SearchActivity method search.
public void search(final String kw) {
new Thread(new Runnable() {
@Override
public void run() {
Gson gson = new Gson();
SearchResult data = new SearchResult();
SearchBean d = gson.fromJson(new API().search_1(kw, 1, 100), SearchBean.class);
data.add(d);
mHander.obtainMessage(1, data).sendToTarget();
// String u = HttpTool.search(getApplicationContext(), kw);
// getHtml(u);
}
}).start();
}
use of cn.liuyin.manhua.data.bean.SearchBean in project Manhua by ag2s20150909.
the class API method search.
public static SearchBean search(String kw, int page, int pagesize) {
Gson gson = new Gson();
SearchBean result = new SearchBean();
FormBody.Builder buider = new FormBody.Builder();
buider.add("pageSize", pagesize + "").add("keyword", kw).add("page", page + "");
FormBody formBody = APIheper.getFormBuider(buider).build();
String url = host + "/api/book/search";
Request request = new Request.Builder().post(formBody).url(url).build();
try {
Response response = APP.getOkhttpClient().newCall(request).execute();
if (response.isSuccessful()) {
result = gson.fromJson(response.body().string(), SearchBean.class);
return result;
} else {
result.code = 1;
result.success = false;
result.message = "nessage:" + response.message() + " \ncode:" + response.code();
return result;
// return "error:" + response.message() + " errorcode:" + response.code();
}
} catch (Exception e) {
result.code = 1;
result.success = false;
result.message = e.getLocalizedMessage();
return result;
}
}
Aggregations