android.os.Handler#getLooper ( )源码实例Demo

下面列出了android.os.Handler#getLooper ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: AndroidTvDemo   文件: ExtractorRendererBuilder.java
@Override
public void buildRenderers(DemoPlayer player) {
  Allocator allocator = new DefaultAllocator(BUFFER_SEGMENT_SIZE);
  Handler mainHandler = player.getMainHandler();

  // Build the video and audio renderers.
  DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(mainHandler, null);
  DataSource dataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
  ExtractorSampleSource sampleSource = new ExtractorSampleSource(uri, dataSource, allocator,
      BUFFER_SEGMENT_COUNT * BUFFER_SEGMENT_SIZE, mainHandler, player, 0);
  MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(context,
      sampleSource, MediaCodecSelector.DEFAULT, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000,
      mainHandler, player, 50);
  MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource,
      MediaCodecSelector.DEFAULT, null, true, mainHandler, player,
      AudioCapabilities.getCapabilities(context), AudioManager.STREAM_MUSIC);
  TrackRenderer textRenderer = new TextTrackRenderer(sampleSource, player,
      mainHandler.getLooper());

  // Invoke the callback.
  TrackRenderer[] renderers = new TrackRenderer[DemoPlayer.RENDERER_COUNT];
  renderers[DemoPlayer.TYPE_VIDEO] = videoRenderer;
  renderers[DemoPlayer.TYPE_AUDIO] = audioRenderer;
  renderers[DemoPlayer.TYPE_TEXT] = textRenderer;
  player.onRenderers(renderers, bandwidthMeter);
}
 
private void postOrRun(Handler handler, Runnable runnable) {
  if (handler.getLooper() == Looper.myLooper()) {
    runnable.run();
  } else {
    handler.post(runnable);
  }
}
 
源代码3 项目: android_9.0.0_r45   文件: WifiDisplayAdapter.java
public WifiDisplayAdapter(DisplayManagerService.SyncRoot syncRoot,
        Context context, Handler handler, Listener listener,
        PersistentDataStore persistentDataStore) {
    super(syncRoot, context, handler, listener, TAG);
    mHandler = new WifiDisplayHandler(handler.getLooper());
    mPersistentDataStore = persistentDataStore;
    mSupportsProtectedBuffers = context.getResources().getBoolean(
            com.android.internal.R.bool.config_wifiDisplaySupportsProtectedBuffers);
}
 
源代码4 项目: android_9.0.0_r45   文件: IntentFirewall.java
public IntentFirewall(AMSInterface ams, Handler handler) {
    mAms = ams;
    mHandler = new FirewallHandler(handler.getLooper());
    File rulesDir = getRulesDir();
    rulesDir.mkdirs();

    readRulesDir(rulesDir);

    mObserver = new RuleObserver(rulesDir);
    mObserver.startWatching();
}
 
源代码5 项目: 365browser   文件: AppWebMessagePort.java
@Override
public void setMessageCallback(MessageCallback messageCallback, Handler handler) {
    if (isClosed() || isTransferred()) {
        throw new IllegalStateException("Port is already closed or transferred");
    }
    mStarted = true;
    synchronized (mLock) {
        mMessageCallback = messageCallback;
        if (handler != null) {
            mHandler = new MessageHandler(handler.getLooper());
        }
    }
    nativeStartReceivingMessages(mNativeAppWebMessagePort);
}
 
源代码6 项目: android_9.0.0_r45   文件: SurfaceView.java
private void runOnUiThread(Runnable runnable) {
    Handler handler = getHandler();
    if (handler != null && handler.getLooper() != Looper.myLooper()) {
        handler.post(runnable);
    } else {
        runnable.run();
    }
}
 
