jumaallan / AndroidNetworkManager

A library to check the Internet Connection Status in Android (WiFi and Mobile Data)
https://androidstudy.com
52 stars 34 forks source link

Automatic lifecycle management #5

Open chweez opened 7 years ago

chweez commented 7 years ago

For now, the user must call Tovuti.from(context).stop() but i want to make it automatic when the Activity/Fragment stops. So, the way Glide implements this feature is by having a view-less Fragment. The view-less fragment is attached to the activity/fragment where the Monitor is attached and these Fragment receives the lifecycle events of the parent/host thus allowing the Monitor to respond accordingly without user intervention (i.e. calling stop method). I'll try see if this way will suit us. The only problem is increasing the complexity of the library unnecessarily. What do you think @jumadeveloper?

jumaallan commented 7 years ago

Yes, having it kill or stop itself is a great idea, ping me if you need any help, but I can see you are doing great already!

chweez commented 7 years ago

Haha...thanks. Though I'll create another pull for the documentation...

jumaallan commented 7 years ago

Great

chweez commented 7 years ago

I've been considering this... @jumadeveloper help me with this... I'd like to hear your take on the matter. Any other perspective.

jumaallan commented 7 years ago

@chweez I think we should make it handle the lifecycle automatically, by somehow receiving the lifecycle event of the parent, as you had stated earlier when creating the issue to reduce code setup needed by the user

jumaallan commented 7 years ago

@chweez I have an idea, we can use livedata own lifecylcle manager, to manage our lifecylce here easily. Have a look at it and probably get back with ideas or suggestions

chweez commented 7 years ago

I've been looking at this. I have a concern for including the LiveData and LifecycleOwner from arch components because of the external dependencies. However, it may prove worth it. What I'm thinking is another module that depends on livedata and another that depends on rxjava. Adding the module dependency will pull in the transitive dependency to :networkmanager. The module names will be; :networkmanager-livedata and :networkmanager-rxjava

jumaallan commented 7 years ago

@chweez I completely agree with you