/// <summary>Handle system messages here.</summary> /// <remarks>Handle system messages here.</remarks> public virtual void dispatchMessage (Message msg) { if (msg.callback != null) { handleCallback (msg); } else { if (mCallback != null) { if (mCallback.handleMessage (msg)) { return; } } handleMessage (msg); } }
private void handleCallback (Message message) { message.callback.run (); }
/// <summary>Subclasses must implement this to receive messages.</summary> /// <remarks>Subclasses must implement this to receive messages.</remarks> public virtual void handleMessage (Message msg) { }
/// <summary> /// Enqueue a message at the front of the message queue, to be processed on /// the next iteration of the message loop. /// </summary> /// <remarks> /// Enqueue a message at the front of the message queue, to be processed on /// the next iteration of the message loop. You will receive it in /// <see cref="handleMessage(Message)">handleMessage(Message)</see> /// , in the thread attached to this handler. /// <b>This method is only for use in very special circumstances -- it /// can easily starve the message queue, cause ordering problems, or have /// other unexpected side-effects.</b> /// </remarks> /// <returns> /// Returns true if the message was successfully placed in to the /// message queue. Returns false on failure, usually because the /// looper processing the message queue is exiting. /// </returns> public bool sendMessageAtFrontOfQueue (Message msg) { throw new NotSupportedException (); }
/// <summary> /// Enqueue a message into the message queue after all pending messages /// before the absolute time (in milliseconds) <var>uptimeMillis</var>. /// </summary> /// <remarks> /// Enqueue a message into the message queue after all pending messages /// before the absolute time (in milliseconds) <var>uptimeMillis</var>. /// <b>The time-base is /// <see cref="SystemClock.uptimeMillis()">SystemClock.uptimeMillis()</see> /// .</b> /// You will receive it in /// <see cref="handleMessage(Message)">handleMessage(Message)</see> /// , in the thread attached /// to this handler. /// </remarks> /// <param name="uptimeMillis"> /// The absolute time at which the message should be /// delivered, using the /// <see cref="SystemClock.uptimeMillis()">SystemClock.uptimeMillis()</see> /// time-base. /// </param> /// <returns> /// Returns true if the message was successfully placed in to the /// message queue. Returns false on failure, usually because the /// looper processing the message queue is exiting. Note that a /// result of true does not mean the message will be processed -- if /// the looper is quit before the delivery time of the message /// occurs then the message will be dropped. /// </returns> public virtual bool sendMessageAtTime (Message msg, long uptimeMillis) { XobotActivityManager.SendMessage (this, msg, uptimeMillis); return true; }
/// <summary> /// Enqueue a message into the message queue after all pending messages /// before (current time + delayMillis). /// </summary> /// <remarks> /// Enqueue a message into the message queue after all pending messages /// before (current time + delayMillis). You will receive it in /// <see cref="handleMessage(Message)">handleMessage(Message)</see> /// , in the thread attached to this handler. /// </remarks> /// <returns> /// Returns true if the message was successfully placed in to the /// message queue. Returns false on failure, usually because the /// looper processing the message queue is exiting. Note that a /// result of true does not mean the message will be processed -- if /// the looper is quit before the delivery time of the message /// occurs then the message will be dropped. /// </returns> public bool sendMessageDelayed (Message msg, long delayMillis) { if (delayMillis < 0) { delayMillis = 0; } return sendMessageAtTime (msg, SystemClock.uptimeMillis () + delayMillis); }
/// <summary> /// Pushes a message onto the end of the message queue after all pending messages /// before the current time. /// </summary> /// <remarks> /// Pushes a message onto the end of the message queue after all pending messages /// before the current time. It will be received in /// <see cref="handleMessage(Message)">handleMessage(Message)</see> /// , /// in the thread attached to this handler. /// </remarks> /// <returns> /// Returns true if the message was successfully placed in to the /// message queue. Returns false on failure, usually because the /// looper processing the message queue is exiting. /// </returns> public bool sendMessage (Message msg) { return sendMessageDelayed (msg, 0); }
/// <summary>Returns a string representing the name of the specified message.</summary> /// <remarks> /// Returns a string representing the name of the specified message. /// The default implementation will either return the class name of the /// message callback if any, or the hexadecimal representation of the /// message "what" field. /// </remarks> /// <param name="message">The message whose name is being queried</param> public virtual string getMessageName (Message message) { if (message.callback != null) { return message.callback.GetType ().FullName; } return "0x" + Sharpen.Util.IntToHexString (message.what); }