源代码7 项目: android_9.0.0_r45   文件: SoundTriggerModule.java
NativeEventHandlerDelegate(final SoundTrigger.StatusListener listener,
                           Handler handler) {
    // find the looper for our new event handler
    Looper looper;
    if (handler != null) {
        looper = handler.getLooper();
    } else {
        looper = Looper.getMainLooper();
    }

    // construct the event handler with this looper
    if (looper != null) {
        // implement the event handler delegate
        mHandler = new Handler(looper) {
            @Override
            public void handleMessage(Message msg) {
                switch(msg.what) {
                case EVENT_RECOGNITION:
                    if (listener != null) {
                        listener.onRecognition(
                                (SoundTrigger.RecognitionEvent)msg.obj);
                    }
                    break;
                case EVENT_SOUNDMODEL:
                    if (listener != null) {
                        listener.onSoundModelUpdate(
                                (SoundTrigger.SoundModelEvent)msg.obj);
                    }
                    break;
                case EVENT_SERVICE_STATE_CHANGE:
                    if (listener != null) {
                        listener.onServiceStateChange(msg.arg1);
                    }
                    break;
                case EVENT_SERVICE_DIED:
                    if (listener != null) {
                        listener.onServiceDied();
                    }
                    break;
                default:
                    break;
                }
            }
        };
    } else {
        mHandler = null;
    }
}
 
源代码8 项目: CodenameOne   文件: GestureDetectorCompat.java
GestureHandler(Handler handler) {
    super(handler.getLooper());
}
 
源代码9 项目: ShareBox   文件: SmoothStreamingRendererBuilder.java
@Override
public void onSingleManifest(SmoothStreamingManifest manifest) {
  if (canceled) {
    return;
  }

  Handler mainHandler = player.getMainHandler();
  LoadControl loadControl = new DefaultLoadControl(new DefaultAllocator(BUFFER_SEGMENT_SIZE));
  DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(mainHandler, player);

  // Check drm support if necessary.
  DrmSessionManager<FrameworkMediaCrypto> drmSessionManager = null;
  if (manifest.protectionElement != null) {
    if (Util.SDK_INT < 18) {
      player.onRenderersError(
          new UnsupportedDrmException(UnsupportedDrmException.REASON_UNSUPPORTED_SCHEME));
      return;
    }
    try {
      drmSessionManager = StreamingDrmSessionManager.newFrameworkInstance(
          manifest.protectionElement.uuid, player.getPlaybackLooper(), drmCallback, null,
          player.getMainHandler(), player);
    } catch (UnsupportedDrmException e) {
      player.onRenderersError(e);
      return;
    }
  }

  // Build the video renderer.
  DataSource videoDataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
  ChunkSource videoChunkSource = new SmoothStreamingChunkSource(manifestFetcher,
      DefaultSmoothStreamingTrackSelector.newVideoInstance(context, true, false),
      videoDataSource, new AdaptiveEvaluator(bandwidthMeter), LIVE_EDGE_LATENCY_MS);
  ChunkSampleSource videoSampleSource = new ChunkSampleSource(videoChunkSource, loadControl,
      VIDEO_BUFFER_SEGMENTS * BUFFER_SEGMENT_SIZE, mainHandler, player,
      DemoPlayer.TYPE_VIDEO);
  TrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(context, videoSampleSource,
      MediaCodecSelector.DEFAULT, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000,
      drmSessionManager, true, mainHandler, player, 50);

  // Build the audio renderer.
  DataSource audioDataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
  ChunkSource audioChunkSource = new SmoothStreamingChunkSource(manifestFetcher,
      DefaultSmoothStreamingTrackSelector.newAudioInstance(),
      audioDataSource, null, LIVE_EDGE_LATENCY_MS);
  ChunkSampleSource audioSampleSource = new ChunkSampleSource(audioChunkSource, loadControl,
      AUDIO_BUFFER_SEGMENTS * BUFFER_SEGMENT_SIZE, mainHandler, player,
      DemoPlayer.TYPE_AUDIO);
  TrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(audioSampleSource,
      MediaCodecSelector.DEFAULT, drmSessionManager, true, mainHandler, player,
      AudioCapabilities.getCapabilities(context), AudioManager.STREAM_MUSIC);

  // Build the text renderer.
  DataSource textDataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
  ChunkSource textChunkSource = new SmoothStreamingChunkSource(manifestFetcher,
      DefaultSmoothStreamingTrackSelector.newTextInstance(),
      textDataSource, null, LIVE_EDGE_LATENCY_MS);
  ChunkSampleSource textSampleSource = new ChunkSampleSource(textChunkSource, loadControl,
      TEXT_BUFFER_SEGMENTS * BUFFER_SEGMENT_SIZE, mainHandler, player,
      DemoPlayer.TYPE_TEXT);
  TrackRenderer textRenderer = new TextTrackRenderer(textSampleSource, player,
      mainHandler.getLooper());

  // Invoke the callback.
  TrackRenderer[] renderers = new TrackRenderer[DemoPlayer.RENDERER_COUNT];
  renderers[DemoPlayer.TYPE_VIDEO] = videoRenderer;
  renderers[DemoPlayer.TYPE_AUDIO] = audioRenderer;
  renderers[DemoPlayer.TYPE_TEXT] = textRenderer;
  player.onRenderers(renderers, bandwidthMeter);
}
 
