本文整理汇总了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;
}
});
}
示例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;
}
});
}
示例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);
}
示例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;
}
});
}
示例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;
}
});
}
示例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;
}
});
}
示例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;
}
});
}
示例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;
}
});
}
});
}
示例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;
}
});
}
});
}
示例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;
}
});
}
}
示例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;
}
});
}
}
示例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);
}
}
示例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;
}
});
}
示例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;
}
示例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);
}
}
}