Skip to content

Commit

Permalink
Auto-update
Browse files Browse the repository at this point in the history
  • Loading branch information
google-automerger committed Jan 21, 2015
1 parent 71375cd commit 48629d5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Message;
import android.util.Log;
import android.util.Size;
import android.util.SparseIntArray;
Expand Down Expand Up @@ -314,6 +315,32 @@ public void onCaptureCompleted(CameraCaptureSession session, CaptureRequest requ

};

/**
* A {@link Handler} for showing {@link Toast}s.
*/
private Handler mMessageHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
Activity activity = getActivity();
if (activity != null) {
Toast.makeText(activity, (String) msg.obj, Toast.LENGTH_SHORT).show();
}
}
};

/**
* Shows a {@link Toast} on the UI thread.
*
* @param text The message to show
*/
private void showToast(String text) {
// We show a Toast by sending request message to mMessageHandler. This makes sure that the
// Toast is shown on the UI thread.
Message message = Message.obtain();
message.obj = text;
mMessageHandler.sendMessage(message);
}

/**
* Given {@code choices} of {@code Size}s supported by a camera, chooses the smallest one whose
* width and height are at least as large as the respective requested values, and whose aspect
Expand Down Expand Up @@ -573,10 +600,7 @@ public void onConfigured(CameraCaptureSession cameraCaptureSession) {

@Override
public void onConfigureFailed(CameraCaptureSession cameraCaptureSession) {
Activity activity = getActivity();
if (null != activity) {
Toast.makeText(activity, "Failed", Toast.LENGTH_SHORT).show();
}
showToast("Failed");
}
}, null
);
Expand Down Expand Up @@ -689,7 +713,7 @@ private void captureStillPicture() {
@Override
public void onCaptureCompleted(CameraCaptureSession session, CaptureRequest request,
TotalCaptureResult result) {
Toast.makeText(getActivity(), "Saved: " + mFile, Toast.LENGTH_SHORT).show();
showToast("Saved: " + mFile);
unlockFocus();
}
};
Expand Down
2 changes: 1 addition & 1 deletion NOTICE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
This sample uses the following software:

Copyright 2014 The Android Open Source Project
Copyright 2015 The Android Open Source Project

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down

0 comments on commit 48629d5

Please sign in to comment.