|
@@ -0,0 +1,514 @@
|
|
|
|
|
+package cn.muchinfo.rma.view.base.main.promotioncode
|
|
|
|
|
+
|
|
|
|
|
+import android.Manifest
|
|
|
|
|
+import android.app.Activity
|
|
|
|
|
+import android.content.Intent
|
|
|
|
|
+import android.net.Uri
|
|
|
|
|
+import android.os.Bundle
|
|
|
|
|
+import android.view.Gravity
|
|
|
|
|
+import android.view.View
|
|
|
|
|
+import android.view.inputmethod.EditorInfo
|
|
|
|
|
+import android.widget.EditText
|
|
|
|
|
+import androidx.lifecycle.MutableLiveData
|
|
|
|
|
+import cn.muchinfo.rma.R
|
|
|
|
|
+import cn.muchinfo.rma.lifecycle.bindOptional
|
|
|
|
|
+import cn.muchinfo.rma.netManage.base.InteractiveException
|
|
|
|
|
+import cn.muchinfo.rma.netManage.utils.UpLoadUtils
|
|
|
|
|
+import cn.muchinfo.rma.view.autoWidget.*
|
|
|
|
|
+import cn.muchinfo.rma.view.autoWidget.photopicter.PhotoUtils
|
|
|
|
|
+import cn.muchinfo.rma.view.autoWidget.photopicter.utils.ImageCaptureManager
|
|
|
|
|
+import cn.muchinfo.rma.view.base.BaseActivity
|
|
|
|
|
+import cn.muchinfo.rma.view.base.app.Constant
|
|
|
|
|
+import cn.muchinfo.rma.view.base.future.trade.itemView
|
|
|
|
|
+import com.alibaba.fastjson.JSON
|
|
|
|
|
+import com.blankj.utilcode.util.ActivityUtils
|
|
|
|
|
+import com.blankj.utilcode.util.LogUtils
|
|
|
|
|
+import com.blankj.utilcode.util.SPUtils
|
|
|
|
|
+import com.tbruyelle.rxpermissions2.RxPermissions
|
|
|
|
|
+import com.zhy.http.okhttp.callback.StringCallback
|
|
|
|
|
+import mtp.polymer.com.autowidget.dialog.SelectData
|
|
|
|
|
+import mtp.polymer.com.autowidget.dialog.creatBottomSheetDialog
|
|
|
|
|
+import mtp.polymer.com.autowidget.utils.TaskUiModel
|
|
|
|
|
+import okhttp3.Call
|
|
|
|
|
+import org.jetbrains.anko.*
|
|
|
|
|
+import org.json.JSONArray
|
|
|
|
|
+import org.json.JSONException
|
|
|
|
|
+import org.json.JSONObject
|
|
|
|
|
+import java.io.File
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 申请推广码页面
|
|
|
|
|
+ */
|
|
|
|
|
+class ApplyPromotionCodeActivity : BaseActivity<MyPromotionCodeViewModel>(){
|
|
|
|
|
+
|
|
|
|
|
+ //以下是正面照
|
|
|
|
|
+ private var positiveUploadFile: String = ""//上传成功后服务给的图片地址
|
|
|
|
|
+ val positiveImageString: MutableLiveData<String> =
|
|
|
|
|
+ MutableLiveData<String>().apply { value = "" }//文件地址
|
|
|
|
|
+
|
|
|
|
|
+ val positiveImagePhotoString: MutableLiveData<String> =
|
|
|
|
|
+ MutableLiveData<String>().apply { value = "" }//拍照后的文件地址
|
|
|
|
|
+
|
|
|
|
|
+ val positiveImageCaptureManager by lazy { ImageCaptureManager(this) }
|
|
|
|
|
+
|
|
|
|
|
+ //以下是反面照
|
|
|
|
|
+ private var reverseUploadFile: String = ""//上传成功后服务给的图片地址
|
|
|
|
|
+ val reverseImageString: MutableLiveData<String> =
|
|
|
|
|
+ MutableLiveData<String>().apply { value = "" }//文件地址
|
|
|
|
|
+
|
|
|
|
|
+ val reverseImagePhotoString: MutableLiveData<String> =
|
|
|
|
|
+ MutableLiveData<String>().apply { value = "" }//拍照后的文件地址
|
|
|
|
|
+ val reverseImageCaptureManager by lazy { ImageCaptureManager(this) }
|
|
|
|
|
+
|
|
|
|
|
+ //输入的姓名
|
|
|
|
|
+ lateinit var name_edittext : EditText
|
|
|
|
|
+
|
|
|
|
|
+ override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
|
|
|
|
+ super.onActivityResult(requestCode, resultCode, data)
|
|
|
|
|
+ if (requestCode == 101 && resultCode == Activity.RESULT_OK) {//正面照拍照后
|
|
|
|
|
+ positiveImageCaptureManager.galleryAddPic()
|
|
|
|
|
+ positiveImagePhotoString.postValue(positiveImageCaptureManager.currentPhotoPath)
|
|
|
|
|
+ LogUtils.eTag("dasdasdsadasdad", positiveImageCaptureManager.currentPhotoPath)
|
|
|
|
|
+ }else if (requestCode == 102 && resultCode == Activity.RESULT_OK) {//反面照拍照后
|
|
|
|
|
+ reverseImageCaptureManager.galleryAddPic()
|
|
|
|
|
+ reverseImagePhotoString.postValue(reverseImageCaptureManager.currentPhotoPath)
|
|
|
|
|
+ LogUtils.eTag("dasdasdsadasdad", reverseImageCaptureManager.currentPhotoPath)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
|
|
+ super.onCreate(savedInstanceState)
|
|
|
|
|
+ verticalLayout {
|
|
|
|
|
+ background = resources.getDrawable(R.color.main_hit_bg_color)
|
|
|
|
|
+ //页面标题
|
|
|
|
|
+ topBar {
|
|
|
|
|
+ commonLeftButton()
|
|
|
|
|
+ commonTitle {
|
|
|
|
|
+ text = "申请推广码"
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ linearLayout {
|
|
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
|
|
+
|
|
|
|
|
+ linearLayout {
|
|
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
|
|
+ textView {
|
|
|
|
|
+ text = "姓名"
|
|
|
|
|
+ textSizeAuto = 31
|
|
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
|
|
+ }.lparams(autoSize(260), wrapContent) {
|
|
|
|
|
+ marginStart = autoSize(36)
|
|
|
|
|
+ }
|
|
|
|
|
+ }.lparams(autoSize(260), autoSize(132))
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ editText {
|
|
|
|
|
+ name_edittext = this
|
|
|
|
|
+ hint = "请输入姓名"
|
|
|
|
|
+ background = null
|
|
|
|
|
+ inputType = EditorInfo.TYPE_CLASS_TEXT
|
|
|
|
|
+ hintColorStr = "#CCCCCC"
|
|
|
|
|
+ textSizeAuto = 31
|
|
|
|
|
+ textColorStr = "#333333"
|
|
|
|
|
+ }.lparams(matchParent, autoSize(132))
|
|
|
|
|
+ }.lparams(matchParent, autoSize(132))
|
|
|
|
|
+
|
|
|
|
|
+ itemView()
|
|
|
|
|
+
|
|
|
|
|
+ linearLayout {
|
|
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
|
|
+
|
|
|
|
|
+ linearLayout {
|
|
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
|
|
+ textView {
|
|
|
|
|
+ text = "身份证号码"
|
|
|
|
|
+ textSizeAuto = 31
|
|
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
|
|
+ }.lparams(autoSize(260), wrapContent) {
|
|
|
|
|
+ marginStart = autoSize(36)
|
|
|
|
|
+ }
|
|
|
|
|
+ }.lparams(autoSize(260), autoSize(132))
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ editText {
|
|
|
|
|
+ name_edittext = this
|
|
|
|
|
+ hint = "请输入身份证号码"
|
|
|
|
|
+ background = null
|
|
|
|
|
+ inputType = EditorInfo.TYPE_CLASS_TEXT
|
|
|
|
|
+ hintColorStr = "#CCCCCC"
|
|
|
|
|
+ textSizeAuto = 31
|
|
|
|
|
+ textColorStr = "#333333"
|
|
|
|
|
+ }.lparams(matchParent, autoSize(132))
|
|
|
|
|
+ }.lparams(matchParent, autoSize(132))
|
|
|
|
|
+
|
|
|
|
|
+ itemView()
|
|
|
|
|
+
|
|
|
|
|
+ linearLayout {
|
|
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
|
|
+
|
|
|
|
|
+ linearLayout {
|
|
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
|
|
+ textView {
|
|
|
|
|
+ text = "上传证件照"
|
|
|
|
|
+ textSizeAuto = 31
|
|
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
|
|
+ }.lparams(autoSize(260), wrapContent) {
|
|
|
|
|
+ marginStart = autoSize(36)
|
|
|
|
|
+ }
|
|
|
|
|
+ }.lparams(autoSize(260), autoSize(132))
|
|
|
|
|
+
|
|
|
|
|
+ }.lparams(matchParent, autoSize(132))
|
|
|
|
|
+
|
|
|
|
|
+ linearLayout {
|
|
|
|
|
+ gravity = Gravity.CENTER_HORIZONTAL
|
|
|
|
|
+ linearLayout {
|
|
|
|
|
+ backgroundResource = R.mipmap.qhj_add_positive_idcard
|
|
|
|
|
+ positiveImageString.bindOptional(context) {
|
|
|
|
|
+ visibility = if (it.isNullOrEmpty()) {
|
|
|
|
|
+ View.VISIBLE
|
|
|
|
|
+ } else {
|
|
|
|
|
+ View.GONE
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ visibility = View.VISIBLE
|
|
|
|
|
+ onThrottleFirstClick {
|
|
|
|
|
+ if (positiveImageString.value.isNullOrEmpty().not()){
|
|
|
|
|
+ return@onThrottleFirstClick
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ val selectDataList = arrayListOf(
|
|
|
|
|
+ SelectData(id = "1", value = "拍照"),
|
|
|
|
|
+ SelectData(id = "2", value = "相册")
|
|
|
|
|
+ )
|
|
|
|
|
+ creatBottomSheetDialog("请选择上传", selectDataList) {
|
|
|
|
|
+ if (this.id == "1"){
|
|
|
|
|
+ RxPermissions(this@ApplyPromotionCodeActivity).request(
|
|
|
|
|
+ Manifest.permission.READ_EXTERNAL_STORAGE,
|
|
|
|
|
+ Manifest.permission.CAMERA)
|
|
|
|
|
+ .subscribe { granted ->
|
|
|
|
|
+ if (granted) {//打开相机拍照
|
|
|
|
|
+ val intent = positiveImageCaptureManager.dispatchTakePictureIntent()
|
|
|
|
|
+ ActivityUtils.startActivityForResult(this@ApplyPromotionCodeActivity, intent, 101)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }else if (this.id == "2"){
|
|
|
|
|
+ PhotoUtils().showPicker(this@ApplyPromotionCodeActivity) {
|
|
|
|
|
+ it.firstOrNull()?.let {
|
|
|
|
|
+ viewModel.loadingDialogStatus.value =
|
|
|
|
|
+ TaskUiModel.inFlight()
|
|
|
|
|
+ UpLoadUtils(this@ApplyPromotionCodeActivity).uploadPicture(
|
|
|
|
|
+ File(it),
|
|
|
|
|
+ object : StringCallback() {
|
|
|
|
|
+ override fun onError(
|
|
|
|
|
+ call: Call,
|
|
|
|
|
+ e: Exception,
|
|
|
|
|
+ id: Int
|
|
|
|
|
+ ) {
|
|
|
|
|
+ LogUtils.e("hidahdashdsdasd", e.message)
|
|
|
|
|
+ viewModel.loadingDialogStatus.value =
|
|
|
|
|
+ TaskUiModel.failed(
|
|
|
|
|
+ InteractiveException(
|
|
|
|
|
+ errorMessage = e.message ?: ""
|
|
|
|
|
+ )
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ override fun onResponse(
|
|
|
|
|
+ response: String,
|
|
|
|
|
+ id: Int
|
|
|
|
|
+ ) {
|
|
|
|
|
+ /*[{"originalName":"tem.jpg","fileName":"201907161657044712.jpg","fileSize":"0KB","fileType":"image/jpeg","filePath":"./uploadFile/20190716/201907161657044712.jpg","submitName":null}]*/
|
|
|
|
|
+ try {
|
|
|
|
|
+ viewModel.loadingDialogStatus.value =
|
|
|
|
|
+ TaskUiModel.success("上传成功")
|
|
|
|
|
+ val jsonArray = JSONArray(response)
|
|
|
|
|
+ LogUtils.eTag(
|
|
|
|
|
+ "图片",
|
|
|
|
|
+ JSON.toJSONString(jsonArray)
|
|
|
|
|
+ )
|
|
|
|
|
+ for (i in 0 until jsonArray.length()) {
|
|
|
|
|
+ positiveUploadFile =
|
|
|
|
|
+ (jsonArray.get(i) as JSONObject).getString(
|
|
|
|
|
+ "filePath"
|
|
|
|
|
+ )
|
|
|
|
|
+ positiveImageString.value = it
|
|
|
|
|
+ LogUtils.e("hidahdashd", positiveUploadFile)
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (e: JSONException) {
|
|
|
|
|
+ e.printStackTrace()
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ 10000.0,
|
|
|
|
|
+ SPUtils.getInstance().getString(Constant.uploadUrl)
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ positiveImagePhotoString.bindOptional(context) {
|
|
|
|
|
+ if (it.isNullOrEmpty().not()) {
|
|
|
|
|
+ viewModel.loadingDialogStatus.value =
|
|
|
|
|
+ TaskUiModel.inFlight()
|
|
|
|
|
+ UpLoadUtils(this@ApplyPromotionCodeActivity).uploadPicture(
|
|
|
|
|
+ File(it),
|
|
|
|
|
+ object : StringCallback() {
|
|
|
|
|
+ override fun onError(
|
|
|
|
|
+ call: Call,
|
|
|
|
|
+ e: Exception,
|
|
|
|
|
+ id: Int
|
|
|
|
|
+ ) {
|
|
|
|
|
+ LogUtils.e("hidahdashdsdasd", e.message)
|
|
|
|
|
+ viewModel.loadingDialogStatus.value =
|
|
|
|
|
+ TaskUiModel.failed(
|
|
|
|
|
+ InteractiveException(
|
|
|
|
|
+ errorMessage = e.message ?: ""
|
|
|
|
|
+ )
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ override fun onResponse(
|
|
|
|
|
+ response: String,
|
|
|
|
|
+ id: Int
|
|
|
|
|
+ ) {
|
|
|
|
|
+ /*[{"originalName":"tem.jpg","fileName":"201907161657044712.jpg","fileSize":"0KB","fileType":"image/jpeg","filePath":"./uploadFile/20190716/201907161657044712.jpg","submitName":null}]*/
|
|
|
|
|
+ try {
|
|
|
|
|
+ viewModel.loadingDialogStatus.value =
|
|
|
|
|
+ TaskUiModel.success("上传成功")
|
|
|
|
|
+ val jsonArray = JSONArray(response)
|
|
|
|
|
+ LogUtils.eTag(
|
|
|
|
|
+ "图片",
|
|
|
|
|
+ JSON.toJSONString(jsonArray)
|
|
|
|
|
+ )
|
|
|
|
|
+ for (i in 0 until jsonArray.length()) {
|
|
|
|
|
+ positiveUploadFile =
|
|
|
|
|
+ (jsonArray.get(i) as JSONObject).getString(
|
|
|
|
|
+ "filePath"
|
|
|
|
|
+ )
|
|
|
|
|
+ positiveImageString.value = it
|
|
|
|
|
+ LogUtils.e("hidahdashd", positiveUploadFile)
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (e: JSONException) {
|
|
|
|
|
+ e.printStackTrace()
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ 10000.0,
|
|
|
|
|
+ SPUtils.getInstance().getString(Constant.uploadUrl)
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }.lparams(autoSize(480), autoSize(288))
|
|
|
|
|
+
|
|
|
|
|
+ imageView {
|
|
|
|
|
+ positiveImageString.bindOptional(context) {
|
|
|
|
|
+ if (it.isNullOrEmpty()) {
|
|
|
|
|
+ visibility = View.GONE
|
|
|
|
|
+ } else {
|
|
|
|
|
+ visibility = View.VISIBLE
|
|
|
|
|
+ setImageURI(Uri.parse(it))
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ visibility = View.GONE
|
|
|
|
|
+ onThrottleFirstClick {
|
|
|
|
|
+ val path = positiveImageString.value.guard {
|
|
|
|
|
+ return@onThrottleFirstClick
|
|
|
|
|
+ }
|
|
|
|
|
+ PhotoUtils().showImageViewer(
|
|
|
|
|
+ this@ApplyPromotionCodeActivity,
|
|
|
|
|
+ 1,
|
|
|
|
|
+ arrayListOf(path)
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+ }.lparams(autoSize(480), autoSize(288)) {
|
|
|
|
|
+ marginStart = autoSize(250)
|
|
|
|
|
+ }
|
|
|
|
|
+ }.lparams(matchParent, autoSize(288)){
|
|
|
|
|
+ topMargin = autoSize(40)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ linearLayout {
|
|
|
|
|
+ gravity = Gravity.CENTER_HORIZONTAL
|
|
|
|
|
+ linearLayout {
|
|
|
|
|
+ backgroundResource = R.mipmap.qhj_add_positive_idcard
|
|
|
|
|
+ reverseImageString.bindOptional(context) {
|
|
|
|
|
+ visibility = if (it.isNullOrEmpty()) {
|
|
|
|
|
+ View.VISIBLE
|
|
|
|
|
+ } else {
|
|
|
|
|
+ View.GONE
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ visibility = View.VISIBLE
|
|
|
|
|
+ onThrottleFirstClick {
|
|
|
|
|
+ if (reverseImageString.value.isNullOrEmpty().not()){
|
|
|
|
|
+ return@onThrottleFirstClick
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ val selectDataList = arrayListOf(
|
|
|
|
|
+ SelectData(id = "1", value = "拍照"),
|
|
|
|
|
+ SelectData(id = "2", value = "相册")
|
|
|
|
|
+ )
|
|
|
|
|
+ creatBottomSheetDialog("请选择上传", selectDataList) {
|
|
|
|
|
+ if (this.id == "1"){
|
|
|
|
|
+ RxPermissions(this@ApplyPromotionCodeActivity).request(
|
|
|
|
|
+ Manifest.permission.READ_EXTERNAL_STORAGE,
|
|
|
|
|
+ Manifest.permission.CAMERA)
|
|
|
|
|
+ .subscribe { granted ->
|
|
|
|
|
+ if (granted) {//打开相机拍照
|
|
|
|
|
+ val intent = reverseImageCaptureManager.dispatchTakePictureIntent()
|
|
|
|
|
+ ActivityUtils.startActivityForResult(this@ApplyPromotionCodeActivity, intent, 102)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }else if (this.id == "2"){
|
|
|
|
|
+ PhotoUtils().showPicker(this@ApplyPromotionCodeActivity) {
|
|
|
|
|
+ it.firstOrNull()?.let {
|
|
|
|
|
+ viewModel.loadingDialogStatus.value =
|
|
|
|
|
+ TaskUiModel.inFlight()
|
|
|
|
|
+ UpLoadUtils(this@ApplyPromotionCodeActivity).uploadPicture(
|
|
|
|
|
+ File(it),
|
|
|
|
|
+ object : StringCallback() {
|
|
|
|
|
+ override fun onError(
|
|
|
|
|
+ call: Call,
|
|
|
|
|
+ e: Exception,
|
|
|
|
|
+ id: Int
|
|
|
|
|
+ ) {
|
|
|
|
|
+ LogUtils.e("hidahdashdsdasd", e.message)
|
|
|
|
|
+ viewModel.loadingDialogStatus.value =
|
|
|
|
|
+ TaskUiModel.failed(
|
|
|
|
|
+ InteractiveException(
|
|
|
|
|
+ errorMessage = e.message ?: ""
|
|
|
|
|
+ )
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ override fun onResponse(
|
|
|
|
|
+ response: String,
|
|
|
|
|
+ id: Int
|
|
|
|
|
+ ) {
|
|
|
|
|
+ /*[{"originalName":"tem.jpg","fileName":"201907161657044712.jpg","fileSize":"0KB","fileType":"image/jpeg","filePath":"./uploadFile/20190716/201907161657044712.jpg","submitName":null}]*/
|
|
|
|
|
+ try {
|
|
|
|
|
+ viewModel.loadingDialogStatus.value =
|
|
|
|
|
+ TaskUiModel.success("上传成功")
|
|
|
|
|
+ val jsonArray = JSONArray(response)
|
|
|
|
|
+ LogUtils.eTag(
|
|
|
|
|
+ "图片",
|
|
|
|
|
+ JSON.toJSONString(jsonArray)
|
|
|
|
|
+ )
|
|
|
|
|
+ for (i in 0 until jsonArray.length()) {
|
|
|
|
|
+ reverseUploadFile =
|
|
|
|
|
+ (jsonArray.get(i) as JSONObject).getString(
|
|
|
|
|
+ "filePath"
|
|
|
|
|
+ )
|
|
|
|
|
+ reverseImageString.value = it
|
|
|
|
|
+ LogUtils.e("hidahdashd", reverseUploadFile)
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (e: JSONException) {
|
|
|
|
|
+ e.printStackTrace()
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ 10000.0,
|
|
|
|
|
+ SPUtils.getInstance().getString(Constant.uploadUrl)
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ reverseImagePhotoString.bindOptional(context) {
|
|
|
|
|
+ if (it.isNullOrEmpty().not()) {
|
|
|
|
|
+ viewModel.loadingDialogStatus.value =
|
|
|
|
|
+ TaskUiModel.inFlight()
|
|
|
|
|
+ UpLoadUtils(this@ApplyPromotionCodeActivity).uploadPicture(
|
|
|
|
|
+ File(it),
|
|
|
|
|
+ object : StringCallback() {
|
|
|
|
|
+ override fun onError(
|
|
|
|
|
+ call: Call,
|
|
|
|
|
+ e: Exception,
|
|
|
|
|
+ id: Int
|
|
|
|
|
+ ) {
|
|
|
|
|
+ LogUtils.e("hidahdashdsdasd", e.message)
|
|
|
|
|
+ viewModel.loadingDialogStatus.value =
|
|
|
|
|
+ TaskUiModel.failed(
|
|
|
|
|
+ InteractiveException(
|
|
|
|
|
+ errorMessage = e.message ?: ""
|
|
|
|
|
+ )
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ override fun onResponse(
|
|
|
|
|
+ response: String,
|
|
|
|
|
+ id: Int
|
|
|
|
|
+ ) {
|
|
|
|
|
+ /*[{"originalName":"tem.jpg","fileName":"201907161657044712.jpg","fileSize":"0KB","fileType":"image/jpeg","filePath":"./uploadFile/20190716/201907161657044712.jpg","submitName":null}]*/
|
|
|
|
|
+ try {
|
|
|
|
|
+ viewModel.loadingDialogStatus.value =
|
|
|
|
|
+ TaskUiModel.success("上传成功")
|
|
|
|
|
+ val jsonArray = JSONArray(response)
|
|
|
|
|
+ LogUtils.eTag(
|
|
|
|
|
+ "图片",
|
|
|
|
|
+ JSON.toJSONString(jsonArray)
|
|
|
|
|
+ )
|
|
|
|
|
+ for (i in 0 until jsonArray.length()) {
|
|
|
|
|
+ reverseUploadFile =
|
|
|
|
|
+ (jsonArray.get(i) as JSONObject).getString(
|
|
|
|
|
+ "filePath"
|
|
|
|
|
+ )
|
|
|
|
|
+ reverseImageString.value = it
|
|
|
|
|
+ LogUtils.e("hidahdashd", reverseUploadFile)
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (e: JSONException) {
|
|
|
|
|
+ e.printStackTrace()
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ 10000.0,
|
|
|
|
|
+ SPUtils.getInstance().getString(Constant.uploadUrl)
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }.lparams(autoSize(480), autoSize(288))
|
|
|
|
|
+
|
|
|
|
|
+ imageView {
|
|
|
|
|
+ reverseImageString.bindOptional(context) {
|
|
|
|
|
+ if (it.isNullOrEmpty()) {
|
|
|
|
|
+ visibility = View.GONE
|
|
|
|
|
+ } else {
|
|
|
|
|
+ visibility = View.VISIBLE
|
|
|
|
|
+ setImageURI(Uri.parse(it))
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ visibility = View.GONE
|
|
|
|
|
+ onThrottleFirstClick {
|
|
|
|
|
+ val path = reverseImageString.value.guard {
|
|
|
|
|
+ return@onThrottleFirstClick
|
|
|
|
|
+ }
|
|
|
|
|
+ PhotoUtils().showImageViewer(
|
|
|
|
|
+ this@ApplyPromotionCodeActivity,
|
|
|
|
|
+ 1,
|
|
|
|
|
+ arrayListOf(path)
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+ }.lparams(autoSize(480), autoSize(288)) {
|
|
|
|
|
+ marginStart = autoSize(250)
|
|
|
|
|
+ }
|
|
|
|
|
+ }.lparams(matchParent, autoSize(288)){
|
|
|
|
|
+ topMargin = autoSize(40)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+}
|