Laggy ListView with Realm BaseAdapter? - android

In my app, I am using the RealmBaseAdapter with Android's Listview, and I'm having some issues with the general lagginess of the application. I was wondering if anyone had any general pointers as to how I can optimize my listview so that is does not appear laggy to the user. I tried routing most of my getView method through an AsyncTask, but, as much of my getView is the model interacting with the UI, pretty much everything had to be put on the onPostExecute thread. Any advice would be greatly appreciated.

Following the advice here is a great first step: http://developer.android.com/training/improving-layouts/smooth-scrolling.html
Otherwise this blog post by Romain Guy, also goes in depth with the tools you can use in order to find the root cause: http://www.curious-creature.com/2012/12/01/android-performance-case-study/
Without your adapter code, it is hard to say anything more concrete.

Related

ListView with a gridView within infinite height

This is one of the implementations that I have the most difficulty in actually finding the best way to solve.
There are a lot of techniques and ways, but the last answers I found did not really seem to me to solve the problem. Another point is that they are usually very old techniques and libraries.
What I want to do is this:
How do I create this ListView with a GridView inside and the screen has infinite height without using ScrollView, so we know that it is not recommended to use ListView within ScrollView.
I am not asking you to develop the code, but rather recommend me the correct architecture that I should use to implement this (ScrollView, ListView, GridView), or memo a library that has new development concepts that can help me.
This question arises because many of the existing responses are too old and have outdated ideas.
I know the question is of a slightly higher level of complexity, but I accept everyone's help.
Thank you very much.
It is very easy to solve this using a RecyclerView.
The documentation is pretty clear and explains all the details necessary for the development of the functionality.
I will leave the necessary documentation links to implement:
RecyclerView
GridLayoutManager
ItemsViewHolder
We know that it is always better to use native components in the development, I recommend, but if you prefer to use a library ready to solve your problem, here are some interesting:
Sticky Headers
recyclerview-stickyheaders
StickyListHeaders

ListView with Cardviews in Android

this is probably a repost but I have to do it, because Android versions change so does the code too and because I have already tried every tutorial on the internet. I am trying to make a listview and the child which is going to be multiplicated is a CardView. And I tried too much different code to post, because this taking me already days. So how do I make this with an Adapter? My problem was that it never displayed the content. If you need further information, and you probably do, please comment below. I am very thankful for your help guys!
Michael

android commonsware endless adapter fetch content before list reaches the end

I am using the endless adapter from https://github.com/commonsguy/cwac-endless
This works great for me, but I am looking to fetch rows not when the users reach the end, but rather before. In other words, I prefer that the user will not see the pending view at all or at least minimize this situation.
I did not find yet the option in this adapter to accomplish this.
Any help would be appreciated..

Using cwac-endless adapter with existing/custom AsyncTasks

I'm currently using what I assume is a common pattern in Android, of fetching data from a network using various AsyncTasks, and updating a simple ArrayAdapter on completion using an interface callback mechanism.
cwac-endless is reasonably easy to plug in to add pagination type scrolling, aside from the fundamental issue that it assumes it will handle running the background task for you. Does this mean I basically have to rip up all my AsyncTask classes and associated interfaces, and move all the code from doInBackground into my EndlessAdapter's cacheInBackground?
Most solutions I've tried seem to end up duplicating much of the code already in cwac-endless, so I feel there must be cleaner solution to using this adapter with an existing AsyncTask?
cwac-endless is reasonably easy to plug in to add pagination type scrolling, aside from the fundamental issue that it assumes it will handle running the background task for you
Handling "running the background task for you" is most of the point behind the adapter.
Does this mean I basically have to rip up all my AsyncTask classes and associated interfaces, and move all the code from doInBackground into my EndlessAdapter's cacheInBackground?
If you wish to use EndlessAdapter as it stands, yes.
You are certainly welcome to grab the code, modify getView() to not use its own executeAsyncTask and AppendTask and replace that logic with your own. However, pretty much every line of code in AppendTask is necessary for EndlessAdapter to work. And I have no idea how any endless construct would work with "custom AsyncTasks" plural, as there has to be a clear end to the work so that we know to show the new rows in the list and get rid of the pending View. Hence, you would still need to designate some AsyncTask of yours as playing the role of AppendTask, doing everything that you are presently doing and all of the logic in AppendTask. Whether that is simpler than just using the existing EndlessAdapter code base, I cannot say, as I do not know your code.
I feel there must be cleaner solution to using this adapter with custom AsyncTasks?
You are the first person to ever raise the issue, and hence I have never considered it prior to typing in this answer. I will give it some thought and may try to do some refactoring to help with your scenario.

Scrollview with paging in android

is there a simple/native way to implement paging/pagination on scrollviews?
By simple, I mean with a short piece of code mainly using classes from Android SDK, like, when programming on iPhone, writing "pagingEnabled = YES".
When I was looking for the topic on the Internet, I saw people putting pieces of code about that matter, but these pieces of code were very large, and I can't help myself to believe Google did put a simple way to do it in their SDK. I also think that the code to implement it could be much easier than what I saw when looking for it. I'm currently working on it, but in the meantime, if anyone know a easier way to do it, I would be delighted to know about it.
Thanks for reading!
I think that there is not a fast solution to do this.
But what you can do is to take the gallery component and override the layout. The gallery component has paging :)
Another solution could be:
Horizontal Pager - https://github.com/ysamlan/horizontalpager
Real View Switcher http://marcreichelt.blogspot.com/2010/09/android-use-realviewswitcher-to-switch.html
Hope this helps...

Categories

Resources