android.os.Message.recycle()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(2.0k)|赞(0)|评价(0)|浏览(366)

本文整理了Java中android.os.Message.recycle()方法的一些代码示例,展示了Message.recycle()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.recycle()方法的具体详情如下:
包路径:android.os.Message
类名称:Message
方法名:recycle

Message.recycle介绍

暂无

代码示例

代码示例来源:origin: ReactiveX/RxAndroid

/**
 * A {@link Scheduler} which executes actions on {@code looper}.
 *
 * @param async if true, the scheduler will use async messaging on API >= 16 to avoid VSYNC
 *              locking. On API < 16 this value is ignored.
 * @see Message#setAsynchronous(boolean)
 */
@SuppressLint("NewApi") // Checking for an @hide API.
public static Scheduler from(Looper looper, boolean async) {
  if (looper == null) throw new NullPointerException("looper == null");
  if (Build.VERSION.SDK_INT < 16) {
    async = false;
  } else if (async && Build.VERSION.SDK_INT < 22) {
    // Confirm that the method is available on this API level despite being @hide.
    Message message = Message.obtain();
    try {
      message.setAsynchronous(true);
    } catch (NoSuchMethodError e) {
      async = false;
    }
    message.recycle();
  }
  return new HandlerScheduler(new Handler(looper), async);
}

代码示例来源:origin: stackoverflow.com

class Looper{
  public static final void prepare() {
    if (sThreadLocal.get() != null) {
      throw new RuntimeException("Only one Looper may be created per thread");
    }
    sThreadLocal.set(new Looper());
  }

  public static final void loop() {
    Looper me = myLooper();
    MessageQueue queue = me.mQueue;
    while (true) {
      Message msg = queue.next(); // might block
      if (msg != null) {
        if (msg.target == null) {
          // No target is a magic identifier for the quit message.
          return;
        }
        msg.target.dispatchMessage(msg);
        msg.recycle();
      }
    }
  }
}

代码示例来源:origin: stackoverflow.com

void removeCallbacksAndMessages(Handler h, Object object) {
  if (h == null) {
    return;
  }

  synchronized (this) {
    Message p = mMessages;

    // Remove all messages at front.
    while (p != null && p.target == h
        && (object == null || p.obj == object)) {
      Message n = p.next;
      mMessages = n;
      p.recycle();
      p = n;
    }

    ...
}

代码示例来源:origin: stackoverflow.com

handler.sendMessage(message);
} else {
 message.recycle();

代码示例来源:origin: stackoverflow.com

handler.sendMessage(message);
} else {
 message.recycle();

代码示例来源:origin: stackoverflow.com

msg.recycle();

相关文章