Android page curl with images streaming from web? -


so, using https://github.com/harism/android_page_curl , project achieve curl functionality create book. want achieve same while streaming images web directly, in asynchronous manner.

but require opengl , progress bar same. don't have knowledge in opengl, how can go tweaking code , achieve functionality want.

also , have @ question more clear view of want achieve...

pagecurl(magazine) image web

package fi.harism.curl;   public class curlactivity extends activity {      private curlview mcurlview;     button btn;     private aquery aq;     drawable d =null;     textview mtext;     list<string> data;     mediaplayer mplayer;      @override     public void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);          setcontentview(r.layout.main);          int index = 0;         if (getlastnonconfigurationinstance() != null) {             index = (integer) getlastnonconfigurationinstance();         }          mcurlview = (curlview) findviewbyid(r.id.curl);         mcurlview.setpageprovider(new pageprovider());         mcurlview.setsizechangedobserver(new sizechangedobserver());         mcurlview.setcurrentindex(index);         mcurlview.setbackgroundcolor(color.green);     }      @override     public void onpause() {         super.onpause();         mcurlview.onpause();     }      @override     public void onresume() {         super.onresume();         mcurlview.onresume();     }      @override     public object onretainnonconfigurationinstance() {         return mcurlview.getcurrentindex();     }      /**      * bitmap provider.      */     private class pageprovider implements curlview.pageprovider {          private string[] mbitmapstrings={"http://myserver.com/image/img%20p1.png",                                           "http://myserver.com/image/img%20p2.png",                                           "http://myserver.com/image/img%20p3.png",                                           "http://myserver.com/image/img%20p4.png"};          @override         public int getpagecount() {             return mbitmapstrings.length;         }           private bitmap loadbitmap(int width, int height, int index) throws malformedurlexception, ioexception {             bitmap b = bitmap.createbitmap(width, height,                     bitmap.config.argb_8888);             b.erasecolor(0xffffffff);             canvas c = new canvas(b);              if(index==mbitmapstrings.length)                {                 index=0;                }              drawable d = new bitmapdrawable(drawable_from_url(mbitmapstrings[index]));              int margin = 7;              int border = 3;             rect r = new rect(margin, margin, width - margin, height - margin);              int imagewidth = r.width() - (border * 2);             int imageheight = imagewidth * d.getintrinsicheight()                     / d.getintrinsicwidth();             if (imageheight > r.height() - (border * 2)) {                 imageheight = r.height() - (border * 2);                 imagewidth = imageheight * d.getintrinsicwidth()                         / d.getintrinsicheight();             }              r.left += ((r.width() - imagewidth) / 2) - border;             r.right = r.left + imagewidth + border + border;             r.top += ((r.height() - imageheight) / 2) - border;             r.bottom = r.top + imageheight + border + border;              paint p = new paint();             p.setcolor(0xffc0c0c0);             c.drawrect(r, p);             r.left += border;             r.right -= border;             r.top += border;             r.bottom -= border;              d.setbounds(r);             d.draw(c);              return b;         }          @override         public void updatepage(curlpage page, int width, int height, int index) {                  bitmap front;                 try {                     front = loadbitmap(width, height, index);                     page.settexture(front, curlpage.side_front);                     page.setcolor(color.rgb(180, 180, 180), curlpage.side_back);                 } catch (malformedurlexception e) {                     // todo auto-generated catch block                     e.printstacktrace();                 } catch (ioexception e) {                     // todo auto-generated catch block                     e.printstacktrace();                 }         }     }      /**      * curlview size changed observer.      */     private class sizechangedobserver implements curlview.sizechangedobserver {         @override         public void onsizechanged(int w, int h) {             /*if (w > h) {                 mcurlview.setviewmode(curlview.show_two_pages);                 mcurlview.setmargins(.1f, .05f, .1f, .05f);             } else {*/                 mcurlview.setviewmode(curlview.show_one_page);                 //mcurlview.setmargins(.1f, .1f, .1f, .1f);                 mcurlview.setmargins(0,0,0,0);              //}         }     }      bitmap drawable_from_url(string url) throws java.net.malformedurlexception, java.io.ioexception {         bitmap x;          httpurlconnection connection = (httpurlconnection)new url(url) .openconnection();         connection.setrequestproperty("user-agent","mozilla/4.0");          connection.connect();         inputstream input = connection.getinputstream();          x = bitmapfactory.decodestream(input);         return x;     } } 

----edit----

also , using android-query library asynchronous image/file loading. feasible use project in case of streaming images web. how?

public class curlactivity extends activity {      private curlview mcurlview;    bitmap y;     @override     public void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.main);          int index = 0;         if (getlastnonconfigurationinstance() != null) {             index = (integer) getlastnonconfigurationinstance();         }         mcurlview = (curlview) findviewbyid(r.id.curl);         mcurlview.setpageprovider(new pageprovider());         mcurlview.setsizechangedobserver(new sizechangedobserver());         mcurlview.setcurrentindex(index);         mcurlview.setbackgroundcolor(0xff202830);       }      @override     public void onpause() {         super.onpause();         mcurlview.onpause();     }      @override     public void onresume() {         super.onresume();         mcurlview.onresume();     }      @override     public object onretainnonconfigurationinstance() {         return mcurlview.getcurrentindex();     }      /**      * bitmap provider.      */     private class pageprovider implements curlview.pageprovider {          // bitmap resources.         /*private int[] mbitmapids = { r.drawable.obama, r.drawable.road_rage,                 r.drawable.taipei_101, r.drawable.world };*/         private string[] mbitmapids = {"your url","your url",                 "your urlg", "your url" };    //your image url          @override         public int getpagecount() {             return 5;         }          private bitmap loadbitmap(int width, int height, int index) {             bitmap b = bitmap.createbitmap(width, height,                     bitmap.config.argb_8888);             b.erasecolor(0xffffffff);             canvas c = new canvas(b);             //uri url = uri.parse("http://stackoverflow.com");             //drawable d =getresources().getdrawable(url);             //drawable d = getresources().getdrawable(mbitmapids[index]);             try {                 drawablefromurl(mbitmapids[index]);             } catch (ioexception e) {                 // todo auto-generated catch block                 e.printstacktrace();             }                        drawable d = new bitmapdrawable(getresources(),y);             //drawable d = new bitmapdrawable(drawable_from_url(y));             int margin = 7;             int border = 3;             rect r = new rect(margin, margin, width - margin, height - margin);              int imagewidth = r.width() - (border * 2);             int imageheight = imagewidth * d.getintrinsicheight()                     / d.getintrinsicwidth();             if (imageheight > r.height() - (border * 2)) {                 imageheight = r.height() - (border * 2);                 imagewidth = imageheight * d.getintrinsicwidth()                         / d.getintrinsicheight();             }              r.left += ((r.width() - imagewidth) / 2) - border;             r.right = r.left + imagewidth + border + border;             r.top += ((r.height() - imageheight) / 2) - border;             r.bottom = r.top + imageheight + border + border;              paint p = new paint();             p.setcolor(0xffc0c0c0);             c.drawrect(r, p);             r.left += border;             r.right -= border;             r.top += border;             r.bottom -= border;              d.setbounds(r);             d.draw(c);              return b;         }          @override         public void updatepage(curlpage page, int width, int height, int index) {              switch (index) {             // first case image on front side, solid colored back.             case 0: {                 bitmap front = loadbitmap(width, height, 0);                 page.settexture(front, curlpage.side_front);                 page.setcolor(color.rgb(180, 180, 180), curlpage.side_back);                 break;             }             // second case image on side, solid colored front.             case 1: {                 bitmap = loadbitmap(width, height, 2);                 page.settexture(back, curlpage.side_back);                 page.setcolor(color.rgb(127, 140, 180), curlpage.side_front);                 break;             }             // third case images on both sides.             case 2: {                 bitmap front = loadbitmap(width, height, 1);                 bitmap = loadbitmap(width, height, 3);                 page.settexture(front, curlpage.side_front);                 page.settexture(back, curlpage.side_back);                 break;             }             // fourth case images on both sides - plus blend against             // separate colors.             case 3: {                 bitmap front = loadbitmap(width, height, 2);                 bitmap = loadbitmap(width, height, 1);                 page.settexture(front, curlpage.side_front);                 page.settexture(back, curlpage.side_back);                 page.setcolor(color.argb(127, 170, 130, 255),                         curlpage.side_front);                 page.setcolor(color.rgb(255, 190, 150), curlpage.side_back);                 break;             }             // fifth case same image assigned front , back. in             // scenario 1 texture used , shared both sides.             case 4:                 bitmap front = loadbitmap(width, height, 0);                 page.settexture(front, curlpage.side_both);                 page.setcolor(color.argb(127, 255, 255, 255),                         curlpage.side_back);                 break;             }         }      }      /**      * curlview size changed observer.      */     private class sizechangedobserver implements curlview.sizechangedobserver {         @override         public void onsizechanged(int w, int h) {             if (w > h) {                 mcurlview.setviewmode(curlview.show_two_pages);                 mcurlview.setmargins(.1f, .05f, .1f, .05f);             } else {                 mcurlview.setviewmode(curlview.show_one_page);                 mcurlview.setmargins(.1f, .1f, .1f, .1f);             }         }     }      public  void drawablefromurl(string url) throws ioexception {         httpurlconnection connection = (httpurlconnection) new url(url).openconnection();         connection.connect();         inputstream input = connection.getinputstream();          y = bitmapfactory.decodestream(input);      } } 

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -