The Source for Java Technology Collaboration

Home » java.net Forums » Mobile & Embedded » LWUIT

Thread: ListModel and RMS

Welcome, Guest Help
Login Login
Guest Settings Guest Settings
Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 2 - Last Post: Sep 8, 2008 4:30 PM by: Alex
Alex
ListModel and RMS
Posted: Aug 26, 2008 12:14 PM
  Click to reply to this thread Reply

Hi,

Thanks to Shai for his latest blog entry which clears up a lot of things on
the implementation of Lists (my previous question was about this). Alongside
whith the post on the TextField (autocomplete) and the proxy pattern
implementation used to filter out entries this gives great insights on the
possibilities of LWUIT Lists.

I however I need a litle piece of advice here on how to use the lwuit
ListModel with RMS alongside with the Proxy pattern for filtering and
sorting of records.

I am using Data Access Objects to access my model from within the RMS. So I
can either retreive single Objects based on their RMS ID or on their unique
ID or even based on a field's value using RecordFilter

The first step I want to achieve is pretty much similar to what is done is
the AutoComplete sample provided on the blog, except that I have much more
entries in my RMS than the ones in the sample.
In the Autocomplete sample found on the Lwuit blog the ListModel is
initialized using a String array of 21 entries :

*final* ListModel underlyingModel = *new* DefaultListModel*(**new*
String*[**]* *{*"Jack", "Kate", "Sawyer",
"Sayid", "Hurley", "Jin", "Sun", "Charlie", "Claire", "Aaron",
"Michael", "Walt", "Boone", "Shannon", "Locke", "Mr. Eko",
"Ana-Lucia", "Libby", "Desmond", "Benjamin Linus", "Juliet Burke" *}**)*;



What would I need to do If I wanted to acheive the same filtering mechanism
for the potential thousands of Contact Objects I have in the RMS without
altering performance ?
Would I need to initialize the underlying model by iterating over all RMS
entries and initialize a String[] containing all of the Names or Unique IDs
of my Contacts ?

To complicate things a litle further I want to sort the displayed entries.
For that I'm using an implementation of the Quicksort algorythm that will
sort a Vector or an Array of Objects. The sorting should be available on
different fields of the Model objects ....

So I think the main problem resides on how to implement the "underlying"
ListModel efficiently so that I can quickly filter and sort entries.

What strategy do the guru's out there suggest ? Let me know if I wasn't
clear enough :)


Thanks for helping.

Cheers.

Alex
[att1.html]


Shai Almog
Re: ListModel and RMS
Posted: Aug 27, 2008 12:43 PM   in response to: Alex
  Click to reply to this thread Reply

Hi Alex,
this is not so much a LWUIT question as an algorithm question.
Features such as a proxy on the client side would require something
like a "fast index" algorithm to narrow down elements fast while
still keeping memory lean.
There are many such algorithms a common one is to build an RMS store
for every letter of the alphabet and include the ID's of only the
elements that contain that letter. This reduces the workload for the
first letter which is the hardest one when fast filtering.

Just look on the internet for search strategies and low overhead,
these are very common in embedded systems and older devices.

> Hi,
>
> Thanks to Shai for his latest blog entry which clears up a lot of
> things on the implementation of Lists (my previous question was
> about this). Alongside whith the post on the TextField
> (autocomplete) and the proxy pattern implementation used to filter
> out entries this gives great insights on the possibilities of LWUIT
> Lists.
>
> I however I need a litle piece of advice here on how to use the
> lwuit ListModel with RMS alongside with the Proxy pattern for
> filtering and sorting of records.
>
> I am using Data Access Objects to access my model from within the
> RMS. So I can either retreive single Objects based on their RMS ID
> or on their unique ID or even based on a field's value using
> RecordFilter
>
> The first step I want to achieve is pretty much similar to what is
> done is the AutoComplete sample provided on the blog, except that I
> have much more entries in my RMS than the ones in the sample.
> In the Autocomplete sample found on the Lwuit blog the ListModel is
> initialized using a String array of 21 entries :
>
> final ListModel underlyingModel = new DefaultListModel(new String[]
> {"Jack", "Kate", "Sawyer",
>
> "Sayid", "Hurley", "Jin", "Sun", "Charlie", "Claire", "Aaron",
>
> "Michael", "Walt", "Boone", "Shannon", "Locke", "Mr. Eko",
>
> "Ana-Lucia", "Libby", "Desmond", "Benjamin Linus", "Juliet
> Burke" });
>
>
>
>
> What would I need to do If I wanted to acheive the same filtering
> mechanism for the potential thousands of Contact Objects I have in
> the RMS without altering performance ?
> Would I need to initialize the underlying model by iterating over
> all RMS entries and initialize a String[] containing all of the
> Names or Unique IDs of my Contacts ?
>
> To complicate things a litle further I want to sort the displayed
> entries. For that I'm using an implementation of the Quicksort
> algorythm that will sort a Vector or an Array of Objects. The
> sorting should be available on different fields of the Model
> objects ....
>
> So I think the main problem resides on how to implement the
> "underlying" ListModel efficiently so that I can quickly filter and
> sort entries.
>
> What strategy do the guru's out there suggest ? Let me know if I
> wasn't clear enough :)
>
>
> Thanks for helping.
>
> Cheers.
>
> Alex

Shai Almog
http://lwuit.blogspot.com/

[att1.html]


Alex
Re: ListModel and RMS
Posted: Sep 8, 2008 4:30 PM   in response to: Shai Almog
  Click to reply to this thread Reply

Just a litle word to say I finally managed (12 days later ... ) to create my
DAO based serialization, indexing and filtering framework based on the
couple of clues you had given me :)
I just saved 1000 bogus contacts on my N95 and I am currently browsing them
in an ULTRA FAST and FLUID way in a LWUIT List on my phone, sorted and
filtered the way I want to.

Although the underlying index loading is pretty slow I'm gonna try and find
a workaround for that.

Thanks again for pointing me in the correct direction ! You are my guru ...
:)

Cheers

Alex.
[att1.html]





 XML java.net RSS