org.robolectric.util.Scheduler.postAtFrontOfQueue()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(4.7k)|赞(0)|评价(0)|浏览(121)

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

Scheduler.postAtFrontOfQueue介绍

[英]Add a runnable to the head of the queue.
[中]将runnable添加到队列的开头。

代码示例

代码示例来源:origin: robolectric/robolectric

/**
 * Enqueue a task to be run ahead of all other delayed tasks.
 *
 * @param runnable    the task to be run
 * @return true if the runnable is enqueued
 * @see android.os.Handler#postAtFrontOfQueue(Runnable)
 * @deprecated Use a {@link android.os.Handler} instance to post to a looper.
 */
@Deprecated
public boolean postAtFrontOfQueue(Runnable runnable) {
 if (!quit) {
  getScheduler().postAtFrontOfQueue(runnable);
  return true;
 } else {
  return false;
 }
}

代码示例来源:origin: robolectric/robolectric

@Override
 public void run() {
  order.add(1);
  scheduler.postAtFrontOfQueue(new Runnable() {
   @Override
   public void run() {
    order.add(3);
   }
  });
  order.add(2);
 }
}, 0);

代码示例来源:origin: robolectric/robolectric

@Override
 public void run() {
  order.add(1);
  scheduler.postAtFrontOfQueue(new Runnable() {
   @Override
   public void run() {
    order.add(3);
   }
  });
  order.add(2);
 }
}, 0);

代码示例来源:origin: robolectric/robolectric

@Test
public void postAtFrontOfQueue_whenUnpaused_runsJobs() throws Exception {
 scheduler.unPause();
 scheduler.postAtFrontOfQueue(new AddToTranscript("three"));
 assertThat(transcript).containsExactly("three");
}

代码示例来源:origin: robolectric/robolectric

@Test
public void postAtFrontOfQueue_addsJobAtFrontOfQueue() throws Exception {
 scheduler.post(new AddToTranscript("one"));
 scheduler.post(new AddToTranscript("two"));
 scheduler.postAtFrontOfQueue(new AddToTranscript("three"));
 scheduler.runOneTask();
 assertThat(transcript).containsExactly("three");
 transcript.clear();
 scheduler.runOneTask();
 assertThat(transcript).containsExactly("one");
 transcript.clear();
 scheduler.runOneTask();
 assertThat(transcript).containsExactly("two");
}

代码示例来源:origin: robolectric/robolectric

shadowOf(msg).setScheduledRunnable(callback);
if (when == 0) {
 scheduler.postAtFrontOfQueue(callback);
} else {
 scheduler.postDelayed(callback, when - scheduler.getCurrentTime());

代码示例来源:origin: org.robolectric/shadows-core

/**
 * Enqueue a task to be run ahead of all other delayed tasks.
 *
 * @param runnable    the task to be run
 * @return true if the runnable is enqueued
 * @see android.os.Handler#postAtFrontOfQueue(Runnable)
 * @deprecated Use a {@link android.os.Handler} instance to post to a looper.
 */
@Deprecated
public boolean postAtFrontOfQueue(Runnable runnable) {
 if (!quit) {
  getScheduler().postAtFrontOfQueue(runnable);
  return true;
 } else {
  return false;
 }
}

代码示例来源:origin: org.robolectric/shadows-core-v23

/**
 * Enqueue a task to be run ahead of all other delayed tasks.
 *
 * @param runnable    the task to be run
 * @return true if the runnable is enqueued
 * @see android.os.Handler#postAtFrontOfQueue(Runnable)
 * @deprecated Use a {@link android.os.Handler} instance to post to a looper.
 */
@Deprecated
public boolean postAtFrontOfQueue(Runnable runnable) {
 if (!quit) {
  getScheduler().postAtFrontOfQueue(runnable);
  return true;
 } else {
  return false;
 }
}

代码示例来源:origin: org.robolectric/shadows-framework

/**
 * Enqueue a task to be run ahead of all other delayed tasks.
 *
 * @param runnable    the task to be run
 * @return true if the runnable is enqueued
 * @see android.os.Handler#postAtFrontOfQueue(Runnable)
 * @deprecated Use a {@link android.os.Handler} instance to post to a looper.
 */
@Deprecated
public boolean postAtFrontOfQueue(Runnable runnable) {
 if (!quit) {
  getScheduler().postAtFrontOfQueue(runnable);
  return true;
 } else {
  return false;
 }
}

代码示例来源:origin: org.robolectric/framework

/**
 * Enqueue a task to be run ahead of all other delayed tasks.
 *
 * @param runnable    the task to be run
 * @return true if the runnable is enqueued
 * @see android.os.Handler#postAtFrontOfQueue(Runnable)
 * @deprecated Use a {@link android.os.Handler} instance to post to a looper.
 */
@Deprecated
public boolean postAtFrontOfQueue(Runnable runnable) {
 if (!quit) {
  getScheduler().postAtFrontOfQueue(runnable);
  return true;
 } else {
  return false;
 }
}

代码示例来源:origin: org.robolectric/framework

shadowOf(msg).setScheduledRunnable(callback);
if (when == 0) {
 scheduler.postAtFrontOfQueue(callback);
} else {
 scheduler.postDelayed(callback, when - scheduler.getCurrentTime());

代码示例来源:origin: org.robolectric/shadows-core

shadowOf(msg).setScheduledRunnable(callback);
if (when == 0) {
 scheduler.postAtFrontOfQueue(callback);
} else {
 scheduler.postDelayed(callback, when - scheduler.getCurrentTime());

代码示例来源:origin: org.robolectric/shadows-framework

shadowOf(msg).setScheduledRunnable(callback);
if (when == 0) {
 scheduler.postAtFrontOfQueue(callback);
} else {
 scheduler.postDelayed(callback, when - scheduler.getCurrentTime());

代码示例来源:origin: org.robolectric/shadows-core-v23

shadowOf(msg).setScheduledRunnable(callback);
if (when == 0) {
 scheduler.postAtFrontOfQueue(callback);
} else {
 scheduler.postDelayed(callback, when - scheduler.getCurrentTime());

相关文章