0

I need functionality like facebook app in my app.

the functionality is that when i login in facebook app then feed data load first time and if i click another tab ,like notification tab then load notification list in facebook.

but if i click again feed tab then all feed data showing instantly ,it's maintain cache or database and it's perform like and share functionality.

in my app when i click home tab then loader visible to fetch data from server and click to another tab then fetch data from server.

the question is that i dont want to load every time loader in my app,it's should be first time in every tab, if data addded in my appp from server then i call webservice.

Thanks in Advance. Forgive me if any type of grammatical mistake.

Mayank Sugandhi
  • 397
  • 1
  • 7
  • 22

1 Answers1

0

Well I am not going to help you with code. that's your part. What I can do is give you some idea how to do that.

--> When the application first launches. What you can do is fetch the data the first time you load app and store it in your SQLlite DB. the relations should match the server side but you can store data how ever suites you best.

--> when you switch tabs. Save the state of the previous tab this question might help.

--> when you switch to a tab trigger a run in background or Async Task or a thread to retrieve data from serve and store it in the same local DB. and bind the views to that data for example if you are updating a list calling notifyDataSetChanged() will actually update that list on the screen.

Thats it. Hope that helps.

Community
  • 1
  • 1
Minato
  • 4,383
  • 1
  • 22
  • 28
  • :- i had implemented , but problem is that how to know that the server added another data to call webservice, and if webservice calling take time and i call like webservice at a time then how it can be possible to call like webservice until that background webservice is not finish and fetching data.? – Mayank Sugandhi Oct 12 '15 at 08:18
  • as far as I know you have call backs .. and for the new data problem.. you can use offset or keys.. for example you are retrieving `posts` data and you have retrieved post # 1,2,3 so pass it along the request header/object and tell the server that data should not contain post # 1,2,3. or something like that. – Minato Oct 12 '15 at 08:40
  • when you are done retrieving new data. i.e the Async task finished the call check if server has sent any data since you have told server not to include old posts. the data received will always be a new one. so add that to your local DB and update the list view and triger `notifyDataSetChanged()` – Minato Oct 12 '15 at 08:44