源代码10 项目: WliveTV   文件: HlsRendererBuilder.java
@Override
public void onSingleManifest(HlsPlaylist manifest) {
  if (canceled) {
    return;
  }

  Handler mainHandler = player.getMainHandler();
  LoadControl loadControl = new DefaultLoadControl(new DefaultAllocator(BUFFER_SEGMENT_SIZE));
  DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();

  int[] variantIndices = null;
  if (manifest instanceof HlsMasterPlaylist) {
    HlsMasterPlaylist masterPlaylist = (HlsMasterPlaylist) manifest;
    try {
      variantIndices = VideoFormatSelectorUtil.selectVideoFormatsForDefaultDisplay(
          context, masterPlaylist.variants, null, false);
    } catch (DecoderQueryException e) {
      player.onRenderersError(e);
      return;
    }
    if (variantIndices.length == 0) {
      player.onRenderersError(new IllegalStateException("No variants selected."));
      return;
    }
  }

  DataSource dataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
  HlsChunkSource chunkSource = new HlsChunkSource(dataSource, url, manifest, bandwidthMeter,
      variantIndices, HlsChunkSource.ADAPTIVE_MODE_SPLICE);
  HlsSampleSource sampleSource = new HlsSampleSource(chunkSource, loadControl,
      BUFFER_SEGMENTS * BUFFER_SEGMENT_SIZE, mainHandler, player, DemoPlayer.TYPE_VIDEO);
  MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(context,
      sampleSource, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000, mainHandler, player, 50);
  MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource,
      null, true, player.getMainHandler(), player, AudioCapabilities.getCapabilities(context));
  MetadataTrackRenderer<Map<String, Object>> id3Renderer = new MetadataTrackRenderer<>(
      sampleSource, new Id3Parser(), player, mainHandler.getLooper());
  Eia608TrackRenderer closedCaptionRenderer = new Eia608TrackRenderer(sampleSource, player,
      mainHandler.getLooper());

  TrackRenderer[] renderers = new TrackRenderer[DemoPlayer.RENDERER_COUNT];
  renderers[DemoPlayer.TYPE_VIDEO] = videoRenderer;
  renderers[DemoPlayer.TYPE_AUDIO] = audioRenderer;
  renderers[DemoPlayer.TYPE_METADATA] = id3Renderer;
  renderers[DemoPlayer.TYPE_TEXT] = closedCaptionRenderer;
  player.onRenderers(renderers, bandwidthMeter);
}
 
源代码11 项目: letv   文件: MediaControllerCompat.java
private void setHandler(Handler handler) {
    this.mHandler = new MessageHandler(handler.getLooper());
}
 
源代码12 项目: letv   文件: GestureDetectorCompat.java
GestureHandler(Handler handler) {
    super(handler.getLooper());
}
 
public VoiceInteractionSession(Context context, Handler handler) {
    mContext = context;
    mHandlerCaller = new HandlerCaller(context, handler.getLooper(),
            mCallbacks, true);
}
 
