Android Example UltimateListView Example

This is an ULV example I wanted to share for a long time, since I thought it was *very* cool.

It demonstrates:
- Sticky headers
- Swipe gestures
- Animations (appearing out)
- Selected State, multiple selection with click
- Secondary Category/Alphabetical ULV allows you to jump in the first ULV to an alphabet like in Contacts

Requires: UltimateListView, AnimationPlus, Phone libraries

Really check this out if you want to know what ULV can do in a real world scenario.
 

Attachments

  • ULVExample.apk
    183.9 KB · Views: 1,775
  • scrtemp.png
    scrtemp.png
    77.6 KB · Views: 4,316
  • ULVExample.zip
    12.2 KB · Views: 2,950

corwin42

Expert
Licensed User
Longtime User
When Google introduced it's new RecyclerView with the Android L Preview and the Preview SDK I looked at its features and my first thought was:

"We have all this in B4A with ULV. But ULV is much easier to use."

Nice example and again a big thanks to Informatix for such a great library.
 

Informatix

Expert
Licensed User
Longtime User
When Google introduced it's new RecyclerView with the Android L Preview and the Preview SDK I looked at its features and my first thought was:

"We have all this in B4A with ULV. But ULV is much easier to use."

Nice example and again a big thanks to Informatix for such a great library.
I wasn't aware of this RecyclerView. Thanks for the information and for the nice compliment.
 
Last edited:

thedesolatesoul

Expert
Licensed User
Longtime User
I am not even sure what the RecyclerView does, it seems just like a more generic view.
But yes Informatix did work hard on the ULV and overcame many many issues. There are so many features added into the ULV like animators and image loaders that are not directly related to a listview but it is all there.

EDIT:
In fact I think the RecylcerView is more closer to the ULV. They now use a ViewHolder implementation with two events, and one is used to load the layout and the other is used to set the content.
 
Last edited:

thedesolatesoul

Expert
Licensed User
Longtime User
I tried the example, and it is very cool indeed, but it would be simpler by using sections. So I modified it to add sections. I also added the application icon in the items and I changed the jump code to place the first item of the section at the top.
Interesting, I never thought of using Sections, and this example should definitely have used them!

Do you think that I should sue Google? :)
Piiiiiirates...
If you have good lawyers!
 

susu

Well-Known Member
Licensed User
Longtime User
I tried the example, and it is very cool indeed, but it would be simpler by using sections. So I modified it to add sections. I also added the application icon in the items and I changed the jump code to place the first item of the section at the top.

Your code crashed when open app

B4X:
java.lang.OutOfMemoryError

    at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
    at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:514)
    at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:359)
    at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:792)
    at android.content.res.Resources.loadDrawable(Resources.java:1969)
    at android.content.res.Resources.getDrawable(Resources.java:673)
    at android.app.ApplicationPackageManager.getDrawable(ApplicationPackageManager.java:605)
    at android.content.pm.PackageItemInfo.loadIcon(PackageItemInfo.java:144)
    at android.app.ApplicationPackageManager.getApplicationIcon(ApplicationPackageManager.java:662)
    at android.app.ApplicationPackageManager.getApplicationIcon(ApplicationPackageManager.java:667)
    at anywheresoftware.b4a.phone.PackageManagerWrapper.GetApplicationIcon(PackageManagerWrapper.java:83)
    at com.maximussoft.ulvexample.actpackagelist._activity_create(actpackagelist.java:361)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:174)
    at com.maximussoft.ulvexample.actpackagelist.afterFirstLayout(actpackagelist.java:98)
    at com.maximussoft.ulvexample.actpackagelist.access$100(actpackagelist.java:16)
    at com.maximussoft.ulvexample.actpackagelist$WaitForLayout.run(actpackagelist.java:76)
    at android.os.Handler.handleCallback(Handler.java:615)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:4886)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
    at dalvik.system.NativeStart.main(Native Method)
 

Informatix

Expert
Licensed User
Longtime User
Your code crashed when open app

B4X:
java.lang.OutOfMemoryError

    at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
    at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:514)
    at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:359)
    at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:792)
    at android.content.res.Resources.loadDrawable(Resources.java:1969)
    at android.content.res.Resources.getDrawable(Resources.java:673)
    at android.app.ApplicationPackageManager.getDrawable(ApplicationPackageManager.java:605)
    at android.content.pm.PackageItemInfo.loadIcon(PackageItemInfo.java:144)
    at android.app.ApplicationPackageManager.getApplicationIcon(ApplicationPackageManager.java:662)
    at android.app.ApplicationPackageManager.getApplicationIcon(ApplicationPackageManager.java:667)
    at anywheresoftware.b4a.phone.PackageManagerWrapper.GetApplicationIcon(PackageManagerWrapper.java:83)
    at com.maximussoft.ulvexample.actpackagelist._activity_create(actpackagelist.java:361)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:174)
    at com.maximussoft.ulvexample.actpackagelist.afterFirstLayout(actpackagelist.java:98)
    at com.maximussoft.ulvexample.actpackagelist.access$100(actpackagelist.java:16)
    at com.maximussoft.ulvexample.actpackagelist$WaitForLayout.run(actpackagelist.java:76)
    at android.os.Handler.handleCallback(Handler.java:615)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:4886)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
    at dalvik.system.NativeStart.main(Native Method)
