From f1fc06ca84940a2537966cd34bddd1006a67f2ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E7=8E=89=E4=B9=85?= <1484288157@qq.com> Date: Tue, 23 Jun 2020 18:13:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=B8=E6=88=8F=E4=B8=8A=E4=BC=A0=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../game/upload/GameUploadFragment.kt | 34 +++++++++---------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/com/gh/gamecenter/game/upload/GameUploadFragment.kt b/app/src/main/java/com/gh/gamecenter/game/upload/GameUploadFragment.kt index be76cd48ab..4f20590c69 100644 --- a/app/src/main/java/com/gh/gamecenter/game/upload/GameUploadFragment.kt +++ b/app/src/main/java/com/gh/gamecenter/game/upload/GameUploadFragment.kt @@ -56,7 +56,7 @@ class GameUploadFragment : NormalFragment() { private var mDisposable: Disposable? = null private var mUploadFileDisposable: Disposable? = null private val mPathMap = LinkedHashMap() - private lateinit var mIsOnline: AtomicBoolean//是否需要联网 + private var mIsOnline: String = ""//是否需要联网 private var mGameLanguage: String = ""//游戏语言 private var mGameType: String = ""//游戏类型 private val mTags = arrayListOf()//游戏标签 @@ -164,11 +164,11 @@ class GameUploadFragment : NormalFragment() { gameIsNetworkingRg.setOnCheckedChangeListener { group, checkedId -> when (checkedId) { R.id.gameNetworkingRb -> { - mIsOnline = AtomicBoolean(true) + mIsOnline = "yes" MtaHelper.onEvent("游戏上传", "是否联网", "需要联网") } R.id.gameNoNetworkingRb -> { - mIsOnline = AtomicBoolean(false) + mIsOnline = "no" MtaHelper.onEvent("游戏上传", "是否联网", "无需联网") } } @@ -364,18 +364,16 @@ class GameUploadFragment : NormalFragment() { requestMap["des"] = et_game_intro.text.toString() requestMap["images"] = imageList requestMap["video"] = gameVideoPathEt.text.toString() - if(::mIsOnline.isInitialized) { - requestMap["is_online"] = mIsOnline.get() + requestMap["developer_say"] = gameDeveloperWordsEt.text.toString() + if (mIsOnline.isNotEmpty()) { + requestMap["is_online"] = mIsOnline } - if(mGameLanguage.isNotEmpty()) { + if (mGameLanguage.isNotEmpty()) { requestMap["language"] = mGameLanguage } - if(mGameType.isNotEmpty()) { + if (mGameType.isNotEmpty()) { requestMap["type"] = mGameType } - if(gameDeveloperWordsEt.text.toString().isNotEmpty()) { - requestMap["developer_say"] = gameDeveloperWordsEt.text.toString() - } val body = RequestBody.create(MediaType.parse("application/json"), GsonUtils.toJson(requestMap)) @@ -384,18 +382,18 @@ class GameUploadFragment : NormalFragment() { private fun showSelectDialog() { - val view = View.inflate(context, R.layout.dialog_suggest_game, null) + val view = View.inflate(requireContext(), R.layout.dialog_suggest_game, null) val recyclerView = view.findViewById(R.id.dialog_suggest_game_rv) val back = view.findViewById(R.id.dialog_suggest_game_back) val pb = view.findViewById(R.id.dialog_suggest_game_load) val manualBtn = view.findViewById(R.id.dialog_suggest_manual) val titleTv = view.findViewById(R.id.titleTv) - recyclerView.layoutManager = GridLayoutManager(context, 4) + recyclerView.layoutManager = GridLayoutManager(requireContext(), 4) recyclerView.adapter = SuggestSelectGameAdapter(this@GameUploadFragment, pb) titleTv.text = "请选择你要上传的游戏" manualBtn.text = "从设备上选择" - mSelectGameDialog = Dialog(context) + mSelectGameDialog = Dialog(requireContext()) mSelectGameDialog?.apply { requestWindowFeature(Window.FEATURE_NO_TITLE) setCanceledOnTouchOutside(false) @@ -500,13 +498,13 @@ class GameUploadFragment : NormalFragment() { !TextUtils.isEmpty(et_game_intro.text.toString()) || !TextUtils.isEmpty(gameDeveloperWordsEt.text.toString()) || !TextUtils.isEmpty(gameVideoPathEt.text.toString()) || - ::mIsOnline.isInitialized || + mIsOnline.isNotEmpty() || mGameLanguage.isNotEmpty() || mGameType.isNotEmpty() || mIconAdapter!!.fileList.size > 0 || mTags.size > 0 || mAdapter!!.fileList.size > 0) { - DialogUtils.showAlertDialog(context, "提示", + DialogUtils.showAlertDialog(requireContext(), "提示", "确定要退出吗?已保存的内容将会消失", "不了", "确定", null, DialogUtils.CancelListener { activity?.finish() }) return true @@ -516,7 +514,7 @@ class GameUploadFragment : NormalFragment() { private fun showAddTagDialog() { val dialog = Dialog(requireContext()) - val view = View.inflate(context, R.layout.dialog_modify_nickname, null) + val view = View.inflate(requireContext(), R.layout.dialog_modify_nickname, null) val title = view.findViewById(R.id.dialog_nickname_title) val input = view.findViewById(R.id.dialog_nickname_input) title.text = "新建标签" @@ -529,7 +527,7 @@ class GameUploadFragment : NormalFragment() { view.findViewById(R.id.dialog_nickname_confirm).setOnClickListener { if (!TextUtils.isEmpty(input.text.toString().trim())) { addTag(input.text.toString().trim()) - Util_System_Keyboard.hideSoftKeyboard(context, input) + Util_System_Keyboard.hideSoftKeyboard(requireContext(), input) dialog.dismiss() } else { ToastUtils.showToast(getString(R.string.vote_empty_hint)) @@ -542,7 +540,7 @@ class GameUploadFragment : NormalFragment() { dialog.requestWindowFeature(Window.FEATURE_NO_TITLE) dialog.setContentView(view) dialog.show() - mBaseHandler.postDelayed({ Util_System_Keyboard.showSoftKeyboard(context, input) }, 300) + mBaseHandler.postDelayed({ Util_System_Keyboard.showSoftKeyboard(requireContext(), input) }, 300) } private fun addTag(tag: String) {