Skip to content

Commit

Permalink
修复拍照和摄影App在 后台是无法恢复
Browse files Browse the repository at this point in the history
  • Loading branch information
chengzichen committed May 25, 2017
1 parent d2f1027 commit 1fc1e1c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/local.properties
/.idea/workspace.xml
/.idea/libraries
/.idea
.DS_Store
/build
/captures
Expand Down
11 changes: 8 additions & 3 deletions gallery/src/main/java/com/dhc/gallery/ui/CameraActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,12 @@ public void onFragmentDestroy() {
return;
}
hideCamera(true);
if(cameraView!=null){
cameraView.destroy(true, null);
FrameLayout frameLayout = (FrameLayout) fragmentView;
frameLayout.removeView(cameraView);
cameraView = null;
}
fragmentView = null;
if (mBaseDialog != null)
mBaseDialog.dismiss();
Expand All @@ -123,7 +125,7 @@ public void onFragmentDestroy() {
@Override
public void didReceivedNotification(int id, Object... args) {
if (id == NotificationCenter.cameraInitied) {
checkCamera(false);
checkCamera(true);
cameraPanel.bringToFront();
recordTime.bringToFront();
}
Expand Down Expand Up @@ -156,7 +158,7 @@ public boolean onTouchEvent(MotionEvent event) {

private void initView(final Context context) {
NotificationCenter.getInstance().addObserver(this, NotificationCenter.cameraInitied);
checkCamera(false);
checkCamera(true);
if (deviceHasGoodCamera) {
CameraController.getInstance().initCamera();
}
Expand Down Expand Up @@ -546,7 +548,7 @@ public void onResume() {
if (paused) {
if (mGalleryConfig == null)
mGalleryConfig = getArguments().getParcelable(GALLERY_CONFIG);
checkCamera(false);
checkCamera(true);
cameraPanel.bringToFront();
recordTime.bringToFront();
}
Expand Down Expand Up @@ -628,6 +630,9 @@ public void hideCamera(boolean async) {
return;
}
cameraView.destroy(async, null);
FrameLayout frameLayout = (FrameLayout) fragmentView;
frameLayout.removeView(cameraView);
cameraView = null;
cameraOpened = false;
}

Expand Down

0 comments on commit 1fc1e1c

Please sign in to comment.