Android Question what libraries to make something like 9gag viewer

Discussion in 'Android Questions' started by Davin, Feb 27, 2015.

  1. Davin

    Davin Member Licensed User

    just some question..


    what i wanna make is apps like 9gag viewer. and what i can think of is :

    1. load top 10 image by json query from a php script.
    2. if almost reach bottom load the next 10.
    3. the display will be like 9gag viewer. image on top. and some button below the image, and another image, same botton again.. and so on. (


    what lib / listview library should i use ?

    What i try before is :

    1. load top 10 image by json from php script
    2. for every image i load a layout.
    3. download using httputils2.
    4. if almost reach bottom. load another one from php.. and repeat

    the problem is.. after around 50++ images.. it will crash saying memory low .

    and when i check similar apps. say 9gag or instagram.. after you load the image and scroll down.. the image that you already load on top is unloaded. and when you scroll up again. it will load again the image.

    how do i do this ?



    thanks
     
  2. KMatle

    KMatle Expert Licensed User

    See the threads about out of memory relating images. LoadBitmapsample could help here (it downsamples the images to a good size).

    You could load 10 "fixed" layouts with 10 images and resuse them. Use a scrollvire and add all 10 to its panel. Get the scrollevent and by reaching the most down view, load the next 10 and set the scrollposition to the top.
     
  3. Davin

    Davin Member Licensed User

    @KMatle

    you mean after it reach to the bottom, set scroll position to the top. and load new image from the 2nd set ? and how if i want to see the previous set ?

    what i really want to do.. ( i dont know how ) is like instagram.. after .. lets say 10 image, the previous 10 get unloaded, and when i scroll up to those 10, it will load the image again,
     
  4. Erel

    Erel Administrator Staff Member Licensed User

  5. Davin

    Davin Member Licensed User

    @Erel
    i believe what you saying is to load the other 'page' of the data right ? that i can do that in abit different way. but the thing is the image i load. after xx image loaded.. it wil crash and saying "downsampling image due to lack of memory"

    what i still cant think of is :

    lets say i load the page 1 ( layout with image from url and some button )..
    after scroll to bottom of page 1. i load page 2 .. page 3
    nah when i load page 2, how to unload those image on page 1. so it will not give me any error message "downsampling stuff " and when i scroll back to the page 1 again. it will load those image .. and unload image on page 2.
    and so on..

    sry if my question is abit hard to understand :|
     
  6. thedesolatesoul

    thedesolatesoul Expert Licensed User

  7. Davin

    Davin Member Licensed User

  8. Davin

    Davin Member Licensed User

    anyone ?

    still looking for enlightenment
     
  9. Erel

    Erel Administrator Staff Member Licensed User

    Yes. However at that point you can also remove old ImageViews so the memory required will stay the same.
    Also make sure to use LoadBitmapSample when loading the images.
     
  10. Davin

    Davin Member Licensed User

    ok lets say i remove the old imageview when i move to 2nd page..

    and how do i tell the imageview to load their data on 1st page again when i decide to scroll up ?
     
  11. thedesolatesoul

    thedesolatesoul Expert Licensed User

    I've implemented this not as bump scrolling but as page scrolling using two buttons to load next and load previous.

    If you want infinite scrolling, I'd use a real listview adapter and a lazy loader. The listview takes care of recycling the imageviews out.
     
    NJDude likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice