Your Sample App's Logic should be inside Library.
https://github.com/tonyofrancis/Fetch/blob/v2/sampleApp/src/main/java/com/tonyodev/fetchapp/App.java
@Mayur-007 Can you explain in more detail?
The instance of Fetch that the App class returns is a global instance. It can be accessed in many different activities. The close check was put in place to ensure that if the instance was closed accidentally inside an activity. An activity should not be calling the close method on the instance because the instance does not technically belong to the activity and the memory will be cleaned automatically when the app process terminates.
The purpose of using any 3rd party library is to make things simpler,
You are missing out on it.
Instead of making users writing so much code, you can make it easy.
@Mayur-007 you have not properly explained the pain points. or the crashes you are getting when using the library.
I have an activity in where I download video, I have maintained it's close while exiting but when a download is in progress and user move to next or previous activity, It crashes.
Also If the activity is closed and I start the download again, it also crashes again.
@Mayur-007 Being that you are using the same Fetch namespace in multiple activities, you can create a global singleton of Fetch and access it in the different activities. You do not have to close the global instance of Fetch and downloads will also continue in the background.
Take a look at Implementation of https://github.com/lingochamp/FileDownloader/wiki/Start-downloading and see how small, easy to use & simple it is.
@Mayur-007 I totally understand and I aim to make Fetch as simple as possible with the more feedback I get. Fetch is very different from FileDownloader because it provides a wide range customization for use cases that FileDownloader that does not support. For example Fetch allows you to provide your own output stream to save downloading files and do encryption and much more. I will be creating a wiki soon to provide further support. Thanks for your feedback.
That sounds great,
I will ping If I get free from work and will see If I can help you in any way.
Thanks
@Mayur-007 Over the weekend I looked into your feedback some more and was able to simplify Fetch a great deal! Thanks. Fixing most of the pain points you mentioned. This will be Fetch 2.1.0. Had to refactor some components to simplify the library but I think its worth it. Gonna perform a few more test and I will release an alpha version within a day or so.
Cool
Still doing some polishing. looks very promising.
Great, you can close if you want.
We can still discuss.
@Mayur-007 Just released Fetch version 2.1.0-RC1. This release does have breaking changes so please view the README and CHANGELOG documents. This release simplifies Fetch's usage and addresses many of the library's pain points. This release also adds a new accompanying library. The FetchFileServer :) . Have been working on it for a while and happy to include it in this release. The sample app has also been updated. Open new issue tickets as needed! Happy Fetching!.
Cool. Will check it out once I get free.
@Mayur-007 Can you explain in more detail?
The instance of Fetch that the App class returns is a global instance. It can be accessed in many different activities. The close check was put in place to ensure that if the instance was closed accidentally inside an activity. An activity should not be calling the close method on the instance because the instance does not technically belong to the activity and the memory will be cleaned automatically when the app process terminates.
Life saving reply, you might want to include in the front page (Readme), because the term "Release fetch() instance when you done" is scare you off.. :)
Most helpful comment
@Mayur-007 Can you explain in more detail?
The instance of Fetch that the App class returns is a global instance. It can be accessed in many different activities. The close check was put in place to ensure that if the instance was closed accidentally inside an activity. An activity should not be calling the close method on the instance because the instance does not technically belong to the activity and the memory will be cleaned automatically when the app process terminates.