[DO NOT MERGE] Convert TakeScreenshot finishers Runnables to Consumer<Uri>

am: 712eb51dc9

Change-Id: I1a5cc3ceef3f95e02abcbe86fcafd56e19aedc65
This commit is contained in:
James O'Leary
2019-11-15 14:05:59 -08:00
committed by android-build-merger
4 changed files with 31 additions and 26 deletions

View File

@@ -6,6 +6,7 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.net.Uri;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
@@ -58,7 +59,7 @@ public class ScreenshotHelper {
*/
public void takeScreenshot(final int screenshotType, final boolean hasStatus,
final boolean hasNav, @NonNull Handler handler,
@Nullable Consumer<Boolean> completionConsumer) {
@Nullable Consumer<Uri> completionConsumer) {
takeScreenshot(screenshotType, hasStatus, hasNav, SCREENSHOT_TIMEOUT_MS, handler,
completionConsumer);
}
@@ -83,12 +84,12 @@ public class ScreenshotHelper {
* the screenshot attempt will be cancelled and `completionConsumer`
* will be run.
* @param handler A handler used in case the screenshot times out
* @param completionConsumer Consumes `false` if a screenshot was not taken, and `true` if the
* screenshot was taken.
* @param completionConsumer Consumes `null` if a screenshot was not taken, and the URI of the
* screenshot if the screenshot was taken.
*/
public void takeScreenshot(final int screenshotType, final boolean hasStatus,
final boolean hasNav, long timeoutMs, @NonNull Handler handler,
@Nullable Consumer<Boolean> completionConsumer) {
@Nullable Consumer<Uri> completionConsumer) {
synchronized (mScreenshotLock) {
if (mScreenshotConnection != null) {
return;
@@ -108,7 +109,7 @@ public class ScreenshotHelper {
}
}
if (completionConsumer != null) {
completionConsumer.accept(false);
completionConsumer.accept(null);
}
}
};
@@ -134,8 +135,9 @@ public class ScreenshotHelper {
handler.removeCallbacks(mScreenshotTimeout);
}
}
if (completionConsumer != null) {
completionConsumer.accept(true);
completionConsumer.accept((Uri) msg.obj);
}
}
};
@@ -148,7 +150,7 @@ public class ScreenshotHelper {
} catch (RemoteException e) {
Log.e(TAG, "Couldn't take screenshot: " + e);
if (completionConsumer != null) {
completionConsumer.accept(false);
completionConsumer.accept(null);
}
}
}