當前位置: 首頁>>代碼示例>>Java>>正文


Java HandlerThread.quit方法代碼示例

本文整理匯總了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();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:23,代碼來源:UserFactory.java

示例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();
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:17,代碼來源:DanmakuSurfaceView.java

示例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();
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:19,代碼來源:DanmakuView.java

示例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();
    }
}
 
開發者ID:lisnstatic,項目名稱:live_master,代碼行數:17,代碼來源:DanmakuSurfaceView.java

示例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();
    }
}
 
開發者ID:lisnstatic,項目名稱:live_master,代碼行數:19,代碼來源:DanmakuView.java

示例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();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:40,代碼來源:PermissionManagerTests.java

示例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();
                }
            }
        }
    };
}
 
開發者ID:AgoraIO,項目名稱:Agora-Screen-Sharing-Android,代碼行數:31,代碼來源:ScreenCapture.java

示例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];
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:44,代碼來源:NotificationsTest.java

示例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();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:42,代碼來源:NotificationsTest.java

示例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();
}
 
開發者ID:PhilippC,項目名稱:keepass2android,代碼行數:10,代碼來源:HandlerThreadCompat_v5.java


注:本文中的android.os.HandlerThread.quit方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。