123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- package com.zswc.creativity.activity
- import android.app.Activity
- import android.content.Intent
- import android.os.Bundle
- import androidx.core.net.toUri
- import com.luck.picture.lib.PictureSelector
- import com.zswc.creativity.base.MBActivity
- import com.zswc.creativity.config.MIntentAction
- import com.zswc.creativity.databinding.ActivityOpinionBinding
- import com.zswc.creativity.inte.OnUploadCallback
- import com.zswc.creativity.utils.FileUtils
- import com.zswc.creativity.utils.OssUtils
- import com.zswc.creativity.vmodel.OpinionVModel
- import java.util.*
- /**
- *Created by shihuiyun
- *on 2020/9/24
- */
- class OpinionActivity : MBActivity<OpinionVModel, ActivityOpinionBinding>(), OnUploadCallback<String> {
- var type=1
- override fun __before() {
- super.__before()
- type= intent?.extras?.getInt("type", 1)!!
- }
- override fun init(savedInstanceState: Bundle?) {
- super.init(savedInstanceState)
- vm.type=type
- }
- override fun binding(): ActivityOpinionBinding {
- return ActivityOpinionBinding.inflate(layoutInflater)
- }
- override fun vmClass(): Class<OpinionVModel> {
- return OpinionVModel::class.java
- }
- override fun title(): String? {
- return if(type==1) {
- "意见反馈"
- }else{
- "举报投诉"
- }
- }
- override fun onUploadSuccess(t: String) {
- val ss: Array<String> = t.split(",".toRegex()).toTypedArray()
- vm.url.value = ss[1]
- }
- override fun onUploadError(error: String?) {
- TODO("Not yet implemented")
- }
- override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
- super.onActivityResult(requestCode, resultCode, data)
- if (resultCode != Activity.RESULT_OK) {
- return
- }
- if (requestCode == MIntentAction.REQUEST_CODE_THREE) {//图片
- val selectList = PictureSelector.obtainMultipleResult(data)
- val list = ArrayList<String>()
- if (null != selectList) {
- if(selectList[0].path.contains("content://")){
- val cr = this.contentResolver
- list.add( FileUtils.getFilePathFromContentUri(selectList[0].path.toUri(),cr))
- }else{
- list.add(selectList[0].path)
- }
- OssUtils(this, vm)
- .setUpLoad("idcard", list, this)
- }
- return
- }
- if (requestCode == MIntentAction.REQUEST_CODE_CAMERA) {//拍照
- //拍照
- val selectList = PictureSelector.obtainMultipleResult(data) ?: return
- val list = ArrayList<String>()
- if(selectList[0].path.contains("content://")){
- val cr = this.contentResolver
- list.add( FileUtils.getFilePathFromContentUri(selectList[0].path.toUri(),cr))
- }else{
- list.add(selectList[0].path)
- }
- OssUtils(this, vm)
- .setUpLoad("idcard", list, this)
- return
- }
- }
- }
|