Performance Problems - Loading Listviews

GuyBooth

Active Member
Licensed User
Longtime User
I am building an app that has 4 sliding panels loaded on the AHViewer. Test results below are based on a Galaxy S3.

One of the panels contains a CustomListView which loads approx 1000 records from a SQLLite database. This takes about 10 secs to load, and may be reloaded in different record order at user request. The CustomListView functionally does everything I need but this load time is way to long. The SQL execution is not the problem, it is really quick - the long load time is a result of loading the CustomListView.

The other panel in question contains a "standard" ListView which loads approx 6000 records from the same database. This takes 4 - 5 secs to load but functionally barely achieves what I need (lack of the persistant color change on a "selected" item being one of the problems). This load time is also longer than I would like, especially since it always happens immediately after the CustomListView loading - it's the nature of the app.
Are there any solutions to these slow load times? Any threading options I should consider? Any caching solutions? I am not technically good enough to build libraries, but I can modify Classes ok and building classes would not be a problem.
 

Informatix

Expert
Licensed User
Longtime User
This loading time is one of the reason why I created the UltimateListView. In my latest demo, a list with 128900 records is opened in less than one second, even on a very ordinary phone. And less than 5 seconds if you include the data sorting (but it's related to the database, not to the list, and that's really fast for 128900 records). I had to change the way a list is usually loaded and recreate every feature of a ListView (including the view recycler). It's not just a few lines added here or there.
If you want to do the same thing yourself, you're going to spend weeks on it (at least) and you have to know Java (for libraries). I don't say that to sell my stuff (it is selling very well without this comment), it's just a fact.
 
Upvote 0

GuyBooth

Active Member
Licensed User
Longtime User
What is the layout of each item in the CustomListView? 10 seconds sounds too much.

Can you upload your project or the part that loads the list?

Hi Erel.
My apologies if I don't do this properly - I'm not familiar with how to upload which pieces in this forum, so I am uploading a zip file that contains some code snippets and a screenshot.
Let me know if more explanation would help!
 

Attachments

  • GBB_clvLoadCode.zip
    120 KB · Views: 228
Upvote 0

GuyBooth

Active Member
Licensed User
Longtime User

I have some concern as to whether UltimateListView will work with the AHViewer panels that I have already built into the app, having tried other sliding panel approaches without success. I saw a thread today that indicated there might be a problem? I might be prepared to buy the product if I knew for sure that it would fulfill all my requirements. I know it looks good, but I am finding with b4a that with every class, module and library there is something that is missing or doesn't quite fit my needs (Scrollviews are great but slow to load, Listviews are fast to load but missing persistant selectability, CustomListViews are missing fast scrolling ....etc).
 
Upvote 0

Informatix

Expert
Licensed User
Longtime User
I have some concern as to whether UltimateListView will work with the AHViewer panels that I have already built into the app, having tried other sliding panel approaches without success. I saw a thread today that indicated there might be a problem?

Yes, the ULV is currently not fully compatible with AHViewPager (or any similar view) but that's not strange. Both views try to detect and interpret horizontal swipes. Which swipe is a page change and which one is an horizontal scroll in ULV? Not easy to solve. Anyway, that works most of the time but "most of the time" is not enough, I agree. The workaround I suggest for now (until Corwin42 find a good solution for that) is to add a margin around the list (so there's an area on screen where the page change can be done for sure).

I might be prepared to buy the product if I knew for sure that it would fulfill all my requirements.

What are you requirements?


You cannot really compare ListViews, CustomListViews or even my own class CheckList (superior to CustomListView in many ways) to ULV. They have too much drawbacks in comparison. It's not fair for them

The thing I wanted to say to you was not "my product is the best, buy it", but only "be prepared for a lot of work if you want to do the same". You cannot solve the loading time issue simply by patching the existing classes or libraries. You have to imagine a different way of loading items (the ULV loads them in real-time while the list is scrolled, that's why there's almost no preparation time).
 
Upvote 0

GuyBooth

Active Member
Licensed User
Longtime User

Can the "Horizontal Swipe" capability of the ULV be "locked" (to allow the AHViewer panels to work) leaving the "Vertical Scroll" capabiity intact? I don't need horizontal swipe capability in the listview itself.

You cannot really compare ListViews, CustomListViews or even my own class CheckList
I wasn`t trying to compare with ULV - just pointing out that every time I think I`ve found a tool to fulfil my needs, I discover something in it that doesn`t quite work out. So my concern is - if I buy your ULV, am I going to find something that doesn`t quite work out with it. It could be a bit like buying a car without taking a test drive, and then finding it doesn`t have windshield wipers.
 
Upvote 0

GuyBooth

Active Member
Licensed User
Longtime User
BTW, CustomListView is not intended for very large lists, because it creates a view for each item. The advantage is that it is quite simple to customize it.
That`s why I didn`t use it for the 6000 item list.

Erel
If it is unlikely that I will be able to reduce the load time down to 1 - 2 secs for the 900 items then I don`t want to take up your time sending you the whole project, which contains a lot of twists and turns and is a long way from completion. I certainly appreciate the offer, and will zip it up if you think that 1 - 2 secs load time is where it could be.

