Search in sources :

Example 1 with WaterData

use of me.yluo.ruisiapp.model.WaterData in project Ruisi by freedom10086.

the class FrageForums method initForums.

void initForums(boolean loginstate) {
    new GetForumList().execute(loginstate);
    if (App.IS_SCHOOL_NET) {
        // 是校园网
        String url = App.BASE_URL_RS + "forum.php";
        HttpUtil.get(url, new ResponseHandler() {

            @Override
            public void onSuccess(byte[] response) {
                List<WaterData> temps = new ArrayList<>();
                Document doc = Jsoup.parse(new String(response));
                Elements waters = doc.select("#portal_block_317").select("li");
                for (Element e : waters) {
                    Elements es = e.select("p").select("a[href^=home.php?mod=space]");
                    String uid = GetId.getId("uid=", es.attr("href"));
                    String imgSrc = e.select("img").attr("src");
                    String uname = es.text();
                    int num = 0;
                    if (e.select("p").size() > 1) {
                        if (e.select("p").get(1).text().contains("帖数")) {
                            num = GetId.getNumber(e.select("p").get(1).text());
                        }
                    }
                    temps.add(new WaterData(uname, uid, num, imgSrc));
                    if (temps.size() >= 16)
                        break;
                }
                if (temps.size() > 0)
                    adapter.setWaterData(temps);
            }
        });
    }
}
Also used : ResponseHandler(me.yluo.ruisiapp.myhttp.ResponseHandler) Element(org.jsoup.nodes.Element) WaterData(me.yluo.ruisiapp.model.WaterData) ArrayList(java.util.ArrayList) List(java.util.List) Document(org.jsoup.nodes.Document) Elements(org.jsoup.select.Elements)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 WaterData (me.yluo.ruisiapp.model.WaterData)1 ResponseHandler (me.yluo.ruisiapp.myhttp.ResponseHandler)1 Document (org.jsoup.nodes.Document)1 Element (org.jsoup.nodes.Element)1 Elements (org.jsoup.select.Elements)1