I have a simple use case where my Android library will be initialized on app startup from the Application class. On initialization, I start a file download in the background which can take around 10-15secs. I need to show the content of this file in my FileDetailsActivity
.
And meanwhile, the file is downloading if the user navigates to the FileDetailsActivity
, I've to show a loader in this activity till downloads get completed. If the file is already downloaded I've to simply show it in FileDetailsActivity
.
FileDetailsActivity.java
- Android activity which show file details.
FileDownloadHelper.java
- Simple thread class which downloads the file and saves it in internal storage.
MyLib.java
- Library public file through which library can be used. Contains 2 methods:
- init() - Initialize library and starts the file download.
- showDetails() - Starts
FileDetailsActivity
activity.
I need help in creating architecture for this use case. Like, how can I sync the download status(downloaded, downloading, error) with my activity from FileDownloadHelper
etc.
Aucun commentaire:
Enregistrer un commentaire