Large Gridview 1100/1100 on android - android

I have to show 64/64 bitmaps in a grid of 1100/1100 but the scrolling is not smooth. What is the optimum way in displaying such ammount of image data?

This is just too much memory consumption for an android app.. I don't think you really want to load all of those at the same time. I would rethink the requirements first.
There should be a solution that still satisfies the user and does not load that many views into memory. I don't know what is the use-case here, but I would suggest implementing something like paging. Load a limited amount of items, and only if user wants to see more, then show progress bar and load more.
E.g. you can load more if user scrolls to the last item, or just create a button like "Show more". I'm not sure which solution will be okay for your app. Also, I would actually load new items into the same GridView replacing previously loaded bitmaps, because each of them requires a lot of memory. You can always control the scrolling position programmatically if needed.

Related

Does the app side-menu navigation get slow when the list is huge?

Currently in my application, I have a side-menu(ION-MENU) and a screen that contains a large list of objects. I have noticed that there is a sluggishness in opening/closing the side menu when the size of the list in the screen is large. However when the size of the list is small the list side-menu or ION-Menu opens and closes pretty quickly. What would be the solution?
Currently I have the ION-MENU in my APP.HTML. I update the content of that in the app.component.ts. In my page I can swipe or click on the menu to get the side menu(ion-menu).
Expected result: Navigation to side-menu should be smooth irrespective of the data in the page on which the side-menu is over
Actual result: The Side-menu is sluggish and slow and needs to be smoother.
Well, of course it could response slowly when the size of all objects is big.
There are 2 possible solutions. Choose the one that suits your needs.
Try to reduce the size of objects. E.g. you can try to remove
properties of the objects that are irrelevant in that case.
Try to use infinite-scroll provided by Ionic. This means that you
only load the new objects if the user is at the end of the scrolling
list. You can find more infos here:

Android - Detect when imageview or layout appear no screen

I have an activity that gets data from a web service. The output of the web service consists of multiple sets of one web URL and some text. The URL points to an image. Each set is displayed by creating a linear layout which contains an imageview and textview. So, for 200 sets, I would have 200 layouts, 200 imageviews, and 200 textiews. I know that a list view would be a better solution, but I've gone too far in the project to change this now.
Currently, I download all images before the activity is displayed. I download around 200 images and in the future this might rise to more than 1000.
I would like to download the images only when the imageview appears on screen. The approach I am thinking of is creating some listener or event so that once the the imageview or layout appears on screen, the download starts. I searched a lot for this but could not find a good solution. My problem is creating the listener not starting the download.
Some solutions suggested lazy load but this would still mean all images are loaded which would not be appropriate for users who have limited download capacity.
Edit: I do not want to load all images, only the ones that appear on screen. And every time the user scrolls, the new imageview that appear on screen also start downloading.
I ended up using a different and easier approach by following #Akos's solution on this link for detecting the end of the scroll view. Once the activity starts, I load 10 layouts. Once the scroll view reaches the end, I display a progress dialog and load 10 more layouts.

How to increase performance of ViewPager?

I want to know how to increase performance of ViewPager. I have ViewPager which has around 25 swipes with large images. I have done memory optimization to avoid OutOfMemoryError. Its working fine.But still there is a lag while swiping. I have set offscreen page limit to 2. If I increase offscreen page limit. It will load more pages in Memory and again I will end up with OOM. So any suggestion how to avoid lag while swiping?
Your ViewPager cannot cache more than 2 pages? It sounds like you need to tweak your fragments a bit more. For example, make sure you don't stretch the background image, and make sure that your layouts are as simple as possible (i.e. don't use unneeded layouts). If you can see how much memory your app is using for these two pages.
Once you verify that see if you can increase the offscreen page limit. Then check that you are properly destroying the fragments.
You can use FragmentStatePagerAdapter istead using FragmentPagerAdapter.
More detailed explanation given here.
Another Possible solution in case of images is that you can try putting them in drawable-hdpi folder, they will load faster. You can look at an answer here.

Android implementing fling action to custom view. Performance

Currently Im developing fling action (similar to that one implemented in IPhones gallery app) in my custom view (image as background + some other staff). I have already working code, but I am thinking if there is a way to increase performance. My idea is simple: I pass 3 bitmaps to view: previous, current and next. When user perform move action on the screen he can see current bitmap + next/previous depend on the movment direction. A big dissadvantage is that I have to have 3 bitmaps loaded in memory all the time. I am using drawBitmap method to draw resized bitmaps to the screen and BitmapFactory to load it. Sometimes UI is not responsive for a while. I think it because there are only space for two bitmaps in memory so one is recycled and have to be reloaded by system. Also in my plans I have also scrolling in vertical directions so that will give me another two bitmaps cached in memory. Is there any chcance to improove performance in my solution, or any other solutions? I was thinking about extending gallery widget, but I need zooming and vertical scrolling also.

ListView and images displaced in the getView method

I have extended an ArrayAdapter to manage a ListView using a certain tamplate (made of 1 ImageView and 1 TextView contained in a RelativeLayout) as row of the list.
Anyway I am now facing some optimization issues. As you guys know, not all the rows are rendered at any 1 time but rather you get the rows progressively rendered when the user scrolls the list and they actually appear on the screen. Basically my problme is this:
when the list is scrolled really rapidly, the rendering engine cannot keep up with the speed and, although the images to display are cached, the placement of the images in the ImageViews of the visible rows take some time.
To be honest I was expecting the getView method to be really fast but apparently when it comes to images there are some tricks to know. Any1 wanna share ??
cheers ;)
You may take a look at my sample. It does exactly the same Lazy load of images in ListView.

Categories

Resources