当前位置: 首页>>代码示例>>Java>>正文


Java Looper.quit方法代码示例

本文整理汇总了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;
        }
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:31,代码来源:TestHelper.java

示例2: quitLooperOrFail

import android.os.Looper; //导入方法依赖的package包/类
public static void quitLooperOrFail() {
    Looper looper = Looper.myLooper();
    if (looper != null) {
        looper.quit();
    } else {
        Assert.fail();
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:TestHelper.java

示例3: quit

import android.os.Looper; //导入方法依赖的package包/类
public boolean quit() {
    Looper looper = getLooper();
    if (looper == null) {
        return false;
    }
    looper.quit();
    return true;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:9,代码来源:DownloadEngine.java

示例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;
    }
 
开发者ID:devyok,项目名称:EventScheduler,代码行数:14,代码来源:EventQueueThread.java

示例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();
}
 
开发者ID:brevent,项目名称:Brevent,代码行数:13,代码来源:BreventActivity.java

示例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();
        }
    }
}
 
开发者ID:fivef,项目名称:add_to_evernote_note,代码行数:34,代码来源:EvernoteUtil.java

示例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;
    }
}
 
开发者ID:simplezhli,项目名称:Tesseract-OCR-Scanner,代码行数:15,代码来源:DecodeHandler.java

示例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();
    }
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:8,代码来源:LooperCompatUtils.java

示例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();
}
 
开发者ID:feifadaima,项目名称:https-github.com-hyb1996-NoRootScriptDroid,代码行数:6,代码来源:Loopers.java

示例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);
    }
}
 
开发者ID:hoanganhtuan95ptit,项目名称:EditPhoto,代码行数:51,代码来源:TextureMovieEncoder.java

示例12: stopSensorConnection

import android.os.Looper; //导入方法依赖的package包/类
private void stopSensorConnection(Looper sensorServiceLooper) {
    onStopConnection();
    sensorServiceLooper.quit();
}
 
开发者ID:kflauri2312lffds,项目名称:Android_watch_magpie,代码行数:5,代码来源:SensorHandler.java

示例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;
}
 
开发者ID:m2049r,项目名称:xmrwallet,代码行数:27,代码来源:MoneroHandlerThread.java


注:本文中的android.os.Looper.quit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。