本文整理汇总了Java中android.os.HandlerThread.quit方法的典型用法代码示例。如果您正苦于以下问题:Java HandlerThread.quit方法的具体用法?Java HandlerThread.quit怎么用?Java HandlerThread.quit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.os.HandlerThread
的用法示例。
在下文中一共展示了HandlerThread.quit方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: logoutAllUsers
import android.os.HandlerThread; //导入方法依赖的package包/类
/**
* Blocking call that logs out all users
*/
public static void logoutAllUsers() {
final CountDownLatch allUsersLoggedOut = new CountDownLatch(1);
final HandlerThread ht = new HandlerThread("LoggingOutUsersThread");
ht.start();
Handler handler = new Handler(ht.getLooper());
handler.post(new Runnable() {
@Override
public void run() {
Map<String, SyncUser> users = SyncUser.all();
for (SyncUser user : users.values()) {
user.logout();
}
allUsersLoggedOut.countDown();
}
});
TestHelper.awaitOrFail(allUsersLoggedOut);
ht.quit();
}
示例2: stopDraw
import android.os.HandlerThread; //导入方法依赖的package包/类
private void stopDraw() {
if (this.handler != null) {
this.handler.quit();
this.handler = null;
}
if (this.mHandlerThread != null) {
HandlerThread handlerThread = this.mHandlerThread;
this.mHandlerThread = null;
try {
handlerThread.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
handlerThread.quit();
}
}
示例3: stopDraw
import android.os.HandlerThread; //导入方法依赖的package包/类
private void stopDraw() {
DrawHandler handler = this.handler;
this.handler = null;
unlockCanvasAndPost();
if (handler != null) {
handler.quit();
}
if (this.mHandlerThread != null) {
HandlerThread handlerThread = this.mHandlerThread;
this.mHandlerThread = null;
try {
handlerThread.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
handlerThread.quit();
}
}
示例4: stopDraw
import android.os.HandlerThread; //导入方法依赖的package包/类
private void stopDraw() {
if (handler != null) {
handler.quit();
handler = null;
}
if (mHandlerThread != null) {
HandlerThread handlerThread = this.mHandlerThread;
mHandlerThread = null;
try {
handlerThread.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
handlerThread.quit();
}
}
示例5: stopDraw
import android.os.HandlerThread; //导入方法依赖的package包/类
private void stopDraw() {
DrawHandler handler = this.handler;
this.handler = null;
unlockCanvasAndPost();
if (handler != null) {
handler.quit();
}
if (mHandlerThread != null) {
HandlerThread handlerThread = this.mHandlerThread;
mHandlerThread = null;
try {
handlerThread.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
handlerThread.quit();
}
}
示例6: createOffer
import android.os.HandlerThread; //导入方法依赖的package包/类
/**
* Creates a offer for a newly created Realm.
*
* @param user User that should create the offer
* @param realmName Realm to create
* @param level accessLevel to offer
* @param expires when the offer expires
*/
private String createOffer(final SyncUser user, final String realmName, final AccessLevel level, final Date expires) {
final CountDownLatch offerReady = new CountDownLatch(1);
final AtomicReference<String> offer = new AtomicReference<>(null);
final HandlerThread ht = new HandlerThread("OfferThread");
ht.start();
Handler handler = new Handler(ht.getLooper());
handler.post(new Runnable() {
@Override
public void run() {
String url = createRemoteRealm(user, realmName);
final PermissionManager pm = user.getPermissionManager();
pm.makeOffer(new PermissionOffer(url, level, expires), new PermissionManager.MakeOfferCallback() {
@Override
public void onSuccess(String offerToken) {
offer.set(offerToken);
pm.close();
offerReady.countDown();
}
@Override
public void onError(ObjectServerError error) {
pm.close();
fail(error.toString());
}
});
}
});
TestHelper.awaitOrFail(offerReady);
ht.quit();
return offer.get();
}
示例7: initScreenSetupThread
import android.os.HandlerThread; //导入方法依赖的package包/类
private void initScreenSetupThread() {
mScreenSetupThread = new HandlerThread("screen_setup_thread", Thread.NORM_PRIORITY);
mScreenSetupThread.start();
mScreenSetupHandler = new Handler(mScreenSetupThread.getLooper()) {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case MSG_SCREEN_START_SCREEN_ACTIVITY: {
doScreenSetup();
break;
}
case MSG_SCREEN_INIT_PROJECTION: {
initProjection(msg.arg1, msg.arg2, mProjectionIntent);
break;
}
case MSG_SCREEN_START: {
startScreenCapture();
break;
}
case MSG_SCREEN_RELEASE: {
doScreenRelease(msg.arg1);
break;
}
case MSG_SCREEN_QUIT: {
mScreenSetupThread.quit();
}
}
}
};
}
示例8: handlerThreadShouldReceiveNotification
import android.os.HandlerThread; //导入方法依赖的package包/类
@Test
public void handlerThreadShouldReceiveNotification() throws ExecutionException, InterruptedException {
final AssertionFailedError[] assertionFailedErrors = new AssertionFailedError[1];
final CountDownLatch backgroundThreadReady = new CountDownLatch(1);
final CountDownLatch numberOfInvocation = new CountDownLatch(1);
HandlerThread handlerThread = new HandlerThread("handlerThread");
handlerThread.start();
Handler handler = new Handler(handlerThread.getLooper());
handler.post(new Runnable() {
@Override
public void run() {
try {
assertEquals("handlerThread", Thread.currentThread().getName());
} catch (AssertionFailedError e) {
assertionFailedErrors[0] = e;
}
final Realm backgroundRealm = Realm.getInstance(realmConfig);
backgroundRealm.addChangeListener(new RealmChangeListener<Realm>() {
@Override
public void onChange(Realm object) {
backgroundRealm.close();
numberOfInvocation.countDown();
}
});
backgroundThreadReady.countDown();
}
});
TestHelper.awaitOrFail(backgroundThreadReady);
// At this point the background thread started & registered the listener.
Realm realm = Realm.getInstance(realmConfig);
realm.beginTransaction();
realm.createObject(AllTypes.class);
realm.commitTransaction();
TestHelper.awaitOrFail(numberOfInvocation);
realm.close();
handlerThread.quit();
if (assertionFailedErrors[0] != null) {
throw assertionFailedErrors[0];
}
}
示例9: nonLooperThreadShouldNotifyLooperThreadAboutCommit
import android.os.HandlerThread; //导入方法依赖的package包/类
@Test
public void nonLooperThreadShouldNotifyLooperThreadAboutCommit() {
final CountDownLatch mainThreadReady = new CountDownLatch(1);
final CountDownLatch backgroundThreadClosed = new CountDownLatch(1);
final CountDownLatch numberOfInvocation = new CountDownLatch(1);
Thread thread = new Thread() {
@Override
public void run() {
TestHelper.awaitOrFail(mainThreadReady);
Realm realm = Realm.getInstance(realmConfig);
realm.beginTransaction();
realm.createObject(AllTypes.class);
realm.commitTransaction();
realm.close();
backgroundThreadClosed.countDown();
}
};
thread.start();
HandlerThread mainThread = new HandlerThread("mainThread");
mainThread.start();
Handler handler = new Handler(mainThread.getLooper());
handler.post(new Runnable() {
@Override
public void run() {
final Realm mainRealm = Realm.getInstance(realmConfig);
mainRealm.addChangeListener(new RealmChangeListener<Realm>() {
@Override
public void onChange(Realm object) {
mainRealm.close();
numberOfInvocation.countDown();
}
});
mainThreadReady.countDown();
}
});
TestHelper.awaitOrFail(numberOfInvocation);
TestHelper.awaitOrFail(backgroundThreadClosed);
mainThread.quit();
}
示例10: quit
import android.os.HandlerThread; //导入方法依赖的package包/类
/**
* Wrapper for {@link HandlerThread#quit()}.
*
* @param thread
* the handler thread.
*/
public static void quit(HandlerThread thread) {
thread.quit();
}