Giter Club home page Giter Club logo

Comments (13)

chweez avatar chweez commented on September 26, 2024 1

Yes. When there's a change, network_connected to network_disconnected or vice versa, the corresponding callbacks are triggered

from androidnetworkmanager.

chweez avatar chweez commented on September 26, 2024

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 ConnectionTypes so we can only listen to connectivity changes of a connection type such as wifi...

NetworkManager.monitor(this,  int connectionType, new ConnectivityChangeListener{...});

from androidnetworkmanager.

jumaallan avatar jumaallan commented on September 26, 2024

Nice, this would be amazing

from androidnetworkmanager.

chweez avatar chweez commented on September 26, 2024

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.

jumaallan avatar jumaallan commented on September 26, 2024

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.

jumaallan avatar jumaallan commented on September 26, 2024

@chweez Are you renaming the class from NetworkManager?

from androidnetworkmanager.

jumaallan avatar jumaallan commented on September 26, 2024

We use the NetworkUtil to check type of connection and also speeds of connection and Tovuti for network monitoring, is this correct?

from androidnetworkmanager.

chweez avatar chweez commented on September 26, 2024

Correct...any suggestions?

from androidnetworkmanager.

chweez avatar chweez commented on September 26, 2024

The implemented version became

Tovuti.from(context)
    .monitor(..., new Listener{...});

Are there any improvements you'd like to see?

from androidnetworkmanager.

chweez avatar chweez commented on September 26, 2024

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.

chweez avatar chweez commented on September 26, 2024

I renamed NetworkManager to NetworkUtil, do you wish the name to remain as NetworkManager?

from androidnetworkmanager.

chweez avatar chweez commented on September 26, 2024

Closed by pull #4... I'll open another issue for the automatic lifecycle management...

from androidnetworkmanager.

jumaallan avatar jumaallan commented on September 26, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.