|
|
@@ -2,7 +2,6 @@ package com.yingyang.healthconsultation.consultationsheet
|
|
|
|
|
|
import android.Manifest
|
|
|
import android.annotation.SuppressLint
|
|
|
-import android.app.Activity
|
|
|
import android.content.Context
|
|
|
import android.content.Intent
|
|
|
import android.os.Bundle
|
|
|
@@ -16,13 +15,11 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
|
|
import androidx.recyclerview.widget.RecyclerView
|
|
|
import com.alibaba.android.arouter.facade.annotation.Route
|
|
|
import com.alibaba.android.arouter.launcher.ARouter
|
|
|
-import com.donkingliang.imageselector.utils.ImageSelector
|
|
|
import com.hjq.permissions.OnPermissionCallback
|
|
|
import com.hjq.permissions.XXPermissions
|
|
|
import com.yingyang.healthconsultation.R
|
|
|
import com.yingyang.healthconsultation.adapter.SickTimeAdapter
|
|
|
import com.yingyang.healthconsultation.databinding.ActivityConsultationSheetBinding
|
|
|
-import com.yingyang.healthconsultation.dialog.SelectPicDialog
|
|
|
import com.yingyang.healthconsultation.entity.PurchaseConsultationBean
|
|
|
import com.yingyang.healthconsultation.entity.UploadImgBean
|
|
|
import com.yingyang.healthconsultation.utils.CommonUtils
|
|
|
@@ -33,6 +30,7 @@ import com.yingyangfly.baselib.ext.getEndAnimation
|
|
|
import com.yingyangfly.baselib.ext.getScaleAnimation
|
|
|
import com.yingyangfly.baselib.ext.setOnSingleClickListener
|
|
|
import com.yingyangfly.baselib.ext.toast
|
|
|
+import com.yingyangfly.baselib.image.XImageSelector
|
|
|
import com.yingyangfly.baselib.mvvm.BaseMVVMActivity
|
|
|
import com.yingyangfly.baselib.router.RouterUrlCommon
|
|
|
import com.yingyangfly.baselib.utils.LogUtil
|
|
|
@@ -177,25 +175,11 @@ class ConsultationSheetActivity :
|
|
|
* 图片选择弹框
|
|
|
*/
|
|
|
private fun selectPic() {
|
|
|
- val dialog = SelectPicDialog()
|
|
|
- dialog.onDialogClickListener = {
|
|
|
- if (TextUtils.equals("album", it)) {
|
|
|
- ImageSelector.builder()
|
|
|
- .useCamera(false) // 设置是否使用拍照
|
|
|
- .setSingle(false) //设置是否单选
|
|
|
- .canPreview(true) //是否点击放大图片查看,,默认为true
|
|
|
- .setMaxSelectCount(if (getImgLocalPaths().size > 0) 9 - getImgLocalPaths().size else 9) // 图片的最大选择数量,小于等于0时,不限数量
|
|
|
- .start(this, requestMedicalRecordsImg) // 打开相册
|
|
|
- } else {
|
|
|
- ImageSelector.builder()
|
|
|
- .useCamera(true)
|
|
|
- .onlyTakePhoto(true)
|
|
|
- .setCrop(false)
|
|
|
- .setSelected(getImgLocalPaths())
|
|
|
- .start(this, requestMedicalRecordsCamera)
|
|
|
- }
|
|
|
- }
|
|
|
- dialog.show(supportFragmentManager, "SelectPicDialog")
|
|
|
+ XImageSelector.config(
|
|
|
+ if (getImgLocalPaths().size > 0) 9 - getImgLocalPaths().size else 9,
|
|
|
+ true,
|
|
|
+ onlyTakePhoto = true
|
|
|
+ ).selectLocal(this@ConsultationSheetActivity)
|
|
|
}
|
|
|
|
|
|
private fun getImgLocalPaths(): ArrayList<String> {
|
|
|
@@ -259,18 +243,9 @@ class ConsultationSheetActivity :
|
|
|
|
|
|
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
|
|
super.onActivityResult(requestCode, resultCode, data)
|
|
|
- if (resultCode == Activity.RESULT_OK) {
|
|
|
- if (requestCode == requestMedicalRecordsCamera) {//拍照
|
|
|
- val images = data?.getStringArrayListExtra(ImageSelector.SELECT_RESULT)
|
|
|
- images?.let {
|
|
|
- withLs(it)
|
|
|
- }
|
|
|
- } else if (requestCode == requestMedicalRecordsImg) {//选择图片
|
|
|
- val images = data?.getStringArrayListExtra(ImageSelector.SELECT_RESULT)
|
|
|
- images?.let {
|
|
|
- withLs(it)
|
|
|
- }
|
|
|
- }
|
|
|
+ val images = XImageSelector.parseResult(requestCode, data)
|
|
|
+ images?.let {
|
|
|
+ withLs(it)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -281,13 +256,11 @@ class ConsultationSheetActivity :
|
|
|
Luban.with(this)
|
|
|
.load(photos)
|
|
|
.ignoreBy(100)
|
|
|
- .setTargetDir(getPath())
|
|
|
.setFocusAlpha(false)
|
|
|
.filter { path -> !(TextUtils.isEmpty(path) || path.lowercase().endsWith(".gif")) }
|
|
|
.setCompressListener(
|
|
|
object : OnCompressListener {
|
|
|
override fun onStart() {
|
|
|
-
|
|
|
}
|
|
|
|
|
|
override fun onSuccess(file: File) {
|
|
|
@@ -298,6 +271,7 @@ class ConsultationSheetActivity :
|
|
|
|
|
|
override fun onError(e: Throwable) {
|
|
|
LogUtil.e("图片压缩失败:$e")
|
|
|
+ addImages(photos)
|
|
|
}
|
|
|
}).launch()
|
|
|
}
|