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

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

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

Message.setAsynchronous介绍

暂无

代码示例

代码示例来源: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: ReactiveX/RxAndroid

  1. @Override
  2. @SuppressLint("NewApi") // Async will only be true when the API is available to call.
  3. public Disposable schedule(Runnable run, long delay, TimeUnit unit) {
  4. if (run == null) throw new NullPointerException("run == null");
  5. if (unit == null) throw new NullPointerException("unit == null");
  6. if (disposed) {
  7. return Disposables.disposed();
  8. }
  9. run = RxJavaPlugins.onSchedule(run);
  10. ScheduledRunnable scheduled = new ScheduledRunnable(handler, run);
  11. Message message = Message.obtain(handler, scheduled);
  12. message.obj = this; // Used as token for batch disposal of this worker's runnables.
  13. if (async) {
  14. message.setAsynchronous(true);
  15. }
  16. handler.sendMessageDelayed(message, unit.toMillis(delay));
  17. // Re-check disposed state for removing in case we were racing a call to dispose().
  18. if (disposed) {
  19. handler.removeCallbacks(scheduled);
  20. return Disposables.disposed();
  21. }
  22. return scheduled;
  23. }

代码示例来源:origin: hsllany/HtmlNative

  1. public void postAsynchronous(Runnable r) {
  2. Message renderMsg = Message.obtain(mHandler, r);
  3. renderMsg.setAsynchronous(true);
  4. mHandler.sendMessage(renderMsg);
  5. }

代码示例来源:origin: wasdennnoch/AndroidN-ify

  1. private static void interceptBackKeyDown() {
  2. // Reset back key state for long press
  3. mBackKeyHandled = false;
  4. // Cancel multi-press detection timeout.
  5. if (mPanicPressOnBackBehavior) {
  6. if (mBackKeyPressCounter != 0
  7. && mBackKeyPressCounter < PANIC_PRESS_BACK_COUNT) {
  8. mHandler.removeMessages(MSG_BACK_DELAYED_PRESS);
  9. }
  10. }
  11. if (mLongPressOnBackBehavior) {
  12. Message msg = mHandler.obtainMessage(MSG_BACK_LONG_PRESS);
  13. msg.setAsynchronous(true);
  14. mHandler.sendMessageDelayed(msg,
  15. (long) XposedHelpers.callMethod(ViewConfiguration.get(mContext), "getDeviceGlobalActionKeyTimeout"));
  16. }
  17. }

代码示例来源:origin: wasdennnoch/AndroidN-ify

  1. private static boolean interceptBackKeyUp(KeyEvent event) {
  2. // Cache handled state
  3. boolean handled = mBackKeyHandled;
  4. if (mPanicPressOnBackBehavior) {
  5. // Check for back key panic press
  6. ++mBackKeyPressCounter;
  7. final long eventTime = event.getDownTime();
  8. if (mBackKeyPressCounter <= PANIC_PRESS_BACK_COUNT) {
  9. // This could be a multi-press. Wait a little bit longer to confirm.
  10. Message msg = mHandler.obtainMessage(MSG_BACK_DELAYED_PRESS,
  11. mBackKeyPressCounter, 0, eventTime);
  12. msg.setAsynchronous(true);
  13. mHandler.sendMessageDelayed(msg, MULTI_PRESS_TIMEOUT);
  14. }
  15. }
  16. // Reset back long press state
  17. cancelPendingBackKeyAction();
  18. return handled;
  19. }

相关文章