java - parse images with jsoup -


ai have problems again))

i have code parse links file. file have links forum treads. this:

http://vao-priut.org/image/cherepashka-metis-gollandskoi-ovcharki-s-72 http://vao-priut.org/image/taiga-s-26

and etc.

i try parse images code:

class parsemypagetask extends asynctask<string, void, string> {      @override     protected string doinbackground(string... params) {         try {             input = new url("https://gist.githubusercontent.com/akhorevich/5b849373dc9abaf921b3/raw/18e79ab6a0c0be007a2a4590e4e176184ced311a/links");              sc = new scanner(input.openstream());             while(sc.hasnextline()){                 string link = sc.nextline();                  doc = jsoup.connect(link).get();                elements names = doc.select("div.node-title");               // elements images = doc.select("div.node div.content img");                 elements imgs = doc.select("div.node div.content img");                  (element img : imgs) {                      element myimage = img;                     string imgsrc = myimage.attr("src");                     inputstream inp = new java.net.url(imgsrc).openstream();                     // decode bitmap                     bitmap = bitmapfactory.decodestream(inp);                 }                   for(element name: names) {                     mdata.add(name.text());                  }                  if(mdata.size() == 0) {                     mdata.add("empty result");                 }              }            } catch (ioexception e) {             e.printstacktrace();             mdata.clear();             mdata.add("exception: " + e.tostring());         }         return text; // получаем весь текст     }      @override     protected void onpostexecute(string result) {         super.onpostexecute(result);          sectorc_adapter = new sectorc_adapter(getactivity());         mlistview.setadapter(sectorc_adapter);      } } 

but parse image last link , add items. how can make images bufferedarray or this? thank you!!!

p.s. forget baseadapter:

class sectorc_adapter extends baseadapter{     private context c;      sectorc_adapter(context c){         this.c = c;     }     @override     public int getcount() {         return mdata.size();     }      @override     public object getitem(int position) {         return mdata.get(position);     }      @override     public long getitemid(int position) {         return position;     }      @override     public view getview(int position, view convertview, viewgroup parent) {         if (convertview==null){             inflater = (layoutinflater)c                     .getsystemservice(c.layout_inflater_service);             row = inflater.inflate(r.layout.sector_row, parent,false);         }else {             row = convertview;         }         tvinfo = (textview)row.findviewbyid(r.id.dog_name);         tvinfo.settext(mdata.get(position).tostring());         dog_view = (imageview)row.findviewbyid(r.id.dog_view);         dog_view.setimagebitmap(bitmap);         return row;     } } 

in here not adding image list

            (element img : imgs) {                  element myimage = img;                 string imgsrc = myimage.attr("src");                 inputstream inp = new java.net.url(imgsrc).openstream();                 // decode bitmap                 bitmap = bitmapfactory.decodestream(inp);                 ///here should add bitmap elements                ///eg. allimages.add(bitmap); or whatever.             } 

i suppose bitmap sort of field added all elements basicly last state stored. have add bitmap inside for-loop.


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -