Example #1
0
  private void startFaceDetection() {

    if (isFinishing()) {
      return;
    }

    mImageView.setImageBitmapResetBase(mBitmap, true);

    Util.startBackgroundJob(
        this,
        null,
        "Please wait\u2026",
        new Runnable() {
          public void run() {

            final CountDownLatch latch = new CountDownLatch(1);
            final Bitmap b = mBitmap;
            mHandler.post(
                new Runnable() {
                  public void run() {

                    if (b != mBitmap && b != null) {
                      mImageView.setImageBitmapResetBase(b, true);
                      mBitmap.recycle();
                      mBitmap = b;
                    }
                    if (mImageView.getScale() == 1F) {
                      mImageView.center(true, true);
                    }
                    latch.countDown();
                  }
                });
            try {
              latch.await();
            } catch (InterruptedException e) {
              throw new RuntimeException(e);
            }
            mRunFaceDetection.run();
          }
        },
        mHandler);
  }