<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          Tape隊(duì)列相關(guān)的Java類

          聯(lián)合創(chuàng)作 · 2023-09-28 18:31

          Tape 是一組跟隊(duì)列相關(guān)的工具類,同時(shí)也適用于 Android 平臺(tái)。

          示例代碼:

          /** Listener for starting the upload service when the queue has tasks. */
          public class ImageQueueServiceListener implements ObjectQueue.Listener<ImageUploadTask> {
            private final Context context;
          
            public ImageQueueServiceStarter(Context context) {
              this.context = context;
            }
          
            @Override public void onAdd(ObjectQueue<ImageUploadTask>, ImageUploadTask task) {
              context.startService(new Intent(context, ImageQueueService.class));
            }
          
            @Override public void onRemove(ObjectQueue<ImageUploadTask>) {}
          }
          
          /** Service which iterates through pending upload tasks one-by-one. */
          public class ImageQueueService extends Service implements ImageUploadTask.Callback {
            private TaskQueue<ImageUploadTask> queue;
            private boolean running;
          
            @Override public void onCreate() {
              super.onCreate();
              // Obtain TaskQueue here (e.g., through injection)
            }
          
            @Override public int onStartCommand(Intent intent, int flags, int startId) {
              executeNext();
              return START_STICKY;
            }
          
            public void executeNext() {
              if (running) return; // Only one task at a time.
              ImageUploadTask task = queue.peek();
              if (task != null) {
                task.execute(this);
                running = true;
                return;
              }
              stopSelf(); // We're done for now.
            }
          
            @Override public void imageUploadComplete() {
              running = false;
              queue.remove();
              executeNext();
            }
          }
          瀏覽 10
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報(bào)
          評(píng)論
          圖片
          表情
          推薦
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報(bào)
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  日韩亚洲精品在线观看视频 | 操一操撸一撸 | A级无码 A集毛片 | 未满十八18禁止免费无码网站 | 亚洲AAA黄片 |