解决录音按钮导致的打不开页面bug
@ -7,6 +7,10 @@
|
||||
<JetCodeStyleSettings>
|
||||
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||
</JetCodeStyleSettings>
|
||||
<codeStyleSettings language="JAVA">
|
||||
<option name="KEEP_LINE_BREAKS" value="false" />
|
||||
<option name="WRAP_LONG_LINES" value="true" />
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="XML">
|
||||
<option name="FORCE_REARRANGE_MODE" value="1" />
|
||||
<indentOptions>
|
||||
|
@ -1,5 +1,6 @@
|
||||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'com.jakewharton.butterknife'
|
||||
apply plugin: 'kotlin-android'
|
||||
android {
|
||||
compileSdkVersion rootProject.ext.gCompileSdkVersion
|
||||
defaultConfig {
|
||||
@ -114,5 +115,4 @@ dependencies {
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -597,23 +597,23 @@ public abstract class BaseActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 程序字号不随系统设置而改变
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Resources getResources() {
|
||||
Resources res = super.getResources();
|
||||
if (res != null) {
|
||||
Configuration config = res.getConfiguration();
|
||||
if (config != null && config.fontScale != 1.0f) {
|
||||
config.fontScale = 1.0f;
|
||||
res.updateConfiguration(config, res.getDisplayMetrics());
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
// /**
|
||||
// * 程序字号不随系统设置而改变
|
||||
// *
|
||||
// * @return
|
||||
// */
|
||||
// @Override
|
||||
// public Resources getResources() {
|
||||
// Resources res = super.getResources();
|
||||
// if (res != null) {
|
||||
// Configuration config = res.getConfiguration();
|
||||
// if (config != null && config.fontScale != 1.0f) {
|
||||
// config.fontScale = 1.0f;
|
||||
// res.updateConfiguration(config, res.getDisplayMetrics());
|
||||
// }
|
||||
// }
|
||||
// return res;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
|
0
baselib/src/main/java/com/tenlionsoft/baselib/core/widget/videorecord/AudioManager.java
Executable file → Normal file
0
baselib/src/main/java/com/tenlionsoft/baselib/core/widget/videorecord/AudioRecordButton.java
Executable file → Normal file
0
baselib/src/main/java/com/tenlionsoft/baselib/core/widget/videorecord/DialogManager.java
Executable file → Normal file
0
baselib/src/main/java/com/tenlionsoft/baselib/core/widget/videorecord/MediaManager.java
Executable file → Normal file
@ -0,0 +1,297 @@
|
||||
package com.tenlionsoft.baselib.core.widget.voicebutton
|
||||
|
||||
import android.content.Context
|
||||
import android.media.AudioAttributes
|
||||
import android.media.AudioFocusRequest
|
||||
import android.media.AudioManager
|
||||
import android.os.Build
|
||||
import android.os.Environment
|
||||
import android.os.Handler
|
||||
import android.util.AttributeSet
|
||||
import android.view.MotionEvent
|
||||
import androidx.appcompat.widget.AppCompatButton
|
||||
import com.tenlionsoft.baselib.core.widget.voicebutton.interfaces.MediaRecorderStateListener
|
||||
import com.tenlionsoft.baselib.core.widget.voicebutton.utils.RecordDialogManager
|
||||
import com.tenlionsoft.baselib.core.widget.voicebutton.utils.RecordManager
|
||||
import com.tenlionsoft.baselib.R
|
||||
import com.tenlionsoft.baselib.utils.LogUtils
|
||||
import java.io.File
|
||||
|
||||
|
||||
class VoiceButton @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = R.attr.buttonStyle
|
||||
) :
|
||||
AppCompatButton(context, attrs, defStyleAttr) {
|
||||
//当前状态
|
||||
private var currentState = STATE_NORMAL
|
||||
private lateinit var recordDialogManager: RecordDialogManager
|
||||
private lateinit var recordManager: RecordManager
|
||||
private val recorderStateListener: RecorderStateListener
|
||||
private var audioManager: AudioManager
|
||||
private lateinit var mFocusRequest: AudioFocusRequest
|
||||
private lateinit var mAudioAttributes: AudioAttributes
|
||||
private var audioFocusChangeListener: AudioManager.OnAudioFocusChangeListener
|
||||
|
||||
//录音中标识
|
||||
private var isRecording = false
|
||||
|
||||
//录音时间
|
||||
private var recordTime: Long = 0
|
||||
|
||||
fun setMaxRecordLength(time: Int) {
|
||||
recordManager?.let {
|
||||
it.maxRecordLength = time
|
||||
}
|
||||
}
|
||||
|
||||
//采样间隔时间
|
||||
private val samplingInterval: Long = 200
|
||||
|
||||
//最短录音时长
|
||||
private val minRecordTime: Long = 600
|
||||
private val mHandler = Handler()
|
||||
|
||||
/**
|
||||
* 更新话筒状态
|
||||
*/
|
||||
private val mUpdateMicStatusTimer = Runnable {
|
||||
while (isRecording) {
|
||||
try {
|
||||
Thread.sleep(samplingInterval)
|
||||
recordTime += samplingInterval
|
||||
mHandler.post(updateDialogRunable)
|
||||
if (recordManager.maxRecordLength - recordTime < 10 * 1000) {
|
||||
//剩余录音时间小于10秒时显示剩余录制时间提示
|
||||
if (currentState != STATE_WANT_TO_CANCEL) {
|
||||
mHandler.post(updateRemainingTimeRunable)
|
||||
}
|
||||
}
|
||||
} catch (e: InterruptedException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
private val updateDialogRunable = Runnable { //时时更新音量显示
|
||||
recordDialogManager.updateVoiceLevel(recordManager.getVoiceLevel(6))
|
||||
}
|
||||
private val updateRemainingTimeRunable = Runnable { //时时更新剩余录音时间显示
|
||||
recordDialogManager.updateRemainingTime((recordManager.maxRecordLength - recordTime).toInt() / 1000)
|
||||
}
|
||||
private val dismissDialogRunable = Runnable { recordDialogManager.dimissDialog() }
|
||||
|
||||
/**
|
||||
* 录音完成后的回调接口
|
||||
*/
|
||||
interface RecorderListener {
|
||||
//开始录音
|
||||
fun onStart()
|
||||
|
||||
//录音时长和文件保存路径
|
||||
fun onFinish(time: Long, filePath: String?)
|
||||
}
|
||||
|
||||
private var recorderListener: RecorderListener? = null
|
||||
fun setRecorderListener(recorderListener: RecorderListener?) {
|
||||
this.recorderListener = recorderListener
|
||||
}
|
||||
|
||||
override fun onTouchEvent(event: MotionEvent): Boolean {
|
||||
//获取手势类型及触摸位置坐标
|
||||
val action = event.action
|
||||
val y = event.y
|
||||
when (action) {
|
||||
MotionEvent.ACTION_DOWN -> setText(R.string.str_recorder_recording)
|
||||
MotionEvent.ACTION_MOVE -> if (isRecording) {
|
||||
//根据x,y的坐标判断是否需要取消
|
||||
if (wantToCancel(y)) {
|
||||
changeState(STATE_WANT_TO_CANCEL)
|
||||
} else {
|
||||
changeState(STATE_RECORDING)
|
||||
}
|
||||
}
|
||||
MotionEvent.ACTION_CANCEL, MotionEvent.ACTION_UP -> {
|
||||
//如果longclick(录音)操作没触发
|
||||
if (currentState == STATE_NORMAL) {
|
||||
LogUtils.e("未触发录音或者录音达到最大时长已经结束")
|
||||
releaseAudioFocus()
|
||||
setText(R.string.str_recorder_normal)
|
||||
resetRecordState()
|
||||
return super.onTouchEvent(event)
|
||||
}
|
||||
//触发了onlongclick(录音)操作,但录音控件没有准备好(即prepare()、start()方法未执行完)或者录音时间过短所以删除文件夹
|
||||
if (currentState == STATE_PREPAREING || recordTime < minRecordTime) {
|
||||
LogUtils.e("未初始化完成或者录音太短")
|
||||
releaseAudioFocus()
|
||||
recordDialogManager.showRocordTooShortDialog()
|
||||
recordManager.cancel()
|
||||
mHandler.postDelayed(dismissDialogRunable, 1000)
|
||||
} else if (currentState == STATE_RECORDING) {
|
||||
LogUtils.e("正常录制结束")
|
||||
releaseAudioFocus()
|
||||
//正常录制结束
|
||||
recordManager.release()
|
||||
recordDialogManager.dimissDialog()
|
||||
if (recorderListener != null) {
|
||||
recorderListener!!.onFinish(
|
||||
recordTime,
|
||||
recordManager.recordAbsoluteFileDir
|
||||
)
|
||||
}
|
||||
} else if (currentState == STATE_WANT_TO_CANCEL) {
|
||||
LogUtils.e("滑动取消了录制")
|
||||
releaseAudioFocus()
|
||||
//想要取消录制
|
||||
recordManager.cancel()
|
||||
recordDialogManager.dimissDialog()
|
||||
}
|
||||
resetRecordState()
|
||||
}
|
||||
}
|
||||
return super.onTouchEvent(event)
|
||||
}
|
||||
|
||||
//判断是否想取消录制
|
||||
private fun wantToCancel(y: Float): Boolean {
|
||||
//如果上下滑出 button 加上我们自定义的距离
|
||||
return y < -DISTANCE_Y_CANCEL
|
||||
}
|
||||
|
||||
//改变状态
|
||||
private fun changeState(state: Int) {
|
||||
if (currentState != state) {
|
||||
currentState = state
|
||||
when (state) {
|
||||
STATE_NORMAL -> setText(R.string.str_recorder_normal)
|
||||
STATE_PREPAREING -> recordDialogManager.showPrepareDialog()
|
||||
STATE_RECORDING -> {
|
||||
setText(R.string.str_recorder_recording)
|
||||
if (isRecording) {
|
||||
recordDialogManager.showRecordingDialog()
|
||||
}
|
||||
}
|
||||
STATE_WANT_TO_CANCEL -> {
|
||||
setText(R.string.str_recorder_want_cancel)
|
||||
recordDialogManager.showCancelRecording()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 恢复录音状态、标志位
|
||||
*/
|
||||
private fun resetRecordState() {
|
||||
changeState(STATE_NORMAL)
|
||||
isRecording = false
|
||||
recordTime = 0
|
||||
}
|
||||
|
||||
private inner class RecorderStateListener : MediaRecorderStateListener {
|
||||
override fun onError(what: Int, extra: Int) {
|
||||
LogUtils.e("录音出错了=====>what:$what,extra:$extra")
|
||||
}
|
||||
|
||||
override fun wellPrepared() {
|
||||
recorderListener?.run {
|
||||
requestAudioFocus()
|
||||
onStart()
|
||||
}
|
||||
isRecording = true
|
||||
changeState(STATE_RECORDING)
|
||||
//开启线程实时更新音量
|
||||
Thread(mUpdateMicStatusTimer).start()
|
||||
}
|
||||
|
||||
override fun onStop(filePath: String?) {
|
||||
LogUtils.e("录音停止了=====>filePath:$filePath")
|
||||
}
|
||||
|
||||
override fun onReachMaxRecordTime(filePath: String?) {
|
||||
//到达最大录制时间录制结束
|
||||
recordManager.release()
|
||||
recordDialogManager.dimissDialog()
|
||||
if (recorderListener != null) {
|
||||
recorderListener!!.onFinish(recordTime, filePath)
|
||||
}
|
||||
resetRecordState()
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val TAG = "VoiceButton"
|
||||
|
||||
//手指滑动指定距离后判定取消录音
|
||||
private const val DISTANCE_Y_CANCEL = 100f
|
||||
|
||||
//录音状态
|
||||
private const val STATE_NORMAL = 1 //默认状态
|
||||
private const val STATE_PREPAREING = 2 //录音控件准备状态
|
||||
private const val STATE_RECORDING = 3 //录制
|
||||
private const val STATE_WANT_TO_CANCEL = 4 //取消录制
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造函数
|
||||
*
|
||||
* @param context
|
||||
*/
|
||||
init {
|
||||
recordDialogManager = RecordDialogManager(context)
|
||||
recorderStateListener = RecorderStateListener()
|
||||
audioManager =
|
||||
context.applicationContext.getSystemService(Context.AUDIO_SERVICE) as AudioManager
|
||||
audioFocusChangeListener = AudioManager.OnAudioFocusChangeListener { }
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
mAudioAttributes = AudioAttributes.Builder()
|
||||
.setUsage(AudioAttributes.USAGE_MEDIA)
|
||||
.setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
|
||||
.build();
|
||||
mFocusRequest =
|
||||
AudioFocusRequest.Builder(AudioManager.AUDIOFOCUS_GAIN_TRANSIENT_EXCLUSIVE)
|
||||
.setAudioAttributes(mAudioAttributes)
|
||||
.setOnAudioFocusChangeListener(audioFocusChangeListener)
|
||||
.build();
|
||||
}
|
||||
var saveFile: File? = null
|
||||
/* 判断sd的外部设置状态是否可以读写 */saveFile =
|
||||
if (Environment.getExternalStorageState() == Environment.MEDIA_MOUNTED) {
|
||||
File(context.getExternalFilesDir(null), "recorder_audios")
|
||||
} else {
|
||||
File(context.filesDir, "recorder_audios")
|
||||
}
|
||||
if (!saveFile.exists()) {
|
||||
saveFile.mkdirs()
|
||||
}
|
||||
recordManager = RecordManager(saveFile.path)
|
||||
recordManager.setMediaRecorderStateListener(recorderStateListener)
|
||||
//按钮长按准备录音包括start
|
||||
setOnLongClickListener {
|
||||
changeState(STATE_PREPAREING)
|
||||
recordManager.prepareAudio()
|
||||
false
|
||||
}
|
||||
setText(R.string.str_recorder_normal)
|
||||
}
|
||||
|
||||
fun requestAudioFocus() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
audioManager.requestAudioFocus(mFocusRequest);
|
||||
} else {
|
||||
audioManager.requestAudioFocus(
|
||||
audioFocusChangeListener,
|
||||
AudioManager.STREAM_MUSIC,
|
||||
AudioManager.AUDIOFOCUS_GAIN_TRANSIENT_EXCLUSIVE
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fun releaseAudioFocus() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
audioManager.abandonAudioFocusRequest(mFocusRequest);
|
||||
} else {
|
||||
audioManager.abandonAudioFocus(audioFocusChangeListener);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package com.tenlionsoft.baselib.core.widget.voicebutton.interfaces
|
||||
|
||||
/**
|
||||
* MediaRecorder准备完毕回调接口
|
||||
*/
|
||||
interface MediaRecorderStateListener {
|
||||
/**
|
||||
* 设备异常
|
||||
*/
|
||||
fun onError(what: Int, extra: Int)
|
||||
|
||||
/**
|
||||
* 设备准备好
|
||||
*/
|
||||
fun wellPrepared()
|
||||
|
||||
/**
|
||||
* 停止录音
|
||||
*
|
||||
* @param filePath 保存路径
|
||||
*/
|
||||
fun onStop(filePath: String?)
|
||||
|
||||
/**
|
||||
* 到达最大录音时长
|
||||
*
|
||||
* @param filePath 保存路径
|
||||
*/
|
||||
fun onReachMaxRecordTime(filePath: String?)
|
||||
}
|
@ -0,0 +1,124 @@
|
||||
package com.tenlionsoft.baselib.core.widget.voicebutton.utils
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import android.widget.ProgressBar
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import com.tenlionsoft.baselib.R
|
||||
|
||||
//录音dialog管理类
|
||||
class RecordDialogManager(private val mContext: Context) {
|
||||
private var mDialog: AlertDialog? = null
|
||||
|
||||
//录音麦克风标志
|
||||
private var mIcon: ImageView? = null
|
||||
|
||||
//录音音量标志
|
||||
private var mVoice: ImageView? = null
|
||||
|
||||
//录音提示
|
||||
private var mLable: TextView? = null
|
||||
|
||||
//准备录音标志
|
||||
private var mProgressBar: ProgressBar? = null
|
||||
|
||||
//显示准备录音dialog
|
||||
fun showPrepareDialog() {
|
||||
if (mDialog == null) {
|
||||
val builder =
|
||||
AlertDialog.Builder(mContext, R.style.Theme_RecordDialog)
|
||||
val inflater = LayoutInflater.from(mContext)
|
||||
val view = inflater.inflate(R.layout.dialog_recorder, null)
|
||||
mIcon = view.findViewById(R.id.iv_recorder_icon)
|
||||
mVoice = view.findViewById(R.id.iv_recorder_voice)
|
||||
mLable = view.findViewById(R.id.tv_recorder_label)
|
||||
mProgressBar = view.findViewById(R.id.progressBar)
|
||||
mIcon!!.visibility = View.GONE
|
||||
mVoice!!.visibility = View.GONE
|
||||
mLable!!.visibility = View.GONE
|
||||
mProgressBar!!.visibility = View.VISIBLE
|
||||
builder.setView(view)
|
||||
mDialog = builder.create()
|
||||
mDialog!!.setCancelable(false)
|
||||
mDialog!!.setCanceledOnTouchOutside(false)
|
||||
mDialog!!.show()
|
||||
}
|
||||
}
|
||||
|
||||
//显示录音dialog
|
||||
fun showRecordingDialog() {
|
||||
if (mDialog != null && mDialog!!.isShowing) {
|
||||
mIcon!!.setImageResource(R.drawable.ic_recorder)
|
||||
mIcon!!.visibility = View.VISIBLE
|
||||
mVoice!!.visibility = View.VISIBLE
|
||||
mLable!!.visibility = View.VISIBLE
|
||||
mProgressBar!!.visibility = View.INVISIBLE
|
||||
mLable!!.setText(R.string.str_recorder_swip_cancel)
|
||||
mLable!!.setBackgroundColor(Color.TRANSPARENT)
|
||||
}
|
||||
}
|
||||
|
||||
//想要取消
|
||||
fun showCancelRecording() {
|
||||
if (mDialog != null && mDialog!!.isShowing) {
|
||||
mIcon!!.setImageResource(R.drawable.record_cancel)
|
||||
mIcon!!.visibility = View.VISIBLE
|
||||
mVoice!!.visibility = View.GONE
|
||||
mLable!!.setText(R.string.str_recorder_want_cancel)
|
||||
mLable!!.setBackgroundResource(R.color.colorDarkOrange)
|
||||
mLable!!.visibility = View.VISIBLE
|
||||
mProgressBar!!.visibility = View.INVISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
//录音时间太短
|
||||
fun showRocordTooShortDialog() {
|
||||
if (mDialog != null && mDialog!!.isShowing) {
|
||||
mIcon!!.setImageResource(R.drawable.voice_to_short)
|
||||
mLable!!.setText(R.string.str_recorder_too_short)
|
||||
mIcon!!.visibility = View.VISIBLE
|
||||
mVoice!!.visibility = View.GONE
|
||||
mLable!!.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
//关闭dialog
|
||||
fun dimissDialog() {
|
||||
if (mDialog != null && mDialog!!.isShowing) {
|
||||
mDialog!!.dismiss()
|
||||
mDialog = null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过level更新voice上的图片
|
||||
*
|
||||
* @param level
|
||||
*/
|
||||
fun updateVoiceLevel(level: Int) {
|
||||
if (mDialog != null && mDialog!!.isShowing) {
|
||||
val resId = mContext.resources
|
||||
.getIdentifier("volume_$level", "drawable", mContext.packageName)
|
||||
mVoice!!.setImageResource(resId)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启倒计时通知
|
||||
*
|
||||
* @param time
|
||||
*/
|
||||
fun updateRemainingTime(time: Int) {
|
||||
if (mDialog != null && mDialog!!.isShowing) {
|
||||
mLable!!.visibility = View.VISIBLE
|
||||
mLable!!.text = String.format(
|
||||
mContext.resources.getString(R.string.time_remaining), time + 1
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,131 @@
|
||||
package com.tenlionsoft.baselib.core.widget.voicebutton.utils
|
||||
|
||||
import android.media.MediaRecorder
|
||||
import com.tenlionsoft.baselib.core.widget.voicebutton.interfaces.MediaRecorderStateListener
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
import java.util.*
|
||||
import kotlin.math.log10
|
||||
|
||||
class RecordManager(
|
||||
//音频文件存储目录
|
||||
private val recordFileDir: String
|
||||
) {
|
||||
|
||||
//音频文件绝对存储路径
|
||||
var recordAbsoluteFileDir: String? = null
|
||||
private set
|
||||
|
||||
//通过MediaRecorder实现录音功能
|
||||
private var mediaRecorder: MediaRecorder? = null
|
||||
|
||||
// 最大录音时长,默认1000*60(一分钟)
|
||||
var maxRecordLength = 1000 * 60
|
||||
|
||||
//录音控件初始化状态标志
|
||||
private var isPrepared = false
|
||||
|
||||
//音量分级标准
|
||||
private val volumeBase: Long = 600
|
||||
private var mediaRecorderStateListener: MediaRecorderStateListener? = null
|
||||
fun setMediaRecorderStateListener(mediaRecorderStateListener: MediaRecorderStateListener?) {
|
||||
this.mediaRecorderStateListener = mediaRecorderStateListener
|
||||
}
|
||||
|
||||
/**
|
||||
* 准备录音控件
|
||||
*/
|
||||
fun prepareAudio() {
|
||||
try {
|
||||
val dir = File(recordFileDir)
|
||||
if (!dir.exists()) {
|
||||
dir.mkdir()
|
||||
}
|
||||
//生成随机文件名
|
||||
val file =
|
||||
File(dir, UUID.randomUUID().toString() + ".amr")
|
||||
recordAbsoluteFileDir = file.absolutePath
|
||||
// 需要每次使用前重新构造,不然在调用setOutputFile()时会报重用异常
|
||||
mediaRecorder?.let {
|
||||
mediaRecorder!!.release()
|
||||
mediaRecorder = null
|
||||
}
|
||||
mediaRecorder = MediaRecorder()
|
||||
//设置输出文件
|
||||
mediaRecorder!!.setOutputFile(recordAbsoluteFileDir)
|
||||
mediaRecorder!!.setMaxDuration(maxRecordLength)
|
||||
//设置MediaRecorder的音频源为麦克风
|
||||
mediaRecorder!!.setAudioSource(MediaRecorder.AudioSource.MIC)
|
||||
//设置音频格式
|
||||
mediaRecorder!!.setOutputFormat(MediaRecorder.OutputFormat.AMR_NB)
|
||||
//设置音频的格式为amr
|
||||
mediaRecorder!!.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB)
|
||||
mediaRecorder!!.setOnInfoListener { mr, what, extra ->
|
||||
if (what == MediaRecorder.MEDIA_RECORDER_INFO_MAX_DURATION_REACHED) {
|
||||
mediaRecorderStateListener?.run {
|
||||
//到达最大录音时间
|
||||
onReachMaxRecordTime(recordAbsoluteFileDir)
|
||||
}
|
||||
}
|
||||
}
|
||||
mediaRecorder!!.setOnErrorListener { mr, what, extra ->
|
||||
mediaRecorderStateListener?.run {
|
||||
//录音发生错误
|
||||
onError(what, extra)
|
||||
}
|
||||
}
|
||||
mediaRecorder!!.prepare()
|
||||
mediaRecorder!!.start()
|
||||
//准备结束,可以开始录音了
|
||||
isPrepared = true
|
||||
|
||||
mediaRecorderStateListener?.run {
|
||||
wellPrepared()
|
||||
}
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
//正常录音结束释放资源
|
||||
fun release() {
|
||||
mediaRecorder?.let {
|
||||
try {
|
||||
mediaRecorder!!.stop()
|
||||
mediaRecorder!!.release()
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
mediaRecorder = null
|
||||
isPrepared = false
|
||||
}
|
||||
}
|
||||
|
||||
//中途取消录音,删除音频文件
|
||||
fun cancel() {
|
||||
release()
|
||||
recordAbsoluteFileDir?.let {
|
||||
val file = File(it)
|
||||
file.delete()
|
||||
recordAbsoluteFileDir = null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据音量分级更新麦克状态
|
||||
*/
|
||||
fun getVoiceLevel(maxLevel: Int): Int {
|
||||
if (isPrepared && mediaRecorder != null) {
|
||||
val ratio = mediaRecorder!!.maxAmplitude.toDouble() / volumeBase
|
||||
var db = 0.0 // 分贝
|
||||
if (ratio > 1) {
|
||||
db = 20 * log10(ratio)
|
||||
return if (db / 4 > maxLevel) {
|
||||
maxLevel
|
||||
} else (db / 4).toInt()
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
}
|
BIN
baselib/src/main/res/drawable-xhdpi/ic_recorder.png
Executable file
After Width: | Height: | Size: 1.8 KiB |
BIN
baselib/src/main/res/drawable-xhdpi/record_cancel.png
Executable file
After Width: | Height: | Size: 1.8 KiB |
BIN
baselib/src/main/res/drawable-xhdpi/voice_to_short.png
Executable file
After Width: | Height: | Size: 1.7 KiB |
BIN
baselib/src/main/res/drawable-xhdpi/volume_0.png
Executable file
After Width: | Height: | Size: 242 B |
BIN
baselib/src/main/res/drawable-xhdpi/volume_1.png
Executable file
After Width: | Height: | Size: 340 B |
BIN
baselib/src/main/res/drawable-xhdpi/volume_2.png
Executable file
After Width: | Height: | Size: 441 B |
BIN
baselib/src/main/res/drawable-xhdpi/volume_3.png
Executable file
After Width: | Height: | Size: 531 B |
BIN
baselib/src/main/res/drawable-xhdpi/volume_4.png
Executable file
After Width: | Height: | Size: 651 B |
BIN
baselib/src/main/res/drawable-xhdpi/volume_5.png
Executable file
After Width: | Height: | Size: 757 B |
BIN
baselib/src/main/res/drawable-xhdpi/volume_6.png
Executable file
After Width: | Height: | Size: 857 B |
6
baselib/src/main/res/drawable/bg_dialog_loading.xml
Executable file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<solid android:color="#888888" />
|
||||
<corners android:radius="4dp" />
|
||||
</shape>
|
44
baselib/src/main/res/layout/dialog_recorder.xml
Executable file
@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/bg_dialog_loading"
|
||||
android:padding="@dimen/margin_padding">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_record_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_recorder_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_recorder" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_recorder_voice"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/volume_1" />
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_recorder_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/ll_record_icon"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="@dimen/margin_padding_small"
|
||||
android:padding="@dimen/margin_padding_min"
|
||||
android:textColor="#ffffff" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressBar"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:visibility="gone" />
|
||||
</RelativeLayout>
|
@ -207,4 +207,6 @@
|
||||
<color name="btn_green">#AA37B54A</color>
|
||||
<color name="btn_purple">#AA6B6FD2</color>
|
||||
<color name="col_main_theme">#216cd8</color>
|
||||
|
||||
<color name="colorDarkOrange">#d84315</color>
|
||||
</resources>
|
@ -19,4 +19,17 @@
|
||||
<dimen name="material_bottom_navigation_shadow_height">1dp</dimen>
|
||||
<dimen name="material_bottom_navigation_text_size">12dp</dimen>
|
||||
|
||||
<dimen name="dia_corner_radius">8dp</dimen>
|
||||
<dimen name="margin_padding">16dp</dimen>
|
||||
<dimen name="margin_padding_big">32dp</dimen>
|
||||
<dimen name="margin_padding_small">8dp</dimen>
|
||||
<dimen name="margin_padding_min">4dp</dimen>
|
||||
|
||||
<dimen name="text_primary">16sp</dimen>
|
||||
<dimen name="text_small">14sp</dimen>
|
||||
<dimen name="text_big">20sp</dimen>
|
||||
<dimen name="text_min">12sp</dimen>
|
||||
|
||||
<dimen name="divider_height">0.5dp</dimen>
|
||||
|
||||
</resources>
|
@ -50,4 +50,12 @@
|
||||
|
||||
<string name="cloudLink_permission_prohibited">权限被禁止,无法选择本地图片</string>
|
||||
|
||||
|
||||
<string name="str_recorder_normal">按住说话</string>
|
||||
<string name="str_recorder_recording">松开结束</string>
|
||||
<string name="str_recorder_want_cancel">松开手指,取消发送</string>
|
||||
<string name="str_recorder_swip_cancel">手指上滑,取消发送</string>
|
||||
<string name="str_recorder_too_short">"录音时间过短"</string>
|
||||
<string name="time_remaining">还可以再录制%d秒</string>
|
||||
|
||||
</resources>
|
||||
|
@ -648,4 +648,20 @@
|
||||
<!--点击 dialog Activity 周围是否关闭弹窗 true 关闭(默认为true) false 为不关闭-->
|
||||
<item name="android:windowCloseOnTouchOutside">false</item>
|
||||
</style>
|
||||
<!-- 录音dialog -->
|
||||
<style name="Theme_RecordDialog" parent="@android:style/Theme.Dialog">
|
||||
<!--自定义对话框风格-->
|
||||
<item name="android:windowFrame">@null</item>
|
||||
<!--边框-->
|
||||
<item name="android:windowIsFloating">true</item>
|
||||
<!--是否浮现在activity之上-->
|
||||
<item name="android:windowIsTranslucent">false</item>
|
||||
<!--半透明-->
|
||||
<item name="android:windowNoTitle">true</item>
|
||||
<!--无标题-->
|
||||
<item name="android:windowBackground">@android:color/transparent</item>
|
||||
<!--背景透明-->
|
||||
<item name="android:backgroundDimEnabled">false</item>
|
||||
<!--模糊-->
|
||||
</style>
|
||||
</resources>
|
@ -6,6 +6,7 @@ if (!IsModuleDev.toBoolean()) {
|
||||
apply plugin: 'com.jakewharton.butterknife'
|
||||
apply plugin: 'android-aspectjx'
|
||||
apply plugin: 'org.jetbrains.kotlin.android'
|
||||
apply plugin: 'kotlin-android'
|
||||
android {
|
||||
buildToolsVersion rootProject.ext.gBuildToolsVersion
|
||||
compileSdkVersion rootProject.ext.gCompileSdkVersion
|
||||
|
@ -21,6 +21,7 @@ import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.ZoomControls;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.widget.SwitchCompat;
|
||||
import androidx.core.widget.NestedScrollView;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
@ -65,12 +66,11 @@ import com.tenlionsoft.baselib.core.retrofit_net.conver.RxTransformer;
|
||||
import com.tenlionsoft.baselib.core.widget.PhotoActivity;
|
||||
import com.tenlionsoft.baselib.core.widget.base.AddPhotoAdapter;
|
||||
import com.tenlionsoft.baselib.core.widget.base.BaseActivity;
|
||||
import com.tenlionsoft.baselib.core.widget.videorecord.AudioRecordButton;
|
||||
import com.tenlionsoft.baselib.core.widget.videorecord.MediaManager;
|
||||
import com.tenlionsoft.baselib.core.widget.views.AreaChooseDialog;
|
||||
import com.tenlionsoft.baselib.core.widget.views.ButtomDialogView;
|
||||
import com.tenlionsoft.baselib.core.widget.voicebutton.VoiceButton;
|
||||
import com.tenlionsoft.baselib.utils.ExceptionHandler;
|
||||
import com.tenlionsoft.baselib.utils.LogUtils;
|
||||
import com.tenlionsoft.baselib.utils.PermissionUtils;
|
||||
import com.tenlionsoft.baselib.utils.UIUtil;
|
||||
import com.tenlionsoft.baselib.utils.UserLgUtils;
|
||||
@ -128,7 +128,7 @@ public class IncidentReportActivity extends BaseActivity {
|
||||
@BindView(R2.id.ll_voice)
|
||||
LinearLayout mLlVoice;
|
||||
@BindView(R2.id.arb_audio)
|
||||
AudioRecordButton mArbAudio;
|
||||
VoiceButton mArbAudio;
|
||||
@BindView(R2.id.btn_submit)
|
||||
Button mBtnSubmit;
|
||||
@BindView(R2.id.et_address)
|
||||
@ -187,8 +187,8 @@ public class IncidentReportActivity extends BaseActivity {
|
||||
mBind = ButterKnife.bind(this);
|
||||
mTvBaseTitle.setText("事件上报");
|
||||
refreshView(STATE_LOAD_SUCCESS);
|
||||
initViews();
|
||||
initMap();
|
||||
initViews();
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
@ -220,10 +220,7 @@ public class IncidentReportActivity extends BaseActivity {
|
||||
if (TextUtils.isEmpty(mSelAreaCode)) {
|
||||
ToastUtils.show("请先选择所在地区");
|
||||
} else {
|
||||
ARouter.getInstance()
|
||||
.build(PathConfig.PATH_MODULE_COMMON_ACTIVITY_SEL_GRID)
|
||||
.withString("areaCode", mSelAreaCode)
|
||||
.navigation(mActivity, 15);
|
||||
ARouter.getInstance().build(PathConfig.PATH_MODULE_COMMON_ACTIVITY_SEL_GRID).withString("areaCode", mSelAreaCode).navigation(mActivity, 15);
|
||||
}
|
||||
});
|
||||
mIvDelVideo.setVisibility(View.GONE);
|
||||
@ -232,9 +229,7 @@ public class IncidentReportActivity extends BaseActivity {
|
||||
mVideoId = "";
|
||||
mIvPlayVideo.setBackgroundResource(R.drawable.picture_icon_video);
|
||||
mIvDelVideo.setVisibility(View.GONE);
|
||||
Glide.with(mActivity)
|
||||
.load(R.drawable.shp_rectangle_black)
|
||||
.into(mIvCover);
|
||||
Glide.with(mActivity).load(R.drawable.shp_rectangle_black).into(mIvCover);
|
||||
});
|
||||
mIvPlayVideo.setBackgroundResource(R.drawable.picture_icon_video);
|
||||
mIvPlayVideo.setOnClickListener(v -> {
|
||||
@ -243,29 +238,34 @@ public class IncidentReportActivity extends BaseActivity {
|
||||
showSelectVideo();
|
||||
} else {
|
||||
//播放视频
|
||||
ARouter.getInstance()
|
||||
.build(PathConfig.PATH_MODULE_PLAYER_SIMPLE_VIDEO)
|
||||
.withString("url", mVideoPath)
|
||||
.withString("title", "事件视频")
|
||||
.navigation();
|
||||
ARouter.getInstance().build(PathConfig.PATH_MODULE_PLAYER_SIMPLE_VIDEO).withString("url", mVideoPath).withString("title", "事件视频").navigation();
|
||||
}
|
||||
});
|
||||
mTvAddressSel.setOnClickListener(v -> ARouter.getInstance()
|
||||
.build(PathConfig.PATH_MODULE_MAP_SEL_POINT)
|
||||
.navigation(mActivity, 16));
|
||||
mTvAddressSel.setOnClickListener(v -> ARouter.getInstance().build(PathConfig.PATH_MODULE_MAP_SEL_POINT).navigation(mActivity, 16));
|
||||
|
||||
//录音
|
||||
mArbAudio.setAudioFinishRecorderListener((seconds, filePath) -> uploadVoice(filePath));
|
||||
// mArbAudio.setAudioFinishRecorderListener((seconds, filePath) -> uploadVoice(filePath));
|
||||
mArbAudio.setRecorderListener(new VoiceButton.RecorderListener() {
|
||||
@Override
|
||||
public void onStart() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish(long time, @Nullable String filePath) {
|
||||
uploadVoice(filePath);
|
||||
}
|
||||
});
|
||||
mLlVoice.setOnClickListener(v -> {
|
||||
if (!TextUtils.isEmpty(mAudioPath)) {
|
||||
AnimationDrawable animationDrawable = (AnimationDrawable) mTvVoiceAnim.getBackground();
|
||||
AnimationDrawable animationDrawable =
|
||||
(AnimationDrawable) mTvVoiceAnim.getBackground();
|
||||
animationDrawable.start();
|
||||
MediaManager.playSound(mAudioPath,
|
||||
mp -> {
|
||||
animationDrawable.selectDrawable(0);//显示动画第一帧
|
||||
animationDrawable.stop();
|
||||
MediaManager.destroy();
|
||||
});
|
||||
MediaManager.playSound(mAudioPath, mp -> {
|
||||
animationDrawable.selectDrawable(0);//显示动画第一帧
|
||||
animationDrawable.stop();
|
||||
MediaManager.destroy();
|
||||
});
|
||||
}
|
||||
});
|
||||
mIvDelAudio.setOnClickListener(v -> {
|
||||
@ -281,11 +281,7 @@ public class IncidentReportActivity extends BaseActivity {
|
||||
showSelectVideo();
|
||||
} else {
|
||||
//视频播放
|
||||
ARouter.getInstance()
|
||||
.build(PathConfig.PATH_MODULE_PLAYER_SIMPLE_VIDEO)
|
||||
.withString("url", mVideoPath)
|
||||
.withString("title", "视频")
|
||||
.navigation();
|
||||
ARouter.getInstance().build(PathConfig.PATH_MODULE_PLAYER_SIMPLE_VIDEO).withString("url", mVideoPath).withString("title", "视频").navigation();
|
||||
}
|
||||
});
|
||||
//是否自处理
|
||||
@ -300,18 +296,14 @@ public class IncidentReportActivity extends BaseActivity {
|
||||
if (mSelGridBean == null) {
|
||||
ToastUtils.show("请选择所在网格");
|
||||
} else {
|
||||
ARouter.getInstance()
|
||||
.build(PathConfig.PATH_MODULE_COMMON_ACTIVITY_INCIDENT_SEL_COMPONENT)
|
||||
.withBoolean("isSingle", true)
|
||||
.withString("id", mSelGridBean.getGridCode())
|
||||
.navigation(mActivity, 13);
|
||||
ARouter.getInstance().build(PathConfig.PATH_MODULE_COMMON_ACTIVITY_INCIDENT_SEL_COMPONENT).withBoolean("isSingle", true).withString("id", mSelGridBean.getGridCode()).navigation(mActivity, 13);
|
||||
}
|
||||
});
|
||||
mBtnSubmit.setOnClickListener(v -> doSubmit());
|
||||
checkAuthority();
|
||||
setCurrentLoc();
|
||||
// getMineGridList();
|
||||
Object curGrid = ((BaseAppContext) getApplicationContext()).getGridBean();
|
||||
Object curGrid = ((BaseAppContext) getApplicationContext()).getGridBean();
|
||||
if (curGrid != null && curGrid instanceof AreaGridListBean.RowsBean) {
|
||||
mSelGridBean = (AreaGridListBean.RowsBean) curGrid;
|
||||
mTvGridId.setText(mSelGridBean.getGridName());
|
||||
@ -338,23 +330,22 @@ public class IncidentReportActivity extends BaseActivity {
|
||||
* 校验权限
|
||||
*/
|
||||
private void checkAuthority() {
|
||||
PermissionUtils.permission(PermissionConstants.STORAGE,
|
||||
PermissionConstants.LOCATION,
|
||||
PermissionConstants.CAMERA,
|
||||
PermissionConstants.MICROPHONE)
|
||||
.callback(new PermissionUtils.SimpleCallback() {
|
||||
@Override
|
||||
public void onGranted() {
|
||||
mArbAudio.setHasRecordPromission(true);
|
||||
}
|
||||
PermissionUtils.permission(PermissionConstants.STORAGE, PermissionConstants.LOCATION,
|
||||
PermissionConstants.CAMERA, PermissionConstants.MICROPHONE).callback(new PermissionUtils.SimpleCallback() {
|
||||
@Override
|
||||
public void onGranted() {
|
||||
// mArbAudio.setHasRecordPromission(true);
|
||||
mArbAudio.setEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDenied() {
|
||||
ToastUtils.show("App需要读取SD的权限,和定位的权限,请前往设置里授权.");
|
||||
mArbAudio.setHasRecordPromission(false);
|
||||
finish();
|
||||
}
|
||||
}).request();
|
||||
@Override
|
||||
public void onDenied() {
|
||||
ToastUtils.show("App需要读取SD的权限,和定位的权限,请前往设置里授权.");
|
||||
// mArbAudio.setHasRecordPromission(false);
|
||||
mArbAudio.setEnabled(false);
|
||||
finish();
|
||||
}
|
||||
}).request();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -365,34 +356,31 @@ public class IncidentReportActivity extends BaseActivity {
|
||||
RequestBody body = buildParams();
|
||||
ProgressDialog dialog = UIUtil.initDialog(mActivity, "上报中...");
|
||||
dialog.show();
|
||||
RetrofitManager.getInstance()
|
||||
.create(GridApis.class)
|
||||
.doSaveCase(body, UserLgUtils.getToken())
|
||||
.compose(RxTransformer.getTransformer())
|
||||
.subscribe(new Observer<SuccessBean>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
RetrofitManager.getInstance().create(GridApis.class).doSaveCase(body,
|
||||
UserLgUtils.getToken()).compose(RxTransformer.getTransformer()).subscribe(new Observer<SuccessBean>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull SuccessBean successBean) {
|
||||
dialog.dismiss();
|
||||
ToastUtils.show("上报成功");
|
||||
finish();
|
||||
}
|
||||
@Override
|
||||
public void onNext(@NonNull SuccessBean successBean) {
|
||||
dialog.dismiss();
|
||||
ToastUtils.show("上报成功");
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
dialog.dismiss();
|
||||
ExceptionHandler.handleException(e);
|
||||
}
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
dialog.dismiss();
|
||||
ExceptionHandler.handleException(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -402,47 +390,40 @@ public class IncidentReportActivity extends BaseActivity {
|
||||
private void getMineGridList() {
|
||||
ProgressDialog dialog = UIUtil.initDialog(mActivity, "加载中...");
|
||||
dialog.show();
|
||||
RetrofitManager.getInstance()
|
||||
.create(GridApis.class)
|
||||
.getMineGridList(UserLgUtils.getToken())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<List<AreaGridListBean.RowsBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
RetrofitManager.getInstance().create(GridApis.class).getMineGridList(UserLgUtils.getToken()).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer<List<AreaGridListBean.RowsBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull List<AreaGridListBean.RowsBean> rowsBeans) {
|
||||
dialog.dismiss();
|
||||
if (rowsBeans != null && rowsBeans.size() > 0) {
|
||||
mSelGridBean = rowsBeans.get(0);
|
||||
mTvGridId.setText(mSelGridBean.getGridName());
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onNext(@NonNull List<AreaGridListBean.RowsBean> rowsBeans) {
|
||||
dialog.dismiss();
|
||||
if (rowsBeans != null && rowsBeans.size() > 0) {
|
||||
mSelGridBean = rowsBeans.get(0);
|
||||
mTvGridId.setText(mSelGridBean.getGridName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
dialog.dismiss();
|
||||
ExceptionHandler.handleException(e);
|
||||
}
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
dialog.dismiss();
|
||||
ExceptionHandler.handleException(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示地区选择
|
||||
*/
|
||||
private void onShowArea() {
|
||||
AreaChooseDialog dialog = new AreaChooseDialog
|
||||
.DialogBuilder(mActivity)
|
||||
.setDefault(true)
|
||||
.build();
|
||||
AreaChooseDialog dialog =
|
||||
new AreaChooseDialog.DialogBuilder(mActivity).setDefault(true).build();
|
||||
dialog.addOnChoseListener((names, id, code) -> {
|
||||
mSelAreaCode = code;
|
||||
mSelAreaId = id;
|
||||
@ -539,7 +520,8 @@ public class IncidentReportActivity extends BaseActivity {
|
||||
}
|
||||
Gson gson = new Gson();
|
||||
String obj = gson.toJson(bean);
|
||||
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), obj);
|
||||
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json; " +
|
||||
"charset=utf-8"), obj);
|
||||
return requestBody;
|
||||
}
|
||||
|
||||
@ -549,12 +531,8 @@ public class IncidentReportActivity extends BaseActivity {
|
||||
* @param bean
|
||||
*/
|
||||
private void showSelectPhoto(AddPhotoBean bean) {
|
||||
ButtomDialogView buttomDialogView = new ButtomDialogView.DialogBuilder(mActivity)
|
||||
.setIsBackCancelable(true)
|
||||
.setIscancelable(true)
|
||||
.setShowLocation(Gravity.BOTTOM)
|
||||
.setIsShowFile(false)
|
||||
.build();
|
||||
ButtomDialogView buttomDialogView =
|
||||
new ButtomDialogView.DialogBuilder(mActivity).setIsBackCancelable(true).setIscancelable(true).setShowLocation(Gravity.BOTTOM).setIsShowFile(false).build();
|
||||
buttomDialogView.addOnChoseListener(new ButtomDialogView.OnChoseListener() {
|
||||
@Override
|
||||
public void choseFile() {
|
||||
@ -564,8 +542,7 @@ public class IncidentReportActivity extends BaseActivity {
|
||||
public void choseAlbum() {
|
||||
mCurrentBean = bean;
|
||||
Intent intent = new Intent(Intent.ACTION_PICK, null);
|
||||
intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
|
||||
"image/*");
|
||||
intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*");
|
||||
startActivityForResult(intent, BaseUrlApi.PHOTO_REQUEST);
|
||||
buttomDialogView.dismiss();
|
||||
}
|
||||
@ -573,11 +550,7 @@ public class IncidentReportActivity extends BaseActivity {
|
||||
@Override
|
||||
public void choseShoot() {
|
||||
mCurrentBean = bean;
|
||||
ARouter.getInstance()
|
||||
.build(PathConfig.PATH_MODULE_BASELIB_TAKE_PHOTO)
|
||||
.withString("path", getExternalFilesDir(Environment.DIRECTORY_DOCUMENTS).getPath())
|
||||
.withString("type", "photo")
|
||||
.navigation(mActivity, BaseUrlApi.CAMERA_REQUEST);
|
||||
ARouter.getInstance().build(PathConfig.PATH_MODULE_BASELIB_TAKE_PHOTO).withString("path", getExternalFilesDir(Environment.DIRECTORY_DOCUMENTS).getPath()).withString("type", "photo").navigation(mActivity, BaseUrlApi.CAMERA_REQUEST);
|
||||
buttomDialogView.dismiss();
|
||||
}
|
||||
|
||||
@ -598,12 +571,8 @@ public class IncidentReportActivity extends BaseActivity {
|
||||
* 显示选择视频
|
||||
*/
|
||||
private void showSelectVideo() {
|
||||
ButtomDialogView buttomDialogView = new ButtomDialogView.DialogBuilder(mActivity)
|
||||
.setIsBackCancelable(true)
|
||||
.setIscancelable(true)
|
||||
.setShowLocation(Gravity.BOTTOM)
|
||||
.setIsShowFile(false)
|
||||
.build();
|
||||
ButtomDialogView buttomDialogView =
|
||||
new ButtomDialogView.DialogBuilder(mActivity).setIsBackCancelable(true).setIscancelable(true).setShowLocation(Gravity.BOTTOM).setIsShowFile(false).build();
|
||||
buttomDialogView.addOnChoseListener(new ButtomDialogView.OnChoseListener() {
|
||||
@Override
|
||||
public void choseFile() {
|
||||
@ -612,19 +581,14 @@ public class IncidentReportActivity extends BaseActivity {
|
||||
@Override
|
||||
public void choseAlbum() {
|
||||
Intent intent = new Intent(Intent.ACTION_PICK, null);
|
||||
intent.setDataAndType(MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
|
||||
"video/*");
|
||||
intent.setDataAndType(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, "video/*");
|
||||
startActivityForResult(intent, BaseUrlApi.CAMERA_REQUEST_PHOTO);
|
||||
buttomDialogView.dismiss();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void choseShoot() {
|
||||
ARouter.getInstance()
|
||||
.build(PathConfig.PATH_MODULE_BASELIB_TAKE_PHOTO)
|
||||
.withString("path", getExternalFilesDir(Environment.DIRECTORY_DOCUMENTS).getPath())
|
||||
.withString("type", "video")
|
||||
.navigation(mActivity, BaseUrlApi.CAMERA_REQUEST_VIDEO);
|
||||
ARouter.getInstance().build(PathConfig.PATH_MODULE_BASELIB_TAKE_PHOTO).withString("path", getExternalFilesDir(Environment.DIRECTORY_DOCUMENTS).getPath()).withString("type", "video").navigation(mActivity, BaseUrlApi.CAMERA_REQUEST_VIDEO);
|
||||
buttomDialogView.dismiss();
|
||||
}
|
||||
|
||||
@ -655,7 +619,8 @@ public class IncidentReportActivity extends BaseActivity {
|
||||
Uri uri = data.getData();
|
||||
String[] proj = {MediaStore.Images.Media.DATA};
|
||||
Cursor cursor = managedQuery(uri, proj, null, null, null);
|
||||
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
|
||||
int column_index =
|
||||
cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
|
||||
cursor.moveToFirst();
|
||||
String srcPath = cursor.getString(column_index);
|
||||
uploadImg(srcPath, 2);
|
||||
@ -673,7 +638,8 @@ public class IncidentReportActivity extends BaseActivity {
|
||||
Uri uri = data.getData();
|
||||
String[] proj = {MediaStore.Images.Media.DATA};
|
||||
Cursor cursor = managedQuery(uri, proj, null, null, null);
|
||||
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
|
||||
int column_index =
|
||||
cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
|
||||
cursor.moveToFirst();
|
||||
String srcPath = cursor.getString(column_index);
|
||||
uploadVideo(srcPath);
|
||||
@ -684,7 +650,8 @@ public class IncidentReportActivity extends BaseActivity {
|
||||
}
|
||||
} else if (resultCode == 13) {
|
||||
if (requestCode == 13) {
|
||||
mSelComponentBean = (CaseComponentListBean.RowsBean) data.getSerializableExtra("bean");
|
||||
mSelComponentBean = (CaseComponentListBean.RowsBean) data.getSerializableExtra(
|
||||
"bean");
|
||||
mTvComponent.setText(mSelComponentBean.getObjName());
|
||||
}
|
||||
} else if (resultCode == 22) {
|
||||
@ -751,8 +718,7 @@ public class IncidentReportActivity extends BaseActivity {
|
||||
if (mBitMap == null) {
|
||||
mBitMap = BitmapDescriptorFactory.fromResource(R.drawable.ic_map_location_marker);
|
||||
}
|
||||
MarkerOptions markerOptions = new MarkerOptions()
|
||||
.position(new LatLng(lat, lng))//mark出现的位置
|
||||
MarkerOptions markerOptions = new MarkerOptions().position(new LatLng(lat, lng))//mark出现的位置
|
||||
.icon(mBitMap) //mark图标
|
||||
.draggable(false)//mark可拖拽
|
||||
.animateType(MarkerOptions.MarkerAnimateType.none);
|
||||
@ -769,53 +735,44 @@ public class IncidentReportActivity extends BaseActivity {
|
||||
progressDialog.show();
|
||||
File file = new File(videoPath);
|
||||
if (file.exists()) {
|
||||
RequestBody requestFile = RequestBody.create(MediaType.parse("multipart/form-data"), file);
|
||||
MultipartBody.Part body = MultipartBody.Part.createFormData("video", file.getName(), requestFile);
|
||||
RetrofitManager.getInstance()
|
||||
.create(BaseApiService.class)
|
||||
.uploadVideo(body, UserLgUtils.getToken())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<BaseSuccessBean>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
RequestBody requestFile = RequestBody.create(MediaType.parse("multipart/form-data"),
|
||||
file);
|
||||
MultipartBody.Part body = MultipartBody.Part.createFormData("video", file.getName(),
|
||||
requestFile);
|
||||
RetrofitManager.getInstance().create(BaseApiService.class).uploadVideo(body,
|
||||
UserLgUtils.getToken()).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer<BaseSuccessBean>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(BaseSuccessBean baseUserBean) {
|
||||
if (progressDialog.isShowing()) {
|
||||
progressDialog.dismiss();
|
||||
}
|
||||
ToastUtils.show("上传成功");
|
||||
mVideoPath = videoPath;
|
||||
mVideoId = baseUserBean.getData();
|
||||
mIvDelVideo.setVisibility(View.VISIBLE);
|
||||
mIvPlayVideo.setBackgroundResource(R.drawable.ic_play_white_icon);
|
||||
Glide.with(mActivity)
|
||||
.setDefaultRequestOptions(
|
||||
new RequestOptions()
|
||||
.frame(0)
|
||||
.centerCrop()
|
||||
)
|
||||
.load(mVideoPath)
|
||||
.into(mIvCover);
|
||||
}
|
||||
@Override
|
||||
public void onNext(BaseSuccessBean baseUserBean) {
|
||||
if (progressDialog.isShowing()) {
|
||||
progressDialog.dismiss();
|
||||
}
|
||||
ToastUtils.show("上传成功");
|
||||
mVideoPath = videoPath;
|
||||
mVideoId = baseUserBean.getData();
|
||||
mIvDelVideo.setVisibility(View.VISIBLE);
|
||||
mIvPlayVideo.setBackgroundResource(R.drawable.ic_play_white_icon);
|
||||
Glide.with(mActivity).setDefaultRequestOptions(new RequestOptions().frame(0).centerCrop()).load(mVideoPath).into(mIvCover);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
if (progressDialog.isShowing()) {
|
||||
progressDialog.dismiss();
|
||||
}
|
||||
ExceptionHandler.handleException(e);
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
if (progressDialog.isShowing()) {
|
||||
progressDialog.dismiss();
|
||||
}
|
||||
ExceptionHandler.handleException(e);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
progressDialog.dismiss();
|
||||
ToastUtils.show("视频文件路径有误.");
|
||||
@ -832,51 +789,49 @@ public class IncidentReportActivity extends BaseActivity {
|
||||
progressDialog.show();
|
||||
File file = new File(filePath);
|
||||
if (file.exists()) {
|
||||
RequestBody requestFile = RequestBody.create(MediaType.parse("multipart/form-data"), file);
|
||||
MultipartBody.Part body = MultipartBody.Part.createFormData("audio", file.getName(), requestFile);
|
||||
RetrofitManager.getInstance()
|
||||
.create(BaseApiService.class)
|
||||
.uploadAudio(body, UserLgUtils.getToken())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<BaseSuccessBean>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
RequestBody requestFile = RequestBody.create(MediaType.parse("multipart/form-data"),
|
||||
file);
|
||||
MultipartBody.Part body = MultipartBody.Part.createFormData("audio", file.getName(),
|
||||
requestFile);
|
||||
RetrofitManager.getInstance().create(BaseApiService.class).uploadAudio(body,
|
||||
UserLgUtils.getToken()).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer<BaseSuccessBean>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(BaseSuccessBean baseUserBean) {
|
||||
mIvVoice.setVisibility(View.GONE);
|
||||
if (progressDialog.isShowing()) {
|
||||
progressDialog.dismiss();
|
||||
}
|
||||
ToastUtils.show("上传成功");
|
||||
mAudioPath = filePath;
|
||||
mAudioId = baseUserBean.getData();
|
||||
mTvVoiceAnim.setVisibility(View.VISIBLE);
|
||||
mIvDelAudio.setVisibility(View.VISIBLE);
|
||||
mArbAudio.setVisibility(View.GONE);
|
||||
}
|
||||
@Override
|
||||
public void onNext(BaseSuccessBean baseUserBean) {
|
||||
mIvVoice.setVisibility(View.GONE);
|
||||
if (progressDialog.isShowing()) {
|
||||
progressDialog.dismiss();
|
||||
}
|
||||
ToastUtils.show("上传成功");
|
||||
mAudioPath = filePath;
|
||||
mAudioId = baseUserBean.getData();
|
||||
mTvVoiceAnim.setVisibility(View.VISIBLE);
|
||||
mIvDelAudio.setVisibility(View.VISIBLE);
|
||||
mArbAudio.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
|
||||
if (progressDialog.isShowing()) {
|
||||
progressDialog.dismiss();
|
||||
}
|
||||
mTvVoiceAnim.setVisibility(View.GONE);
|
||||
mIvDelAudio.setVisibility(View.GONE);
|
||||
mArbAudio.setVisibility(View.VISIBLE);
|
||||
mIvVoice.setVisibility(View.VISIBLE);
|
||||
ExceptionHandler.handleException(e);
|
||||
}
|
||||
if (progressDialog.isShowing()) {
|
||||
progressDialog.dismiss();
|
||||
}
|
||||
mTvVoiceAnim.setVisibility(View.GONE);
|
||||
mIvDelAudio.setVisibility(View.GONE);
|
||||
mArbAudio.setVisibility(View.VISIBLE);
|
||||
mIvVoice.setVisibility(View.VISIBLE);
|
||||
ExceptionHandler.handleException(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
progressDialog.dismiss();
|
||||
ToastUtils.show("录音文件路径有误.");
|
||||
@ -898,47 +853,44 @@ public class IncidentReportActivity extends BaseActivity {
|
||||
ProgressDialog progressDialog = UIUtil.initDialog(mActivity, "正在上传...");
|
||||
progressDialog.show();
|
||||
RequestBody requestFile = RequestBody.create(MediaType.parse("multipart/form-data"), file);
|
||||
MultipartBody.Part body = MultipartBody.Part.createFormData("image", file.getName(), requestFile);
|
||||
RetrofitManager.getInstance()
|
||||
.create(BaseApiService.class)
|
||||
.uploadImage(body, UserLgUtils.getToken())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<BaseSuccessBean>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
MultipartBody.Part body = MultipartBody.Part.createFormData("image", file.getName(),
|
||||
requestFile);
|
||||
RetrofitManager.getInstance().create(BaseApiService.class).uploadImage(body,
|
||||
UserLgUtils.getToken()).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer<BaseSuccessBean>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(BaseSuccessBean baseUserBean) {
|
||||
if (progressDialog != null && progressDialog.isShowing()) {
|
||||
progressDialog.dismiss();
|
||||
}
|
||||
ToastUtils.show("上传成功");
|
||||
mPhotoIds += (baseUserBean.getData() + ",");
|
||||
mCurrentBean.setId(baseUserBean.getData());
|
||||
mCurrentBean.setPath(picPath);
|
||||
if (mPhotos.size() < 8) {
|
||||
mPhotos.add(new AddPhotoBean());
|
||||
}
|
||||
mAddPhotoAdapter.notifyDataSetChanged();
|
||||
mCurrentBean = null;
|
||||
}
|
||||
@Override
|
||||
public void onNext(BaseSuccessBean baseUserBean) {
|
||||
if (progressDialog != null && progressDialog.isShowing()) {
|
||||
progressDialog.dismiss();
|
||||
}
|
||||
ToastUtils.show("上传成功");
|
||||
mPhotoIds += (baseUserBean.getData() + ",");
|
||||
mCurrentBean.setId(baseUserBean.getData());
|
||||
mCurrentBean.setPath(picPath);
|
||||
if (mPhotos.size() < 8) {
|
||||
mPhotos.add(new AddPhotoBean());
|
||||
}
|
||||
mAddPhotoAdapter.notifyDataSetChanged();
|
||||
mCurrentBean = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
if (progressDialog != null && progressDialog.isShowing()) {
|
||||
progressDialog.dismiss();
|
||||
}
|
||||
ExceptionHandler.handleException(e);
|
||||
}
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
if (progressDialog != null && progressDialog.isShowing()) {
|
||||
progressDialog.dismiss();
|
||||
}
|
||||
ExceptionHandler.handleException(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -960,12 +912,7 @@ public class IncidentReportActivity extends BaseActivity {
|
||||
} else {
|
||||
ToastUtils.show("详细类型数据未录入,无法选取");
|
||||
}
|
||||
})
|
||||
.setTitleText("请选择")
|
||||
.setCancelColor(Color.parseColor("#1189FF"))
|
||||
.setSubmitColor(Color.parseColor("#1189FF"))
|
||||
.setTitleColor(Color.parseColor("#1189FF"))
|
||||
.build();
|
||||
}).setTitleText("请选择").setCancelColor(Color.parseColor("#1189FF")).setSubmitColor(Color.parseColor("#1189FF")).setTitleColor(Color.parseColor("#1189FF")).build();
|
||||
mTypePicker.setPicker(mTypeList, mTypeSubList);
|
||||
}
|
||||
mTypePicker.show();
|
||||
@ -980,39 +927,34 @@ public class IncidentReportActivity extends BaseActivity {
|
||||
private void getTypeDatas() {
|
||||
ProgressDialog dialog = UIUtil.initDialog(mActivity, "获取中...");
|
||||
dialog.show();
|
||||
RetrofitManager.getInstance()
|
||||
.create(GridApis.class)
|
||||
.getCaseTypeListAll(UserLgUtils.getToken())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<List<CaseTypeBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
RetrofitManager.getInstance().create(GridApis.class).getCaseTypeListAll(UserLgUtils.getToken()).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer<List<CaseTypeBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull List<CaseTypeBean> componentTypeBeans) {
|
||||
dialog.dismiss();
|
||||
if (componentTypeBeans != null && componentTypeBeans.size() > 0) {
|
||||
mTypeList = componentTypeBeans;
|
||||
buildTypeSubBean();
|
||||
} else {
|
||||
ToastUtils.show("暂无数据");
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onNext(@NonNull List<CaseTypeBean> componentTypeBeans) {
|
||||
dialog.dismiss();
|
||||
if (componentTypeBeans != null && componentTypeBeans.size() > 0) {
|
||||
mTypeList = componentTypeBeans;
|
||||
buildTypeSubBean();
|
||||
} else {
|
||||
ToastUtils.show("暂无数据");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
dialog.dismiss();
|
||||
ExceptionHandler.handleException(e);
|
||||
}
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
dialog.dismiss();
|
||||
ExceptionHandler.handleException(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void buildTypeSubBean() {
|
||||
|
@ -19,6 +19,11 @@ import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.widget.NestedScrollView;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.bigkoo.pickerview.builder.OptionsPickerBuilder;
|
||||
@ -48,10 +53,10 @@ import com.tenlionsoft.baselib.core.retrofit_net.api.BaseApiService;
|
||||
import com.tenlionsoft.baselib.core.widget.PhotoActivity;
|
||||
import com.tenlionsoft.baselib.core.widget.base.AddPhotoAdapter;
|
||||
import com.tenlionsoft.baselib.core.widget.base.BaseActivity;
|
||||
import com.tenlionsoft.baselib.core.widget.videorecord.AudioRecordButton;
|
||||
import com.tenlionsoft.baselib.core.widget.videorecord.MediaManager;
|
||||
import com.tenlionsoft.baselib.core.widget.views.AreaChooseDialog;
|
||||
import com.tenlionsoft.baselib.core.widget.views.ButtomDialogView;
|
||||
import com.tenlionsoft.baselib.core.widget.voicebutton.VoiceButton;
|
||||
import com.tenlionsoft.baselib.utils.ExceptionHandler;
|
||||
import com.tenlionsoft.baselib.utils.LogUtils;
|
||||
import com.tenlionsoft.baselib.utils.PermissionUtils;
|
||||
@ -63,9 +68,6 @@ import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.core.widget.NestedScrollView;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.Unbinder;
|
||||
@ -113,7 +115,7 @@ public class TaskConverIncidentReportActivity extends BaseActivity {
|
||||
@BindView(R2.id.ll_voice)
|
||||
LinearLayout mLlVoice;
|
||||
@BindView(R2.id.arb_audio)
|
||||
AudioRecordButton mArbAudio;
|
||||
VoiceButton mArbAudio;
|
||||
@BindView(R2.id.btn_submit)
|
||||
Button mBtnSubmit;
|
||||
@BindView(R2.id.et_address)
|
||||
@ -216,10 +218,7 @@ public class TaskConverIncidentReportActivity extends BaseActivity {
|
||||
if (TextUtils.isEmpty(mSelAreaCode)) {
|
||||
ToastUtils.show("请先选择所在地区");
|
||||
} else {
|
||||
ARouter.getInstance()
|
||||
.build(PathConfig.PATH_MODULE_COMMON_ACTIVITY_SEL_GRID)
|
||||
.withString("areaCode", mSelAreaCode)
|
||||
.navigation(mActivity, 15);
|
||||
ARouter.getInstance().build(PathConfig.PATH_MODULE_COMMON_ACTIVITY_SEL_GRID).withString("areaCode", mSelAreaCode).navigation(mActivity, 15);
|
||||
}
|
||||
});
|
||||
mIvDelVideo.setVisibility(View.GONE);
|
||||
@ -228,9 +227,7 @@ public class TaskConverIncidentReportActivity extends BaseActivity {
|
||||
mVideoId = "";
|
||||
mIvPlayVideo.setBackgroundResource(R.drawable.picture_icon_video);
|
||||
mIvDelVideo.setVisibility(View.GONE);
|
||||
Glide.with(mActivity)
|
||||
.load(R.drawable.shp_rectangle_black)
|
||||
.into(mIvCover);
|
||||
Glide.with(mActivity).load(R.drawable.shp_rectangle_black).into(mIvCover);
|
||||
});
|
||||
mIvPlayVideo.setBackgroundResource(R.drawable.picture_icon_video);
|
||||
mIvPlayVideo.setOnClickListener(v -> {
|
||||
@ -239,29 +236,32 @@ public class TaskConverIncidentReportActivity extends BaseActivity {
|
||||
showSelectVideo();
|
||||
} else {
|
||||
//播放视频
|
||||
ARouter.getInstance()
|
||||
.build(PathConfig.PATH_MODULE_PLAYER_SIMPLE_VIDEO)
|
||||
.withString("url", mVideoPath)
|
||||
.withString("title", "事件视频")
|
||||
.navigation();
|
||||
ARouter.getInstance().build(PathConfig.PATH_MODULE_PLAYER_SIMPLE_VIDEO).withString("url", mVideoPath).withString("title", "事件视频").navigation();
|
||||
}
|
||||
});
|
||||
mTvAddressSel.setOnClickListener(v -> ARouter.getInstance()
|
||||
.build(PathConfig.PATH_MODULE_MAP_SEL_POINT)
|
||||
.navigation(mActivity, 16));
|
||||
mTvAddressSel.setOnClickListener(v -> ARouter.getInstance().build(PathConfig.PATH_MODULE_MAP_SEL_POINT).navigation(mActivity, 16));
|
||||
|
||||
//录音
|
||||
mArbAudio.setAudioFinishRecorderListener((seconds, filePath) -> uploadVoice(filePath));
|
||||
mArbAudio.setRecorderListener(new VoiceButton.RecorderListener() {
|
||||
@Override
|
||||
public void onStart() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish(long time, @Nullable String filePath) {
|
||||
uploadVoice(filePath);
|
||||
}
|
||||
});
|
||||
mLlVoice.setOnClickListener(v -> {
|
||||
if (!TextUtils.isEmpty(mAudioPath)) {
|
||||
AnimationDrawable animationDrawable = (AnimationDrawable) mTvVoiceAnim.getBackground();
|
||||
animationDrawable.start();
|
||||
MediaManager.playSound(mAudioPath,
|
||||
mp -> {
|
||||
animationDrawable.selectDrawable(0);//显示动画第一帧
|
||||
animationDrawable.stop();
|
||||
MediaManager.destroy();
|
||||
});
|
||||
MediaManager.playSound(mAudioPath, mp -> {
|
||||
animationDrawable.selectDrawable(0);//显示动画第一帧
|
||||
animationDrawable.stop();
|
||||
MediaManager.destroy();
|
||||
});
|
||||
}
|
||||
});
|
||||
mIvDelAudio.setOnClickListener(v -> {
|
||||
@ -275,22 +275,14 @@ public class TaskConverIncidentReportActivity extends BaseActivity {
|
||||
showSelectVideo();
|
||||
} else {
|
||||
//视频播放
|
||||
ARouter.getInstance()
|
||||
.build(PathConfig.PATH_MODULE_PLAYER_SIMPLE_VIDEO)
|
||||
.withString("url", mVideoPath)
|
||||
.withString("title", "视频")
|
||||
.navigation();
|
||||
ARouter.getInstance().build(PathConfig.PATH_MODULE_PLAYER_SIMPLE_VIDEO).withString("url", mVideoPath).withString("title", "视频").navigation();
|
||||
}
|
||||
});
|
||||
mTvComponent.setOnClickListener(v -> {
|
||||
if (mSelGridBean == null) {
|
||||
ToastUtils.show("请选择所在网格");
|
||||
} else {
|
||||
ARouter.getInstance()
|
||||
.build(PathConfig.PATH_MODULE_COMMON_ACTIVITY_INCIDENT_SEL_COMPONENT)
|
||||
.withBoolean("isSingle", true)
|
||||
.withString("id", mSelGridBean.getGridCode())
|
||||
.navigation(mActivity, 13);
|
||||
ARouter.getInstance().build(PathConfig.PATH_MODULE_COMMON_ACTIVITY_INCIDENT_SEL_COMPONENT).withBoolean("isSingle", true).withString("id", mSelGridBean.getGridCode()).navigation(mActivity, 13);
|
||||
}
|
||||
});
|
||||
mBtnSubmit.setOnClickListener(v -> doSubmit());
|
||||
@ -316,13 +308,7 @@ public class TaskConverIncidentReportActivity extends BaseActivity {
|
||||
*/
|
||||
private void onShowTime() {
|
||||
hideSoftKeyboard();
|
||||
TimePickerView mTimePickerView = new TimePickerBuilder(mActivity, (date, v) -> mTvTime.setText(TimeUtils.date2String(date)))
|
||||
.setTitleText("请选时间")
|
||||
.setCancelColor(Color.parseColor("#1189FF"))
|
||||
.setSubmitColor(Color.parseColor("#1189FF"))
|
||||
.setType(new boolean[]{true, true, true, true, true, true})
|
||||
.setTitleColor(Color.parseColor("#1189FF"))
|
||||
.build();
|
||||
TimePickerView mTimePickerView = new TimePickerBuilder(mActivity, (date, v) -> mTvTime.setText(TimeUtils.date2String(date))).setTitleText("请选时间").setCancelColor(Color.parseColor("#1189FF")).setSubmitColor(Color.parseColor("#1189FF")).setType(new boolean[]{true, true, true, true, true, true}).setTitleColor(Color.parseColor("#1189FF")).build();
|
||||
mTimePickerView.show();
|
||||
}
|
||||
|
||||
@ -330,23 +316,21 @@ public class TaskConverIncidentReportActivity extends BaseActivity {
|
||||
* 校验权限
|
||||
*/
|
||||
private void checkAuthority() {
|
||||
PermissionUtils.permission(PermissionConstants.STORAGE,
|
||||
PermissionConstants.LOCATION,
|
||||
PermissionConstants.CAMERA,
|
||||
PermissionConstants.MICROPHONE)
|
||||
.callback(new PermissionUtils.SimpleCallback() {
|
||||
@Override
|
||||
public void onGranted() {
|
||||
mArbAudio.setHasRecordPromission(true);
|
||||
}
|
||||
PermissionUtils.permission(PermissionConstants.STORAGE, PermissionConstants.LOCATION, PermissionConstants.CAMERA, PermissionConstants.MICROPHONE).callback(new PermissionUtils.SimpleCallback() {
|
||||
@Override
|
||||
public void onGranted() {
|
||||
// mArbAudio.setHasRecordPromission(true);
|
||||
mArbAudio.setEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDenied() {
|
||||
ToastUtils.show("App需要读取SD的权限,和定位的权限,请前往设置里授权.");
|
||||
mArbAudio.setHasRecordPromission(false);
|
||||
finish();
|
||||
}
|
||||
}).request();
|
||||
@Override
|
||||
public void onDenied() {
|
||||
ToastUtils.show("App需要读取SD的权限,和定位的权限,请前往设置里授权.");
|
||||
// mArbAudio.setHasRecordPromission(false);
|
||||
mArbAudio.setEnabled(false);
|
||||
finish();
|
||||
}
|
||||
}).request();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -357,36 +341,31 @@ public class TaskConverIncidentReportActivity extends BaseActivity {
|
||||
RequestBody body = buildParams();
|
||||
ProgressDialog dialog = UIUtil.initDialog(mActivity, "提交中...");
|
||||
dialog.show();
|
||||
RetrofitManager.getInstance()
|
||||
.create(GridApis.class)
|
||||
.doSaveTaskReport(body, UserLgUtils.getToken())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<SuccessBean>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
RetrofitManager.getInstance().create(GridApis.class).doSaveTaskReport(body, UserLgUtils.getToken()).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer<SuccessBean>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull SuccessBean successBean) {
|
||||
dialog.dismiss();
|
||||
ToastUtils.show("上报成功");
|
||||
setResult(13);
|
||||
finish();
|
||||
}
|
||||
@Override
|
||||
public void onNext(@NonNull SuccessBean successBean) {
|
||||
dialog.dismiss();
|
||||
ToastUtils.show("上报成功");
|
||||
setResult(13);
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
dialog.dismiss();
|
||||
ExceptionHandler.handleException(e);
|
||||
}
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
dialog.dismiss();
|
||||
ExceptionHandler.handleException(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -394,10 +373,7 @@ public class TaskConverIncidentReportActivity extends BaseActivity {
|
||||
* 显示地区选择
|
||||
*/
|
||||
private void onShowArea() {
|
||||
AreaChooseDialog dialog = new AreaChooseDialog
|
||||
.DialogBuilder(mActivity)
|
||||
.setDefault(true)
|
||||
.build();
|
||||
AreaChooseDialog dialog = new AreaChooseDialog.DialogBuilder(mActivity).setDefault(true).build();
|
||||
dialog.addOnChoseListener((names, id, code) -> {
|
||||
mSelAreaCode = code;
|
||||
mSelAreaId = id;
|
||||
@ -514,12 +490,7 @@ public class TaskConverIncidentReportActivity extends BaseActivity {
|
||||
* @param bean
|
||||
*/
|
||||
private void showSelectPhoto(AddPhotoBean bean) {
|
||||
ButtomDialogView buttomDialogView = new ButtomDialogView.DialogBuilder(mActivity)
|
||||
.setIsBackCancelable(true)
|
||||
.setIscancelable(true)
|
||||
.setShowLocation(Gravity.BOTTOM)
|
||||
.setIsShowFile(false)
|
||||
.build();
|
||||
ButtomDialogView buttomDialogView = new ButtomDialogView.DialogBuilder(mActivity).setIsBackCancelable(true).setIscancelable(true).setShowLocation(Gravity.BOTTOM).setIsShowFile(false).build();
|
||||
buttomDialogView.addOnChoseListener(new ButtomDialogView.OnChoseListener() {
|
||||
@Override
|
||||
public void choseFile() {
|
||||
@ -529,8 +500,7 @@ public class TaskConverIncidentReportActivity extends BaseActivity {
|
||||
public void choseAlbum() {
|
||||
mCurrentBean = bean;
|
||||
Intent intent = new Intent(Intent.ACTION_PICK, null);
|
||||
intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
|
||||
"image/*");
|
||||
intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*");
|
||||
startActivityForResult(intent, BaseUrlApi.PHOTO_REQUEST);
|
||||
buttomDialogView.dismiss();
|
||||
}
|
||||
@ -538,11 +508,7 @@ public class TaskConverIncidentReportActivity extends BaseActivity {
|
||||
@Override
|
||||
public void choseShoot() {
|
||||
mCurrentBean = bean;
|
||||
ARouter.getInstance()
|
||||
.build(PathConfig.PATH_MODULE_BASELIB_TAKE_PHOTO)
|
||||
.withString("path", getExternalFilesDir(Environment.DIRECTORY_DOCUMENTS).getPath())
|
||||
.withString("type", "photo")
|
||||
.navigation(mActivity, BaseUrlApi.CAMERA_REQUEST);
|
||||
ARouter.getInstance().build(PathConfig.PATH_MODULE_BASELIB_TAKE_PHOTO).withString("path", getExternalFilesDir(Environment.DIRECTORY_DOCUMENTS).getPath()).withString("type", "photo").navigation(mActivity, BaseUrlApi.CAMERA_REQUEST);
|
||||
buttomDialogView.dismiss();
|
||||
}
|
||||
|
||||
@ -563,12 +529,7 @@ public class TaskConverIncidentReportActivity extends BaseActivity {
|
||||
* 显示选择视频
|
||||
*/
|
||||
private void showSelectVideo() {
|
||||
ButtomDialogView buttomDialogView = new ButtomDialogView.DialogBuilder(mActivity)
|
||||
.setIsBackCancelable(true)
|
||||
.setIscancelable(true)
|
||||
.setShowLocation(Gravity.BOTTOM)
|
||||
.setIsShowFile(false)
|
||||
.build();
|
||||
ButtomDialogView buttomDialogView = new ButtomDialogView.DialogBuilder(mActivity).setIsBackCancelable(true).setIscancelable(true).setShowLocation(Gravity.BOTTOM).setIsShowFile(false).build();
|
||||
buttomDialogView.addOnChoseListener(new ButtomDialogView.OnChoseListener() {
|
||||
@Override
|
||||
public void choseFile() {
|
||||
@ -577,19 +538,14 @@ public class TaskConverIncidentReportActivity extends BaseActivity {
|
||||
@Override
|
||||
public void choseAlbum() {
|
||||
Intent intent = new Intent(Intent.ACTION_PICK, null);
|
||||
intent.setDataAndType(MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
|
||||
"video/*");
|
||||
intent.setDataAndType(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, "video/*");
|
||||
startActivityForResult(intent, BaseUrlApi.CAMERA_REQUEST_PHOTO);
|
||||
buttomDialogView.dismiss();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void choseShoot() {
|
||||
ARouter.getInstance()
|
||||
.build(PathConfig.PATH_MODULE_BASELIB_TAKE_PHOTO)
|
||||
.withString("path", getExternalFilesDir(Environment.DIRECTORY_DOCUMENTS).getPath())
|
||||
.withString("type", "video")
|
||||
.navigation(mActivity, BaseUrlApi.CAMERA_REQUEST_VIDEO);
|
||||
ARouter.getInstance().build(PathConfig.PATH_MODULE_BASELIB_TAKE_PHOTO).withString("path", getExternalFilesDir(Environment.DIRECTORY_DOCUMENTS).getPath()).withString("type", "video").navigation(mActivity, BaseUrlApi.CAMERA_REQUEST_VIDEO);
|
||||
buttomDialogView.dismiss();
|
||||
}
|
||||
|
||||
@ -685,51 +641,39 @@ public class TaskConverIncidentReportActivity extends BaseActivity {
|
||||
if (file.exists()) {
|
||||
RequestBody requestFile = RequestBody.create(MediaType.parse("multipart/form-data"), file);
|
||||
MultipartBody.Part body = MultipartBody.Part.createFormData("video", file.getName(), requestFile);
|
||||
RetrofitManager.getInstance()
|
||||
.create(BaseApiService.class)
|
||||
.uploadVideo(body, UserLgUtils.getToken())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<BaseSuccessBean>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
RetrofitManager.getInstance().create(BaseApiService.class).uploadVideo(body, UserLgUtils.getToken()).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer<BaseSuccessBean>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(BaseSuccessBean baseUserBean) {
|
||||
if (progressDialog.isShowing()) {
|
||||
progressDialog.dismiss();
|
||||
}
|
||||
ToastUtils.show("上传成功");
|
||||
mVideoPath = videoPath;
|
||||
mVideoId = baseUserBean.getData();
|
||||
mIvDelVideo.setVisibility(View.VISIBLE);
|
||||
mIvPlayVideo.setBackgroundResource(R.drawable.ic_play_white_icon);
|
||||
Glide.with(mActivity).setDefaultRequestOptions(new RequestOptions().frame(0).centerCrop()).load(videoPath).into(mIvCover);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(BaseSuccessBean baseUserBean) {
|
||||
if (progressDialog.isShowing()) {
|
||||
progressDialog.dismiss();
|
||||
}
|
||||
ToastUtils.show("上传成功");
|
||||
mVideoPath = videoPath;
|
||||
mVideoId = baseUserBean.getData();
|
||||
mIvDelVideo.setVisibility(View.VISIBLE);
|
||||
mIvPlayVideo.setBackgroundResource(R.drawable.ic_play_white_icon);
|
||||
Glide.with(mActivity)
|
||||
.setDefaultRequestOptions(
|
||||
new RequestOptions()
|
||||
.frame(0)
|
||||
.centerCrop()
|
||||
)
|
||||
.load(videoPath)
|
||||
.into(mIvCover);
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
if (progressDialog.isShowing()) {
|
||||
progressDialog.dismiss();
|
||||
}
|
||||
ExceptionHandler.handleException(e);
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
if (progressDialog.isShowing()) {
|
||||
progressDialog.dismiss();
|
||||
}
|
||||
ExceptionHandler.handleException(e);
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
progressDialog.dismiss();
|
||||
ToastUtils.show("视频文件路径有误.");
|
||||
@ -748,46 +692,41 @@ public class TaskConverIncidentReportActivity extends BaseActivity {
|
||||
if (file.exists()) {
|
||||
RequestBody requestFile = RequestBody.create(MediaType.parse("multipart/form-data"), file);
|
||||
MultipartBody.Part body = MultipartBody.Part.createFormData("audio", file.getName(), requestFile);
|
||||
RetrofitManager.getInstance()
|
||||
.create(BaseApiService.class)
|
||||
.uploadAudio(body, UserLgUtils.getToken())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<BaseSuccessBean>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
RetrofitManager.getInstance().create(BaseApiService.class).uploadAudio(body, UserLgUtils.getToken()).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer<BaseSuccessBean>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(BaseSuccessBean baseUserBean) {
|
||||
if (progressDialog.isShowing()) {
|
||||
progressDialog.dismiss();
|
||||
}
|
||||
ToastUtils.show("上传成功");
|
||||
mAudioPath = filePath;
|
||||
mAudioId = baseUserBean.getData();
|
||||
mTvVoiceAnim.setVisibility(View.VISIBLE);
|
||||
mIvDelAudio.setVisibility(View.VISIBLE);
|
||||
mArbAudio.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(BaseSuccessBean baseUserBean) {
|
||||
if (progressDialog.isShowing()) {
|
||||
progressDialog.dismiss();
|
||||
}
|
||||
ToastUtils.show("上传成功");
|
||||
mAudioPath = filePath;
|
||||
mAudioId = baseUserBean.getData();
|
||||
mTvVoiceAnim.setVisibility(View.VISIBLE);
|
||||
mIvDelAudio.setVisibility(View.VISIBLE);
|
||||
mArbAudio.setVisibility(View.GONE);
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
if (progressDialog.isShowing()) {
|
||||
progressDialog.dismiss();
|
||||
}
|
||||
mTvVoiceAnim.setVisibility(View.GONE);
|
||||
mIvDelAudio.setVisibility(View.GONE);
|
||||
mArbAudio.setVisibility(View.VISIBLE);
|
||||
ExceptionHandler.handleException(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
if (progressDialog.isShowing()) {
|
||||
progressDialog.dismiss();
|
||||
}
|
||||
mTvVoiceAnim.setVisibility(View.GONE);
|
||||
mIvDelAudio.setVisibility(View.GONE);
|
||||
mArbAudio.setVisibility(View.VISIBLE);
|
||||
ExceptionHandler.handleException(e);
|
||||
}
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
progressDialog.dismiss();
|
||||
ToastUtils.show("录音文件路径有误.");
|
||||
@ -810,46 +749,41 @@ public class TaskConverIncidentReportActivity extends BaseActivity {
|
||||
progressDialog.show();
|
||||
RequestBody requestFile = RequestBody.create(MediaType.parse("multipart/form-data"), file);
|
||||
MultipartBody.Part body = MultipartBody.Part.createFormData("image", file.getName(), requestFile);
|
||||
RetrofitManager.getInstance()
|
||||
.create(BaseApiService.class)
|
||||
.uploadImage(body, UserLgUtils.getToken())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<BaseSuccessBean>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
RetrofitManager.getInstance().create(BaseApiService.class).uploadImage(body, UserLgUtils.getToken()).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer<BaseSuccessBean>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(BaseSuccessBean baseUserBean) {
|
||||
if (progressDialog != null && progressDialog.isShowing()) {
|
||||
progressDialog.dismiss();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(BaseSuccessBean baseUserBean) {
|
||||
if (progressDialog != null && progressDialog.isShowing()) {
|
||||
progressDialog.dismiss();
|
||||
}
|
||||
ToastUtils.show("上传成功");
|
||||
mPhotoIds += (baseUserBean.getData() + ",");
|
||||
mCurrentBean.setId(baseUserBean.getData());
|
||||
mCurrentBean.setPath(picPath);
|
||||
if (mPhotos.size() < 4) {
|
||||
mPhotos.add(new AddPhotoBean());
|
||||
}
|
||||
mAddPhotoAdapter.notifyDataSetChanged();
|
||||
mCurrentBean = null;
|
||||
ToastUtils.show("上传成功");
|
||||
mPhotoIds += (baseUserBean.getData() + ",");
|
||||
mCurrentBean.setId(baseUserBean.getData());
|
||||
mCurrentBean.setPath(picPath);
|
||||
if (mPhotos.size() < 4) {
|
||||
mPhotos.add(new AddPhotoBean());
|
||||
}
|
||||
mAddPhotoAdapter.notifyDataSetChanged();
|
||||
mCurrentBean = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
if (progressDialog != null && progressDialog.isShowing()) {
|
||||
progressDialog.dismiss();
|
||||
}
|
||||
ExceptionHandler.handleException(e);
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
if (progressDialog != null && progressDialog.isShowing()) {
|
||||
progressDialog.dismiss();
|
||||
}
|
||||
ExceptionHandler.handleException(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -871,12 +805,7 @@ public class TaskConverIncidentReportActivity extends BaseActivity {
|
||||
} else {
|
||||
ToastUtils.show("详细类型数据未录入,无法选取");
|
||||
}
|
||||
})
|
||||
.setTitleText("请选择")
|
||||
.setCancelColor(Color.parseColor("#1189FF"))
|
||||
.setSubmitColor(Color.parseColor("#1189FF"))
|
||||
.setTitleColor(Color.parseColor("#1189FF"))
|
||||
.build();
|
||||
}).setTitleText("请选择").setCancelColor(Color.parseColor("#1189FF")).setSubmitColor(Color.parseColor("#1189FF")).setTitleColor(Color.parseColor("#1189FF")).build();
|
||||
mTypePicker.setPicker(mTypeList, mTypeSubList);
|
||||
}
|
||||
mTypePicker.show();
|
||||
@ -891,39 +820,34 @@ public class TaskConverIncidentReportActivity extends BaseActivity {
|
||||
private void getTypeDatas() {
|
||||
ProgressDialog dialog = UIUtil.initDialog(mActivity, "获取中...");
|
||||
dialog.show();
|
||||
RetrofitManager.getInstance()
|
||||
.create(GridApis.class)
|
||||
.getCaseTypeListAll(UserLgUtils.getToken())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<List<CaseTypeBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
RetrofitManager.getInstance().create(GridApis.class).getCaseTypeListAll(UserLgUtils.getToken()).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer<List<CaseTypeBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull List<CaseTypeBean> componentTypeBeans) {
|
||||
dialog.dismiss();
|
||||
if (componentTypeBeans != null && componentTypeBeans.size() > 0) {
|
||||
mTypeList = componentTypeBeans;
|
||||
buildTypeSubBean();
|
||||
} else {
|
||||
ToastUtils.show("暂无数据");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull List<CaseTypeBean> componentTypeBeans) {
|
||||
dialog.dismiss();
|
||||
if (componentTypeBeans != null && componentTypeBeans.size() > 0) {
|
||||
mTypeList = componentTypeBeans;
|
||||
buildTypeSubBean();
|
||||
} else {
|
||||
ToastUtils.show("暂无数据");
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
dialog.dismiss();
|
||||
ExceptionHandler.handleException(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
dialog.dismiss();
|
||||
ExceptionHandler.handleException(e);
|
||||
}
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void buildTypeSubBean() {
|
||||
|
@ -330,14 +330,15 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.3">
|
||||
|
||||
<com.tenlionsoft.baselib.core.widget.videorecord.AudioRecordButton
|
||||
<com.tenlionsoft.baselib.core.widget.voicebutton.VoiceButton
|
||||
android:id="@+id/arb_audio"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="35dp"
|
||||
android:background="@drawable/sel_btn_submit_circle"
|
||||
android:gravity="center"
|
||||
android:text="@string/long_click_record"
|
||||
android:textColor="#fff" />
|
||||
android:textColor="#fff"
|
||||
android:textSize="14dp" />
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_del_audio"
|
||||
|
@ -329,7 +329,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.3">
|
||||
|
||||
<com.tenlionsoft.baselib.core.widget.videorecord.AudioRecordButton
|
||||
<com.tenlionsoft.baselib.core.widget.voicebutton.VoiceButton
|
||||
android:id="@+id/arb_audio"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="35dp"
|
||||
|