上报页面优化
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package com.zmkg.coaloperation
|
package com.zmkg.coaloperation
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
@@ -10,7 +11,7 @@ import com.zmkg.coaloperation.bottomtab.HomeBottomTabLayout
|
|||||||
import com.zmkg.coaloperation.databinding.ActivityMainBinding
|
import com.zmkg.coaloperation.databinding.ActivityMainBinding
|
||||||
import com.zmkg.coaloperation.ui.home.fragment.HomeFragment
|
import com.zmkg.coaloperation.ui.home.fragment.HomeFragment
|
||||||
import com.zmkg.coaloperation.ui.record.fragment.RecordFragment
|
import com.zmkg.coaloperation.ui.record.fragment.RecordFragment
|
||||||
import com.zmkg.coaloperation.ui.report.fragment.ReportFragment
|
import com.zmkg.coaloperation.ui.report.fragment.Report2Fragment
|
||||||
import com.zmkg.coaloperation.ui.user.fragment.UserFragment
|
import com.zmkg.coaloperation.ui.user.fragment.UserFragment
|
||||||
|
|
||||||
class MainActivity : BaseVMBActivity<TestViewModel, ActivityMainBinding>(R.layout.activity_main),
|
class MainActivity : BaseVMBActivity<TestViewModel, ActivityMainBinding>(R.layout.activity_main),
|
||||||
@@ -56,7 +57,7 @@ class MainActivity : BaseVMBActivity<TestViewModel, ActivityMainBinding>(R.layou
|
|||||||
}
|
}
|
||||||
|
|
||||||
TAG_REPORT -> {
|
TAG_REPORT -> {
|
||||||
return ReportFragment()
|
return Report2Fragment()
|
||||||
}
|
}
|
||||||
|
|
||||||
// TAG_MESSAGE -> {
|
// TAG_MESSAGE -> {
|
||||||
@@ -77,4 +78,5 @@ class MainActivity : BaseVMBActivity<TestViewModel, ActivityMainBinding>(R.layou
|
|||||||
override fun transparentStatusBar(): Boolean {
|
override fun transparentStatusBar(): Boolean {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package com.zmkg.coaloperation.adapter
|
||||||
|
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.core.view.updateLayoutParams
|
||||||
|
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||||
|
import com.chad.library.adapter.base.viewholder.BaseViewHolder
|
||||||
|
import com.zmkg.coaloperation.R
|
||||||
|
import com.zmkg.coaloperation.bean.CommonImageBean
|
||||||
|
import com.zmkg.coaloperation.databinding.ListItemCommonImageBinding
|
||||||
|
import com.zmkg.coaloperation.superfuntion.loadRoundedImage
|
||||||
|
import com.zmkg.coaloperation.utils.dp
|
||||||
|
import com.zmkg.coaloperation.utils.load
|
||||||
|
|
||||||
|
class CommonImageAdapter(var list: MutableList<CommonImageBean>, var imageSize: Int = 70.dp):
|
||||||
|
BaseQuickAdapter<CommonImageBean, CommonImageAdapter.VH>(
|
||||||
|
R.layout.list_item_common_image, list
|
||||||
|
){
|
||||||
|
|
||||||
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): VH {
|
||||||
|
val binding = ListItemCommonImageBinding.inflate(
|
||||||
|
LayoutInflater.from(context), parent, false
|
||||||
|
)
|
||||||
|
return VH(binding).also {
|
||||||
|
bindViewClickListener(it, viewType)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun convert(
|
||||||
|
holder: VH,
|
||||||
|
item: CommonImageBean
|
||||||
|
) {
|
||||||
|
holder.binding.ivImage.let {
|
||||||
|
it.updateLayoutParams {
|
||||||
|
width = imageSize
|
||||||
|
height = imageSize
|
||||||
|
}
|
||||||
|
if (item.isAddFlag) {
|
||||||
|
it.load(R.drawable.ic_add_image)
|
||||||
|
} else {
|
||||||
|
it.loadRoundedImage(item.imagePath, 3F)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inner class VH(var binding: ListItemCommonImageBinding): BaseViewHolder(binding.root)
|
||||||
|
|
||||||
|
}
|
||||||
-41
@@ -1,41 +0,0 @@
|
|||||||
package com.zmkg.coaloperation.adapter
|
|
||||||
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
|
||||||
import com.chad.library.adapter.base.viewholder.BaseViewHolder
|
|
||||||
import com.zmkg.coaloperation.R
|
|
||||||
import com.zmkg.coaloperation.bean.GeoPointImage
|
|
||||||
import com.zmkg.coaloperation.databinding.ListItemPointImageBinding
|
|
||||||
import com.zmkg.coaloperation.utils.load
|
|
||||||
|
|
||||||
class GeoPointImageAdapter(list: MutableList<GeoPointImage>):
|
|
||||||
BaseQuickAdapter<GeoPointImage, GeoPointImageAdapter.VH>(
|
|
||||||
R.layout.list_item_point_image, list
|
|
||||||
){
|
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): VH {
|
|
||||||
val binding = ListItemPointImageBinding.inflate(
|
|
||||||
LayoutInflater.from(context), parent, false
|
|
||||||
)
|
|
||||||
return VH(binding).also {
|
|
||||||
bindViewClickListener(it, viewType)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun convert(
|
|
||||||
holder: VH,
|
|
||||||
item: GeoPointImage
|
|
||||||
) {
|
|
||||||
holder.binding.ivPointImage.let {
|
|
||||||
if (item.isAddFlag) {
|
|
||||||
it.load(R.drawable.ic_add_image)
|
|
||||||
} else {
|
|
||||||
it.load(item.imagePath)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inner class VH(var binding: ListItemPointImageBinding): BaseViewHolder(binding.root)
|
|
||||||
|
|
||||||
}
|
|
||||||
+21
-11
@@ -1,7 +1,6 @@
|
|||||||
package com.zmkg.coaloperation.adapter
|
package com.zmkg.coaloperation.adapter
|
||||||
|
|
||||||
import android.Manifest
|
import android.annotation.SuppressLint
|
||||||
import android.app.Activity
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import androidx.core.view.updateLayoutParams
|
import androidx.core.view.updateLayoutParams
|
||||||
@@ -9,14 +8,13 @@ import androidx.recyclerview.widget.GridLayoutManager
|
|||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter
|
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter
|
||||||
import com.chad.library.adapter.base.viewholder.BaseViewHolder
|
import com.chad.library.adapter.base.viewholder.BaseViewHolder
|
||||||
|
import com.zhihu.matisse.Matisse
|
||||||
import com.zmkg.coaloperation.R
|
import com.zmkg.coaloperation.R
|
||||||
import com.zmkg.coaloperation.base.BaseActivity
|
import com.zmkg.coaloperation.base.BaseActivity
|
||||||
import com.zmkg.coaloperation.bean.BaseItem
|
import com.zmkg.coaloperation.bean.CommonImageBean
|
||||||
import com.zmkg.coaloperation.bean.GeoPointImage
|
|
||||||
import com.zmkg.coaloperation.bean.GeoPointMultiItem
|
import com.zmkg.coaloperation.bean.GeoPointMultiItem
|
||||||
import com.zmkg.coaloperation.databinding.ListItemPointBaseHorizontalBinding
|
import com.zmkg.coaloperation.databinding.ListItemPointBaseHorizontalBinding
|
||||||
import com.zmkg.coaloperation.databinding.ListItemPointBaseVerticalBinding
|
import com.zmkg.coaloperation.databinding.ListItemPointBaseVerticalBinding
|
||||||
import com.zmkg.coaloperation.ui.geologging.AddGeologicalPointFragment
|
|
||||||
import com.zmkg.coaloperation.utils.GalleryUtils
|
import com.zmkg.coaloperation.utils.GalleryUtils
|
||||||
import com.zmkg.coaloperation.utils.gone
|
import com.zmkg.coaloperation.utils.gone
|
||||||
import com.zmkg.coaloperation.utils.permission.StorageUtils
|
import com.zmkg.coaloperation.utils.permission.StorageUtils
|
||||||
@@ -60,18 +58,16 @@ class GeoPointMultiAdapter(list: MutableList<GeoPointMultiItem>) :
|
|||||||
if (item.images == null) {
|
if (item.images == null) {
|
||||||
item.images = mutableListOf()
|
item.images = mutableListOf()
|
||||||
}
|
}
|
||||||
|
val images = item.images!!
|
||||||
rvImageList.let { rv ->
|
rvImageList.let { rv ->
|
||||||
rv.layoutManager = GridLayoutManager(rv.context, 4, GridLayoutManager.VERTICAL, false)
|
rv.layoutManager = GridLayoutManager(rv.context, 4, GridLayoutManager.VERTICAL, false)
|
||||||
rv.adapter = GeoPointImageAdapter(item.images!!).also {
|
rv.adapter = CommonImageAdapter(images).also {
|
||||||
it.setOnItemClickListener { adapter, view, position ->
|
it.setOnItemClickListener { adapter, view, position ->
|
||||||
if (it.data[position].isAddFlag.not()) {
|
if (it.data[position].isAddFlag.not()) {
|
||||||
return@setOnItemClickListener
|
return@setOnItemClickListener
|
||||||
}
|
}
|
||||||
(context as BaseActivity).let { activity ->
|
openGallery(context as BaseActivity, it)
|
||||||
StorageUtils.requestPermission(activity) {
|
}
|
||||||
GalleryUtils.openGallery(context as Activity, AddGeologicalPointFragment.IMAGE_REQUEST_CODE)
|
|
||||||
}
|
|
||||||
} }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -121,4 +117,18 @@ class GeoPointMultiAdapter(list: MutableList<GeoPointMultiItem>) :
|
|||||||
llBaseBottom.addView(itemBinding.root)
|
llBaseBottom.addView(itemBinding.root)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("NotifyDataSetChanged")
|
||||||
|
private fun openGallery(activity: BaseActivity, adapter: CommonImageAdapter) {
|
||||||
|
StorageUtils.requestPermission(activity) {
|
||||||
|
GalleryUtils.openGallery(activity) { data ->
|
||||||
|
val paths = Matisse.obtainPathResult(data) // 获取文件路径列表
|
||||||
|
paths?.forEach { path ->
|
||||||
|
val size = adapter.list.size
|
||||||
|
adapter.list.add(size - 1, CommonImageBean(imagePath = path))
|
||||||
|
}
|
||||||
|
adapter.notifyDataSetChanged()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,143 @@
|
|||||||
|
package com.zmkg.coaloperation.adapter
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
|
import android.view.Gravity
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.widget.LinearLayout
|
||||||
|
import androidx.core.view.updateLayoutParams
|
||||||
|
import androidx.recyclerview.widget.GridLayoutManager
|
||||||
|
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||||
|
import com.chad.library.adapter.base.viewholder.BaseViewHolder
|
||||||
|
import com.zhihu.matisse.Matisse
|
||||||
|
import com.zmkg.coaloperation.R
|
||||||
|
import com.zmkg.coaloperation.base.BaseActivity
|
||||||
|
import com.zmkg.coaloperation.bean.CommonImageBean
|
||||||
|
import com.zmkg.coaloperation.bean.ReportItem
|
||||||
|
import com.zmkg.coaloperation.databinding.ListItemReportBinding
|
||||||
|
import com.zmkg.coaloperation.utils.GalleryUtils
|
||||||
|
import com.zmkg.coaloperation.utils.dp
|
||||||
|
import com.zmkg.coaloperation.utils.gone
|
||||||
|
import com.zmkg.coaloperation.utils.permission.StorageUtils
|
||||||
|
import com.zmkg.coaloperation.utils.visible
|
||||||
|
|
||||||
|
class ReportAdapter(list: MutableList<ReportItem>) :
|
||||||
|
BaseQuickAdapter<ReportItem, ReportAdapter.VH>(R.layout.list_item_report, list) {
|
||||||
|
|
||||||
|
inner class VH(var binding: ListItemReportBinding) : BaseViewHolder(binding.root)
|
||||||
|
|
||||||
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): VH {
|
||||||
|
val binding = ListItemReportBinding.inflate(
|
||||||
|
LayoutInflater.from(context), parent, false
|
||||||
|
)
|
||||||
|
return VH(binding).also {
|
||||||
|
bindViewClickListener(it, viewType)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun convert(holder: VH, item: ReportItem) {
|
||||||
|
val binding = holder.binding
|
||||||
|
val position = holder.layoutPosition
|
||||||
|
binding.tvItemName.run {
|
||||||
|
text = item.name
|
||||||
|
gravity = Gravity.CENTER_VERTICAL
|
||||||
|
updateLayoutParams<LinearLayout.LayoutParams> {
|
||||||
|
gravity = if (item.viewType == 4) Gravity.CENTER_VERTICAL else Gravity.TOP
|
||||||
|
}
|
||||||
|
}
|
||||||
|
binding.divider.run {
|
||||||
|
if (position == data.size - 1) gone() else visible()
|
||||||
|
}
|
||||||
|
when (item.viewType) {
|
||||||
|
1 -> {
|
||||||
|
binding.tvItemValue.gone()
|
||||||
|
binding.rvReportImage.gone()
|
||||||
|
binding.etInputValue.let { et ->
|
||||||
|
et.visible()
|
||||||
|
et.setText(item.value)
|
||||||
|
et.hint = item.inputHint
|
||||||
|
et.isSingleLine = item.isSingleLine
|
||||||
|
if (item.isSingleLine) {
|
||||||
|
et.gravity = Gravity.CENTER_VERTICAL
|
||||||
|
et.setLines(1)
|
||||||
|
et.updateLayoutParams<LinearLayout.LayoutParams> { height = 50.dp }
|
||||||
|
} else {
|
||||||
|
et.gravity = Gravity.TOP
|
||||||
|
et.setLines(item.inputShowLines)
|
||||||
|
et.updateLayoutParams<LinearLayout.LayoutParams> {
|
||||||
|
height = LinearLayout.LayoutParams.WRAP_CONTENT
|
||||||
|
topMargin = 15.dp
|
||||||
|
bottomMargin = 15.dp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
2 -> {
|
||||||
|
binding.rvReportImage.gone()
|
||||||
|
binding.etInputValue.gone()
|
||||||
|
binding.tvItemValue.let { tv ->
|
||||||
|
tv.visible()
|
||||||
|
tv.text = item.value
|
||||||
|
tv.setCompoundDrawablesWithIntrinsicBounds(
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
R.drawable.ic_arrow_down_gray,
|
||||||
|
0
|
||||||
|
)
|
||||||
|
tv.updateLayoutParams<LinearLayout.LayoutParams> {
|
||||||
|
width = LinearLayout.LayoutParams.MATCH_PARENT
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
3 -> {
|
||||||
|
binding.rvReportImage.gone()
|
||||||
|
binding.etInputValue.gone()
|
||||||
|
binding.tvItemValue.let { tv ->
|
||||||
|
tv.visible()
|
||||||
|
tv.text = item.value
|
||||||
|
tv.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_select_time, 0)
|
||||||
|
tv.updateLayoutParams<LinearLayout.LayoutParams> {
|
||||||
|
width = LinearLayout.LayoutParams.WRAP_CONTENT
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
4 -> {
|
||||||
|
binding.tvItemValue.gone()
|
||||||
|
binding.etInputValue.gone()
|
||||||
|
if (item.images == null) {
|
||||||
|
item.images = mutableListOf()
|
||||||
|
}
|
||||||
|
binding.rvReportImage.let { rv ->
|
||||||
|
rv.visible()
|
||||||
|
rv.layoutManager = GridLayoutManager(rv.context, 2)
|
||||||
|
rv.adapter = CommonImageAdapter(item.images!!, 80.dp).also {
|
||||||
|
it.setOnItemClickListener { adapter, view, position ->
|
||||||
|
if (it.data[position].isAddFlag.not()) {
|
||||||
|
return@setOnItemClickListener
|
||||||
|
}
|
||||||
|
openGallery(context as BaseActivity, it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("NotifyDataSetChanged")
|
||||||
|
private fun openGallery(activity: BaseActivity, adapter: CommonImageAdapter) {
|
||||||
|
StorageUtils.requestPermission(activity) {
|
||||||
|
GalleryUtils.openGallery(activity) { data ->
|
||||||
|
val paths = Matisse.obtainPathResult(data) // 获取文件路径列表
|
||||||
|
paths?.forEach { path ->
|
||||||
|
val size = adapter.list.size
|
||||||
|
adapter.list.add(size - 1, CommonImageBean(imagePath = path))
|
||||||
|
}
|
||||||
|
adapter.notifyDataSetChanged()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -63,10 +63,10 @@ data class GeoPointMultiItem(
|
|||||||
var pointName: String = "",
|
var pointName: String = "",
|
||||||
var pointDistance: String = "",
|
var pointDistance: String = "",
|
||||||
var totalDistance: String = "",
|
var totalDistance: String = "",
|
||||||
var baseTopList: MutableList<BaseItem>?=null,
|
var baseTopList: MutableList<BaseItem>? = null,
|
||||||
var baseBottomList: MutableList<BaseItem>?=null,
|
var baseBottomList: MutableList<BaseItem>? = null,
|
||||||
var images: MutableList<GeoPointImage>?=null
|
var images: MutableList<CommonImageBean>? = null
|
||||||
): MultiItemEntity {
|
) : MultiItemEntity {
|
||||||
companion object {
|
companion object {
|
||||||
const val TYPE_BASE_INFO = 1
|
const val TYPE_BASE_INFO = 1
|
||||||
const val TYPE_LOGGING_INFO = 2
|
const val TYPE_LOGGING_INFO = 2
|
||||||
@@ -75,7 +75,19 @@ data class GeoPointMultiItem(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data class GeoPointImage(
|
data class CommonImageBean(
|
||||||
var imagePath: String = "",
|
var imagePath: String = "",
|
||||||
var isAddFlag:Boolean = false
|
var isAddFlag: Boolean = false
|
||||||
|
)
|
||||||
|
|
||||||
|
data class ReportItem(
|
||||||
|
var name: String = "",
|
||||||
|
var value: String = "",
|
||||||
|
var id: String = "",
|
||||||
|
//1-输入框,2-文本选择弹窗,3-时间选择弹窗,4-上传图片
|
||||||
|
var viewType: Int = 0,
|
||||||
|
var inputHint: String = "",
|
||||||
|
var inputShowLines: Int = 0,
|
||||||
|
var isSingleLine: Boolean = true,
|
||||||
|
var images: MutableList<CommonImageBean>? = null
|
||||||
)
|
)
|
||||||
@@ -207,7 +207,7 @@ fun ImageView.loadCircle(@DrawableRes resourceId: Int) {
|
|||||||
* @param imageView View
|
* @param imageView View
|
||||||
* @param placeholder 占位图
|
* @param placeholder 占位图
|
||||||
*/
|
*/
|
||||||
fun ImageView.loadRoundedImage(
|
fun ImageView.loadRoundedImage2(
|
||||||
url: String?,
|
url: String?,
|
||||||
roundingRadius: Float,
|
roundingRadius: Float,
|
||||||
@DrawableRes defaultResId: Int = 0,
|
@DrawableRes defaultResId: Int = 0,
|
||||||
@@ -239,6 +239,32 @@ fun ImageView.loadRoundedImage(
|
|||||||
.into(this)
|
.into(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun ImageView.loadRoundedImage(
|
||||||
|
any: Any,
|
||||||
|
roundingRadius: Float,
|
||||||
|
@DrawableRes defaultResId: Int = 0,
|
||||||
|
isCenterCrop:Boolean = true
|
||||||
|
) {
|
||||||
|
//设置图片圆角角度
|
||||||
|
val roundedCorners = RoundedCorners(dp2px(roundingRadius))
|
||||||
|
val multiTransformation: MultiTransformation<Bitmap> = MultiTransformation(
|
||||||
|
if (isCenterCrop) CenterCrop() else FitCenter(), roundedCorners
|
||||||
|
)
|
||||||
|
val options = RequestOptions
|
||||||
|
.bitmapTransform(multiTransformation)
|
||||||
|
if (defaultResId == 0) {
|
||||||
|
options.placeholder(R.drawable.ic_default)
|
||||||
|
.error(R.drawable.ic_default)
|
||||||
|
} else {
|
||||||
|
options.placeholder(defaultResId)
|
||||||
|
.error(defaultResId)
|
||||||
|
}
|
||||||
|
Glide.with(context)
|
||||||
|
.load(any)
|
||||||
|
.apply(options)
|
||||||
|
.into(this)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 加载图片到ImageView
|
* 加载图片到ImageView
|
||||||
* @param imageUrl 图片地址
|
* @param imageUrl 图片地址
|
||||||
|
|||||||
+3
-23
@@ -1,17 +1,14 @@
|
|||||||
package com.zmkg.coaloperation.ui.geologging
|
package com.zmkg.coaloperation.ui.geologging
|
||||||
|
|
||||||
import android.app.Activity
|
|
||||||
import android.content.Intent
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import com.zhihu.matisse.Matisse
|
|
||||||
import com.zmkg.coaloperation.R
|
import com.zmkg.coaloperation.R
|
||||||
import com.zmkg.coaloperation.adapter.GeoPointMultiAdapter
|
import com.zmkg.coaloperation.adapter.GeoPointMultiAdapter
|
||||||
import com.zmkg.coaloperation.base.BaseVMBFragment
|
import com.zmkg.coaloperation.base.BaseVMBFragment
|
||||||
import com.zmkg.coaloperation.base.viewmodel.TestViewModel
|
import com.zmkg.coaloperation.base.viewmodel.TestViewModel
|
||||||
import com.zmkg.coaloperation.bean.BaseItem
|
import com.zmkg.coaloperation.bean.BaseItem
|
||||||
import com.zmkg.coaloperation.bean.GeoPointImage
|
import com.zmkg.coaloperation.bean.CommonImageBean
|
||||||
import com.zmkg.coaloperation.bean.GeoPointMultiItem
|
import com.zmkg.coaloperation.bean.GeoPointMultiItem
|
||||||
import com.zmkg.coaloperation.databinding.FragmentAddGeologicalPointBinding
|
import com.zmkg.coaloperation.databinding.FragmentAddGeologicalPointBinding
|
||||||
|
|
||||||
@@ -40,8 +37,8 @@ class AddGeologicalPointFragment :
|
|||||||
BaseItem(name = "底板", value = ""),
|
BaseItem(name = "底板", value = ""),
|
||||||
BaseItem(name = "巷顶煤厚", value = ""),
|
BaseItem(name = "巷顶煤厚", value = ""),
|
||||||
)
|
)
|
||||||
val imageList = mutableListOf<GeoPointImage>()
|
val imageList = mutableListOf<CommonImageBean>()
|
||||||
imageList.add(GeoPointImage(isAddFlag = true))
|
imageList.add(CommonImageBean(isAddFlag = true))
|
||||||
geoPointList.run {
|
geoPointList.run {
|
||||||
add(
|
add(
|
||||||
GeoPointMultiItem(
|
GeoPointMultiItem(
|
||||||
@@ -73,21 +70,4 @@ class AddGeologicalPointFragment :
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated("Deprecated in Java")
|
|
||||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
|
||||||
super.onActivityResult(requestCode, resultCode, data)
|
|
||||||
if (requestCode == IMAGE_REQUEST_CODE && resultCode == Activity.RESULT_OK) {
|
|
||||||
val uris = Matisse.obtainResult(data) // 获取选中URI列表
|
|
||||||
val paths = Matisse.obtainPathResult(data) // 获取文件路径列表
|
|
||||||
|
|
||||||
geoPointList[3].let {
|
|
||||||
paths?.forEach { path ->
|
|
||||||
val size = it.images!!.size
|
|
||||||
it.images!!.add(size - 1, GeoPointImage(imagePath = path))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
geoPointAdapter.notifyItemChanged(3)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
+123
-123
@@ -1,123 +1,123 @@
|
|||||||
package com.zmkg.coaloperation.ui.report.adapter
|
//package com.zmkg.coaloperation.ui.report.adapter
|
||||||
|
//
|
||||||
import android.view.View
|
//import android.view.View
|
||||||
import com.chad.library.adapter.base.module.LoadMoreModule
|
//import com.chad.library.adapter.base.module.LoadMoreModule
|
||||||
import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder
|
//import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder
|
||||||
import com.zmkg.coaloperation.R
|
//import com.zmkg.coaloperation.R
|
||||||
import com.zmkg.coaloperation.adapter.common.BaseDataBindingAdapter
|
//import com.zmkg.coaloperation.adapter.common.BaseDataBindingAdapter
|
||||||
import com.zmkg.coaloperation.bean.ImageBean
|
//import com.zmkg.coaloperation.bean.ImageBean
|
||||||
import com.zmkg.coaloperation.databinding.ItemRecycleImageBinding
|
//import com.zmkg.coaloperation.databinding.ItemRecycleImageBinding
|
||||||
import com.zmkg.coaloperation.superfuntion.loadRoundedImage
|
//import com.zmkg.coaloperation.superfuntion.loadRoundedImage
|
||||||
import java.io.File
|
//import java.io.File
|
||||||
|
//
|
||||||
class ImageAdapter(var maxNum: Int): BaseDataBindingAdapter<ImageBean, ItemRecycleImageBinding>(
|
//class ImageAdapter(var maxNum: Int): BaseDataBindingAdapter<ImageBean, ItemRecycleImageBinding>(
|
||||||
R.layout.item_recycle_image
|
// R.layout.item_recycle_image
|
||||||
), LoadMoreModule {
|
//), LoadMoreModule {
|
||||||
private var isEditModel = false
|
// private var isEditModel = false
|
||||||
private var editImageShow = false
|
// private var editImageShow = false
|
||||||
override fun bindViewClickListener(
|
// override fun bindViewClickListener(
|
||||||
viewHolder: BaseDataBindingHolder<ItemRecycleImageBinding>,
|
// viewHolder: BaseDataBindingHolder<ItemRecycleImageBinding>,
|
||||||
viewType: Int
|
// viewType: Int
|
||||||
) {
|
// ) {
|
||||||
addChildClickViewIds(R.id.btn_delete)
|
// addChildClickViewIds(R.id.btn_delete)
|
||||||
super.bindViewClickListener(viewHolder, viewType)
|
// super.bindViewClickListener(viewHolder, viewType)
|
||||||
}
|
// }
|
||||||
override fun convert(
|
// override fun convert(
|
||||||
holder: BaseDataBindingHolder<ItemRecycleImageBinding>,
|
// holder: BaseDataBindingHolder<ItemRecycleImageBinding>,
|
||||||
item: ImageBean
|
// item: ImageBean
|
||||||
) {
|
// ) {
|
||||||
val mBinding = holder.dataBinding
|
// val mBinding = holder.dataBinding
|
||||||
mBinding?.let {
|
// mBinding?.let {
|
||||||
if(item.isAddButton){
|
// if(item.isAddButton){
|
||||||
mBinding.ivImage.setImageResource(R.mipmap.upload)
|
// mBinding.ivImage.setImageResource(R.mipmap.upload)
|
||||||
mBinding.btnDelete.visibility = View.GONE
|
// mBinding.btnDelete.visibility = View.GONE
|
||||||
}else{
|
// }else{
|
||||||
if(item.isFilePath){
|
// if(item.isFilePath){
|
||||||
mBinding.ivImage.loadRoundedImage(File(item.imageUrl), 5f)
|
// mBinding.ivImage.loadRoundedImage(File(item.imageUrl), 5f)
|
||||||
}else{
|
// }else{
|
||||||
mBinding.ivImage.loadRoundedImage(item.imageUrl, 5f, R.drawable.ic_default)
|
// mBinding.ivImage.loadRoundedImage(item.imageUrl, 5f, R.drawable.ic_default)
|
||||||
}
|
// }
|
||||||
if(isEditModel){
|
// if(isEditModel){
|
||||||
mBinding.btnDelete.visibility = View.VISIBLE
|
// mBinding.btnDelete.visibility = View.VISIBLE
|
||||||
}else{
|
// }else{
|
||||||
mBinding.btnDelete.visibility = View.GONE
|
// mBinding.btnDelete.visibility = View.GONE
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
fun isEditModel(isEdit: Boolean){
|
// fun isEditModel(isEdit: Boolean){
|
||||||
isEditModel = isEdit
|
// isEditModel = isEdit
|
||||||
notifyDataSetChanged()
|
// notifyDataSetChanged()
|
||||||
if(isEditModel && !editImageShow){
|
// if(isEditModel && !editImageShow){
|
||||||
showAddButton(true)
|
// showAddButton(true)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
override fun setList(list: Collection<ImageBean>?) {
|
// override fun setList(list: Collection<ImageBean>?) {
|
||||||
super.setList(list)
|
// super.setList(list)
|
||||||
if(isEditModel){
|
// if(isEditModel){
|
||||||
showAddButton(true)
|
// showAddButton(true)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
override fun setNewInstance(list: MutableList<ImageBean>?) {
|
// override fun setNewInstance(list: MutableList<ImageBean>?) {
|
||||||
super.setNewInstance(list)
|
// super.setNewInstance(list)
|
||||||
if(isEditModel){
|
// if(isEditModel){
|
||||||
showAddButton(true)
|
// showAddButton(true)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
override fun addData(newData: Collection<ImageBean>) {
|
// override fun addData(newData: Collection<ImageBean>) {
|
||||||
if(isEditModel){
|
// if(isEditModel){
|
||||||
if(editImageShow){
|
// if(editImageShow){
|
||||||
var lastPosition = data.size - 1
|
// var lastPosition = data.size - 1
|
||||||
if(lastPosition < 0){
|
// if(lastPosition < 0){
|
||||||
lastPosition = 0
|
// lastPosition = 0
|
||||||
}
|
// }
|
||||||
addData(lastPosition, newData)
|
// addData(lastPosition, newData)
|
||||||
}else{
|
// }else{
|
||||||
showAddButton(true)
|
// showAddButton(true)
|
||||||
}
|
// }
|
||||||
if(data.size > maxNum){
|
// if(data.size > maxNum){
|
||||||
showAddButton(false)
|
// showAddButton(false)
|
||||||
}
|
// }
|
||||||
}else{
|
// }else{
|
||||||
super.addData(newData)
|
// super.addData(newData)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
override fun removeAt(position: Int) {
|
// override fun removeAt(position: Int) {
|
||||||
super.removeAt(position)
|
// super.removeAt(position)
|
||||||
if(isEditModel && !editImageShow){
|
// if(isEditModel && !editImageShow){
|
||||||
showAddButton(true)
|
// showAddButton(true)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
fun getImageList(): MutableList<ImageBean>{
|
// fun getImageList(): MutableList<ImageBean>{
|
||||||
var list = mutableListOf<ImageBean>()
|
// var list = mutableListOf<ImageBean>()
|
||||||
data.forEach { imageBean ->
|
// data.forEach { imageBean ->
|
||||||
if(!imageBean.isAddButton){
|
// if(!imageBean.isAddButton){
|
||||||
list.add(imageBean)
|
// list.add(imageBean)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return list
|
// return list
|
||||||
}
|
// }
|
||||||
fun getImageSize(): Int {
|
// fun getImageSize(): Int {
|
||||||
if(isEditModel && editImageShow){
|
// if(isEditModel && editImageShow){
|
||||||
return getDefItemCount() - 1
|
// return getDefItemCount() - 1
|
||||||
}
|
// }
|
||||||
return getDefItemCount()
|
// return getDefItemCount()
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 显示添加图片按钮
|
// * 显示添加图片按钮
|
||||||
* @param isShow true为显示 false为隐藏
|
// * @param isShow true为显示 false为隐藏
|
||||||
*/
|
// */
|
||||||
private fun showAddButton(isShow: Boolean){
|
// private fun showAddButton(isShow: Boolean){
|
||||||
editImageShow = if(isShow){
|
// editImageShow = if(isShow){
|
||||||
addData(ImageBean(isAddButton = true))
|
// addData(ImageBean(isAddButton = true))
|
||||||
true
|
// true
|
||||||
}else{
|
// }else{
|
||||||
removeAt(data.size-1)
|
// removeAt(data.size-1)
|
||||||
false
|
// false
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
+79
@@ -0,0 +1,79 @@
|
|||||||
|
package com.zmkg.coaloperation.ui.report.fragment
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.View
|
||||||
|
import android.widget.RelativeLayout
|
||||||
|
import androidx.core.view.updateLayoutParams
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
import com.zmkg.coaloperation.R
|
||||||
|
import com.zmkg.coaloperation.adapter.ReportAdapter
|
||||||
|
import com.zmkg.coaloperation.base.BaseVMBFragment
|
||||||
|
import com.zmkg.coaloperation.bean.CommonImageBean
|
||||||
|
import com.zmkg.coaloperation.bean.ReportItem
|
||||||
|
import com.zmkg.coaloperation.databinding.FragmentReport2Binding
|
||||||
|
import com.zmkg.coaloperation.ui.report.viewmodel.ReportViewModel
|
||||||
|
import com.zmkg.coaloperation.utils.dp
|
||||||
|
import com.zmkg.coaloperation.utils.gone
|
||||||
|
|
||||||
|
class Report2Fragment :
|
||||||
|
BaseVMBFragment<ReportViewModel, FragmentReport2Binding>(R.layout.fragment_report2) {
|
||||||
|
|
||||||
|
lateinit var pageStatus: PageStatus
|
||||||
|
|
||||||
|
enum class PageStatus(val status: Int) {
|
||||||
|
ADD(1),
|
||||||
|
EDIT(2),
|
||||||
|
SEE(3),
|
||||||
|
NO_EDIT(4)
|
||||||
|
}
|
||||||
|
|
||||||
|
private val reportItemList = mutableListOf(
|
||||||
|
ReportItem(viewType = 2, name = "上报类型"),
|
||||||
|
ReportItem(viewType = 2, name = "上报区域"),
|
||||||
|
ReportItem(viewType = 1, name = "上报地点", isSingleLine = true, inputHint = "请输入"),
|
||||||
|
ReportItem(viewType = 1, name = "上报描述", isSingleLine = true, inputHint = "请输入"),
|
||||||
|
ReportItem(viewType = 3, name = "上报时间"),
|
||||||
|
ReportItem(viewType = 2, name = "处理状态"),
|
||||||
|
ReportItem(viewType = 2, name = "上报人"),
|
||||||
|
ReportItem(viewType = 2, name = "处理人"),
|
||||||
|
ReportItem(viewType = 1, name = "处理策略", isSingleLine = false, inputShowLines = 4, inputHint = "请输入"),
|
||||||
|
ReportItem(viewType = 1, name = "处理结果", isSingleLine = false, inputShowLines = 4, inputHint = "请输入"),
|
||||||
|
ReportItem(viewType = 3, name = "处理时间"),
|
||||||
|
ReportItem(viewType = 4, name = "上传图片", images = mutableListOf(
|
||||||
|
CommonImageBean(isAddFlag = true)
|
||||||
|
)),
|
||||||
|
ReportItem(viewType = 1, name = "备注", isSingleLine = false, inputShowLines = 6 ,inputHint = "请输入备注信息,120字以内"),
|
||||||
|
)
|
||||||
|
private val reportAdapter by lazy {
|
||||||
|
ReportAdapter(reportItemList)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun initView(root: View?, savedInstanceState: Bundle?) {
|
||||||
|
mBinding.toolbarLay.title = "新增临时上报"
|
||||||
|
mBinding.toolbarLay.rightText = "查看记录"
|
||||||
|
mBinding.toolbarLay.titleIvBack.gone()
|
||||||
|
mBinding.toolbarLay.titleTvName.updateLayoutParams<RelativeLayout.LayoutParams> {
|
||||||
|
leftMargin = 20.dp
|
||||||
|
}
|
||||||
|
mBinding.rvReport.let {
|
||||||
|
it.layoutManager = LinearLayoutManager(it.context)
|
||||||
|
it.adapter = reportAdapter
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
override fun bindEvent() {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onClick(v: View?) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun transparentStatusBar(): Boolean {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun createObserve() {
|
||||||
|
super.createObserve()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+204
-204
@@ -1,204 +1,204 @@
|
|||||||
package com.zmkg.coaloperation.ui.report.fragment
|
//package com.zmkg.coaloperation.ui.report.fragment
|
||||||
|
//
|
||||||
import android.os.Bundle
|
//import android.os.Bundle
|
||||||
import android.view.View
|
//import android.view.View
|
||||||
import androidx.core.view.ViewCompat
|
//import androidx.core.view.ViewCompat
|
||||||
import androidx.lifecycle.Lifecycle
|
//import androidx.lifecycle.Lifecycle
|
||||||
import androidx.lifecycle.lifecycleScope
|
//import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.lifecycle.repeatOnLifecycle
|
//import androidx.lifecycle.repeatOnLifecycle
|
||||||
import androidx.recyclerview.widget.GridLayoutManager
|
//import androidx.recyclerview.widget.GridLayoutManager
|
||||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
//import com.chad.library.adapter.base.BaseQuickAdapter
|
||||||
import com.chad.library.adapter.base.listener.OnItemChildClickListener
|
//import com.chad.library.adapter.base.listener.OnItemChildClickListener
|
||||||
import com.chad.library.adapter.base.listener.OnItemClickListener
|
//import com.chad.library.adapter.base.listener.OnItemClickListener
|
||||||
import com.luck.picture.lib.basic.PictureSelectionModel
|
//import com.luck.picture.lib.basic.PictureSelectionModel
|
||||||
import com.luck.picture.lib.basic.PictureSelector
|
//import com.luck.picture.lib.basic.PictureSelector
|
||||||
import com.luck.picture.lib.config.SelectMimeType
|
//import com.luck.picture.lib.config.SelectMimeType
|
||||||
import com.luck.picture.lib.config.SelectModeConfig
|
//import com.luck.picture.lib.config.SelectModeConfig
|
||||||
import com.luck.picture.lib.entity.LocalMedia
|
//import com.luck.picture.lib.entity.LocalMedia
|
||||||
import com.luck.picture.lib.interfaces.OnResultCallbackListener
|
//import com.luck.picture.lib.interfaces.OnResultCallbackListener
|
||||||
import com.luck.picture.lib.utils.SandboxTransformUtils
|
//import com.luck.picture.lib.utils.SandboxTransformUtils
|
||||||
import com.zmkg.coaloperation.utils.pictureSelector.ImageFileCompressEngine
|
//import com.zmkg.coaloperation.utils.pictureSelector.ImageFileCompressEngine
|
||||||
import com.zmkg.coaloperation.R
|
//import com.zmkg.coaloperation.R
|
||||||
import com.zmkg.coaloperation.base.BaseActivity
|
//import com.zmkg.coaloperation.base.BaseActivity
|
||||||
import com.zmkg.coaloperation.base.BaseVMBFragment
|
//import com.zmkg.coaloperation.base.BaseVMBFragment
|
||||||
import com.zmkg.coaloperation.bean.ImageBean
|
//import com.zmkg.coaloperation.bean.ImageBean
|
||||||
import com.zmkg.coaloperation.databinding.FragmentReportBinding
|
//import com.zmkg.coaloperation.databinding.FragmentReportBinding
|
||||||
import com.zmkg.coaloperation.ui.report.adapter.ImageAdapter
|
//import com.zmkg.coaloperation.ui.report.adapter.ImageAdapter
|
||||||
import com.zmkg.coaloperation.ui.report.viewmodel.ReportViewModel
|
//import com.zmkg.coaloperation.ui.report.viewmodel.ReportViewModel
|
||||||
import com.zmkg.coaloperation.utils.permission.StorageUtils
|
//import com.zmkg.coaloperation.utils.permission.StorageUtils
|
||||||
import com.zmkg.coaloperation.utils.pictureSelector.GlideEngine
|
//import com.zmkg.coaloperation.utils.pictureSelector.GlideEngine
|
||||||
import kotlinx.coroutines.flow.collectLatest
|
//import kotlinx.coroutines.flow.collectLatest
|
||||||
import kotlinx.coroutines.launch
|
//import kotlinx.coroutines.launch
|
||||||
|
//
|
||||||
class ReportFragment :
|
//class ReportFragment :
|
||||||
BaseVMBFragment<ReportViewModel, FragmentReportBinding>(R.layout.fragment_report),
|
// BaseVMBFragment<ReportViewModel, FragmentReportBinding>(R.layout.fragment_report),
|
||||||
OnItemClickListener, OnItemChildClickListener {
|
// OnItemClickListener, OnItemChildClickListener {
|
||||||
|
//
|
||||||
private val imageAdapter by lazy { ImageAdapter(maxImageNum) }
|
// private val imageAdapter by lazy { ImageAdapter(maxImageNum) }
|
||||||
lateinit var pageStatus: PageStatus
|
// lateinit var pageStatus: PageStatus
|
||||||
|
//
|
||||||
companion object {
|
// companion object {
|
||||||
const val maxImageNum = 5
|
// const val maxImageNum = 5
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
override fun initView(root: View?, savedInstanceState: Bundle?) {
|
// override fun initView(root: View?, savedInstanceState: Bundle?) {
|
||||||
|
//
|
||||||
mBinding.apply {
|
// mBinding.apply {
|
||||||
val gridLayoutManager = GridLayoutManager(context, 3)
|
// val gridLayoutManager = GridLayoutManager(context, 3)
|
||||||
layInspectionReport.rvList.layoutManager = gridLayoutManager
|
// layInspectionReport.rvList.layoutManager = gridLayoutManager
|
||||||
imageAdapter.setOnItemClickListener(this@ReportFragment)
|
// imageAdapter.setOnItemClickListener(this@ReportFragment)
|
||||||
imageAdapter.setOnItemChildClickListener(this@ReportFragment)
|
// imageAdapter.setOnItemChildClickListener(this@ReportFragment)
|
||||||
mBinding.layInspectionReport.rvList.adapter = imageAdapter
|
// mBinding.layInspectionReport.rvList.adapter = imageAdapter
|
||||||
ViewCompat.setNestedScrollingEnabled(layInspectionReport.rvList, false)
|
// ViewCompat.setNestedScrollingEnabled(layInspectionReport.rvList, false)
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
setPageModel(PageStatus.ADD)
|
// setPageModel(PageStatus.ADD)
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
enum class PageStatus(val status: Int) {
|
// enum class PageStatus(val status: Int) {
|
||||||
ADD(1),
|
// ADD(1),
|
||||||
EDIT(2),
|
// EDIT(2),
|
||||||
SEE(3),
|
// SEE(3),
|
||||||
NO_EDIT(4)
|
// NO_EDIT(4)
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private fun setPageModel(status: PageStatus) {
|
// private fun setPageModel(status: PageStatus) {
|
||||||
this.pageStatus = status
|
// this.pageStatus = status
|
||||||
mBinding?.apply {
|
// mBinding?.apply {
|
||||||
when (status) {
|
// when (status) {
|
||||||
PageStatus.ADD -> {
|
// PageStatus.ADD -> {
|
||||||
lifecycleScope.launch {
|
// lifecycleScope.launch {
|
||||||
mViewModel.noEdit.emit(false)
|
// mViewModel.noEdit.emit(false)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
PageStatus.EDIT -> {
|
// PageStatus.EDIT -> {
|
||||||
lifecycleScope.launch {
|
// lifecycleScope.launch {
|
||||||
mViewModel.noEdit.emit(false)
|
// mViewModel.noEdit.emit(false)
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
PageStatus.SEE -> {
|
// PageStatus.SEE -> {
|
||||||
lifecycleScope.launch {
|
// lifecycleScope.launch {
|
||||||
mViewModel.noEdit.emit(true)
|
// mViewModel.noEdit.emit(true)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
PageStatus.NO_EDIT -> {
|
// PageStatus.NO_EDIT -> {
|
||||||
lifecycleScope.launch {
|
// lifecycleScope.launch {
|
||||||
mViewModel.noEdit.emit(true)
|
// mViewModel.noEdit.emit(true)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
override fun bindEvent() {
|
// override fun bindEvent() {
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
override fun onClick(v: View?) {
|
// override fun onClick(v: View?) {
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
override fun transparentStatusBar(): Boolean {
|
// override fun transparentStatusBar(): Boolean {
|
||||||
return true
|
// return true
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
override fun createObserve() {
|
// override fun createObserve() {
|
||||||
super.createObserve()
|
// super.createObserve()
|
||||||
lifecycleScope.launch {
|
// lifecycleScope.launch {
|
||||||
repeatOnLifecycle(Lifecycle.State.CREATED) {
|
// repeatOnLifecycle(Lifecycle.State.CREATED) {
|
||||||
mViewModel.noEdit.collectLatest { noEdit ->
|
// mViewModel.noEdit.collectLatest { noEdit ->
|
||||||
mBinding.apply {
|
// mBinding.apply {
|
||||||
imageAdapter.isEditModel(!noEdit)
|
// imageAdapter.isEditModel(!noEdit)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
override fun onItemClick(adapter: BaseQuickAdapter<*, *>, view: View, position: Int) {
|
// override fun onItemClick(adapter: BaseQuickAdapter<*, *>, view: View, position: Int) {
|
||||||
val imageBean: ImageBean = adapter.getItem(position) as ImageBean
|
// val imageBean: ImageBean = adapter.getItem(position) as ImageBean
|
||||||
imageBean?.let { it ->
|
// imageBean?.let { it ->
|
||||||
if (it.isAddButton) {
|
// if (it.isAddButton) {
|
||||||
StorageUtils.requestPermission(context as BaseActivity) {
|
// StorageUtils.requestPermission(context as BaseActivity) {
|
||||||
initPictureSelectorModel()
|
// initPictureSelectorModel()
|
||||||
.forResult(object : OnResultCallbackListener<LocalMedia?> {
|
// .forResult(object : OnResultCallbackListener<LocalMedia?> {
|
||||||
override fun onResult(result: ArrayList<LocalMedia?>?) {
|
// override fun onResult(result: ArrayList<LocalMedia?>?) {
|
||||||
result?.let { list ->
|
// result?.let { list ->
|
||||||
var resultList = localMediaToImageList(list)
|
// var resultList = localMediaToImageList(list)
|
||||||
imageAdapter.addData(resultList)
|
// imageAdapter.addData(resultList)
|
||||||
setImageNum(imageAdapter.getImageSize())
|
// setImageNum(imageAdapter.getImageSize())
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
override fun onCancel() {}
|
// override fun onCancel() {}
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
// startFullScreenImageActivity(
|
//// startFullScreenImageActivity(
|
||||||
// it.isFilePath,
|
//// it.isFilePath,
|
||||||
// it.imageUrl
|
//// it.imageUrl
|
||||||
// )
|
//// )
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
fun setImageNum(size: Int) {
|
// fun setImageNum(size: Int) {
|
||||||
mBinding.layInspectionReport.tvImageNum.text = getString(
|
// mBinding.layInspectionReport.tvImageNum.text = getString(
|
||||||
R.string.image_list_num,
|
// R.string.image_list_num,
|
||||||
size,
|
// size,
|
||||||
maxImageNum
|
// maxImageNum
|
||||||
)
|
// )
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private fun initPictureSelectorModel(): PictureSelectionModel {
|
// private fun initPictureSelectorModel(): PictureSelectionModel {
|
||||||
return PictureSelector.create(this)
|
// return PictureSelector.create(this)
|
||||||
.openGallery(SelectMimeType.TYPE_IMAGE)
|
// .openGallery(SelectMimeType.TYPE_IMAGE)
|
||||||
.setSelectionMode(SelectModeConfig.MULTIPLE)
|
// .setSelectionMode(SelectModeConfig.MULTIPLE)
|
||||||
.setMaxSelectNum(maxImageNum - imageAdapter.getImageSize())
|
// .setMaxSelectNum(maxImageNum - imageAdapter.getImageSize())
|
||||||
.setCompressEngine(ImageFileCompressEngine())
|
// .setCompressEngine(ImageFileCompressEngine())
|
||||||
.setImageEngine(GlideEngine.createGlideEngine())
|
// .setImageEngine(GlideEngine.createGlideEngine())
|
||||||
.setSandboxFileEngine { context, srcPath, mineType, call ->
|
// .setSandboxFileEngine { context, srcPath, mineType, call ->
|
||||||
if (call != null) {
|
// if (call != null) {
|
||||||
var sandboxPath =
|
// var sandboxPath =
|
||||||
SandboxTransformUtils.copyPathToSandbox(context, srcPath, mineType)
|
// SandboxTransformUtils.copyPathToSandbox(context, srcPath, mineType)
|
||||||
call.onCallback(srcPath, sandboxPath)
|
// call.onCallback(srcPath, sandboxPath)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
override fun onItemChildClick(adapter: BaseQuickAdapter<*, *>, view: View, position: Int) {
|
// override fun onItemChildClick(adapter: BaseQuickAdapter<*, *>, view: View, position: Int) {
|
||||||
adapter.removeAt(position)
|
// adapter.removeAt(position)
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
fun localMediaToImageList(result: ArrayList<LocalMedia?>): MutableList<ImageBean> {
|
// fun localMediaToImageList(result: ArrayList<LocalMedia?>): MutableList<ImageBean> {
|
||||||
var imageList = mutableListOf<ImageBean>()
|
// var imageList = mutableListOf<ImageBean>()
|
||||||
var imageBean: ImageBean
|
// var imageBean: ImageBean
|
||||||
result.forEach {
|
// result.forEach {
|
||||||
it?.let {
|
// it?.let {
|
||||||
imageBean = ImageBean(getImagePath(it), true)
|
// imageBean = ImageBean(getImagePath(it), true)
|
||||||
imageList.add(imageBean)
|
// imageList.add(imageBean)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return imageList
|
// return imageList
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private fun getImagePath(localMedia: LocalMedia): String {
|
// private fun getImagePath(localMedia: LocalMedia): String {
|
||||||
if (!localMedia.cutPath.isNullOrEmpty()) {
|
// if (!localMedia.cutPath.isNullOrEmpty()) {
|
||||||
return localMedia.cutPath
|
// return localMedia.cutPath
|
||||||
}
|
// }
|
||||||
if (!localMedia.compressPath.isNullOrEmpty()) {
|
// if (!localMedia.compressPath.isNullOrEmpty()) {
|
||||||
return localMedia.compressPath
|
// return localMedia.compressPath
|
||||||
}
|
// }
|
||||||
if (!localMedia.sandboxPath.isNullOrEmpty()) {
|
// if (!localMedia.sandboxPath.isNullOrEmpty()) {
|
||||||
return localMedia.sandboxPath
|
// return localMedia.sandboxPath
|
||||||
}
|
// }
|
||||||
return localMedia.path
|
// return localMedia.path
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|||||||
@@ -1,20 +1,27 @@
|
|||||||
package com.zmkg.coaloperation.utils
|
package com.zmkg.coaloperation.utils
|
||||||
|
|
||||||
import android.app.Activity
|
import android.content.Intent
|
||||||
import android.content.pm.ActivityInfo
|
import android.content.pm.ActivityInfo
|
||||||
import com.zhihu.matisse.Matisse
|
import com.zhihu.matisse.Matisse
|
||||||
import com.zhihu.matisse.MimeType
|
import com.zhihu.matisse.MimeType
|
||||||
import com.zhihu.matisse.R
|
import com.zhihu.matisse.R
|
||||||
import com.zhihu.matisse.engine.impl.GlideEngine
|
import com.zhihu.matisse.engine.impl.GlideEngine
|
||||||
import com.zhihu.matisse.internal.entity.CaptureStrategy
|
import com.zhihu.matisse.internal.entity.CaptureStrategy
|
||||||
|
import com.zmkg.coaloperation.base.BaseActivity
|
||||||
|
|
||||||
object GalleryUtils {
|
object GalleryUtils {
|
||||||
|
|
||||||
fun openGallery(activity: Activity, requestCode:Int) {
|
fun openGallery(activity: BaseActivity, action:(Intent)-> Unit) {
|
||||||
Matisse.from(activity)
|
Matisse.from(activity)
|
||||||
.choose(MimeType.ofImage(),false) // 只选图片
|
.choose(MimeType.ofImage(), false) // 只选图片
|
||||||
.capture(true)
|
.capture(true)
|
||||||
.captureStrategy(CaptureStrategy(true, "${activity.packageName}.fileprovider", "coalImage"))
|
.captureStrategy(
|
||||||
|
CaptureStrategy(
|
||||||
|
true,
|
||||||
|
"${activity.packageName}.fileprovider",
|
||||||
|
"coalImage"
|
||||||
|
)
|
||||||
|
)
|
||||||
.countable(true) // 显示选中数量
|
.countable(true) // 显示选中数量
|
||||||
.maxSelectable(9) // 最多选9张
|
.maxSelectable(9) // 最多选9张
|
||||||
.gridExpectedSize(120.dp)
|
.gridExpectedSize(120.dp)
|
||||||
@@ -22,7 +29,13 @@ object GalleryUtils {
|
|||||||
.thumbnailScale(0.8f)
|
.thumbnailScale(0.8f)
|
||||||
.theme(R.style.Matisse_Dracula)
|
.theme(R.style.Matisse_Dracula)
|
||||||
.imageEngine(GlideEngine()) // 必须设置引擎
|
.imageEngine(GlideEngine()) // 必须设置引擎
|
||||||
.forResult(requestCode)
|
.forResultLaunch { intent ->
|
||||||
|
activity.launchActivityResult(intent) { result ->
|
||||||
|
result.data?.let {
|
||||||
|
action(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 699 B |
@@ -0,0 +1,49 @@
|
|||||||
|
<?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">
|
||||||
|
|
||||||
|
<data>
|
||||||
|
|
||||||
|
</data>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="@color/black_bg"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<include
|
||||||
|
android:id="@+id/toolbar_lay"
|
||||||
|
layout="@layout/lay_title_right_bar"
|
||||||
|
app:goneBack="@{true}"
|
||||||
|
app:title="@{@string/title_report}"
|
||||||
|
app:transparentBg="@{true}" />
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/rvReport"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:overScrollMode="never"
|
||||||
|
tools:listitem="@layout/list_item_report"
|
||||||
|
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||||
|
tools:itemCount="10"
|
||||||
|
android:background="@drawable/bg_stroke_gray"
|
||||||
|
android:layout_marginHorizontal="20dp"
|
||||||
|
android:layout_weight="1" />
|
||||||
|
|
||||||
|
<com.allen.library.shape.ShapeButton
|
||||||
|
android:id="@+id/btnConfirm"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="40dp"
|
||||||
|
android:layout_marginHorizontal="45dp"
|
||||||
|
android:layout_marginVertical="20dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="确认"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:textSize="16sp"
|
||||||
|
app:shapeCornersRadius="20dp"
|
||||||
|
app:shapeSolidColor="@color/text_green" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</layout>
|
||||||
+2
-1
@@ -5,10 +5,11 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/ivPointImage"
|
android:id="@+id/ivImage"
|
||||||
android:layout_width="70dp"
|
android:layout_width="70dp"
|
||||||
android:layout_height="70dp"
|
android:layout_height="70dp"
|
||||||
android:layout_marginVertical="5dp"
|
android:layout_marginVertical="5dp"
|
||||||
|
android:layout_marginHorizontal="5dp"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:scaleType="centerCrop"
|
android:scaleType="centerCrop"
|
||||||
android:src="@drawable/ic_add_image"/>
|
android:src="@drawable/ic_add_image"/>
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
app:spanCount="4"
|
app:spanCount="4"
|
||||||
android:paddingVertical="5dp"
|
android:paddingVertical="5dp"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
tools:listitem="@layout/list_item_point_image"
|
tools:listitem="@layout/list_item_common_image"
|
||||||
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"/>
|
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|||||||
@@ -0,0 +1,77 @@
|
|||||||
|
<?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">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
tools:background="@color/black_bg">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvItemName"
|
||||||
|
android:layout_width="100dp"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_marginStart="20dp"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:textColor="#6A6F87"
|
||||||
|
android:textSize="16sp"
|
||||||
|
tools:text="功能名称" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/etInputValue"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginEnd="20dp"
|
||||||
|
android:background="@color/transparent"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:hint="请输入"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:textColorHint="#757B8C"
|
||||||
|
android:textCursorDrawable="@drawable/cursor_white"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvItemValue"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:layout_marginEnd="20dp"
|
||||||
|
android:background="@color/transparent"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:hint="请选择"
|
||||||
|
android:drawablePadding="20dp"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:textColorHint="#757B8C"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:visibility="gone"
|
||||||
|
app:drawableEndCompat="@drawable/ic_arrow_down_gray" />
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/rvReportImage"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:visibility="gone"
|
||||||
|
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
|
||||||
|
app:spanCount="3"
|
||||||
|
tools:itemCount="6"
|
||||||
|
tools:listitem="@layout/list_item_common_image" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<com.google.android.material.divider.MaterialDivider
|
||||||
|
android:id="@+id/divider"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
app:dividerColor="#282C38" />
|
||||||
|
</LinearLayout>
|
||||||
|
</layout>
|
||||||
@@ -38,6 +38,7 @@ import java.lang.annotation.Retention;
|
|||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_BEHIND;
|
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_BEHIND;
|
||||||
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR;
|
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR;
|
||||||
@@ -368,4 +369,15 @@ public final class SelectionCreator {
|
|||||||
mSelectionSpec.showPreview = showPreview;
|
mSelectionSpec.showPreview = showPreview;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void forResultLaunch(Consumer<Intent> consumer) {
|
||||||
|
Activity activity = mMatisse.getActivity();
|
||||||
|
if (activity == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Intent intent = new Intent(activity, MatisseActivity.class);
|
||||||
|
if (consumer!=null) {
|
||||||
|
consumer.accept(intent);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user