Search in sources :

Example 1 with SearchResult

use of cn.liuyin.manhua.data.bean.SearchResult in project Manhua by ag2s20150909.

the class SearchActivity method getHtml.

// public void search(final String kw) {
// new Thread(new Runnable() {
// 
// @Override
// public void run() {
// 
// String u = HttpTool.search(getApplicationContext(), kw);
// getHtml(u);
// }
// }).start();
// }
public void getHtml(final String url) {
    new Thread(new Runnable() {

        @Override
        public void run() {
            try {
                String d = HttpTool.httpGet(url);
                if (d.startsWith("error:")) {
                    mHander.obtainMessage(0, d).sendToTarget();
                } else {
                    Document doc = Jsoup.parse(d, url);
                    // FileTool.writeFile("doc.html",doc.html());
                    Elements lists = doc.select(".cont-list").select("li");
                    mHander.obtainMessage(0, "搜索到" + lists.size() + "条结果").sendToTarget();
                    SearchResult data = new SearchResult();
                    for (Element item : lists) {
                        Book temp = new Book();
                        temp.link = item.select("a").attr("abs:href") + "/";
                        temp.name = item.select("h3").text();
                        temp.img = item.select("img").attr("data-src");
                        temp.author = item.select("dd").get(0).text();
                        temp.type = item.select("dd").get(1).text();
                        temp.newChapter = item.select("dd").get(2).text();
                        temp.updateTime = item.select("dd").get(3).text();
                        data.add(temp);
                    }
                    // FileTool.writeFile("update.html",doc.toString());
                    mHander.obtainMessage(1, data).sendToTarget();
                }
            } catch (Exception e) {
                mHander.obtainMessage(0, "error" + e).sendToTarget();
            }
        }
    }).start();
}
Also used : Book(cn.liuyin.manhua.data.tool.Book) Element(org.jsoup.nodes.Element) SearchResult(cn.liuyin.manhua.data.bean.SearchResult) Document(org.jsoup.nodes.Document) Elements(org.jsoup.select.Elements)

Example 2 with SearchResult

use of cn.liuyin.manhua.data.bean.SearchResult 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();
}
Also used : SearchBean(cn.liuyin.manhua.data.bean.SearchBean) Gson(com.google.gson.Gson) SearchResult(cn.liuyin.manhua.data.bean.SearchResult) API(cn.liuyin.manhua.data.api.API)

Example 3 with SearchResult

use of cn.liuyin.manhua.data.bean.SearchResult in project Manhua by ag2s20150909.

the class HomeActivity method getType.

public void getType(final int classId) {
    new Thread(new Runnable() {

        @Override
        public void run() {
            API api = new API();
            try {
                SearchResult d = new SearchResult();
                ClassListBean data = gson.fromJson(api.getCateDetail(classId, 1, 100), ClassListBean.class);
                d.add(data);
                mHander.obtainMessage(1, d).sendToTarget();
            } catch (Exception e) {
                FileTool.writeError(e);
                mHander.obtainMessage(0, e.getLocalizedMessage()).sendToTarget();
            }
        }
    }).start();
}
Also used : ClassListBean(cn.liuyin.manhua.data.bean.ClassListBean) API(cn.liuyin.manhua.data.api.API) SearchResult(cn.liuyin.manhua.data.bean.SearchResult)

Example 4 with SearchResult

use of cn.liuyin.manhua.data.bean.SearchResult in project Manhua by ag2s20150909.

the class HomeActivity method getNew.

public void getNew() {
    new Thread(new Runnable() {

        @Override
        public void run() {
            API api = new API();
            try {
                SearchResult d = new SearchResult();
                RankingBean data = gson.fromJson(api.getRanking("newOnline", 1, 100), RankingBean.class);
                d.add(data);
                mHander.obtainMessage(1, d).sendToTarget();
            } catch (Exception e) {
                FileTool.writeError(e);
                mHander.obtainMessage(0, e.getLocalizedMessage()).sendToTarget();
            }
        }
    }).start();
}
Also used : API(cn.liuyin.manhua.data.api.API) SearchResult(cn.liuyin.manhua.data.bean.SearchResult) RankingBean(cn.liuyin.manhua.data.bean.RankingBean)

Aggregations

SearchResult (cn.liuyin.manhua.data.bean.SearchResult)4 API (cn.liuyin.manhua.data.api.API)3 ClassListBean (cn.liuyin.manhua.data.bean.ClassListBean)1 RankingBean (cn.liuyin.manhua.data.bean.RankingBean)1 SearchBean (cn.liuyin.manhua.data.bean.SearchBean)1 Book (cn.liuyin.manhua.data.tool.Book)1 Gson (com.google.gson.Gson)1 Document (org.jsoup.nodes.Document)1 Element (org.jsoup.nodes.Element)1 Elements (org.jsoup.select.Elements)1