private void buildRenderers() {
    Period period = manifest.getPeriod(0);
    Handler mainHandler = player.getMainHandler();
    LoadControl loadControl = new DefaultLoadControl(new DefaultAllocator(
            BUFFER_SEGMENT_SIZE));
    DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(mainHandler, player);

    boolean hasContentProtection = false;
    for (int i = 0; i < period.adaptationSets.size(); i++) {
        AdaptationSet adaptationSet = period.adaptationSets.get(i);
        if (adaptationSet.type != AdaptationSet.TYPE_UNKNOWN) {
            hasContentProtection |= adaptationSet.hasContentProtection();
        }
    }

    // Check drm support if necessary.
    boolean filterHdContent = false;
    StreamingDrmSessionManager drmSessionManager = null;
    if (hasContentProtection) {
        if (Util.SDK_INT < 18) {
            player.onRenderersError(
                    new UnsupportedDrmException(
                            UnsupportedDrmException.REASON_UNSUPPORTED_SCHEME));
            return;
        }
        try {
            drmSessionManager = StreamingDrmSessionManager.newWidevineInstance(
                    player.getPlaybackLooper(), drmCallback, null, player.getMainHandler(),
                    player);
            filterHdContent =
                    getWidevineSecurityLevel(drmSessionManager) != SECURITY_LEVEL_1;
        } catch (UnsupportedDrmException e) {
            player.onRenderersError(e);
            return;
        }
    }

    // Build the video renderer.
    DataSource videoDataSource =
            new DefaultUriDataSource(context, bandwidthMeter, userAgent);
    ChunkSource videoChunkSource = new DashChunkSource(manifestFetcher,
            DefaultDashTrackSelector.newVideoInstance(context, true, filterHdContent),
            videoDataSource, new AdaptiveEvaluator(bandwidthMeter), LIVE_EDGE_LATENCY_MS,
            elapsedRealtimeOffset, mainHandler, player, DemoPlayer.TYPE_VIDEO);
    ChunkSampleSource videoSampleSource =
            new ChunkSampleSource(videoChunkSource, loadControl,
                    VIDEO_BUFFER_SEGMENTS * BUFFER_SEGMENT_SIZE, mainHandler, player,
                    DemoPlayer.TYPE_VIDEO);
    TrackRenderer videoRenderer =
            new MediaCodecVideoTrackRenderer(context, videoSampleSource,
                    MediaCodecSelector.DEFAULT, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT,
                    5000,
                    drmSessionManager, true, mainHandler, player, 50);

    // Build the audio renderer.
    DataSource audioDataSource =
            new DefaultUriDataSource(context, bandwidthMeter, userAgent);
    ChunkSource audioChunkSource = new DashChunkSource(manifestFetcher,
            DefaultDashTrackSelector.newAudioInstance(), audioDataSource, null,
            LIVE_EDGE_LATENCY_MS,
            elapsedRealtimeOffset, mainHandler, player, DemoPlayer.TYPE_AUDIO);
    ChunkSampleSource audioSampleSource =
            new ChunkSampleSource(audioChunkSource, loadControl,
                    AUDIO_BUFFER_SEGMENTS * BUFFER_SEGMENT_SIZE, mainHandler, player,
                    DemoPlayer.TYPE_AUDIO);
    TrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(audioSampleSource,
            MediaCodecSelector.DEFAULT, drmSessionManager, true, mainHandler, player,
            AudioCapabilities.getCapabilities(context), AudioManager.STREAM_MUSIC);

    // Build the text renderer.
    DataSource textDataSource =
            new DefaultUriDataSource(context, bandwidthMeter, userAgent);
    ChunkSource textChunkSource = new DashChunkSource(manifestFetcher,
            DefaultDashTrackSelector.newTextInstance(), textDataSource, null,
            LIVE_EDGE_LATENCY_MS,
            elapsedRealtimeOffset, mainHandler, player, DemoPlayer.TYPE_TEXT);
    ChunkSampleSource textSampleSource = new ChunkSampleSource(textChunkSource, loadControl,
            TEXT_BUFFER_SEGMENTS * BUFFER_SEGMENT_SIZE, mainHandler, player,
            DemoPlayer.TYPE_TEXT);
    TrackRenderer textRenderer = new TextTrackRenderer(textSampleSource, player,
            mainHandler.getLooper());

    // Invoke the callback.
    TrackRenderer[] renderers = new TrackRenderer[DemoPlayer.RENDERER_COUNT];
    renderers[DemoPlayer.TYPE_VIDEO] = videoRenderer;
    renderers[DemoPlayer.TYPE_AUDIO] = audioRenderer;
    renderers[DemoPlayer.TYPE_TEXT] = textRenderer;
    player.onRenderers(renderers, bandwidthMeter);
}
 
