populate UI from local db table initially, then if webserivice has new data update table and UI

Ankit

ok this is my first post,

i have a ListView that is populated from local db table. from there i have to check if there is new data available from web service, if so first i have to update that particular table then UI.

now i need rough idea on how to implement this?

the data from web service isn't going to change frequently. so i need to create some architecture/mechanism where data is always loaded from database first then if new data is available from web service then i parse service update table then update UI.

basically i want something like this

    MainThread
        |
        |
        |-------->>--------separate thread----->>-----|
        |                                             |
        |                    listener/              query db,
   populate UI <<----------- observer/  ------<<----get data 
        |                    something                |
        |                                             |
        |                                             |
        |                                             |
        |                               check if we have new data--->> if no-- DONE       
        |                                             |
        |                                           if yes
        |                                             |
        |                                     call web service,
        |                                         fetch data,
        |                                        update table
        |                     listener/               |
    update UI  <<-------------observer/-----<<--------|
        |                     something               
        |

Kinda like Tumblr android App..

now i think i can achieve this with wrapping AsyncTask inside a class and an Interface(as observer/listener)

but i like to use Loader(available in android),

any other suggestion ?

HoodVinci

Good question !

It seems that you are trying to achieve the Famous Google I/O design pattern? Google IO Rest design pattern, Finished ContentProvider and stuck now https://www.youtube.com/watch?v=xHXn3Kg2IQE

I did it in the past (maybe as not as well as it should have been done ;-) ). And my advice is be sure of this two points :

  • Your tables are not too complex
  • Your updates are not always occuring.

If it's not the case, you 'll probably face performance issues due to database accesses. But it's a really good pattern.

Another advice is to use an Event bus instead of boiler-plate, frustrating interfaces for updating the UI . (I usaully use this one https://github.com/greenrobot/EventBus no performance problems, Otto is good and simple too but does not integrate well with android-annotations).

Hope it'll help.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

Populate data table from data reader

From Dev

Populate Gridview from Data Table

From Dev

How to populate a table from data in JSON array

From Dev

Create new jQuery ui tab and populate with Ajax data

From Dev

Update SQL Server table with local data

From Dev

retrieving data from db table to populate links

From Dev

SQL Server Local DB cannot insert into data in new table

From Dev

Adding new column in table from UI input

From Dev

angular-ui-tree, populate the tree from data from DATABASE

From Dev

Update datagrid row by row from a big data table (Progress database), using a task or thread, but keeping the UI responsive during the update

From Dev

Material UI table data refresh after redux update data

From Dev

How to delete all data from MySQL table and populate table with new data

From Dev

Update table with data from same table

From Dev

Populate a table with data from a database using a loop

From Dev

Populate MySQL table with dummy data using times from another table

From Dev

Create new jQuery ui tab and populate with Ajax data

From Dev

how to update table(new_DB) from old table(old_DB)

From Dev

Populate data from an array into an html table

From Dev

how to display 1 million data from a table on UI

From Dev

Import Data to a new table that has a nested table in it

From Dev

Populate form with data from relation table

From Dev

SQL Server Local DB cannot insert into data in new table

From Dev

update data in a table from a FK referenced table

From Dev

PHP populate using data from table

From Dev

Update table from table with general data

From Dev

populate an intersection table with data from unrelated tables

From Dev

How To Populate A Local Table?

From Dev

Update a local db table from remote SQL Server db table

From Dev

calling data from restapi and parssing into table in the ui

Related Related

  1. 1

    Populate data table from data reader

  2. 2

    Populate Gridview from Data Table

  3. 3

    How to populate a table from data in JSON array

  4. 4

    Create new jQuery ui tab and populate with Ajax data

  5. 5

    Update SQL Server table with local data

  6. 6

    retrieving data from db table to populate links

  7. 7

    SQL Server Local DB cannot insert into data in new table

  8. 8

    Adding new column in table from UI input

  9. 9

    angular-ui-tree, populate the tree from data from DATABASE

  10. 10

    Update datagrid row by row from a big data table (Progress database), using a task or thread, but keeping the UI responsive during the update

  11. 11

    Material UI table data refresh after redux update data

  12. 12

    How to delete all data from MySQL table and populate table with new data

  13. 13

    Update table with data from same table

  14. 14

    Populate a table with data from a database using a loop

  15. 15

    Populate MySQL table with dummy data using times from another table

  16. 16

    Create new jQuery ui tab and populate with Ajax data

  17. 17

    how to update table(new_DB) from old table(old_DB)

  18. 18

    Populate data from an array into an html table

  19. 19

    how to display 1 million data from a table on UI

  20. 20

    Import Data to a new table that has a nested table in it

  21. 21

    Populate form with data from relation table

  22. 22

    SQL Server Local DB cannot insert into data in new table

  23. 23

    update data in a table from a FK referenced table

  24. 24

    PHP populate using data from table

  25. 25

    Update table from table with general data

  26. 26

    populate an intersection table with data from unrelated tables

  27. 27

    How To Populate A Local Table?

  28. 28

    Update a local db table from remote SQL Server db table

  29. 29

    calling data from restapi and parssing into table in the ui

HotTag

Archive