Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static android.Manifest.permission.CAMERA;

import android.annotation.SuppressLint;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.content.pm.ActivityInfo;
Expand Down Expand Up @@ -108,6 +109,7 @@ public void captureSample(PluginCall call) {
fragment.takeSnapshot(quality);
}

@SuppressLint("WrongConstant")
@PluginMethod
public void stop(final PluginCall call) {
bridge
Expand All @@ -120,13 +122,16 @@ public void run() {

// allow orientation changes after closing camera:
getBridge().getActivity().setRequestedOrientation(previousOrientationRequest);
getBridge().getWebView().setOnTouchListener(null);

if (containerView != null) {
((ViewGroup) getBridge().getWebView().getParent()).removeView(containerView);
getBridge().getWebView().setBackgroundColor(Color.WHITE);
FragmentManager fragmentManager = getActivity().getFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.remove(fragment);
if (fragment != null) {
fragmentTransaction.remove(fragment);
}
fragmentTransaction.commit();
fragment = null;

Expand Down Expand Up @@ -346,7 +351,6 @@ public void run() {
((ViewGroup) getBridge().getWebView().getParent()).addView(containerView);
if (toBack == true) {
getBridge().getWebView().getParent().bringChildToFront(getBridge().getWebView());
setupBroadcast();
}

FragmentManager fragmentManager = getBridge().getActivity().getFragmentManager();
Expand Down Expand Up @@ -410,9 +414,17 @@ public void onBackButton() {}

@Override
public void onCameraStarted() {
if (fragment != null && fragment.toBack) {
setupBroadcast();
}

PluginCall pluginCall = bridge.getSavedCall(cameraStartCallbackId);
pluginCall.resolve();
bridge.releaseCall(pluginCall);
if (pluginCall != null) {
pluginCall.resolve();
bridge.releaseCall(pluginCall);
} else {
Logger.warn(getLogTag(), "onCameraStarted but no saved start call (cameraStartCallbackId=" + cameraStartCallbackId + ")");
}
}

@Override
Expand Down Expand Up @@ -480,7 +492,7 @@ private void setupBroadcast() {
new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if ((null != fragment) && (fragment.toBack == true)) {
if (fragment != null && fragment.toBack && fragment.frameContainerLayout != null) {
fragment.frameContainerLayout.dispatchTouchEvent(event);
}
return false;
Expand Down