use of android.os.MessageQueue.IdleHandler in project android_frameworks_base by DirtyUnicorns.
the class BaseActivity method addListenerForLaunchCompletion.
/**
* Closes the activity when it's idle.
*/
private void addListenerForLaunchCompletion() {
addEventListener(new EventListener() {
@Override
public void onDirectoryNavigated(Uri uri) {
}
@Override
public void onDirectoryLoaded(Uri uri) {
removeEventListener(this);
getMainLooper().getQueue().addIdleHandler(new IdleHandler() {
@Override
public boolean queueIdle() {
// close the activity once idle, and notify the testing activity.
if (getIntent().getBooleanExtra(EXTRA_BENCHMARK, false) && BENCHMARK_TESTING_PACKAGE.equals(getCallingPackage())) {
setResult(RESULT_OK);
finish();
}
Metrics.logStartupMs(BaseActivity.this, (int) (new Date().getTime() - mStartTime));
// Remove the idle handler.
return false;
}
});
new Handler().post(new Runnable() {
@Override
public void run() {
}
});
}
});
}
use of android.os.MessageQueue.IdleHandler in project android_frameworks_base by AOSPA.
the class BaseActivity method addListenerForLaunchCompletion.
/**
* Closes the activity when it's idle.
*/
private void addListenerForLaunchCompletion() {
addEventListener(new EventListener() {
@Override
public void onDirectoryNavigated(Uri uri) {
}
@Override
public void onDirectoryLoaded(Uri uri) {
removeEventListener(this);
getMainLooper().getQueue().addIdleHandler(new IdleHandler() {
@Override
public boolean queueIdle() {
// close the activity once idle, and notify the testing activity.
if (getIntent().getBooleanExtra(EXTRA_BENCHMARK, false) && BENCHMARK_TESTING_PACKAGE.equals(getCallingPackage())) {
setResult(RESULT_OK);
finish();
}
Metrics.logStartupMs(BaseActivity.this, (int) (new Date().getTime() - mStartTime));
// Remove the idle handler.
return false;
}
});
new Handler().post(new Runnable() {
@Override
public void run() {
}
});
}
});
}
use of android.os.MessageQueue.IdleHandler in project double-espresso by JakeWharton.
the class GoogleInstrumentation method onCreate.
/**
* Sets up intent spying, lifecycle monitoring, and argument registry.
*
* Subclasses must call up to onCreate(). This oncreate method does not call start()
* it is the subclasses responsibility to call start if it desires.
*/
@Override
public void onCreate(Bundle arguments) {
Log.i(LOG_TAG, "Instrumentation Started!");
tryLoadingIntentSpy();
InstrumentationRegistry.registerInstance(this);
ActivityLifecycleMonitorRegistry.registerInstance(lifecycleMonitor);
handlerForMainLooper = new Handler(Looper.getMainLooper());
mainThread = Thread.currentThread();
executorService = Executors.newCachedThreadPool();
Looper.myQueue().addIdleHandler(idleHandler);
super.onCreate(arguments);
}
use of android.os.MessageQueue.IdleHandler in project platform_frameworks_base by android.
the class BaseActivity method addListenerForLaunchCompletion.
/**
* Closes the activity when it's idle.
*/
private void addListenerForLaunchCompletion() {
addEventListener(new EventListener() {
@Override
public void onDirectoryNavigated(Uri uri) {
}
@Override
public void onDirectoryLoaded(Uri uri) {
removeEventListener(this);
getMainLooper().getQueue().addIdleHandler(new IdleHandler() {
@Override
public boolean queueIdle() {
// close the activity once idle, and notify the testing activity.
if (getIntent().getBooleanExtra(EXTRA_BENCHMARK, false) && BENCHMARK_TESTING_PACKAGE.equals(getCallingPackage())) {
setResult(RESULT_OK);
finish();
}
Metrics.logStartupMs(BaseActivity.this, (int) (new Date().getTime() - mStartTime));
// Remove the idle handler.
return false;
}
});
new Handler().post(new Runnable() {
@Override
public void run() {
}
});
}
});
}
use of android.os.MessageQueue.IdleHandler in project double-espresso by JakeWharton.
the class LooperIdlingResource method registerIdleTransitionCallback.
@Override
public void registerIdleTransitionCallback(ResourceCallback resourceCallback) {
this.resourceCallback = resourceCallback;
// on main thread here.
queueInterrogator = new QueueInterrogator(monitoredLooper);
// must load idle handlers from monitored looper thread.
IdleHandler idleHandler = new ResourceCallbackIdleHandler(resourceCallback, queueInterrogator, monitoredHandler);
checkState(monitoredHandler.postAtFrontOfQueue(new Initializer(idleHandler)), "Monitored looper exiting.");
}
Aggregations