源代码15 项目: guideshow   文件: GestureDetectorCompat.java
GestureHandler(Handler handler) {
    super(handler.getLooper());
}
 
源代码16 项目: ShareBox   文件: DashRendererBuilder.java
private void buildRenderers() {
  Period period = manifest.getPeriod(0);
  Handler mainHandler = player.getMainHandler();
  LoadControl loadControl = new DefaultLoadControl(new DefaultAllocator(BUFFER_SEGMENT_SIZE));
  DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(mainHandler, player);

  boolean hasContentProtection = false;
  for (int i = 0; i < period.adaptationSets.size(); i++) {
    AdaptationSet adaptationSet = period.adaptationSets.get(i);
    if (adaptationSet.type != AdaptationSet.TYPE_UNKNOWN) {
      hasContentProtection |= adaptationSet.hasContentProtection();
    }
  }

  // Check drm support if necessary.
  boolean filterHdContent = false;
  StreamingDrmSessionManager<FrameworkMediaCrypto> drmSessionManager = null;
  if (hasContentProtection) {
    if (Util.SDK_INT < 18) {
      player.onRenderersError(
          new UnsupportedDrmException(UnsupportedDrmException.REASON_UNSUPPORTED_SCHEME));
      return;
    }
    try {
      drmSessionManager = StreamingDrmSessionManager.newWidevineInstance(
          player.getPlaybackLooper(), drmCallback, null, player.getMainHandler(), player);
      filterHdContent = getWidevineSecurityLevel(drmSessionManager) != SECURITY_LEVEL_1;
    } catch (UnsupportedDrmException e) {
      player.onRenderersError(e);
      return;
    }
  }

  // Build the video renderer.
  DataSource videoDataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
  ChunkSource videoChunkSource = new DashChunkSource(manifestFetcher,
      DefaultDashTrackSelector.newVideoInstance(context, true, filterHdContent),
      videoDataSource, new AdaptiveEvaluator(bandwidthMeter), LIVE_EDGE_LATENCY_MS,
      elapsedRealtimeOffset, mainHandler, player, DemoPlayer.TYPE_VIDEO);
  ChunkSampleSource videoSampleSource = new ChunkSampleSource(videoChunkSource, loadControl,
      VIDEO_BUFFER_SEGMENTS * BUFFER_SEGMENT_SIZE, mainHandler, player,
      DemoPlayer.TYPE_VIDEO);
  TrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(context, videoSampleSource,
      MediaCodecSelector.DEFAULT, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000,
      drmSessionManager, true, mainHandler, player, 50);

  // Build the audio renderer.
  DataSource audioDataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
  ChunkSource audioChunkSource = new DashChunkSource(manifestFetcher,
      DefaultDashTrackSelector.newAudioInstance(), audioDataSource, null, LIVE_EDGE_LATENCY_MS,
      elapsedRealtimeOffset, mainHandler, player, DemoPlayer.TYPE_AUDIO);
  ChunkSampleSource audioSampleSource = new ChunkSampleSource(audioChunkSource, loadControl,
      AUDIO_BUFFER_SEGMENTS * BUFFER_SEGMENT_SIZE, mainHandler, player,
      DemoPlayer.TYPE_AUDIO);
  TrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(audioSampleSource,
      MediaCodecSelector.DEFAULT, drmSessionManager, true, mainHandler, player,
      AudioCapabilities.getCapabilities(context), AudioManager.STREAM_MUSIC);

  // Build the text renderer.
  DataSource textDataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
  ChunkSource textChunkSource = new DashChunkSource(manifestFetcher,
      DefaultDashTrackSelector.newTextInstance(), textDataSource, null, LIVE_EDGE_LATENCY_MS,
      elapsedRealtimeOffset, mainHandler, player, DemoPlayer.TYPE_TEXT);
  ChunkSampleSource textSampleSource = new ChunkSampleSource(textChunkSource, loadControl,
      TEXT_BUFFER_SEGMENTS * BUFFER_SEGMENT_SIZE, mainHandler, player,
      DemoPlayer.TYPE_TEXT);
  TrackRenderer textRenderer = new TextTrackRenderer(textSampleSource, player,
      mainHandler.getLooper());

  // Invoke the callback.
  TrackRenderer[] renderers = new TrackRenderer[DemoPlayer.RENDERER_COUNT];
  renderers[DemoPlayer.TYPE_VIDEO] = videoRenderer;
  renderers[DemoPlayer.TYPE_AUDIO] = audioRenderer;
  renderers[DemoPlayer.TYPE_TEXT] = textRenderer;
  player.onRenderers(renderers, bandwidthMeter);
}
 
