Improve VideoCameraButtonView internalClickListener
This commit is contained in:
parent
5f92d70b65
commit
4b6bec4429
1 changed files with 9 additions and 22 deletions
|
@ -38,18 +38,14 @@ public class VideoCameraButtonView extends View {
|
||||||
private final RectF progressRect = new RectF();
|
private final RectF progressRect = new RectF();
|
||||||
private final RectF stopIconRect = new RectF();
|
private final RectF stopIconRect = new RectF();
|
||||||
|
|
||||||
private final @NonNull OnClickListener startRecordingClickListener = v -> {
|
private final @NonNull OnClickListener internalClickListener = v -> {
|
||||||
|
if(isRecordingVideo) {
|
||||||
notifyVideoCaptureStarted();
|
notifyVideoCaptureStarted();
|
||||||
setScaleX(1f);
|
|
||||||
setScaleY(1f);
|
|
||||||
isRecordingVideo = true;
|
isRecordingVideo = true;
|
||||||
};
|
} else {
|
||||||
|
|
||||||
private final @NonNull OnClickListener stopRecordingClickListener = v -> {
|
|
||||||
notifyVideoCaptureEnded();
|
notifyVideoCaptureEnded();
|
||||||
setScaleX(1f);
|
|
||||||
setScaleY(1f);
|
|
||||||
isRecordingVideo = false;
|
isRecordingVideo = false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public VideoCameraButtonView(@NonNull Context context) {
|
public VideoCameraButtonView(@NonNull Context context) {
|
||||||
|
@ -160,7 +156,7 @@ public class VideoCameraButtonView extends View {
|
||||||
|
|
||||||
if (videoCaptureListener != null) {
|
if (videoCaptureListener != null) {
|
||||||
this.videoCaptureListener = videoCaptureListener;
|
this.videoCaptureListener = videoCaptureListener;
|
||||||
setOnClickListener(startRecordingClickListener);
|
setOnClickListener(internalClickListener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,13 +176,4 @@ public class VideoCameraButtonView extends View {
|
||||||
videoCaptureListener.onVideoCaptureComplete();
|
videoCaptureListener.onVideoCaptureComplete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean performClick() {
|
|
||||||
if (isRecordingVideo) {
|
|
||||||
setOnClickListener(stopRecordingClickListener);
|
|
||||||
} else {
|
|
||||||
setOnClickListener(startRecordingClickListener);
|
|
||||||
}
|
|
||||||
return super.performClick();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue