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

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

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

Message.recycle介绍

暂无

代码示例

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

  1. /**
  2. * A {@link Scheduler} which executes actions on {@code looper}.
  3. *
  4. * @param async if true, the scheduler will use async messaging on API >= 16 to avoid VSYNC
  5. * locking. On API < 16 this value is ignored.
  6. * @see Message#setAsynchronous(boolean)
  7. */
  8. @SuppressLint("NewApi") // Checking for an @hide API.
  9. public static Scheduler from(Looper looper, boolean async) {
  10. if (looper == null) throw new NullPointerException("looper == null");
  11. if (Build.VERSION.SDK_INT < 16) {
  12. async = false;
  13. } else if (async && Build.VERSION.SDK_INT < 22) {
  14. // Confirm that the method is available on this API level despite being @hide.
  15. Message message = Message.obtain();
  16. try {
  17. message.setAsynchronous(true);
  18. } catch (NoSuchMethodError e) {
  19. async = false;
  20. }
  21. message.recycle();
  22. }
  23. return new HandlerScheduler(new Handler(looper), async);
  24. }

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

  1. class Looper{
  2. public static final void prepare() {
  3. if (sThreadLocal.get() != null) {
  4. throw new RuntimeException("Only one Looper may be created per thread");
  5. }
  6. sThreadLocal.set(new Looper());
  7. }
  8. public static final void loop() {
  9. Looper me = myLooper();
  10. MessageQueue queue = me.mQueue;
  11. while (true) {
  12. Message msg = queue.next(); // might block
  13. if (msg != null) {
  14. if (msg.target == null) {
  15. // No target is a magic identifier for the quit message.
  16. return;
  17. }
  18. msg.target.dispatchMessage(msg);
  19. msg.recycle();
  20. }
  21. }
  22. }
  23. }

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

  1. void removeCallbacksAndMessages(Handler h, Object object) {
  2. if (h == null) {
  3. return;
  4. }
  5. synchronized (this) {
  6. Message p = mMessages;
  7. // Remove all messages at front.
  8. while (p != null && p.target == h
  9. && (object == null || p.obj == object)) {
  10. Message n = p.next;
  11. mMessages = n;
  12. p.recycle();
  13. p = n;
  14. }
  15. ...
  16. }

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

  1. handler.sendMessage(message);
  2. } else {
  3. message.recycle();

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

  1. handler.sendMessage(message);
  2. } else {
  3. message.recycle();

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

  1. msg.recycle();

相关文章