Android Lazy loading without ListView - android

I am looking to implement lazy loading in my app and I cannot seem to get it done. I've looked everywhere and nothing seems to be working.
My app is a news app making a SQL query to my wordpress website and getting the image URL and the article title associated to the image. The thing is I cannot use list views for this app because I want the first article to be a way bigger image that takes a third of the screen and the title placed on the image (the same way it is done in this image : http://iphone-apple.fr/wp-content/uploads/2010/06/lequipe2-iphone.jpg).
To create the design I have used RelativeLayout. Each article is a RelativeLayout composed of an ImageView and a TextView.
My problem is that all of the tutorials I found on lazy loading for ImageViews on the internet are for ListViews.
I have tried AsyncTask but it did not work. It actually worked but it showed all of the images at the end of the load so I had a black screen for about 5-10 secs before showing the main activity.
Does anyone have any idea how I could proceed ?
Thanks a lot for all of your answers ! :)

May be you are working with Native Emulator that work in slow environment.Install bluestack emulator or try to work on some android device

Related

NavigationView lag with network Image using Glide

I have an activity with a viewpager displaying three fragments. The third fragment is a basic recyclerview using a grid layout manager.
The grid items are basic image and title items nothing complex and I am using Glide to load images.
The problem is this, when I try opening/closing the NavigationView drawer when on this page, it lags very badly.
This is what I've noticed, the lag only happens when I load an image from a url. Local drawables are fine, and the drawer opens smoothly. I'm at a loss and have no idea where to look anymore.
I would post code, but I am not sure which part to post. If you need to see some portion, please ask and I'll do so. Moreover I feel it's not from the code.
UPDATE:
I continued debugging and decided to test the same code using Picasso. This time, it works perfectly, there is no lag at all and it works like it should. No idea why. I am going to raise a ticket on Glide's github.
After hours more of debugging and even trying to use Fresco (usage sucks),
I finally solved the problem.
I had to use dontTransform(). Apparently, this is affecting all pages where I have large images like grids. This solved the problem for me.

Android loading large data to horizontal view

This is not a question on how to load the data. I have already loaded the data and it works fine. The issue that I am trying to solve is when ever i go to that page / view it seems to show a black screen before showing the data on the screen. which I can solve by putting a spinner on the screen. But my question is how does app like gmail loads all its information on the listview so quickly. I tried using the CursorAdapters but it still takes few second before the screen is populated with the data. The screen only has images and text. at most it loads like 20 data in the list. Can some one please help.
Thanks in advance.
Here is a screen shot of what is displayed on the screen.
Well you are loading heavy data(images not just raw strings). I know its not answer you wanted but im not sure what could you do. Putting it on some background service might help. Again not sure about solution.

LruCache and Concurrent acces gridview / listview with BitMap from files in Android

Before write this thread, I read a lot of stackoverflow thread, and also many tutorial.
I think people maybe some times write tutorial only to "write something".
I use a gridview to show file (imageView+textView) from files
I've got my File's list called files. I set up a Custom BaseAdappter. It worked very well, because rather in a folder I' ve got more than 5 image. So in adapter I can call 3 different method from imageView: imageView.setImageResource(), setImageBitmpa(), setImageUri(). I used the last, because I can call Uri.fromFile(file) after get current file in adapter.
I found big problems when go to "DCIM/Camera" folder. Here, my apps work without crash. Scrool is really fast. This, because I follow all google developer instructions to manage bitmap.
So, now my adater use AsynkTask and also a LruCache. The example by official google developer page use methods where bitma is decoded from resource. So I had to edit some line, and change decodeResource() in decodeFile();
this last method want fileName, and Options. So, my app show "well" all image from default gallery folder, but with a big problem.
After a totally load of gridview, if I scrool down 20 row (example), and return at position 0 scrolling up, many imageView are changed with other image. This problems happens all time I do a little or large scrool.
I cannot post any Log, any Error, because AS not show me any Error. Only some time Log show me something like "WaitForConcurrentGcToComlete blocked..."
Thanks

Android display data like the Guardian app

I'm looking for a simple example of how to display data on a screen in the same way the Guardian app does (including the image on the left) that I'm pulling from a php page as shown in the screen shot below. I just can't find any examples on the internet that fit this description.
https://play.google.com/store/apps/details?id=com.guardian&hl=en
Sorry for what might seem like a simple question :)
I think these should help.
On stackoverflow, amongst others:
SO - ListView and images, which also links to SO - Lazy loading of images in ListView
External:
vogella.com - Android ListView and ListActivity - Tutorial
Ben's blog - Lazy loading of images in Listview

Android: Download images from web and show them on gridview

I want to create a program that gets some images from a webpage, and shows them on a gridview. I dont know how many of them exactly. It could be from 20 to 30. Ill do it with asynctask, which i have allready used before and more or less know how it works. But i don't know which way use it this time.
For now, what i would like to get is a progressbar (circle clicking) while image is downloading. And once its downloaded, it would disappear and image will load. I will use an array of objects with an adapter, to fill the gridview.
Which way would you use the asynctask?
Thanks in advance.
I would suggest you check out Lecture 6 of Harvard Extension CS76. There is a URLImageAdapter and example source code that does example what you are looking for.
Best of luck
If you want to save downloaded images and reuse them in future then you must look DownloadManager
To display dialog with cycling circle, look this: howto use ProgressDialog

Categories

Resources