app/src/main/java/com/yahala/xmpp/XMPPManager.java
/**
     * Removes all references to the old connection.
     * <p/>
     * Spawns a new disconnect runnable if the connection
     * is still connected and removes packetListeners and
     * Callbacks for the reconnectHandler.
     * <p/>
     * synchronized because cleanupConnection() ->
     * maybeStartReconnect() -> connectionClosedOnError()
     * is called from a different thread
     */
Removes all references to the old connection.

Spawns a new disconnect runnable if the connection
is still connected and removes packetListeners and
Callbacks for the reconnectHandler.

synchronized because cleanupConnection() ->
maybeStartReconnect() -> connectionClosedOnError()
is called from a different thread
Removes all references to the old connection . Spawns a new disconnect runnable if the connection is still connected and removes packetListeners and Callbacks for the reconnectHandler . synchronized because cleanupConnection () - > maybeStartReconnect () - > connectionClosedOnError () is called from a different thread
private synchronized void cleanupConnection() {
        Utilities.stageQueue.handler.removeCallbacks(stageRunnable);
        if (connection != null) {
            FileLog.e("XMPPManager", "Cleanup connection");
            if (packetListener != null) {
                connection.removeAsyncStanzaListener(packetListener);
            }
            /*if (connectionGeneralListener != null) {
                connection.removeConnectionListener(connectionGeneralListener);
                connectionGeneralListener = null;
            }*/
            if (rosterListener != null) {
                Roster roster = Roster.getInstanceFor(connection);
                roster.removeRosterListener(rosterListener);
            }
            if (connection.isConnected()) {
                try {
                    connection.disconnect();
                } catch (Exception e) {
                    e.printStackTrace();
                }
                connection = null;
                mPingManager = null;
            }
        }
        FileLog.e("XMPPManager", "cleanupConnection end");
    }
private synchronized void cleanupConnection ( ) { Utilities . stageQueue . handler . removeCallbacks ( stageRunnable ) ; if ( connection != null ) { FileLog . e ( "XMPPManager" , "Cleanup connection" ) ; if ( packetListener != null ) { connection . removeAsyncStanzaListener ( packetListener ) ; } /*if (connectionGeneralListener != null) {
                connection.removeConnectionListener(connectionGeneralListener);
                connectionGeneralListener = null;
            }*/ if ( rosterListener != null ) { Roster roster = Roster . getInstanceFor ( connection ) ; roster . removeRosterListener ( rosterListener ) ; } if ( connection . isConnected ( ) ) { try { connection . disconnect ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } connection = null ; mPingManager = null ; } } FileLog . e ( "XMPPManager" , "cleanupConnection end" ) ; }
Removes all references to the old connection.
Removes all references to the old connection .
// Removing the PacketListener should not be necessary // as it's also done by XMPPConnection.disconnect() // but it couldn't harm anyway