跳过导航链接
io.rong.imlib.stateMachine

类 StateMachine

    • 嵌套类概要

      嵌套类 
      限定符和类型 类和说明
      static class  StateMachine.LogRec
      StateMachine logging record.
    • 字段概要

      字段 
      限定符和类型 字段和说明
      static boolean HANDLED
      Convenience constant that maybe returned by processMessage to indicate the the message was processed and is not to be processed by parent states
      static boolean NOT_HANDLED
      Convenience constant that maybe returned by processMessage to indicate the the message was NOT processed and is to be processed by parent states
    • 构造器概要

      构造器 
      限定符 构造器和说明
      protected StateMachine(java.lang.String name)
      Constructor creates a StateMachine with its own thread.
      protected StateMachine(java.lang.String name, android.os.Handler handler)
      Constructor creates a StateMachine using the handler.
      protected StateMachine(java.lang.String name, android.os.Looper looper)
      Constructor creates a StateMachine using the looper.
    • 方法概要

      所有方法 实例方法 具体方法 
      限定符和类型 方法和说明
      protected void addLogRec(java.lang.String string)
      Add the string to LogRecords.
      protected void addState(State state)
      Add a new state to the state machine, parent will be null
      protected void addState(State state, State parent)
      Add a new state to the state machine
      java.util.Collection<StateMachine.LogRec> copyLogRecs() 
      protected void deferMessage(android.os.Message msg)
      Defer this message until next state transition.
      void dump(java.io.FileDescriptor fd, java.io.PrintWriter pw, java.lang.String[] args) 
      protected android.os.Message getCurrentMessage() 
      protected IState getCurrentState() 
      android.os.Handler getHandler() 
      StateMachine.LogRec getLogRec(int index) 
      int getLogRecCount() 
      int getLogRecSize() 
      protected java.lang.String getLogRecString(android.os.Message msg)
      Return a string to be logged by LogRec, default is an empty string.
      java.lang.String getName() 
      protected java.lang.String getWhatToString(int what) 
      protected void haltedProcessMessage(android.os.Message msg)
      Called for any message that is received after transitionToHalting is called.
      boolean isDbg() 
      protected boolean isQuit(android.os.Message msg)
      Validate that the message was sent by quit() or quitNow().
      protected void log(java.lang.String s)
      Log with debug
      protected void logAndAddLogRec(java.lang.String s)
      Log with debug and add to the LogRecords.
      protected void logd(java.lang.String s)
      Log with debug attribute
      protected void loge(java.lang.String s)
      Log with error attribute
      protected void loge(java.lang.String s, java.lang.Throwable e)
      Log with error attribute
      protected void logi(java.lang.String s)
      Log with info attribute
      protected void logv(java.lang.String s)
      Log with verbose attribute
      protected void logw(java.lang.String s)
      Log with warning attribute
      android.os.Message obtainMessage()
      Get a message and set Message.target state machine handler.
      android.os.Message obtainMessage(int what)
      Get a message and set Message.target state machine handler, what.
      android.os.Message obtainMessage(int what, int arg1)
      Get a message and set Message.target state machine handler, what, arg1 and arg2 Note: The handler can be null if the state machine has quit, which means target will be null and may cause a AndroidRuntimeException in MessageQueue#enqueMessage if sent directly or if sent using StateMachine#sendMessage the message will just be ignored.
      android.os.Message obtainMessage(int what, int arg1, int arg2)
      Get a message and set Message.target state machine handler, what, arg1 and arg2 Note: The handler can be null if the state machine has quit, which means target will be null and may cause a AndroidRuntimeException in MessageQueue#enqueMessage if sent directly or if sent using StateMachine#sendMessage the message will just be ignored.
      android.os.Message obtainMessage(int what, int arg1, int arg2, java.lang.Object obj)
      Get a message and set Message.target state machine handler, what, arg1, arg2 and obj Note: The handler can be null if the state machine has quit, which means target will be null and may cause a AndroidRuntimeException in MessageQueue#enqueMessage if sent directly or if sent using StateMachine#sendMessage the message will just be ignored.
      android.os.Message obtainMessage(int what, java.lang.Object obj)
      Get a message and set Message.target state machine handler, what and obj.
      protected void onHalting()
      This will be called once after handling a message that called transitionToHalting.
      protected void onQuitting()
      This will be called once after a quit message that was NOT handled by the derived StateMachine.
      protected void quit()
      Quit the state machine after all currently queued up messages are processed.
      protected void quitNow()
      Quit the state machine immediately all currently queued messages will be discarded.
      protected boolean recordLogRec(android.os.Message msg) 
      protected void removeMessages(int what)
      Removes a message from the message queue.
      void sendMessage(int what)
      Enqueue a message to this state machine.
      void sendMessage(int what, int arg1)
      Enqueue a message to this state machine.
      void sendMessage(int what, int arg1, int arg2)
      Enqueue a message to this state machine.
      void sendMessage(int what, int arg1, int arg2, java.lang.Object obj)
      Enqueue a message to this state machine.
      void sendMessage(int what, java.lang.Object obj)
      Enqueue a message to this state machine.
      void sendMessage(android.os.Message msg)
      Enqueue a message to this state machine.
      protected void sendMessageAtFrontOfQueue(int what)
      Enqueue a message to the front of the queue for this state machine.
      protected void sendMessageAtFrontOfQueue(int what, int arg1)
      Enqueue a message to the front of the queue for this state machine.
      protected void sendMessageAtFrontOfQueue(int what, int arg1, int arg2)
      Enqueue a message to the front of the queue for this state machine.
      protected void sendMessageAtFrontOfQueue(int what, int arg1, int arg2, java.lang.Object obj)
      Enqueue a message to the front of the queue for this state machine.
      protected void sendMessageAtFrontOfQueue(int what, java.lang.Object obj)
      Enqueue a message to the front of the queue for this state machine.
      protected void sendMessageAtFrontOfQueue(android.os.Message msg)
      Enqueue a message to the front of the queue for this state machine.
      void sendMessageDelayed(int what, int arg1, int arg2, long delayMillis)
      Enqueue a message to this state machine after a delay.
      void sendMessageDelayed(int what, int arg1, int arg2, java.lang.Object obj, long delayMillis)
      Enqueue a message to this state machine after a delay.
      void sendMessageDelayed(int what, int arg1, long delayMillis)
      Enqueue a message to this state machine after a delay.
      void sendMessageDelayed(int what, long delayMillis)
      Enqueue a message to this state machine after a delay.
      void sendMessageDelayed(int what, java.lang.Object obj, long delayMillis)
      Enqueue a message to this state machine after a delay.
      void sendMessageDelayed(android.os.Message msg, long delayMillis)
      Enqueue a message to this state machine after a delay.
      void setDbg(boolean dbg)
      Set debug enable/disabled.
      protected void setInitialState(State initialState)
      Set the initial state.
      void setLogOnlyTransitions(boolean enable)
      Set to log only messages that cause a state transition
      void setLogRecSize(int maxSize)
      Set number of log records to maintain and clears all current records.
      void start()
      Start the state machine.
      protected void transitionTo(IState destState)
      transition to destination state.
      protected void transitionToHaltingState()
      transition to halt state.
      protected void unhandledMessage(android.os.Message msg)
      Called when message wasn't handled
      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 字段详细资料

      • HANDLED

        public static final boolean HANDLED
        Convenience constant that maybe returned by processMessage to indicate the the message was processed and is not to be processed by parent states
        另请参阅:
        常量字段值
      • NOT_HANDLED

        public static final boolean NOT_HANDLED
        Convenience constant that maybe returned by processMessage to indicate the the message was NOT processed and is to be processed by parent states
        另请参阅:
        常量字段值
    • 构造器详细资料

      • StateMachine

        protected StateMachine(java.lang.String name)
        Constructor creates a StateMachine with its own thread.
        参数:
        name - of the state machine
      • StateMachine

        protected StateMachine(java.lang.String name,
                               android.os.Looper looper)
        Constructor creates a StateMachine using the looper.
        参数:
        name - of the state machine
      • StateMachine

        protected StateMachine(java.lang.String name,
                               android.os.Handler handler)
        Constructor creates a StateMachine using the handler.
        参数:
        name - of the state machine
    • 方法详细资料

      • addState

        protected final void addState(State state,
                                      State parent)
        Add a new state to the state machine
        参数:
        state - the state to add
        parent - the parent of state
      • addState

        protected final void addState(State state)
        Add a new state to the state machine, parent will be null
        参数:
        state - to add
      • setInitialState

        protected final void setInitialState(State initialState)
        Set the initial state. This must be invoked before and messages are sent to the state machine.
        参数:
        initialState - is the state which will receive the first message.
      • getCurrentMessage

        protected final android.os.Message getCurrentMessage()
        返回:
        current message
      • getCurrentState

        protected final IState getCurrentState()
        返回:
        current state
      • transitionTo

        protected final void transitionTo(IState destState)
        transition to destination state. Upon returning from processMessage the current state's exit will be executed and upon the next message arriving destState.enter will be invoked. this function can also be called inside the enter function of the previous transition target, but the behavior is undefined when it is called mid-way through a previous transition (for example, calling this in the enter() routine of a intermediate node when the current transition target is one of the nodes descendants).
        参数:
        destState - will be the state that receives the next message.
      • transitionToHaltingState

        protected final void transitionToHaltingState()
        transition to halt state. Upon returning from processMessage we will exit all current states, execute the onHalting() method and then for all subsequent messages haltedProcessMessage will be called.
      • deferMessage

        protected final void deferMessage(android.os.Message msg)
        Defer this message until next state transition. Upon transitioning all deferred messages will be placed on the queue and reprocessed in the original order. (i.e. The next state the oldest messages will be processed first)
        参数:
        msg - is deferred until the next transition.
      • unhandledMessage

        protected void unhandledMessage(android.os.Message msg)
        Called when message wasn't handled
        参数:
        msg - that couldn't be handled.
      • haltedProcessMessage

        protected void haltedProcessMessage(android.os.Message msg)
        Called for any message that is received after transitionToHalting is called.
      • onHalting

        protected void onHalting()
        This will be called once after handling a message that called transitionToHalting. All subsequent messages will invoke haltedProcessMessage(Message)
      • onQuitting

        protected void onQuitting()
        This will be called once after a quit message that was NOT handled by the derived StateMachine. The StateMachine will stop and any subsequent messages will be ignored. In addition, if this StateMachine created the thread, the thread will be stopped after this method returns.
      • getName

        public final java.lang.String getName()
        返回:
        the name
      • setLogRecSize

        public final void setLogRecSize(int maxSize)
        Set number of log records to maintain and clears all current records.
        参数:
        maxSize - number of messages to maintain at anyone time.
      • setLogOnlyTransitions

        public final void setLogOnlyTransitions(boolean enable)
        Set to log only messages that cause a state transition
        参数:
        enable - true to enable, false to disable
      • getLogRecSize

        public final int getLogRecSize()
        返回:
        number of log records
      • getLogRecCount

        public final int getLogRecCount()
        返回:
        the total number of records processed
      • getLogRec

        public final StateMachine.LogRec getLogRec(int index)
        返回:
        a log record, or null if index is out of range
      • copyLogRecs

        public final java.util.Collection<StateMachine.LogRec> copyLogRecs()
        返回:
        a copy of LogRecs as a collection
      • addLogRec

        protected void addLogRec(java.lang.String string)
        Add the string to LogRecords.
        参数:
        string - log
      • recordLogRec

        protected boolean recordLogRec(android.os.Message msg)
        返回:
        true if msg should be saved in the log, default is true.
      • getLogRecString

        protected java.lang.String getLogRecString(android.os.Message msg)
        Return a string to be logged by LogRec, default is an empty string. Override if additional information is desired.
        参数:
        msg - that was processed
        返回:
        information to be logged as a String
      • getWhatToString

        protected java.lang.String getWhatToString(int what)
        返回:
        the string for msg.what
      • getHandler

        public final android.os.Handler getHandler()
        返回:
        Handler, maybe null if state machine has quit.
      • obtainMessage

        public final android.os.Message obtainMessage()
        Get a message and set Message.target state machine handler. Note: The handler can be null if the state machine has quit, which means target will be null and may cause a AndroidRuntimeException in MessageQueue#enqueMessage if sent directly or if sent using StateMachine#sendMessage the message will just be ignored.
        返回:
        A Message object from the global pool
      • obtainMessage

        public final android.os.Message obtainMessage(int what)
        Get a message and set Message.target state machine handler, what. Note: The handler can be null if the state machine has quit, which means target will be null and may cause a AndroidRuntimeException in MessageQueue#enqueMessage if sent directly or if sent using StateMachine#sendMessage the message will just be ignored.
        参数:
        what - is the assigned to Message.what.
        返回:
        A Message object from the global pool
      • obtainMessage

        public final android.os.Message obtainMessage(int what,
                                                      java.lang.Object obj)
        Get a message and set Message.target state machine handler, what and obj. Note: The handler can be null if the state machine has quit, which means target will be null and may cause a AndroidRuntimeException in MessageQueue#enqueMessage if sent directly or if sent using StateMachine#sendMessage the message will just be ignored.
        参数:
        what - is the assigned to Message.what.
        obj - is assigned to Message.obj.
        返回:
        A Message object from the global pool
      • obtainMessage

        public final android.os.Message obtainMessage(int what,
                                                      int arg1)
        Get a message and set Message.target state machine handler, what, arg1 and arg2 Note: The handler can be null if the state machine has quit, which means target will be null and may cause a AndroidRuntimeException in MessageQueue#enqueMessage if sent directly or if sent using StateMachine#sendMessage the message will just be ignored.
        参数:
        what - is assigned to Message.what
        arg1 - is assigned to Message.arg1
        返回:
        A Message object from the global pool
      • obtainMessage

        public final android.os.Message obtainMessage(int what,
                                                      int arg1,
                                                      int arg2)
        Get a message and set Message.target state machine handler, what, arg1 and arg2 Note: The handler can be null if the state machine has quit, which means target will be null and may cause a AndroidRuntimeException in MessageQueue#enqueMessage if sent directly or if sent using StateMachine#sendMessage the message will just be ignored.
        参数:
        what - is assigned to Message.what
        arg1 - is assigned to Message.arg1
        arg2 - is assigned to Message.arg2
        返回:
        A Message object from the global pool
      • obtainMessage

        public final android.os.Message obtainMessage(int what,
                                                      int arg1,
                                                      int arg2,
                                                      java.lang.Object obj)
        Get a message and set Message.target state machine handler, what, arg1, arg2 and obj Note: The handler can be null if the state machine has quit, which means target will be null and may cause a AndroidRuntimeException in MessageQueue#enqueMessage if sent directly or if sent using StateMachine#sendMessage the message will just be ignored.
        参数:
        what - is assigned to Message.what
        arg1 - is assigned to Message.arg1
        arg2 - is assigned to Message.arg2
        obj - is assigned to Message.obj
        返回:
        A Message object from the global pool
      • sendMessage

        public final void sendMessage(int what)
        Enqueue a message to this state machine. Message is ignored if state machine has quit.
      • sendMessage

        public final void sendMessage(int what,
                                      java.lang.Object obj)
        Enqueue a message to this state machine. Message is ignored if state machine has quit.
      • sendMessage

        public final void sendMessage(int what,
                                      int arg1)
        Enqueue a message to this state machine. Message is ignored if state machine has quit.
      • sendMessage

        public final void sendMessage(int what,
                                      int arg1,
                                      int arg2)
        Enqueue a message to this state machine. Message is ignored if state machine has quit.
      • sendMessage

        public final void sendMessage(int what,
                                      int arg1,
                                      int arg2,
                                      java.lang.Object obj)
        Enqueue a message to this state machine. Message is ignored if state machine has quit.
      • sendMessage

        public final void sendMessage(android.os.Message msg)
        Enqueue a message to this state machine. Message is ignored if state machine has quit.
      • sendMessageDelayed

        public final void sendMessageDelayed(int what,
                                             long delayMillis)
        Enqueue a message to this state machine after a delay. Message is ignored if state machine has quit.
      • sendMessageDelayed

        public final void sendMessageDelayed(int what,
                                             java.lang.Object obj,
                                             long delayMillis)
        Enqueue a message to this state machine after a delay. Message is ignored if state machine has quit.
      • sendMessageDelayed

        public final void sendMessageDelayed(int what,
                                             int arg1,
                                             long delayMillis)
        Enqueue a message to this state machine after a delay. Message is ignored if state machine has quit.
      • sendMessageDelayed

        public final void sendMessageDelayed(int what,
                                             int arg1,
                                             int arg2,
                                             long delayMillis)
        Enqueue a message to this state machine after a delay. Message is ignored if state machine has quit.
      • sendMessageDelayed

        public final void sendMessageDelayed(int what,
                                             int arg1,
                                             int arg2,
                                             java.lang.Object obj,
                                             long delayMillis)
        Enqueue a message to this state machine after a delay. Message is ignored if state machine has quit.
      • sendMessageDelayed

        public final void sendMessageDelayed(android.os.Message msg,
                                             long delayMillis)
        Enqueue a message to this state machine after a delay. Message is ignored if state machine has quit.
      • sendMessageAtFrontOfQueue

        protected final void sendMessageAtFrontOfQueue(int what)
        Enqueue a message to the front of the queue for this state machine. Protected, may only be called by instances of StateMachine. Message is ignored if state machine has quit.
      • sendMessageAtFrontOfQueue

        protected final void sendMessageAtFrontOfQueue(int what,
                                                       java.lang.Object obj)
        Enqueue a message to the front of the queue for this state machine. Protected, may only be called by instances of StateMachine. Message is ignored if state machine has quit.
      • sendMessageAtFrontOfQueue

        protected final void sendMessageAtFrontOfQueue(int what,
                                                       int arg1)
        Enqueue a message to the front of the queue for this state machine. Protected, may only be called by instances of StateMachine. Message is ignored if state machine has quit.
      • sendMessageAtFrontOfQueue

        protected final void sendMessageAtFrontOfQueue(int what,
                                                       int arg1,
                                                       int arg2)
        Enqueue a message to the front of the queue for this state machine. Protected, may only be called by instances of StateMachine. Message is ignored if state machine has quit.
      • sendMessageAtFrontOfQueue

        protected final void sendMessageAtFrontOfQueue(int what,
                                                       int arg1,
                                                       int arg2,
                                                       java.lang.Object obj)
        Enqueue a message to the front of the queue for this state machine. Protected, may only be called by instances of StateMachine. Message is ignored if state machine has quit.
      • sendMessageAtFrontOfQueue

        protected final void sendMessageAtFrontOfQueue(android.os.Message msg)
        Enqueue a message to the front of the queue for this state machine. Protected, may only be called by instances of StateMachine. Message is ignored if state machine has quit.
      • removeMessages

        protected final void removeMessages(int what)
        Removes a message from the message queue. Protected, may only be called by instances of StateMachine.
      • isQuit

        protected final boolean isQuit(android.os.Message msg)
        Validate that the message was sent by quit() or quitNow().
      • quit

        protected final void quit()
        Quit the state machine after all currently queued up messages are processed.
      • quitNow

        protected final void quitNow()
        Quit the state machine immediately all currently queued messages will be discarded.
      • isDbg

        public boolean isDbg()
        返回:
        if debugging is enabled
      • setDbg

        public void setDbg(boolean dbg)
        Set debug enable/disabled.
        参数:
        dbg - is true to enable debugging.
      • start

        public void start()
        Start the state machine.
      • dump

        public void dump(java.io.FileDescriptor fd,
                         java.io.PrintWriter pw,
                         java.lang.String[] args)
      • logAndAddLogRec

        protected void logAndAddLogRec(java.lang.String s)
        Log with debug and add to the LogRecords.
        参数:
        s - is string log
      • log

        protected void log(java.lang.String s)
        Log with debug
        参数:
        s - is string log
      • logd

        protected void logd(java.lang.String s)
        Log with debug attribute
        参数:
        s - is string log
      • logv

        protected void logv(java.lang.String s)
        Log with verbose attribute
        参数:
        s - is string log
      • logi

        protected void logi(java.lang.String s)
        Log with info attribute
        参数:
        s - is string log
      • logw

        protected void logw(java.lang.String s)
        Log with warning attribute
        参数:
        s - is string log
      • loge

        protected void loge(java.lang.String s)
        Log with error attribute
        参数:
        s - is string log
      • loge

        protected void loge(java.lang.String s,
                            java.lang.Throwable e)
        Log with error attribute
        参数:
        s - is string log
        e - is a Throwable which logs additional information.