问题描述:

I'm looking for some guidance or direction where to head. I don't need any ready solutions but examples like, which classes to use (cursoradapter, baseadapter etc).

Here's what I'm trying to do:

  1. Create grid dynamically.
  2. Parse JSON (which returns me 20 items total).
  3. Check if JSON item exists in database, if not, insert it to database and display it on grid.
  4. Download picture (url in JSON) and display it also to same grid item.

I'm not sure if I should do it in this order: Create grid -> Add grid item -> Parse JSON for that entry -> Display text -> Check if exists in database -> Save it to database -> Download the picture and display and then proceed to next item.

And if item exists in database: Create grid -> Add grid item -> Parse JSON for that entry -> Display text -> Check if exists in database -> Skip saving -> Fetch it from database(?) -> Download the picture and display and then proceed to next item.

I have to download around 8 different JSON (20 items per feed) feeds in first activity (asynctask) and pictures as well. So I'm wondering what's the best way to do it without blocking the UI or slowing the UI performance by having too many connections simultaneously.

Thank you for your time.

网友答案:

The simplest way is to do it in that order:

  1. Create grid
  2. start asynctask (for example) to load items from database 3 if data exists, add them to grid
  3. start asynctask to load data from network
  4. insert data into database ( except all that not exists there)
  5. start asynctask to load from database and add them to grid
相关阅读:
Top