Commit 608ebbf0 by huangzhicong

增加对最大录音时长的限制,规范化对录音返回结果的处理函数

parent 8e557287
......@@ -45,7 +45,7 @@ class MainFragment : Fragment() {
savedInstanceState: Bundle?
): View? {
setFragmentResultListener(RecorderBottomSheet.REQUEST_KEY) { requestKey, bundle ->
val (uri, path) = RecorderBottomSheet.getRequest(bundle)
val (uri, path) = RecorderBottomSheet.getResult(bundle)
recordAudioContract.onResult(uri, path)
Log.d(TAG, "$requestKey, uri: $uri")
}
......
......@@ -40,7 +40,7 @@ class RecorderBottomSheet : BottomSheetDialogFragment() {
fun createRecorderBundle(maxDuration: Int): Bundle = Bundle().apply { putInt(ARG_MAX_DURATION, maxDuration) }
fun getRequest(bundle: Bundle): Pair<Uri?, String?> =
fun getResult(bundle: Bundle): Pair<Uri?, String?> =
Pair(bundle.getParcelable(request_uri), bundle.getString(request_path))
}
......@@ -94,7 +94,7 @@ class RecorderBottomSheet : BottomSheetDialogFragment() {
start = view.findViewById(R.id.start)
var maxDuration = arguments?.getInt(ARG_MAX_DURATION)
if (maxDuration == null || maxDuration == 0) {
if (maxDuration == null || maxDuration == 0 || maxDuration > DEFAULT_MAX_RECORD_TIME) {
maxDuration = DEFAULT_MAX_RECORD_TIME
}
// 显示的录音限制时长不包含最大值,因此需要-1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment