feat: 国际进港舱单详情页展示交接图片缩略图并支持点击查看大图
从舱单列表接口新增的 pic/originalPic/picNumber 字段透传至详情页, 缩略图以水平 RecyclerView 展示,点击后通过 PreviewActivity 查看原图。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -73,7 +73,10 @@ class GjjManifestBean(
|
||||
var wbNo: String = "",
|
||||
var weight: String = "",
|
||||
var storageTime: String = "",
|
||||
var whslocation: String? = ""
|
||||
var whslocation: String? = "",
|
||||
var pic: String = "",
|
||||
var originalPic: String = "",
|
||||
var picNumber: String = ""
|
||||
) : BaseObservable(), ICheck {
|
||||
|
||||
// 展示逻辑
|
||||
|
||||
@@ -401,5 +401,8 @@ interface Constant {
|
||||
|
||||
// 运单类型
|
||||
const val AWB_TYPE = "awbType"
|
||||
|
||||
const val PIC = "pic"
|
||||
const val ORIGINAL_PIC = "originalPic"
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,14 @@ package com.lukouguoji.gjj.activity
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.lukouguoji.gjj.R
|
||||
import com.lukouguoji.gjj.databinding.ActivityGjjManifestDetailsBinding
|
||||
import com.lukouguoji.gjj.holder.GjjManifestPicViewHolder
|
||||
import com.lukouguoji.gjj.viewModel.GjjManifestDetailsViewModel
|
||||
import com.lukouguoji.module_base.base.BaseBindingActivity
|
||||
import com.lukouguoji.module_base.base.CommonAdapter
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.ktx.noNull
|
||||
|
||||
@@ -21,17 +23,33 @@ class GjjManifestDetailsActivity :
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
setBackArrow("国际进港舱单详情")
|
||||
viewModel.id = intent.getStringExtra(Constant.Key.ID).noNull()
|
||||
viewModel.pic = intent.getStringExtra(Constant.Key.PIC).noNull()
|
||||
viewModel.originalPic = intent.getStringExtra(Constant.Key.ORIGINAL_PIC).noNull()
|
||||
|
||||
binding.viewModel = viewModel
|
||||
|
||||
val picAdapter = CommonAdapter(
|
||||
this,
|
||||
R.layout.item_gjj_manifest_pic,
|
||||
GjjManifestPicViewHolder::class.java
|
||||
)
|
||||
binding.rvPic.layoutManager = LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false)
|
||||
binding.rvPic.adapter = picAdapter
|
||||
|
||||
viewModel.picList.observe(this) { list ->
|
||||
picAdapter.refresh(list)
|
||||
}
|
||||
|
||||
viewModel.getData()
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context, id: String) {
|
||||
fun start(context: Context, id: String, pic: String = "", originalPic: String = "") {
|
||||
val starter = Intent(context, GjjManifestDetailsActivity::class.java)
|
||||
.putExtra(Constant.Key.ID, id)
|
||||
.putExtra(Constant.Key.PIC, pic)
|
||||
.putExtra(Constant.Key.ORIGINAL_PIC, originalPic)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.lukouguoji.gjj.holder
|
||||
|
||||
import android.view.View
|
||||
import com.lukouguoji.gjj.databinding.ItemGjjManifestPicBinding
|
||||
import com.lukouguoji.module_base.base.BaseViewHolder
|
||||
import com.lukouguoji.module_base.bean.FileBean
|
||||
import com.lukouguoji.module_base.ktx.commonAdapter
|
||||
import com.lukouguoji.module_base.ui.page.preview.PreviewActivity
|
||||
|
||||
class GjjManifestPicViewHolder(view: View) :
|
||||
BaseViewHolder<FileBean, ItemGjjManifestPicBinding>(view) {
|
||||
|
||||
override fun onBind(item: Any?, position: Int) {
|
||||
val bean = getItemBean(item)!!
|
||||
binding.bean = bean
|
||||
|
||||
binding.ivThumbnail.setOnClickListener {
|
||||
val items = getRecyclerView()?.commonAdapter()?.items
|
||||
?.filterIsInstance<FileBean>() ?: listOf(bean)
|
||||
val originalList = items.map { fb ->
|
||||
FileBean(path = if (fb.originalPic.isNotEmpty()) fb.originalPic else fb.path)
|
||||
}
|
||||
PreviewActivity.start(itemView.context, originalList, position)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.lukouguoji.gjj.viewModel
|
||||
import android.view.View
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.lukouguoji.module_base.base.BaseViewModel
|
||||
import com.lukouguoji.module_base.bean.FileBean
|
||||
import com.lukouguoji.module_base.http.net.NetApply
|
||||
import com.lukouguoji.module_base.interfaces.IGetData
|
||||
import com.lukouguoji.module_base.ktx.finish
|
||||
@@ -13,6 +14,7 @@ import com.lukouguoji.module_base.ktx.showToast
|
||||
import com.lukouguoji.module_base.ktx.toRequestBody
|
||||
import com.lukouguoji.module_base.ktx.verifyNullOrEmpty
|
||||
import com.lukouguoji.module_base.util.DictUtils
|
||||
import com.lukouguoji.module_base.util.MediaUtil
|
||||
import dev.utils.app.info.KeyValue
|
||||
import dev.utils.common.DateUtils
|
||||
|
||||
@@ -20,6 +22,11 @@ class GjjManifestDetailsViewModel : BaseViewModel(), IGetData {
|
||||
|
||||
var id = ""
|
||||
var fid = ""
|
||||
var pic = ""
|
||||
var originalPic = ""
|
||||
|
||||
// 交接图片列表
|
||||
val picList = MutableLiveData<List<FileBean>>(emptyList())
|
||||
|
||||
// 是否修改状态
|
||||
var modifyAble = MutableLiveData(false)
|
||||
@@ -88,6 +95,7 @@ class GjjManifestDetailsViewModel : BaseViewModel(), IGetData {
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
override fun getData() {
|
||||
parsePicList()
|
||||
showLoading()
|
||||
launchCollect({
|
||||
NetApply.api.getGjjManifestDetail(id)
|
||||
@@ -256,4 +264,21 @@ class GjjManifestDetailsViewModel : BaseViewModel(), IGetData {
|
||||
fun onCancelClick(view: View) {
|
||||
modifyAble.value = false
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析 pic / originalPic 字符串为 FileBean 列表
|
||||
*/
|
||||
fun parsePicList() {
|
||||
val thumbUrls = pic.split(",").filter { it.isNotEmpty() }
|
||||
val originalUrls = originalPic.split(",").filter { it.isNotEmpty() }
|
||||
val list = thumbUrls.mapIndexed { index, thumbFile ->
|
||||
val originalFile = originalUrls.getOrElse(index) { thumbFile }
|
||||
FileBean(
|
||||
path = MediaUtil.fillUrl(thumbFile),
|
||||
url = thumbFile,
|
||||
originalPic = MediaUtil.fillUrl(originalFile)
|
||||
)
|
||||
}
|
||||
picList.value = list
|
||||
}
|
||||
}
|
||||
@@ -243,7 +243,7 @@ class GjjManifestListViewModel : BasePageViewModel(), IOnItemClickListener {
|
||||
}
|
||||
|
||||
R.id.tv_details -> {
|
||||
GjjManifestDetailsActivity.start(DevUtils.getTopActivity(), bean.mfId)
|
||||
GjjManifestDetailsActivity.start(DevUtils.getTopActivity(), bean.mfId, bean.pic, bean.originalPic)
|
||||
}
|
||||
|
||||
R.id.tv_delete -> {
|
||||
|
||||
@@ -432,6 +432,25 @@
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginRight="15dp"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<TextView
|
||||
style="@style/tv_manifest_details_label_no_mi"
|
||||
android:text="交接图片:" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_pic"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1" />
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
<View
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
|
||||
20
module_gjj/src/main/res/layout/item_gjj_manifest_pic.xml
Normal file
20
module_gjj/src/main/res/layout/item_gjj_manifest_pic.xml
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<data>
|
||||
|
||||
<variable
|
||||
name="bean"
|
||||
type="com.lukouguoji.module_base.bean.FileBean" />
|
||||
|
||||
</data>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_thumbnail"
|
||||
loadImage="@{bean.path}"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="80dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:scaleType="centerCrop" />
|
||||
|
||||
</layout>
|
||||
Reference in New Issue
Block a user