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.
Related
I experienced a flickering of the imageviews in my recyclerview when scrolling very fast. All the imagerequests would be downloaded and showed. This would a weird effect on the imageviews.
I'm using Volley library to execute the downloads, together with Picasso to show the images. Yes this is a funny combination, but I needed to customise my headers & have authentication of my requests. Picasso not allowing me this easily.
I have experimented with a lot of possibilities;
- Pausing the requestQueue when scrolling. Resume downloads when idle. This would result in the same issue, but delayed.
- Use of Volley's imageLoader/NetworkImageView. Imageloader cannot be customized like a volley request.
- Delete all requests when scrolling. Resume when idle. This would result with imageviews not being downloaded.
So as I didn't find any easy solution online, I would like to share mine.
2 lines of code that are now perfectly working with my existing code;
MyApplication.mRequestqueue.cancelAll(imgView);
imageRequest.setTag(imgView);
Then I add my request
MyApplication.mRequestqueue.add(imageRequest);
the imgView is a... ImageView
I tried with a String but behind the scenes it is checking for == and not equal, resulting in not finding and cancelling the same requests going on.
Hope this will help someone!
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.
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
I am using Navigation drawer in my application. for this I have support libraries included in my project(support library 7 and 4). everything is fine and working well but I have a problem that is when my main activity launches then it becomes blank for 2 to 3 seconds. my main activity contains code for the navigation drawer. I have placed all the code to onResume(). I have tried different ways to overcome this problem but every time I face same problem. is this the standard time which an activity takes to become visible or it is something unexpected behavior of my app. earlier I tried with actionbarsherlock but Now I removed it. so please suggest me a possible solution to this problem.
I have more description to this problem hereStack overflow question
There can be several reasons behind slow loading of activity
Probably you are using a complex layout file which takes time to render. You could use ViewStub and inflate your layouts only when required
if you are loading some data you could use an asynctask to load the data in background and populate views when data is loaded.
Check if you are loading large images in oncreate or onresume.
also some more reference from Android Guidelines
I want to create GridView same like google's play(show below image). I search on this and also refer this question but still not find any solution.
I have tried StaggeredGridView but in this it will create problem while orientation changes. I had also tried with Override onConfigurationChanged and in that gridView.invalidate(); and adapter.notifyDataSetInvalidated();But still getting problem.
The Problem is, if I load application in landscape mode and load images and at the time of loading images if I change the orientation then there will be a Gap shown in GridView.
Any one has any idea related to this then please share with me.
I suggest you to use this which allows user to create a GridView with uneven rows similar to how looks like Pinterest,GooglePlay's gridview .
It also Includes own OnItemClickListener and OnItemLongClickListener, selector, and fixed position restore.
If you already used the StaggeredGridView, then there is also one more library which works the same just you want and also look at this solution .
I hope this serve your purpose.
Hope this helps ... :)