大致完成选择论坛、选择本地视频、预览视频、发视频UI
This commit is contained in:
@ -8,9 +8,12 @@ import androidx.lifecycle.MutableLiveData
|
||||
import com.gh.common.util.*
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.entity.ErrorEntity
|
||||
import com.gh.gamecenter.entity.LocalVideoEntity
|
||||
import com.gh.gamecenter.qa.answer.edit.AnswerEditActivity
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.gh.gamecenter.retrofit.service.ApiService
|
||||
import com.gh.gamecenter.video.upload.OnUploadListener
|
||||
import com.gh.gamecenter.video.upload.UploadManager
|
||||
import com.lightgame.utils.Utils
|
||||
import com.zhihu.matisse.Matisse
|
||||
import com.zhihu.matisse.internal.utils.PathUtils
|
||||
@ -27,6 +30,8 @@ abstract class BaseRichEditorViewModel(application: Application) : AndroidViewMo
|
||||
val chooseImagesUploadSuccess = MutableLiveData<LinkedHashMap<String, String>>()
|
||||
var uploadImageSubscription: Disposable? = null
|
||||
val mapImages = HashMap<String, String>()
|
||||
val localVideoList = ArrayList<LocalVideoEntity>()
|
||||
var currentUploadingVideo: LocalVideoEntity? = null
|
||||
|
||||
//检查图片是否符合规则并上传图片
|
||||
fun uploadPic(data: Intent) {
|
||||
@ -106,4 +111,26 @@ abstract class BaseRichEditorViewModel(application: Application) : AndroidViewMo
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun uploadVideo() {
|
||||
if (localVideoList.isEmpty()) return
|
||||
currentUploadingVideo = localVideoList[0]
|
||||
UploadManager.createUploadTask(currentUploadingVideo!!.filePath, object : OnUploadListener {
|
||||
override fun onProgressChanged(uploadFilePath: String, currentSize: Long, totalSize: Long, speed: Long) {
|
||||
val percent = currentSize * 100 / totalSize.toFloat()
|
||||
Utils.log("上传中...${percent.roundTo(1)}%")
|
||||
}
|
||||
|
||||
override fun onUploadSuccess(uploadFilePath: String, url: String) {
|
||||
Utils.log("上传完成:$uploadFilePath--$url")
|
||||
localVideoList.remove(currentUploadingVideo!!)
|
||||
currentUploadingVideo = null
|
||||
uploadVideo()
|
||||
}
|
||||
|
||||
override fun onUploadFailure(uploadFilePath: String, errorMsg: String) {
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user