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

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

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

Message.setAsynchronous介绍

暂无

代码示例

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

@Override
@SuppressLint("NewApi") // Async will only be true when the API is available to call.
public Disposable schedule(Runnable run, long delay, TimeUnit unit) {
  if (run == null) throw new NullPointerException("run == null");
  if (unit == null) throw new NullPointerException("unit == null");
  if (disposed) {
    return Disposables.disposed();
  }
  run = RxJavaPlugins.onSchedule(run);
  ScheduledRunnable scheduled = new ScheduledRunnable(handler, run);
  Message message = Message.obtain(handler, scheduled);
  message.obj = this; // Used as token for batch disposal of this worker's runnables.
  if (async) {
    message.setAsynchronous(true);
  }
  handler.sendMessageDelayed(message, unit.toMillis(delay));
  // Re-check disposed state for removing in case we were racing a call to dispose().
  if (disposed) {
    handler.removeCallbacks(scheduled);
    return Disposables.disposed();
  }
  return scheduled;
}

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

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

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

private static void interceptBackKeyDown() {
  // Reset back key state for long press
  mBackKeyHandled = false;
  // Cancel multi-press detection timeout.
  if (mPanicPressOnBackBehavior) {
    if (mBackKeyPressCounter != 0
        && mBackKeyPressCounter < PANIC_PRESS_BACK_COUNT) {
      mHandler.removeMessages(MSG_BACK_DELAYED_PRESS);
    }
  }
  if (mLongPressOnBackBehavior) {
    Message msg = mHandler.obtainMessage(MSG_BACK_LONG_PRESS);
    msg.setAsynchronous(true);
    mHandler.sendMessageDelayed(msg,
        (long) XposedHelpers.callMethod(ViewConfiguration.get(mContext), "getDeviceGlobalActionKeyTimeout"));
  }
}

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

private static boolean interceptBackKeyUp(KeyEvent event) {
  // Cache handled state
  boolean handled = mBackKeyHandled;
  if (mPanicPressOnBackBehavior) {
    // Check for back key panic press
    ++mBackKeyPressCounter;
    final long eventTime = event.getDownTime();
    if (mBackKeyPressCounter <= PANIC_PRESS_BACK_COUNT) {
      // This could be a multi-press.  Wait a little bit longer to confirm.
      Message msg = mHandler.obtainMessage(MSG_BACK_DELAYED_PRESS,
          mBackKeyPressCounter, 0, eventTime);
      msg.setAsynchronous(true);
      mHandler.sendMessageDelayed(msg, MULTI_PRESS_TIMEOUT);
    }
  }
  // Reset back long press state
  cancelPendingBackKeyAction();
  return handled;
}

相关文章