feat: 对接畅玩反馈接口
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
package com.gh.vspace
|
||||
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.Parcelable
|
||||
import android.view.Gravity
|
||||
@ -8,22 +9,36 @@ import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.widget.doOnTextChanged
|
||||
import androidx.lifecycle.ViewModel
|
||||
import com.gh.common.util.PackageUtils
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.base.fragment.BaseDialogFragment
|
||||
import com.gh.gamecenter.common.utils.dip2px
|
||||
import com.gh.gamecenter.common.utils.toColor
|
||||
import com.gh.gamecenter.common.exposure.meta.MetaUtil
|
||||
import com.gh.gamecenter.common.json.json
|
||||
import com.gh.gamecenter.common.retrofit.Response
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
||||
import com.gh.gamecenter.core.utils.ToastUtils
|
||||
import com.gh.gamecenter.databinding.DialogVgameFeedbackBinding
|
||||
import com.gh.gamecenter.databinding.ItemVfeedbackOptionBinding
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.utils.Utils
|
||||
import com.lightgame.utils.toast.ToastHelper
|
||||
import com.walkud.rom.checker.RomIdentifier
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import kotlinx.parcelize.Parcelize
|
||||
import okhttp3.ResponseBody
|
||||
import org.json.JSONArray
|
||||
|
||||
class VFeedbackDialogFragment : BaseDialogFragment() {
|
||||
|
||||
private var mGame: GameEntity? = null
|
||||
private var mTagList: List<FeedbackTag>? = null
|
||||
private val mBinding by lazy { DialogVgameFeedbackBinding.inflate(layoutInflater) }
|
||||
private val mViewModel: VFeedbackViewModel by lazy { viewModelProvider() }
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
@ -39,10 +54,17 @@ class VFeedbackDialogFragment : BaseDialogFragment() {
|
||||
mTagList = arguments?.getParcelableArrayList(KEY_TAG_LIST)
|
||||
|
||||
mGame = arguments?.getParcelable(KEY_GAME)
|
||||
mGame?.let {
|
||||
|
||||
if (mGame == null) {
|
||||
Utils.log("遇到内部异常")
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
|
||||
mGame!!.let {
|
||||
mBinding.gameIconIv.displayGameIcon(it)
|
||||
mBinding.gameNameTv.text = it.name
|
||||
}
|
||||
mBinding.closeIv.enlargeTouchArea()
|
||||
mBinding.closeIv.setOnClickListener {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
@ -58,6 +80,7 @@ class VFeedbackDialogFragment : BaseDialogFragment() {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
mBinding.submitTv.setOnClickListener {
|
||||
mViewModel.postFeedback(mGame!!.id, mBinding.feedbackEt.text.toString(), getSelectedTagString())
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
checkLabel()
|
||||
@ -65,17 +88,14 @@ class VFeedbackDialogFragment : BaseDialogFragment() {
|
||||
updateSubmitButton()
|
||||
}
|
||||
|
||||
private fun getSelectedTagString(): String {
|
||||
val builder = StringBuilder()
|
||||
private fun getSelectedTagString(): ArrayList<String> {
|
||||
val selectedTagList = arrayListOf<String>()
|
||||
mTagList?.forEachIndexed { index, tag ->
|
||||
if (tag.checked) {
|
||||
if (index != 0) {
|
||||
builder.append(",")
|
||||
}
|
||||
builder.append(tag.tagName)
|
||||
selectedTagList.add(mTagList!![index].tagName)
|
||||
}
|
||||
}
|
||||
return builder.toString()
|
||||
return selectedTagList
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
@ -162,4 +182,39 @@ class VFeedbackDialogFragment : BaseDialogFragment() {
|
||||
var checked: Boolean = false
|
||||
) : Parcelable
|
||||
|
||||
class VFeedbackViewModel : ViewModel() {
|
||||
|
||||
fun postFeedback(gameId: String, message: String, tags: ArrayList<String>) {
|
||||
val json = json {
|
||||
"from" to ""
|
||||
"ghversion" to PackageUtils.getGhVersionName()
|
||||
"channel" to HaloApp.getInstance().channel
|
||||
"type" to Build.MODEL
|
||||
"sdk" to Build.VERSION.SDK_INT.toString()
|
||||
"version" to Build.VERSION.RELEASE
|
||||
"source" to HaloApp.getInstance().application.getString(R.string.app_name)
|
||||
"jnfj" to MetaUtil.getBase64EncodedIMEI()
|
||||
"manufacturer" to Build.MANUFACTURER
|
||||
"rom" to RomIdentifier.getRom().name + " " + RomIdentifier.getRom().versionName
|
||||
|
||||
"suggestion_type" to "畅玩问题"
|
||||
"game_id" to gameId
|
||||
"message" to message
|
||||
"tags" to JSONArray(tags)
|
||||
}
|
||||
|
||||
val requestBody = json.toRequestBody()
|
||||
RetrofitManager.getInstance().api.postSuggestion(requestBody)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : Response<ResponseBody?>() {
|
||||
override fun onResponse(response: ResponseBody?) {
|
||||
super.onResponse(response)
|
||||
ToastUtils.showToast("感谢您的反馈信息,我们将尽快处理~")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user