As you can see from the thread I am also considering Informatix`s ULV, but still have some questions that need to be answered before I can decide whether it will do the job.
 
Upvote 0

Informatix

Expert
Licensed User
Longtime User
Can the "Horizontal Swipe" capability of the ULV be "locked" (to allow the AHViewer panels to work) leaving the "Vertical Scroll" capabiity intact? I don't need horizontal swipe capability in the listview itself.

That means: I have to implement in my view an horizontal swipe detection (of no use in normal time because the horizontal scroll is handled automatically by the Android API in my view) to fix an issue in another view. And I have no idea about what to do exactly when I have detected the swipe.
All that does not make sense to me when you can ask for a fix to the author of the other view. The AHViewPager is the parent view. It's supposed to intercept the touch events and consume the ones it needs for the page changing.

So my concern is - if I buy your ULV, am I going to find something that doesn`t quite work out with it. It could be a bit like buying a car without taking a test drive, and then finding it doesn`t have windshield wipers.

Yes I know but I can't offer a try of the package; it's mostly source code. If you have specific requirements, the best thing is to post in the ULV thread to ask other customers (and they are numerous now) what they think about it.
 
Upvote 0

Inman

Well-Known Member
Licensed User
Longtime User

I started using AHViewPager and ULV in my project today and they work without issues. I don't need horizontal scroll on ULV, so I disabled it by setting PanelWidth in ULV.Initialize to -1.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
ULV looks like an excellent solution to me.

Still you can probably further optimize your solution.
The following code takes 1.8 seconds on Galaxy Nexus:
B4X:
Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("1")

   Dim s As Long = DateTime.Now
   clv2.Initialize(Me, "clv2")
   Panel2.AddView(clv2.AsView, 0, 0, Panel2.Width, Panel2.Height)
   For i = 1 To 1000
      clv2.Add(CreateListItem("Item #" & i, clv2.AsView.Width, 50dip), 50dip, "Item #" & i)
   Next

   Log(DateTime.Now - s)
End Sub



Sub CreateListItem(Text As String, Width As Int, Height As Int) As Panel
   Dim p As Panel
   p.Initialize("")
   p.Color = Colors.Black
   Dim lbl2 As Label
   lbl2.Initialize("")
   lbl2.Text = "Test"
   Dim lbl As Label
   lbl.Initialize("")
   lbl.Gravity = Bit.Or(Gravity.CENTER_VERTICAL, Gravity.LEFT)
   lbl.Text = Text
   lbl.TextSize = 16
   lbl.TextColor = Colors.White
   p.AddView(lbl, 5dip, 2dip, 150dip, Height - 4dip) 'view #0
   p.AddView(lbl2, 155dip, 2dip, 110dip, Height - 4dip) 'view #1
   Return p
End Sub
 
Upvote 0

GuyBooth

Active Member
Licensed User
Longtime User
I started using AHViewPager and ULV in my project today and they work without issues. I don't need horizontal scroll on ULV, so I disabled it by setting PanelWidth in ULV.Initialize to -1.

Inman, what OS is this using (am I supposed to be able to see this in a profile without asking you? Sorry if I'm missing something).
 
Upvote 0

GuyBooth

Active Member
Licensed User
Longtime User
ULV looks like an excellent solution to me.

Still you can probably further optimize your solution.
Erel thanks for this.
Interestingly this is almost identical to part of the code that I am using, as one of the routines in the CustomListView package. When applied to my "real" data the times are very similar, so it looks as though I am unlikely to make progress in that direction. Worth a try though!
 
Upvote 0

GuyBooth

Active Member
Licensed User
Longtime User
Informatix - a couple of questions on ULV:
Can I add an array to each list item (as I can in the CLV) in addition to text?
I saw somewhere a description of having the fast scroll display the first letter of the displayed item. Will I be able to make it display the first letter from a different an element which is part of the array in question 1?

Thanks
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
I've experienced such loading times with sqlite, in cases where I had forgotten to close a cursor, and in cases where the db was not compacted after many insertions/deletions. Don't know if this could be the problem in your case though.
By the way, wouldn't 1,000 records be too much for an end-user to browse? In some of my apps, I usually choose to have no more than 40-50 records per view, using buttons to switch to another area. But sure, just my way of doing it, everyone has his very own
 
Upvote 0

GuyBooth

Active Member
Licensed User
Longtime User
I ran some tests and concluded that the data was being extracted from the database to a table pretty quickly. Moving it from the table to the listview is what is taking all the time.Its also a static database - so I shouldn' ahve to face that problem, unless I change how I intend to use it.!
Good thoughts about the number of records for browsing. I use a fast scroller that seems to work pretty well. There is also a full set of filters so the numbers can be reduced - performance is fine with these reduced numbers.
Thanks for the input.
 
Upvote 0

Inman

Well-Known Member
Licensed User
Longtime User
Inman, what OS is this using (am I supposed to be able to see this in a profile without asking you? Sorry if I'm missing something).

I am using Android 4.1.2. Of course I started using ULV only yesterday so I will have to test it further but so far I don't see any issues regarding swiping tabs in AHViewPager, with horizontal swipe disabled in ULV.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…