app/src/main/java/com/yahala/xmpp/XMPPManager.java
/**
     * This method *requests* a state change - what state things actually
     * wind up in is impossible to know (eg, a request to connect may wind up
     * with a state of CONNECTED, DISCONNECTED or WAITING_TO_CONNECT...
     */
This method *requests* a state change - what state things actually
wind up in is impossible to know (eg, a request to connect may wind up
with a state of CONNECTED, DISCONNECTED or WAITING_TO_CONNECT
This method * requests * a state change - what state things actually wind up in is impossible to know ( eg a request to connect may wind up with a state of CONNECTED DISCONNECTED or WAITING_TO_CONNECT
public void xmppRequestStateChange(final ConnectionState newState) {
        xmppQueue.postRunnable(new Runnable() {
            @Override
            public void run() {
                FileLog.d("XMPPManager", "xmppRequestStateChange " + connectionState + " => " + newState.toString());
                switch (newState) {
                    case ONLINE:
                        FileLog.e("XMPPManager", "ONLINE case");
                        if (!isConnected() /*&& tryConnectOrNot()*/) {
                            cleanupConnection();
                            FileLog.e("XMPPManager", "cleanup Connection and start");
                            start(ConnectionState.ONLINE);
                        }
                        break;
                    case DISCONNECTED:
                        FileLog.e("Test Internet", "DISCONNECTED");
                        stop();
                        break;
                    case RECONNECT_DELAYED:
                        cleanupConnection();
                        start(ConnectionState.RECONNECT_DELAYED);
                        break;
                    case RECONNECT_NETWORK:
                        cleanupConnection();
                        start(ConnectionState.RECONNECT_NETWORK);
                        break;
                    default:
                        FileLog.e("XMPPManager", "xmppRequestStateChange() invalid state to switch to: " + newState.toString());
                }
            }
        });
    }
public void xmppRequestStateChange ( final ConnectionState newState ) { xmppQueue . postRunnable ( new Runnable ( ) { @ Override public void run ( ) { FileLog . d ( "XMPPManager" , "xmppRequestStateChange " + connectionState + " => " + newState . toString ( ) ) ; switch ( newState ) { case ONLINE : FileLog . e ( "XMPPManager" , "ONLINE case" ) ; if ( ! isConnected ( ) /*&& tryConnectOrNot()*/ ) { cleanupConnection ( ) ; FileLog . e ( "XMPPManager" , "cleanup Connection and start" ) ; start ( ConnectionState . ONLINE ) ; } break ; case DISCONNECTED : FileLog . e ( "Test Internet" , "DISCONNECTED" ) ; stop ( ) ; break ; case RECONNECT_DELAYED : cleanupConnection ( ) ; start ( ConnectionState . RECONNECT_DELAYED ) ; break ; case RECONNECT_NETWORK : cleanupConnection ( ) ; start ( ConnectionState . RECONNECT_NETWORK ) ; break ; default : FileLog . e ( "XMPPManager" , "xmppRequestStateChange() invalid state to switch to: " + newState . toString ( ) ) ; } } } ) ; }
This method *requests* a state change - what state things actually
 wind up in is impossible to know (eg, a request to connect may wind up
 with a state of CONNECTED, DISCONNECTED or WAITING_TO_CONNECT...
This method * requests * a state change - what state things actually wind up in is impossible to know ( eg a request to connect may wind up with a state of CONNECTED DISCONNECTED or WAITING_TO_CONNECT ...
//ConnectionState currentState = getConnectionStatus(); // Now we have requested a new state, our state receiver will see when // the state actually changes and update everything accordingly.