Android Question what libraries to make something like 9gag viewer

Davin

Member
Licensed User
Longtime 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
 

KMatle

Expert
Licensed User
Longtime 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.
 
Upvote 0

Davin

Member
Licensed User
Longtime 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,
 
Upvote 0

Davin

Member
Licensed User
Longtime 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 :|
 
Upvote 0

Davin

Member
Licensed User
Longtime 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.
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 ?
 
Upvote 0
Top