Skip to content

Commit

Permalink
#58 修复如果设置GlobalSpec.maxSelectable为null,会导致录制时没有录制声音的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
aaatttcccc committed Sep 9, 2022
1 parent 2491b97 commit 7b8e1db
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ protected void setView() {
// 处理图片、视频等需要进度显示
getPhotoVideoLayout().getViewHolder().btnConfirm.setProgressMode(true);

// 初始化cameraView,判断是否开启录制视频,如果开启就开启声音
// 初始化cameraView,判断是否开启录制视频,如果开启就开启录制声音
if (!SelectableUtils.videoValid()) {
getCameraView().setAudio(Audio.OFF);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,11 @@ object SelectableUtils {
.containsAll(ofVideo())
) {
// 是否激活视频并且总数量大于1
return GlobalSpec.maxSelectable != null && GlobalSpec.maxSelectable!! > 0
if (GlobalSpec.maxSelectable != null) {
return GlobalSpec.maxSelectable!! > 0
} else if (GlobalSpec.maxVideoSelectable != null) {
return GlobalSpec.maxVideoSelectable!! > 0
}
}
}
return false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,12 @@ class MaskProgressLayout : FrameLayout, MaskProgressApi {
* 设置最多显示多少个图片/视频/语音
*/
fun setMaxMediaCount(maxMediaCount: Int?, maxImageSelectable: Int?, maxVideoSelectable: Int?, maxAudioSelectable: Int?) {
check(!(maxMediaCount == null && maxImageSelectable == null)) { "setMaxMediaCount 方法中如果 maxMediaCount 为null,那么 maxImageSelectable 必须是0或者0以上数值" }
check(!(maxMediaCount == null && maxVideoSelectable == null)) { "setMaxMediaCount 方法中如果 maxMediaCount 为null,那么 maxVideoSelectable 必须是0或者0以上数值" }
check(!(maxMediaCount == null && maxAudioSelectable == null)) { "setMaxMediaCount 方法中如果 maxMediaCount 为null,那么 maxAudioSelectable 必须是0或者0以上数值" }
check(!(maxMediaCount != null && maxImageSelectable != null && maxImageSelectable > maxMediaCount)) { "maxMediaCount 必须比 maxImageSelectable 大" }
check(!(maxMediaCount != null && maxVideoSelectable != null && maxVideoSelectable > maxMediaCount)) { "maxMediaCount 必须比 maxVideoSelectable 大" }
check(!(maxMediaCount != null && maxAudioSelectable != null && maxAudioSelectable > maxMediaCount)) { "maxMediaCount 必须比 maxAudioSelectable 大" }
// 计算最终呈现的总数,这个总数决定是否还能点击添加
val isMaxMediaCount = maxMediaCount != null &&
(maxImageSelectable == null || maxVideoSelectable == null || maxAudioSelectable == null)
Expand Down

0 comments on commit 7b8e1db

Please sign in to comment.