当前位置: 首页>>代码示例>>Java>>正文


Java MessageQueue类代码示例

本文整理汇总了Java中android.os.MessageQueue的典型用法代码示例。如果您正苦于以下问题:Java MessageQueue类的具体用法?Java MessageQueue怎么用?Java MessageQueue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MessageQueue类属于android.os包,在下文中一共展示了MessageQueue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onLoadResult

import android.os.MessageQueue; //导入依赖的package包/类
@Override
public void onLoadResult(File patchDirectory, int loadCode, long cost) {
    super.onLoadResult(patchDirectory, loadCode, cost);
    switch (loadCode) {
        case ShareConstants.ERROR_LOAD_OK:
            SampleTinkerReport.onLoaded(cost);
            break;
    }
    Looper.getMainLooper().myQueue().addIdleHandler(new MessageQueue.IdleHandler() {
        @Override
        public boolean queueIdle() {
            UpgradePatchRetry.getInstance(context).onPatchRetryLoad();
            return false;
        }
    });
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:SampleLoadReporter.java

示例2: onLoadResult

import android.os.MessageQueue; //导入依赖的package包/类
@Override
public void onLoadResult(File patchDirectory, int loadCode, long cost) {
    super.onLoadResult(patchDirectory, loadCode, cost);
    switch (loadCode) {
        case ShareConstants.ERROR_LOAD_OK:
            SampleTinkerReport.onLoaded(cost);
            break;
    }
    Looper.getMainLooper().myQueue().addIdleHandler(new MessageQueue.IdleHandler() {
        @Override
        public boolean queueIdle() {
            if (UpgradePatchRetry.getInstance(context).onPatchRetryLoad()) {
                SampleTinkerReport.onReportRetryPatch();
            }
            return false;
        }
    });
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:SampleLoadReporter.java

示例3: onCreate

import android.os.MessageQueue; //导入依赖的package包/类
@Override
    public void onCreate() {
        super.onCreate();
        instance = this;
        Global.init(this);
        LeakCanary.install(this);
//        CrashHandler.getInstance().init(this);
        Looper.myQueue().addIdleHandler(new MessageQueue.IdleHandler() {
            @Override
            public boolean queueIdle() {

                KeepAliveWatcher.keepAlive(BigBangApp.this);
                startService(new Intent(BigBangApp.this, ListenClipboardService.class));
                startService(new Intent(BigBangApp.this, BigBangMonitorService.class));
                return false;
            }
        });
        AppManager.getInstance(this);
    }
 
开发者ID:l465659833,项目名称:Bigbang,代码行数:20,代码来源:BigBangApp.java

示例4: queueDeferredTasksOnIdleHandler

import android.os.MessageQueue; //导入依赖的package包/类
/**
 * Add the idle handler which will run deferred startup tasks in sequence when idle. This can
 * be called multiple times by different activities to schedule their own deferred startup
 * tasks.
 */
public void queueDeferredTasksOnIdleHandler() {
    mMaxTaskDuration = 0;
    mDeferredStartupDuration = 0;
    Looper.myQueue().addIdleHandler(new MessageQueue.IdleHandler() {
        @Override
        public boolean queueIdle() {
            Runnable currentTask = mDeferredTasks.poll();
            if (currentTask == null) {
                if (mDeferredStartupInitializedForApp) {
                    mDeferredStartupCompletedForApp = true;
                    recordDeferredStartupStats();
                }
                return false;
            }

            long startTime = SystemClock.uptimeMillis();
            currentTask.run();
            long timeTaken = SystemClock.uptimeMillis() - startTime;

            mMaxTaskDuration = Math.max(mMaxTaskDuration, timeTaken);
            mDeferredStartupDuration += timeTaken;
            return true;
        }
    });
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:31,代码来源:DeferredStartupHandler.java

示例5: testInject

import android.os.MessageQueue; //导入依赖的package包/类
private void testInject() {
    Looper.myQueue().addIdleHandler(new MessageQueue.IdleHandler() {
        @Override
        public boolean queueIdle() {
            TestInject annotation = BActivity.this.getClass().getAnnotation(TestInject.class);
            if (annotation != null) {
                if (annotation.value() != null) {
                    startActivity(new Intent(BActivity.this, annotation.value()));
                }
            }
            return false;

        }
    });

}
 
开发者ID:fengdongfei,项目名称:CXJPadProject,代码行数:17,代码来源:BActivity.java

示例6: onLoadResult

import android.os.MessageQueue; //导入依赖的package包/类
/**
 * 这个是无论加载失败或者成功都会回调的接口。
 * 它返回了本次加载所用的时间、返回码等信息。
 * 默认我们只是简单的输出这个信息,你可以在这里加上监控上报逻辑。
 */
@Override
public void onLoadResult(File patchDirectory, int loadCode, long cost) {
    super.onLoadResult(patchDirectory, loadCode, cost);
    switch (loadCode) {
        case ShareConstants.ERROR_LOAD_OK:
            SampleTinkerReport.onLoaded(cost);
            break;
    }
    Looper.getMainLooper().myQueue().addIdleHandler(new MessageQueue.IdleHandler() {
        @Override
        public boolean queueIdle() {
            if (UpgradePatchRetry.getInstance(context).onPatchRetryLoad()) {
               SampleTinkerReport.onReportRetryPatch();
            }
            return false;
        }
    });
}
 
开发者ID:GitLqr,项目名称:HotFixDemo,代码行数:24,代码来源:SampleLoadReporter.java

示例7: onLoadResult

import android.os.MessageQueue; //导入依赖的package包/类
@Override
public void onLoadResult(File patchDirectory, int loadCode, long cost) {
    super.onLoadResult(patchDirectory, loadCode, cost);
    switch (loadCode) {
        case ShareConstants.ERROR_LOAD_OK:
            PatchManager.getInstance().onLoadSuccess();
            SampleTinkerReport.onLoaded(cost);
            break;

        default:
            break;
    }
    Looper.getMainLooper().myQueue().addIdleHandler(new MessageQueue.IdleHandler() {
        @Override
        public boolean queueIdle() {
            if (UpgradePatchRetry.getInstance(context).onPatchRetryLoad()) {
                SampleTinkerReport.onReportRetryPatch();
            }
            return false;
        }
    });
}
 
开发者ID:baidao,项目名称:tinker-manager,代码行数:23,代码来源:SampleLoadReporter.java

示例8: showToast

import android.os.MessageQueue; //导入依赖的package包/类
private void showToast(final FutureResult<Toast> waitingForToast) {
  mainHandler.post(new Runnable() {
    @Override public void run() {
      final Toast toast = new Toast(context);
      toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
      toast.setDuration(Toast.LENGTH_LONG);
      LayoutInflater inflater = LayoutInflater.from(context);
      toast.setView(inflater.inflate(R.layout.leak_canary_heap_dump_toast, null));
      toast.setDuration(Toast.LENGTH_LONG);
      toast.show();
      // Waiting for Idle to make sure Toast gets rendered.
      Looper.myQueue().addIdleHandler(new MessageQueue.IdleHandler() {
        @Override public boolean queueIdle() {
          waitingForToast.set(toast);
          return false;
        }
      });
    }
  });
}
 
开发者ID:shengxiadeyu,项目名称:leakcannary,代码行数:21,代码来源:AndroidHeapDumper.java

示例9: showToast

import android.os.MessageQueue; //导入依赖的package包/类
private void showToast(final FutureResult<Toast> waitingForToast) {
  mainHandler.post(new Runnable() {
    @Override public void run() {
      final Toast toast = new Toast(context);
      toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
      toast.setDuration(Toast.LENGTH_LONG);
      LayoutInflater inflater = LayoutInflater.from(context);
      toast.setView(inflater.inflate(R.layout.leak_canary_heap_dump_toast, null));
      toast.show();
      // Waiting for Idle to make sure Toast gets rendered.
      Looper.myQueue().addIdleHandler(new MessageQueue.IdleHandler() {
        @Override public boolean queueIdle() {
          waitingForToast.set(toast);
          return false;
        }
      });
    }
  });
}
 
开发者ID:liangxiwei,项目名称:LeakCanary4Eclipse,代码行数:20,代码来源:AndroidHeapDumper.java

示例10: checkTinkerUpdate

import android.os.MessageQueue; //导入依赖的package包/类
/**
 * 检查服务器是否有补丁更新
 * @param immediately 是否立刻检查,忽略时间间隔限制
 */
public static void checkTinkerUpdate(final boolean immediately) {
    if (sTinkerServerClient == null) {
        TinkerLog.e(TAG, "checkTinkerUpdate, sTinkerServerClient == null");
        return;
    }
    Tinker tinker = sTinkerServerClient.getTinker();
    //only check at the main process
    if (tinker.isMainProcess()) {
        Looper.getMainLooper().myQueue().addIdleHandler(new MessageQueue.IdleHandler() {
            @Override public boolean queueIdle() {
                sTinkerServerClient.checkTinkerUpdate(immediately);
                return false;
            }
        });
    }
}
 
开发者ID:TinkerPatch,项目名称:tinkerpatch-sdk,代码行数:21,代码来源:TinkerServerManager.java

示例11: getDynamicConfig

import android.os.MessageQueue; //导入依赖的package包/类
/**
 * 向服务器请求在线参数信息
 * @param configRequestCallback
 * @param immediately            是否立刻请求,忽略时间间隔限制
 */
public static void getDynamicConfig(final ConfigRequestCallback configRequestCallback, final boolean immediately) {
    if (sTinkerServerClient == null) {
        TinkerLog.e(TAG, "checkTinkerUpdate, sTinkerServerClient == null");
        return;
    }
    Tinker tinker = sTinkerServerClient.getTinker();
    //only check at the main process
    if (tinker.isMainProcess()) {
        Looper.getMainLooper().myQueue().addIdleHandler(new MessageQueue.IdleHandler() {
            @Override public boolean queueIdle() {
                sTinkerServerClient.getDynamicConfig(configRequestCallback, immediately);
                return false;
            }
        });
    }
}
 
开发者ID:TinkerPatch,项目名称:tinkerpatch-sdk,代码行数:22,代码来源:TinkerServerManager.java

示例12: postDeferredStartupIfNeeded

import android.os.MessageQueue; //导入依赖的package包/类
private final void postDeferredStartupIfNeeded() {
    if (!mDeferredStartupNotified) {
        // We want to perform deferred startup tasks a short time after the first page
        // load completes, but only when the main thread Looper has become idle.
        mHandler.postDelayed(new Runnable() {
            @Override
            public void run() {
                if (!mDeferredStartupNotified && !isActivityDestroyed()) {
                    mDeferredStartupNotified = true;
                    Looper.myQueue().addIdleHandler(new MessageQueue.IdleHandler() {
                        @Override
                        public boolean queueIdle() {
                            onDeferredStartup();
                            return false;  // Remove this idle handler.
                        }
                    });
                }
            }
        }, DEFERRED_STARTUP_DELAY_MS);
    }
}
 
开发者ID:Smalinuxer,项目名称:Vafrinn,代码行数:22,代码来源:ChromeActivity.java

示例13: queueDeferredTasksOnIdleHandler

import android.os.MessageQueue; //导入依赖的package包/类
/**
 * Add the idle handler which will run deferred startup tasks in sequence when idle. This can
 * be called multiple times by different activities to schedule their own deferred startup
 * tasks.
 */
public void queueDeferredTasksOnIdleHandler() {
    mMaxTaskDuration = 0;
    mDeferredStartupDuration = 0;
    Looper.myQueue().addIdleHandler(new MessageQueue.IdleHandler() {
        @Override
        public boolean queueIdle() {
            Runnable currentTask = mDeferredTasks.poll();
            if (currentTask == null) {
                if (!mDeferredStartupCompletedForApp) {
                    mDeferredStartupCompletedForApp = true;
                    recordDeferredStartupStats();
                }
                return false;
            }

            long startTime = SystemClock.uptimeMillis();
            currentTask.run();
            long timeTaken = SystemClock.uptimeMillis() - startTime;

            mMaxTaskDuration = Math.max(mMaxTaskDuration, timeTaken);
            mDeferredStartupDuration += timeTaken;
            return true;
        }
    });
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:31,代码来源:DeferredStartupHandler.java

示例14: onCreate

import android.os.MessageQueue; //导入依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();

    // Delay TracingControllerAndroid.registerReceiver() until the main loop is idle.
    Looper.myQueue().addIdleHandler(new MessageQueue.IdleHandler() {
        @Override
        public boolean queueIdle() {
            // Will retry if the native library has not been initialized.
            if (!LibraryLoader.isInitialized()) return true;

            try {
                getTracingController().registerReceiver(ContentApplication.this);
            } catch (SecurityException e) {
                // Happens if the process is isolated. Ignore.
            }
            // Remove the idle handler.
            return false;
        }
    });

    mLibraryDependenciesInitialized = true;
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:24,代码来源:ContentApplication.java

示例15: initializeQueue

import android.os.MessageQueue; //导入依赖的package包/类
private void initializeQueue() {
  if (interrogatedLooper == Looper.myLooper()) {
    interrogatedQueue = Looper.myQueue();
  } else {
    Handler oneShotHandler = new Handler(interrogatedLooper);
    FutureTask<MessageQueue> queueCapture = new FutureTask<MessageQueue>(
        new Callable<MessageQueue>() {
          @Override
          public MessageQueue call() {
            return Looper.myQueue();
          }
        });
    oneShotHandler.postAtFrontOfQueue(queueCapture);
    try {
      interrogatedQueue = queueCapture.get();
    } catch (ExecutionException ee) {
      throw propagate(ee.getCause());
    } catch (InterruptedException ie) {
      throw propagate(ie);
    }
  }
}
 
开发者ID:DocuSignDev,项目名称:android-test-kit,代码行数:23,代码来源:QueueInterrogator.java


注:本文中的android.os.MessageQueue类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。