opensrp / opensrp-client

Android app for Frontline Health Workers (FHWs).
Other
15 stars 32 forks source link

Refactor Cursor Adapter to allow usage of older approach possible #240

Open maimoonak opened 8 years ago

maimoonak commented 8 years ago
maina commented 8 years ago

@maimoonak You mean ArrayAdapter by "In Memory adaptor"?

maimoonak commented 8 years ago

Nopes. It means the older approach where app was loading all data in memory first then was sorting and filtering based on that. Instead of using cursor or new query foreach search or sort.

maina commented 8 years ago

A cursoradapter has been proven to be faster any time records are being loaded from the database. Why do we need the in memory implementation back? I fear this might make the app slow and lead to more Application Not Responding (ANR) errors...

maimoonak commented 8 years ago

We may require a register that loads all data in memory and work on that. Cursor adapter is the recommended approach but some people may have register where expected data is not supposed to be more than 100. Then this approach may make sense. Also cursor adaptor make you to write sql which sometimes is not very flexible for search, sort, filter. So for such cases site may have option to use older approach on their own responsibilty.

Or maybe a hybrid approach of using cursor adapter for main register and In Memory approach for sub register can be a usecase. We may have a usecase for TB app where patient records are cursor adapter based but regimen or treatment history loaded internally could be In Memory.

maina commented 8 years ago

A cursor adapter should be able to display any number of records as may be necessary using pagination whereby all or some records may be displayed. When it comes to searching, filtering and sorting I guess this is where the cursor adapter is most useful since a tablet doesn't have the memory resources that might be needed by the in memory approach for these operations.

raihan-mpower commented 8 years ago

it is not interchangeable , as the search and previous method used to select from memory, wherelse now cursor adapter displays from cursor and searches and loads a fresh cursor. Old approach would even grow slower over time with hundred records as well. The values or lists in indetail page can still be done with older approach. We did so in our household register. The detail page has children which uses older in memory adapter. The sites can use older adapter if necessary as we have still kept it in the core.

maimoonak commented 8 years ago

I think a documentation of what we have done would be helpful in explaining the archtitecture. I would try to share the documentation before this month ends.