源代码17 项目: android_9.0.0_r45   文件: InputManager.java
public OnTabletModeChangedListenerDelegate(
        OnTabletModeChangedListener listener, Handler handler) {
    super(handler != null ? handler.getLooper() : Looper.myLooper());
    mListener = listener;
}
 
源代码18 项目: Camera2   文件: BlockingCameraManager.java
/**
 * Open the camera, blocking it until it succeeds or fails.
 *
 * <p>Note that the Handler provided must not be null. Furthermore, if there is a handler,
 * its Looper must not be the current thread's Looper. Otherwise we'd never receive
 * the callbacks from the CameraDevice since this function would prevent them from being
 * processed.</p>
 *
 * <p>Throws {@link CameraAccessException} for the same reason {@link CameraManager#openCamera}
 * does.</p>
 *
 * <p>Throws {@link BlockingOpenException} when the open fails asynchronously (due to
 * {@link CameraDevice.StateCallback#onDisconnected(CameraDevice)} or
 * ({@link CameraDevice.StateCallback#onError(CameraDevice)}.</p>
 *
 * <p>Throws {@link TimeoutRuntimeException} if opening times out. This is usually
 * highly unrecoverable, and all future calls to opening that camera will fail since the
 * service will think it's busy. This class will do its best to clean up eventually.</p>
 *
 * @param cameraId
 *            Id of the camera
 * @param listener
 *            Listener to the camera. onOpened, onDisconnected, onError need not be implemented.
 * @param handler
 *            Handler which to run the listener on. Must not be null.
 *
 * @return CameraDevice
 *
 * @throws IllegalArgumentException
 *            If the handler is null, or if the handler's looper is current.
 * @throws CameraAccessException
 *            If open fails immediately.
 * @throws BlockingOpenException
 *            If open fails after blocking for some amount of time.
 * @throws TimeoutRuntimeException
 *            If opening times out. Typically unrecoverable.
 */
public CameraDevice openCamera(String cameraId, CameraDevice.StateCallback listener,
        Handler handler) throws CameraAccessException, BlockingOpenException {

    if (handler == null) {
        throw new IllegalArgumentException("handler must not be null");
    } else if (handler.getLooper() == Looper.myLooper()) {
        throw new IllegalArgumentException("handler's looper must not be the current looper");
    }

    return (new OpenListener(mManager, cameraId, listener, handler)).blockUntilOpen();
}
 
源代码19 项目: xdroid   文件: ThreadUtils.java
/**
 * Creates new {@link Handler} with the same {@link Looper} as the original handler.
 *
 * @param original original handler, can not be null
 * @param callback message handling callback, may be null
 * @return new instance
 */
public static Handler newHandler(Handler original, Handler.Callback callback) {
    return new Handler(original.getLooper(), callback);
}
 
源代码20 项目: weex   文件: HandlerUtil.java
/**
 * Checks whether the current thread is the same thread that the {@link Handler} is associated
 * with.
 * @return true if the current thread is the same thread that the {@link Handler} is associated
 * with; otherwise false.
 */
public static boolean checkThreadAccess(Handler handler) {
  return Looper.myLooper() == handler.getLooper();
}