Comments (13)
Yes. When there's a change, network_connected to network_disconnected or vice versa, the corresponding callbacks are triggered
from androidnetworkmanager.
The use case I'm thinking;
/**
*@param this is an Activity or a Fragment or a View or an Application
**/
NetworkManager.monitor(this, new ConnectivityChangeListener{
@Override
public onConnected(int connectionType, boolean isFast){
//user code here
...
}
@Override
public void onConnectionLost(){
...
}
});
An overload will provide filtering for ConnectionType
s so we can only listen to connectivity changes of a connection type such as wifi...
NetworkManager.monitor(this, int connectionType, new ConnectivityChangeListener{...});
from androidnetworkmanager.
Nice, this would be amazing
from androidnetworkmanager.
Just as onConnected(int, boolean)
is triggered for the corresponding connectionType
or aany connection, so will the onConnectionLost()
, i.e;
In the second overload, .monitor(Context, int, Listener)
if the Connection of type connectionType
is lost the callback to onConnectionLost
is triggered.
But for the Listener
that listens to any network change, the onConnectionLost
is only triggered when all connections are lost.
from androidnetworkmanager.
The .monitor
is an amazing feature, esp when building applications that require constant internet connection to work, and even trigger changes to UI componets, like disabling send button. Awesome!
Will the onConnected(int, boolean
be triggered when the connection is restored?
from androidnetworkmanager.
@chweez Are you renaming the class from NetworkManager?
from androidnetworkmanager.
We use the NetworkUtil
to check type of connection and also speeds of connection and Tovuti
for network monitoring, is this correct?
from androidnetworkmanager.
Correct...any suggestions?
from androidnetworkmanager.
The implemented version became
Tovuti.from(context)
.monitor(..., new Listener{...});
Are there any improvements you'd like to see?
from androidnetworkmanager.
Also, 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?
from androidnetworkmanager.
I renamed NetworkManager
to NetworkUtil
, do you wish the name to remain as NetworkManager
?
from androidnetworkmanager.
Closed by pull #4... I'll open another issue for the automatic lifecycle management...
from androidnetworkmanager.
The naming is perfect, NetworkManager
may seem confusing or as part of the AndroidSDK
, let me follow the other open issue
from androidnetworkmanager.
Related Issues (8)
- Tovuti.from(Activity).stop(); Might throw IllegalArgumentException: Receiver not registered HOT 7
- No internet connection
- Detect Connection Type (WiFi or Mobile Data) - Feature HOT 2
- Automatic lifecycle management HOT 8
- Documentation for the changes made upto now HOT 2
- Rename Core Methods HOT 2
- monitor method should return Tovuti, but return void HOT 12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from androidnetworkmanager.