优化
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
package com.zmkg.coaloperation.dialog
|
||||
|
||||
import android.app.Dialog
|
||||
import android.content.Context
|
||||
import androidx.annotation.StyleRes
|
||||
import com.zmkg.coaloperation.R
|
||||
|
||||
open class BaseDialog(context: Context, @StyleRes dialogTheme: Int) :
|
||||
Dialog(context, dialogTheme) {
|
||||
constructor(context: Context) : this(context, R.style.DialogTheme)
|
||||
|
||||
override fun show() {
|
||||
super.show()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package com.zmkg.coaloperation.dialog
|
||||
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.os.Bundle
|
||||
import android.text.SpannableStringBuilder
|
||||
import android.view.Gravity
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.WindowManager
|
||||
import android.widget.TextView
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import com.allen.library.shape.ShapeButton
|
||||
import com.zmkg.coaloperation.databinding.DialogCommonBinding
|
||||
import com.zmkg.coaloperation.utils.dp
|
||||
|
||||
class CustomCenterDialog(
|
||||
var activity: FragmentActivity,
|
||||
var defaultWidth: Int = 300.dp
|
||||
) : BaseDialog(activity) {
|
||||
|
||||
private lateinit var binding: DialogCommonBinding
|
||||
|
||||
var dialogCancelable = false
|
||||
var dialogCanceledOnTouchOutside = false
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
binding = DialogCommonBinding.inflate(LayoutInflater.from(activity))
|
||||
setContentView(binding.root)
|
||||
|
||||
setCancelable(dialogCancelable)
|
||||
setCanceledOnTouchOutside(dialogCanceledOnTouchOutside)
|
||||
window?.apply {
|
||||
setLayout(defaultWidth, WindowManager.LayoutParams.WRAP_CONTENT)
|
||||
setBackgroundDrawable(ColorDrawable())
|
||||
setGravity(Gravity.CENTER)
|
||||
}
|
||||
binding.btnCancel.setOnClickListener { onLeftClick?.invoke(this) }
|
||||
binding.btnConfirm.setOnClickListener { onRightClick?.invoke(this) }
|
||||
}
|
||||
|
||||
private var dialogTitle: String = ""
|
||||
fun setDialogTitle(title: String) {
|
||||
this.dialogTitle = title
|
||||
}
|
||||
|
||||
private var dialogContent: String = ""
|
||||
fun setDialogContent(content: String) {
|
||||
this.dialogContent = content
|
||||
}
|
||||
|
||||
private var spannableBuilder: SpannableStringBuilder? = null
|
||||
fun setDialogContent(spannableBuilder: SpannableStringBuilder) {
|
||||
this.spannableBuilder = spannableBuilder
|
||||
}
|
||||
|
||||
private var dialogLeftBtnText = ""
|
||||
private var onLeftClick: ((CustomCenterDialog) -> Unit)? = null
|
||||
fun setCancelButton(
|
||||
text: String,
|
||||
onClick: (CustomCenterDialog) -> Unit
|
||||
) {
|
||||
this.dialogLeftBtnText = text
|
||||
this.onLeftClick = onClick
|
||||
}
|
||||
|
||||
private var dialogRightBtnText = ""
|
||||
private var onRightClick: ((CustomCenterDialog) -> Unit)? = null
|
||||
fun setConfirmButton(
|
||||
text: String,
|
||||
onClick: (CustomCenterDialog) -> Unit
|
||||
) {
|
||||
this.dialogRightBtnText = text
|
||||
this.onRightClick = onClick
|
||||
}
|
||||
|
||||
private var showSingleButton = false
|
||||
fun setShowSingleButton(show: Boolean) {
|
||||
this.showSingleButton = show
|
||||
}
|
||||
|
||||
|
||||
var bgLayoutSetting: ((View) -> Unit)? = null
|
||||
var titleSetting: ((TextView) -> Unit)? = null
|
||||
var contentSetting: ((TextView) -> Unit)? = null
|
||||
var leftBtnSetting: ((ShapeButton) -> Unit)? = null
|
||||
var rightBtnSetting: ((ShapeButton) -> Unit)? = null
|
||||
|
||||
override fun show() {
|
||||
super.show()
|
||||
|
||||
binding.tvDialogTitle.apply {
|
||||
text = dialogTitle
|
||||
}
|
||||
binding.tvDialogContent.apply {
|
||||
text = dialogContent
|
||||
}
|
||||
|
||||
bgLayoutSetting?.invoke(binding.root)
|
||||
titleSetting?.invoke(binding.tvDialogTitle)
|
||||
contentSetting?.invoke(binding.tvDialogContent)
|
||||
leftBtnSetting?.invoke(binding.btnCancel)
|
||||
rightBtnSetting?.invoke(binding.btnConfirm)
|
||||
}
|
||||
}
|
||||
+4
@@ -19,11 +19,13 @@ import com.luck.picture.lib.interfaces.OnResultCallbackListener
|
||||
import com.luck.picture.lib.utils.SandboxTransformUtils
|
||||
import com.zmkg.coaloperation.utils.pictureSelector.ImageFileCompressEngine
|
||||
import com.zmkg.coaloperation.R
|
||||
import com.zmkg.coaloperation.base.BaseActivity
|
||||
import com.zmkg.coaloperation.base.BaseVMBFragment
|
||||
import com.zmkg.coaloperation.bean.ImageBean
|
||||
import com.zmkg.coaloperation.databinding.FragmentReportBinding
|
||||
import com.zmkg.coaloperation.ui.report.adapter.ImageAdapter
|
||||
import com.zmkg.coaloperation.ui.report.viewmodel.ReportViewModel
|
||||
import com.zmkg.coaloperation.utils.permission.StorageUtils
|
||||
import com.zmkg.coaloperation.utils.pictureSelector.GlideEngine
|
||||
import kotlinx.coroutines.flow.collectLatest
|
||||
import kotlinx.coroutines.launch
|
||||
@@ -121,6 +123,7 @@ class ReportFragment :
|
||||
val imageBean: ImageBean = adapter.getItem(position) as ImageBean
|
||||
imageBean?.let { it ->
|
||||
if (it.isAddButton) {
|
||||
StorageUtils.requestPermission(context as BaseActivity) {
|
||||
initPictureSelectorModel()
|
||||
.forResult(object : OnResultCallbackListener<LocalMedia?> {
|
||||
override fun onResult(result: ArrayList<LocalMedia?>?) {
|
||||
@@ -133,6 +136,7 @@ class ReportFragment :
|
||||
|
||||
override fun onCancel() {}
|
||||
})
|
||||
}
|
||||
} else {
|
||||
// startFullScreenImageActivity(
|
||||
// it.isFilePath,
|
||||
|
||||
+12
-12
@@ -11,21 +11,21 @@ object StorageUtils {
|
||||
|
||||
fun requestPermission(activity: BaseActivity, callback: () -> Unit) {
|
||||
activity.requestSinglePermissionResult(Manifest.permission.CAMERA) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
if (Environment.isExternalStorageManager()) {
|
||||
callback()
|
||||
} else {
|
||||
val intent = Intent(Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION)
|
||||
// activity.startActivityForResult(intent, MANAGE_REQUEST_CODE)
|
||||
activity.launchActivityResult(intent) {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
// if (Environment.isExternalStorageManager()) {
|
||||
// callback()
|
||||
// } else {
|
||||
// val intent = Intent(Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION)
|
||||
//// activity.startActivityForResult(intent, MANAGE_REQUEST_CODE)
|
||||
// activity.launchActivityResult(intent) {
|
||||
// callback()
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
activity.requestSinglePermissionResult(Manifest.permission.WRITE_EXTERNAL_STORAGE) {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<com.allen.library.shape.ShapeLinearLayout
|
||||
android:layout_width="300dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
app:shapeCornersRadius="30dp"
|
||||
app:shapeSolidColor="#17181C"
|
||||
app:shapeStrokeColor="#282C38"
|
||||
app:shapeStrokeWidth="1dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvDialogTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="50dp"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="20sp"
|
||||
tools:text="保存" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvDialogContent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="20dp"
|
||||
android:textColor="#6A6F87"
|
||||
android:textSize="14sp"
|
||||
tools:text="是否确认保存输入的消息" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="44dp"
|
||||
android:layout_marginBottom="50dp"
|
||||
android:layout_marginTop="30dp">
|
||||
|
||||
<com.allen.library.shape.ShapeButton
|
||||
android:id="@+id/btnCancel"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_weight="1"
|
||||
android:textSize="14sp"
|
||||
app:shapeCornersRadius="22dp"
|
||||
tools:text="取消"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/white"
|
||||
app:shapeSolidColor="#353846" />
|
||||
|
||||
<com.allen.library.shape.ShapeButton
|
||||
android:id="@+id/btnConfirm"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:layout_weight="1"
|
||||
android:textSize="14sp"
|
||||
tools:text="确定"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/white"
|
||||
app:shapeCornersRadius="22dp"
|
||||
app:shapeSolidColor="#21A69A" />
|
||||
</LinearLayout>
|
||||
|
||||
</com.allen.library.shape.ShapeLinearLayout>
|
||||
</layout>
|
||||
@@ -28,14 +28,13 @@
|
||||
android:layout_marginBottom="70dp">
|
||||
|
||||
|
||||
<com.allen.library.shape.ShapeLinearLayout
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="10dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:orientation="vertical"
|
||||
app:shapeCornersRadius="6dp"
|
||||
app:shapeSolidColor="@color/theme_color">
|
||||
android:background="@drawable/bg_stroke_gray">
|
||||
|
||||
<com.zmkg.coaloperation.view.CustomTextSelectView
|
||||
android:id="@+id/type"
|
||||
@@ -153,7 +152,7 @@
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
</com.allen.library.shape.ShapeLinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
|
||||
@@ -38,5 +38,9 @@
|
||||
<!-- 遮罩层 -->
|
||||
<item name="android:backgroundDimAmount">0.5</item>
|
||||
</style>
|
||||
|
||||
<!-- <style name="Theme_dialog" parent="@android:style/Theme.Dialog">-->
|
||||
<!-- <item name="android:windowBackground">@android:color/transparent</item>-->
|
||||
<!-- <item name="android:windowNoTitle">true</item>-->
|
||||
<!-- <item name="android:windowIsFloating">true</item>-->
|
||||
<!-- </style>-->
|
||||
</resources>
|
||||
Reference in New Issue
Block a user