Skip to content

Commit df15c0b

Browse files
author
luowei
committed
Fix for CameraView blacks outs and Aspect ratio iteration issue google#125
1 parent bccd24b commit df15c0b

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

library/src/main/api14/com/google/android/cameraview/Camera1.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import java.util.List;
2727
import java.util.Set;
2828
import java.util.SortedSet;
29+
import java.util.TreeSet;
2930
import java.util.concurrent.atomic.AtomicBoolean;
3031

3132

@@ -150,7 +151,8 @@ int getFacing() {
150151
@Override
151152
Set<AspectRatio> getSupportedAspectRatios() {
152153
SizeMap idealAspectRatios = mPreviewSizes;
153-
for (AspectRatio aspectRatio : idealAspectRatios.ratios()) {
154+
Set<AspectRatio> ratios = new TreeSet<>(idealAspectRatios.ratios());
155+
for (AspectRatio aspectRatio : ratios) {
154156
if (mPictureSizes.sizes(aspectRatio) == null) {
155157
idealAspectRatios.remove(aspectRatio);
156158
}

library/src/main/java/com/google/android/cameraview/CameraView.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,10 @@ protected void onRestoreInstanceState(Parcelable state) {
243243
*/
244244
public void start() {
245245
if (!mImpl.start()) {
246+
if (mImpl.getView() != null) {
247+
this.removeView(mImpl.getView());
248+
}
249+
246250
//store the state ,and restore this state after fall back o Camera1
247251
Parcelable state = onSaveInstanceState();
248252
// Camera2 uses legacy hardware layer; fall back to Camera1

0 commit comments

Comments
 (0)