You have too many applications on your phone ! ;)
You get this error because all application icons are loaded in a map before displaying the list. They should be saved in the disk cache, and only the cache ID should be stored in the map. Then they would be retrieved from the cache by LoadImageAsync, as usual. I didn't think to fix that.
 

Mahares

Expert
Licensed User
Longtime User
I imported records from a SQLite table, But for the life of me I cannot figure out how to reduce the vertical spacing between the rows despite playing around with all views. Please see my screenshot
 

Attachments

  • ULV103114.png
    ULV103114.png
    172.7 KB · Views: 1,592

Informatix

Expert
Licensed User
Longtime User
Your code crashed when open app

B4X:
java.lang.OutOfMemoryError

    at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
    at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:514)
    at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:359)
    at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:792)
    at android.content.res.Resources.loadDrawable(Resources.java:1969)
    at android.content.res.Resources.getDrawable(Resources.java:673)
    at android.app.ApplicationPackageManager.getDrawable(ApplicationPackageManager.java:605)
    at android.content.pm.PackageItemInfo.loadIcon(PackageItemInfo.java:144)
    at android.app.ApplicationPackageManager.getApplicationIcon(ApplicationPackageManager.java:662)
    at android.app.ApplicationPackageManager.getApplicationIcon(ApplicationPackageManager.java:667)
    at anywheresoftware.b4a.phone.PackageManagerWrapper.GetApplicationIcon(PackageManagerWrapper.java:83)
    at com.maximussoft.ulvexample.actpackagelist._activity_create(actpackagelist.java:361)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:174)
    at com.maximussoft.ulvexample.actpackagelist.afterFirstLayout(actpackagelist.java:98)
    at com.maximussoft.ulvexample.actpackagelist.access$100(actpackagelist.java:16)
    at com.maximussoft.ulvexample.actpackagelist$WaitForLayout.run(actpackagelist.java:76)
    at android.os.Handler.handleCallback(Handler.java:615)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:4886)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
    at dalvik.system.NativeStart.main(Native Method)
This problem should be fixed with this new code.
Instead of storing all icons in a map, I save them to a cache:
B4X:
pMap.IconID = ConvertNameToID(packagename)
Dim Drawable As BitmapDrawable = PM.GetApplicationIcon(packagename)
ULV.FeedDiskCacheWithBitmap(Drawable.Bitmap, pMap.IconID, False)
And I read my icon with LoadImageAsync (I don't set a location because the icon is supposed to be found in the disk cache):
B4X:
ULV.LoadImageAsync(IV, "", PMap.IconID, Gravity.FILL)
I added a function in this example, ConvertNameToID, which will probably be useful in all cases where you want to convert a string to an unique identifier. With very long strings, there's a (very small) risk of collision so you should use it mainly for file names, people names, etc.
 

Attachments

  • ULVFloatControllerExample.zip
    12.4 KB · Views: 1,061

thedesolatesoul

Expert
Licensed User
Longtime User
This problem should be fixed with this new code.
Instead of storing all icons in a map, I save them to a cache:
B4X:
pMap.IconID = ConvertNameToID(packagename)
Dim Drawable As BitmapDrawable = PM.GetApplicationIcon(packagename)
ULV.FeedDiskCacheWithBitmap(Drawable.Bitmap, pMap.IconID, False)
And I read my icon with LoadImageAsync (I don't set a location because the icon is supposed to be found in the disk cache):
B4X:
ULV.LoadImageAsync(IV, "", PMap.IconID, Gravity.FILL)
I added a function in this example, ConvertNameToID, which will probably be useful in all cases where you want to convert a string to an unique identifier. With very long strings, there's a (very small) risk of collision so you should use it mainly for file names, people names, etc.
I didnt know about the DiskCache, and the lazy loading function, very useful (I think its outside the scope of the ULV but thank you for implementing it).
I was wondering if I should convert my GridView into an EasyGridview like Erel does in his ListView, but I figured that it will eventually run out of memory loading too many images. The only solution to that was a diskcache and letting images load asyncronously. Probably too much work for me.
Thanks!
 

incendio

Well-Known Member
Licensed User
Longtime User
App runs, but on log window got :
Section not found: "3"
Section not found: "A"
Section not found: "B", etc.
 
Top