Given the code below. It uploads well and can track progress but does not jump to COMPLETE, CANCELLED etc. It takes to much time to load
AmityCoreClient.newFileRepository()
.uploadVideo(uri = videoUri, contentFeedType = AmityContentFeedType.POST)
.doOnNext { uploadResult: AmityUploadResult →
when (uploadResult) {
is AmityUploadResult.PROGRESS → {
// upload progress event
val progress = uploadResult.getUploadInfo().getProgressPercentage()
attachment_progress = progress
Log.e(“PROGRESS”, attachment_progress.toString())
}
is AmityUploadResult.COMPLETE → {
// completion event
val video: AmityVideo = uploadResult.getFile()
fileIds.add(video.getFileId())
attachment_type = “video”
val postAttachments = mutableListOf<PostAttachment>()
for (fileId in fileIds) {
val postAttachment = PostAttachment(fileId, "video")
postAttachments.add(postAttachment)
}
postAttachmentAdapter = PostAttachmentAdapter(this@SocialPostCreateActivity, postAttachments)
binding.recyclerViewAttachment.adapter = postAttachmentAdapter
binding.textViewProgress.text = "Loading .."
binding.cardViewProgress.visibility = GONE
}
is AmityUploadResult.ERROR -> {
// error event
val error = AmityError.from(uploadResult.getError())
Toast.makeText(this@SocialPostCreateActivity, "Error attaching files", Toast.LENGTH_SHORT).show()
binding.textViewProgress.text = "Loading .."
binding.cardViewProgress.visibility = GONE
}
is AmityUploadResult.CANCELLED -> {
// cancelled upload event
binding.textViewProgress.text = "Loading .."
binding.cardViewProgress.visibility = GONE
}
}
}
.subscribe()