本文整理汇总了Java中android.os.Looper.quit方法的典型用法代码示例。如果您正苦于以下问题:Java Looper.quit方法的具体用法?Java Looper.quit怎么用?Java Looper.quit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.os.Looper
的用法示例。
在下文中一共展示了Looper.quit方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: exitOrThrow
import android.os.Looper; //导入方法依赖的package包/类
@SuppressWarnings("Finally")
public static void exitOrThrow(ExecutorService executorService, CountDownLatch testFinishedSignal, LooperTest test) throws Throwable {
// Waits for the signal indicating the test's use case is done.
try {
// Even if this fails we want to try as hard as possible to cleanup. If we fail to close all resources
// properly, the `after()` method will most likely throw as well because it tries do delete any Realms
// used. Any exception in the `after()` code will mask the original error.
TestHelper.awaitOrFail(testFinishedSignal);
} finally {
Looper looper = test.getLooper();
if (looper != null) {
// Failing to quit the looper will not execute the finally block responsible
// of closing the Realm.
looper.quit();
}
// Waits for the finally block to execute and closes the Realm.
TestHelper.awaitOrFail(test.getRealmClosedSignal());
// Closes the executor.
// This needs to be called after waiting since it might interrupt waitRealmThreadExecutorFinish().
executorService.shutdownNow();
Throwable fault = test.getAssertionError();
if (fault != null) {
// Throws any assertion errors happened in the background thread.
throw fault;
}
}
}
示例2: quitLooperOrFail
import android.os.Looper; //导入方法依赖的package包/类
public static void quitLooperOrFail() {
Looper looper = Looper.myLooper();
if (looper != null) {
looper.quit();
} else {
Assert.fail();
}
}
示例3: quit
import android.os.Looper; //导入方法依赖的package包/类
public boolean quit() {
Looper looper = getLooper();
if (looper == null) {
return false;
}
looper.quit();
return true;
}
示例4: quit
import android.os.Looper; //导入方法依赖的package包/类
public boolean quit() {
if(mLooper == Looper.getMainLooper()) {
throw new EventSchedulerRuntimeException("main looper don't quit");
}
Looper looper = mLooper;
if (looper != null) {
looper.quit();
return true;
}
return false;
}
示例5: onDestroy
import android.os.Looper; //导入方法依赖的package包/类
@Override
protected void onDestroy() {
if (mHandler != null) {
Looper looper = mHandler.getLooper();
if (looper != null) {
looper.quit();
}
mHandler = null;
uiHandler = null;
}
super.onDestroy();
}
示例6: removeAllCookiesV21
import android.os.Looper; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private static void removeAllCookiesV21() {
final CookieManager cookieManager = CookieManager.getInstance();
Looper looper = Looper.myLooper();
boolean prepared = false;
if (looper == null) {
Looper.prepare();
prepared = true;
}
// requires a looper
cookieManager.removeAllCookies(new ValueCallback<Boolean>() {
@Override
public void onReceiveValue(Boolean value) {
Thread thread = new Thread() {
@Override
public void run() {
// is synchronous, run in background
cookieManager.flush();
}
};
thread.start();
}
});
if (prepared) {
looper = Looper.myLooper();
if (looper != null) {
looper.quit();
}
}
}
示例7: handleMessage
import android.os.Looper; //导入方法依赖的package包/类
@Override
public void handleMessage(Message message) {
switch (message.what) {
case R.id.decode:
decode((byte[]) message.obj, message.arg1, message.arg2);
break;
case R.id.quit:
Looper looper = Looper.myLooper();
if (null != looper) {
looper.quit();
}
break;
}
}
示例8: quitSafely
import android.os.Looper; //导入方法依赖的package包/类
public static void quitSafely(final Looper looper) {
if (null != METHOD_quitSafely) {
CompatUtils.invoke(looper, null /* default return value */, METHOD_quitSafely);
} else {
looper.quit();
}
}
示例9: quitLoop
import android.os.Looper; //导入方法依赖的package包/类
private void quitLoop() {
Looper looper = Looper.myLooper();
if (looper != null) {
looper.quit();
}
}
开发者ID:feifadaima,项目名称:https-github.com-hyb1996-NoRootScriptDroid,代码行数:7,代码来源:GlobalActionAutomator.java
示例10: quitForThread
import android.os.Looper; //导入方法依赖的package包/类
public static void quitForThread(Thread thread) {
Looper looper = sLoopers.remove(thread);
if (looper != null)
looper.quit();
}
示例11: handleMessage
import android.os.Looper; //导入方法依赖的package包/类
@Override // runs on encoder thread
public void handleMessage(Message inputMessage) {
int what = inputMessage.what;
Object obj = inputMessage.obj;
TextureMovieEncoder encoder = mWeakEncoder.get();
if (encoder == null) {
Log.w(TAG, "EncoderHandler.handleMessage: encoder is null");
return;
}
switch (what) {
case MSG_START_RECORDING:
encoder.handleStartRecording((EncoderConfig) obj);
break;
case MSG_STOP_RECORDING:
encoder.handleStopRecording();
break;
case MSG_SCALE_MVP_MATRIX:
encoder.handleSaleMVPMatrix((PointF) obj);
break;
case MSG_FRAME_AVAILABLE:
long timestamp =
(((long) inputMessage.arg1) << 32) | (((long) inputMessage.arg2)
& 0xffffffffL);
encoder.handleFrameAvailable((float[]) obj, timestamp);
break;
case MSG_SET_TEXTURE_ID:
encoder.handleSetTexture(inputMessage.arg1);
break;
case MSG_UPDATE_SHARED_CONTEXT:
encoder.handleUpdateSharedContext((EGLContext) inputMessage.obj);
break;
case MSG_UPDATE_FILTER:
encoder.handleUpdateFilter((FilterType) inputMessage.obj);
break;
case MSG_QUIT:
Looper looper = Looper.myLooper();
if (looper != null) {
looper.quit();
}
break;
default:
throw new RuntimeException("Unhandled msg what=" + what);
}
}
示例12: stopSensorConnection
import android.os.Looper; //导入方法依赖的package包/类
private void stopSensorConnection(Looper sensorServiceLooper) {
onStopConnection();
sensorServiceLooper.quit();
}
示例13: quit
import android.os.Looper; //导入方法依赖的package包/类
/**
* Quits the handler thread's looper.
* <p>
* Causes the handler thread's looper to terminate without processing any
* more messages in the message queue.
* </p><p>
* Any attempt to post messages to the queue after the looper is asked to quit will fail.
* For example, the {@link Handler#sendMessage(Message)} method will return false.
* </p><p class="note">
* Using this method may be unsafe because some messages may not be delivered
* before the looper terminates. Consider using {@link #quitSafely} instead to ensure
* that all pending work is completed in an orderly manner.
* </p>
*
* @return True if the looper looper has been asked to quit or false if the
* thread had not yet started running.
* @see #quitSafely
*/
public boolean quit() {
Looper looper = getLooper();
if (looper != null) {
looper.quit();
return true;
}
return false;
}