RedApparat / Fotoapparat

Making Camera for Android more friendly. 📸
Apache License 2.0
3.82k stars 406 forks source link

Update parameter for focus mode doesn't seems to work #94

Closed kennywfl closed 6 years ago

kennywfl commented 7 years ago

Hi there,

I was trying to reset the focus mode to continuous mode 2 seconds after user tapped to focus by using the updateParameters method, but it doesn't change at all. Below are the code snippets of the resetting part along with the tap to focus.

private View.OnTouchListener onFocusTouchListener = new View.OnTouchListener() {
    @Override
    public boolean onTouch(View v, MotionEvent event) {
        if (event.getAction() == MotionEvent.ACTION_DOWN) {
            cvCamera.setOnTouchListener(null);
            faCamera.focus()
                    .whenDone(new PendingResult.Callback<FocusResult>() {
                        @Override
                        public void onResult(FocusResult focusResult) {
                            hideFocusIndicator();
                            cvCamera.setOnTouchListener(onFocusTouchListener);
                        }
                    });
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    faCamera.updateParameters(
                            UpdateRequest.builder()
                                    .focusMode(
                                            Selectors.firstAvailable(
                                                    FocusModeSelectors.continuousFocus(),
                                                    FocusModeSelectors.autoFocus(),
                                                    FocusModeSelectors.fixed()
                                            ))
                                    .build()
                    );
                }
            }, 2000);
            float x = event.getX();
            float y = event.getY();
            fiFocus.updateFocusIndicator((int) x, (int) y);
            showFocusIndicator();
            return true;
        }
        return false;
    }
};
dmitry-zaitsev commented 6 years ago

Your issue might've been fixed together with #96 Please try a new version of the library and if it still does not work: