多张照片上传

This commit is contained in:
lijia 2024-04-30 11:23:36 +08:00
parent 23f6e12b35
commit b4e38fe52f
7 changed files with 161 additions and 73 deletions

View File

@ -310,6 +310,12 @@
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan|stateHidden" />
<activity
android:name=".ui.waybill.activity.WaybillUpPicActivity"
android:configChanges="keyboardHidden|orientation|locale"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan|stateHidden" />
<activity
android:name=".ui.waybill.activity.WaybillUpPicActivity"
android:configChanges="keyboardHidden|orientation|locale"

View File

@ -33,7 +33,6 @@ import com.arpa.mylibrary.utils.ActivityUtils
import com.arpa.mylibrary.utils.BitmapUtil
import com.arpa.mylibrary.utils.FileUtil
import com.arpa.mylibrary.utils.LoadingUtils
import com.arpa.mylibrary.utils.LoadingUtils.Companion.instance
import com.arpa.mylibrary.utils.PopsUtils
import com.arpa.mylibrary.utils.TimeUtil
import com.arpa.mylibrary.utils.ToastUtils
@ -123,30 +122,27 @@ class WaybillUpPicActivity : BaseActivity<ActivityWaybillUppicBinding>() {
)
var myAdapter = GridImageAdapter(mContext, mData)
myAdapter.selectMax = 1
myAdapter.selectMax = 6
myAdapter.setOnItemClickListener(object : OnItemClickListener {
override fun onItemClick(v: View?, position: Int) {
PopsUtils.getInstance()
.showSelPic(mContext, 1, true, myAdapter) {
OssServiceUtil.getInstance().run {
asyncPutImage(it[0].realPath, this@WaybillUpPicActivity)
setResultCallBack { data, oldPath ->
.showSelPic(mContext, if (type==2) 6 else 1, true, myAdapter) { it ->
OssServiceUtil.getInstance().asyncPutImages(it.map { it.availablePath },this@WaybillUpPicActivity
) { success, failure ->
upBean.waybillPhotoList.removeAll { it.type=="3" }
success.forEachIndexed { index, s ->
picBean = WaybillPhoto()
picBean.run {
localPhotoUrl = it[0].availablePath
photoUrl = oldPath
localPhotoUrl = it[index].availablePath
photoUrl = s
location = binding.tvLoca.text.toString()
receiptType =
if (type == 1) "4" else if (type == 2) "5" else "6"
this.type = "3"
}
if (upBean.waybillPhotoList.find { it.type == "3" } == null) {
upBean.waybillPhotoList.add(picBean)
} else {
upBean.waybillPhotoList.find { it.type == "3" }!!.photoUrl =
oldPath
}
upBean.waybillPhotoList.add(picBean)
}
}
myAdapter.data.run {
clear()
@ -158,32 +154,56 @@ class WaybillUpPicActivity : BaseActivity<ActivityWaybillUppicBinding>() {
override fun openPicture() {
PopsUtils.getInstance()
.showSelPic(mContext, 1, true, myAdapter) {
OssServiceUtil.getInstance().run {
asyncPutImage(it[0].realPath, this@WaybillUpPicActivity)
setResultCallBack { data, oldPath ->
picBean = WaybillPhoto()
picBean.run {
localPhotoUrl = it[0].availablePath
photoUrl = oldPath
location = binding.tvLoca.text.toString()
receiptType =
if (type == 1) "4" else if (type == 2) "5" else "6"
this.type = "3"
}
if (upBean.waybillPhotoList.find { it.type == "3" } == null) {
.showSelPic(mContext, if (type==2) 6 else 1, true, myAdapter) { it ->
OssServiceUtil.getInstance().asyncPutImages(it.map { it.availablePath },this@WaybillUpPicActivity
) { success, failure ->
upBean.waybillPhotoList.removeAll { it.type=="3" }
success.forEachIndexed { index, s ->
picBean = WaybillPhoto()
picBean.run {
localPhotoUrl = it[index].availablePath
photoUrl = s
location = binding.tvLoca.text.toString()
receiptType =
if (type == 1) "4" else if (type == 2) "5" else "6"
this.type = "3"
}
upBean.waybillPhotoList.add(picBean)
} else {
upBean.waybillPhotoList.find { it.type == "3" }!!.photoUrl =
oldPath
}
}
}
myAdapter.data.run {
clear()
addAll(it)
}
myAdapter.notifyDataSetChanged()
// OssServiceUtil.getInstance().run {
// asyncPutImage(it[0].realPath, this@WaybillUpPicActivity2)
// setResultCallBack { data, oldPath ->
// picBean = WaybillPhoto()
// picBean.run {
// localPhotoUrl = it[0].availablePath
// photoUrl = oldPath
// location = binding.tvLoca.text.toString()
// receiptType =
// if (type == 1) "4" else if (type == 2) "5" else "6"
// this.type = "3"
// }
// if (upBean.waybillPhotoList.find { it.type == "3" } == null) {
// upBean.waybillPhotoList.add(picBean)
// } else {
// upBean.waybillPhotoList.find { it.type == "3" }!!.photoUrl =
// oldPath
// }
// }
// }
// myAdapter.data.run {
// clear()
// addAll(it)
// }
// myAdapter.notifyDataSetChanged()
}
}
@ -344,7 +364,7 @@ class WaybillUpPicActivity : BaseActivity<ActivityWaybillUppicBinding>() {
upTrafficReceipt(location)
receiptImage()
//平台更换运单状态
//todo 平台更换运单状态 暂时注释
DataManager.getInstance().driverLoadOrUnload(upBean)
.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
.subscribe(BaseObserver(mContext, object : RxHttpCallBack<Any>() {
@ -491,46 +511,106 @@ class WaybillUpPicActivity : BaseActivity<ActivityWaybillUppicBinding>() {
//卸货回单照片
fun receiptImage() {
///storage/emulated/0/Android/data/com.oneclouds.wangluohuoyun/files/Pictures/163124593063154.jpg
var upCount = 0
upBean.waybillPhotoList.filter { it.type == "3" && it.receiptType == "5" }.forEach { it ->
var photoPaht = it.localPhotoUrl
val file: File = File(photoPaht)
val image = Image()
val base = BitmapUtil.imageToBase64(photoPaht)
image.fileData = "data:image/" + FileUtil.lastName(file) + ";base64," + base
image.fileExt = FileUtil.lastName(file)
image.fileName = FileUtil.fileName(file)
image.imageTakenDate = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(Date())
image.baiduLongitude = bdLatLng.longitude
image.baiduLatitude = bdLatLng.latitude
image.location = binding.tvLoca.text.toString()
MDPLocationCollectionManager.uploadPODImage(
mContext,
orderBean.orderNum,
image,
object : OnResultListener {
override fun onSuccess() {
Log.e("上报安联", "回单照片上传成功")
upCount++
dissLoading()
if (upCount==upBean.waybillPhotoList.filter { it.type == "3" && it.receiptType == "5" }.size){
//跳转成功页面,停止上传轨迹
OrderUtils.getInstance().stopUpLocation(mContext)
ActivityUtils.startActivity(
mContext,
WaybillSuccActivity::class.java,
intent.extras
)
Toast.makeText(mContext, "上传成功", Toast.LENGTH_SHORT).show()
}
var photoPaht =
upBean.waybillPhotoList.find { it.type == "3" && it.receiptType == "5" }?.localPhotoUrl
val file: File = File(photoPaht)
val image = Image()
val base = BitmapUtil.imageToBase64(photoPaht)
image.fileData = "data:image/" + FileUtil.lastName(file) + ";base64," + base
image.fileExt = FileUtil.lastName(file)
image.fileName = FileUtil.fileName(file)
image.imageTakenDate = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(Date())
image.baiduLongitude = bdLatLng.longitude
image.baiduLatitude = bdLatLng.latitude
image.location = binding.tvLoca.text.toString()
MDPLocationCollectionManager.uploadPODImage(
mContext,
orderBean.orderNum,
image,
object : OnResultListener {
override fun onSuccess() {
Log.e("上报安联", "回单照片上传成功")
dissLoading()
//跳转成功页面,停止上传轨迹
OrderUtils.getInstance().stopUpLocation(mContext)
ActivityUtils.startActivity(
mContext,
WaybillSuccActivity::class.java,
intent.extras
)
Toast.makeText(mContext, "上传成功", Toast.LENGTH_SHORT).show()
// finish()
}
}
override fun onFailure(s: String, s1: String) {
Log.e("上报安联失败(回单照片):", s + s1)
// SPUtil.insSP(con,"make","回单",sob.getData().getShippingNoteNumber());
override fun onFailure(s: String, s1: String) {
upCount++
if (upCount==upBean.waybillPhotoList.filter { it.type == "3" && it.receiptType == "5" }.size){
//跳转成功页面,停止上传轨迹
OrderUtils.getInstance().stopUpLocation(mContext)
ActivityUtils.startActivity(
mContext,
WaybillSuccActivity::class.java,
intent.extras
)
Toast.makeText(mContext, "上传成功", Toast.LENGTH_SHORT).show()
}
Log.e("上报安联失败(回单照片):", s + s1)
// SPUtil.insSP(con,"make","回单",sob.getData().getShippingNoteNumber());
//// SPUtil.insSP(con,"make","回单-"+sob.getData().getShippingNoteNumber(),gson.toJson(image));
//// Intent serviceIn=new Intent(con, MakeUpAlService.class);
//// startService(serviceIn);
}
})
}
})
}
// var photoPaht =
// upBean.waybillPhotoList.find { it.type == "3" && it.receiptType == "5" }?.localPhotoUrl
// val file: File = File(photoPaht)
// val image = Image()
// val base = BitmapUtil.imageToBase64(photoPaht)
// image.fileData = "data:image/" + FileUtil.lastName(file) + ";base64," + base
// image.fileExt = FileUtil.lastName(file)
// image.fileName = FileUtil.fileName(file)
// image.imageTakenDate = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(Date())
// image.baiduLongitude = bdLatLng.longitude
// image.baiduLatitude = bdLatLng.latitude
// image.location = binding.tvLoca.text.toString()
// MDPLocationCollectionManager.uploadPODImage(
// mContext,
// orderBean.orderNum,
// image,
// object : OnResultListener {
// override fun onSuccess() {
// Log.e("上报安联", "回单照片上传成功")
// dissLoading()
// //跳转成功页面,停止上传轨迹
// OrderUtils.getInstance().stopUpLocation(mContext)
// ActivityUtils.startActivity(
// mContext,
// WaybillSuccActivity::class.java,
// intent.extras
// )
// Toast.makeText(mContext, "上传成功", Toast.LENGTH_SHORT).show()
//// finish()
// }
//
// override fun onFailure(s: String, s1: String) {
// Log.e("上报安联失败(回单照片):", s + s1)
// // SPUtil.insSP(con,"make","回单",sob.getData().getShippingNoteNumber());
////// SPUtil.insSP(con,"make","回单-"+sob.getData().getShippingNoteNumber(),gson.toJson(image));
////// Intent serviceIn=new Intent(con, MakeUpAlService.class);
////// startService(serviceIn);
// }
// })
}

View File

@ -19,9 +19,9 @@ import com.arpa.hndahesudintocctmsdriver.ui.waybill.activity.WaybillAppraiseActi
import com.arpa.hndahesudintocctmsdriver.ui.waybill.activity.WaybillLoadActivity
import com.arpa.hndahesudintocctmsdriver.ui.waybill.activity.WaybillRateActivity
import com.arpa.hndahesudintocctmsdriver.ui.waybill.activity.WaybillUnlLoadActivity
import com.arpa.hndahesudintocctmsdriver.ui.waybill.activity.WaybillUpPicActivity
import com.arpa.hndahesudintocctmsdriver.utils.SPUtils
import com.arpa.glex.bean.OrderBean
import com.arpa.hndahesudintocctmsdriver.ui.waybill.activity.WaybillUpPicActivity
import com.arpa.mylibrary.base.BaseFragment
import com.arpa.mylibrary.callback.RefreshCallBack
import com.arpa.mylibrary.net.CommonResponseBean

View File

@ -16,9 +16,9 @@ import com.arpa.hndahesudintocctmsdriver.net.BaseObserver
import com.arpa.hndahesudintocctmsdriver.net.DataManager
import com.arpa.hndahesudintocctmsdriver.net.RxHttpCallBack
import com.arpa.hndahesudintocctmsdriver.ui.waybill.activity.WaybillLoadActivity
import com.arpa.hndahesudintocctmsdriver.ui.waybill.activity.WaybillUpPicActivity
import com.arpa.hndahesudintocctmsdriver.utils.SPUtils
import com.arpa.glex.bean.OrderBean
import com.arpa.hndahesudintocctmsdriver.ui.waybill.activity.WaybillUpPicActivity
import com.arpa.mylibrary.base.BaseFragment
import com.arpa.mylibrary.callback.RefreshCallBack
import com.arpa.mylibrary.net.CommonResponseBean

View File

@ -16,9 +16,9 @@ import com.arpa.hndahesudintocctmsdriver.net.BaseObserver
import com.arpa.hndahesudintocctmsdriver.net.DataManager
import com.arpa.hndahesudintocctmsdriver.net.RxHttpCallBack
import com.arpa.hndahesudintocctmsdriver.ui.waybill.activity.WaybillUnlLoadActivity
import com.arpa.hndahesudintocctmsdriver.ui.waybill.activity.WaybillUpPicActivity
import com.arpa.hndahesudintocctmsdriver.utils.SPUtils
import com.arpa.glex.bean.OrderBean
import com.arpa.hndahesudintocctmsdriver.ui.waybill.activity.WaybillUpPicActivity
import com.arpa.mylibrary.base.BaseFragment
import com.arpa.mylibrary.callback.RefreshCallBack
import com.arpa.mylibrary.net.CommonResponseBean

View File

@ -148,7 +148,7 @@ class CommonPopUtils private constructor() {
false, true, -1, -1, ConvertUtils.dp2px(10F), false,
Color.rgb(32, 36, 46),
{ popupView, position ->
popupView.updateSrcView(recyclerView.getChildAt(position) as ImageView)
// popupView.updateSrcView(recyclerView.getChildAt(position) as ImageView)
}, SmartGlideImageLoader(true, R.mipmap.ic_launcher), null
)
.show()

View File

@ -203,7 +203,7 @@
android:layout_height="wrap_content"
android:maxLines="1"
android:singleLine="true"
android:text="26431.5"
tools:text="26431.5"
android:textColor="@color/black"
android:textSize="@dimen/sp_20"
android:textStyle="bold"></TextView>
@ -254,7 +254,9 @@
android:id="@+id/tvIncome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2643.5"
tools:text="2643.5"
android:maxLines="1"
android:ellipsize="end"
android:textColor="@color/black"
android:textSize="@dimen/sp_20"
android:textStyle="bold"></TextView>