jeudi 26 novembre 2015

Design solutions for fragments and asynchronous processing in Android

I struggled with some issues about design complex tasks with fragments use. Fragments and asynchronous are quite new for me, so I think it will be better to describe my app.

Application App works with GitHub API and has two screens: list of repositories and details about selected one. For retrieving data from json I use Retrofit and store it in SQLite. Little remark As I understood Retrofit can be used asynchronously but in case of additional work with DB it is better to use asynchronous for operations under DB also. In my case I'm checking internet connection: in case of absence I load data from DB. Otherwise I upgrade DB and then use it. Now I want to add fragments for different screen density support( usual master - detail workflow).

And my questions are

Where is the better place to run async tasks? Is it a right solution to make it in activity and then pass result to fragments?

What is the better solution for asynchronous processing? As I understood from my search about that, AsyncTask is deprecated but the easiest solution.

Aucun commentaire:

Enregistrer un commentaire