diff --git a/.gradle/7.3.3/executionHistory/executionHistory.bin b/.gradle/7.3.3/executionHistory/executionHistory.bin index 571db6f..b73cd3d 100644 Binary files a/.gradle/7.3.3/executionHistory/executionHistory.bin and b/.gradle/7.3.3/executionHistory/executionHistory.bin differ diff --git a/.gradle/7.3.3/executionHistory/executionHistory.lock b/.gradle/7.3.3/executionHistory/executionHistory.lock index a3da5e6..532408d 100644 Binary files a/.gradle/7.3.3/executionHistory/executionHistory.lock and b/.gradle/7.3.3/executionHistory/executionHistory.lock differ diff --git a/.gradle/7.3.3/fileHashes/fileHashes.bin b/.gradle/7.3.3/fileHashes/fileHashes.bin index f3be0ca..75c5615 100644 Binary files a/.gradle/7.3.3/fileHashes/fileHashes.bin and b/.gradle/7.3.3/fileHashes/fileHashes.bin differ diff --git a/.gradle/7.3.3/fileHashes/fileHashes.lock b/.gradle/7.3.3/fileHashes/fileHashes.lock index de0cf88..89a87f1 100644 Binary files a/.gradle/7.3.3/fileHashes/fileHashes.lock and b/.gradle/7.3.3/fileHashes/fileHashes.lock differ diff --git a/.gradle/7.3.3/fileHashes/resourceHashesCache.bin b/.gradle/7.3.3/fileHashes/resourceHashesCache.bin index 41da9b0..f75d617 100644 Binary files a/.gradle/7.3.3/fileHashes/resourceHashesCache.bin and b/.gradle/7.3.3/fileHashes/resourceHashesCache.bin differ diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock index 06eb3cc..3208f4a 100644 Binary files a/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/.gradle/buildOutputCleanup/outputFiles.bin b/.gradle/buildOutputCleanup/outputFiles.bin index 0be0359..2b4c499 100644 Binary files a/.gradle/buildOutputCleanup/outputFiles.bin and b/.gradle/buildOutputCleanup/outputFiles.bin differ diff --git a/.gradle/file-system.probe b/.gradle/file-system.probe index dcd71bb..c2bbd11 100644 Binary files a/.gradle/file-system.probe and b/.gradle/file-system.probe differ diff --git a/app/build.gradle b/app/build.gradle index c7aacae..9e47899 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -24,11 +24,11 @@ android { buildToolsVersion "30.0.3" defaultConfig { - applicationId "com.coldmint.rust.beta" + applicationId "com.coldmint.rust.pro" minSdkVersion 21 targetSdkVersion 32 - versionCode 18 - versionName "2.1 alpha1 (2022-8-25)" + versionCode 19 + versionName "2.1 Beta1 (2022-9-1)" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } diff --git a/app/release/output-metadata.json b/app/release/output-metadata.json new file mode 100644 index 0000000..c2258b3 --- /dev/null +++ b/app/release/output-metadata.json @@ -0,0 +1,20 @@ +{ + "version": 3, + "artifactType": { + "type": "APK", + "kind": "Directory" + }, + "applicationId": "com.coldmint.rust.pro", + "variantName": "release", + "elements": [ + { + "type": "SINGLE", + "filters": [], + "attributes": [], + "versionCode": 19, + "versionName": "2.1 Beta1 (2022-9-1)", + "outputFile": "app-release.apk" + } + ], + "elementType": "File" +} \ No newline at end of file diff --git a/app/src/main/java/com/coldmint/rust/pro/SearchActivity.kt b/app/src/main/java/com/coldmint/rust/pro/SearchActivity.kt index 40a065c..8d0b3c8 100644 --- a/app/src/main/java/com/coldmint/rust/pro/SearchActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/SearchActivity.kt @@ -65,14 +65,14 @@ class SearchActivity : BaseActivity() { override fun onQueryTextChange(newText: String?): Boolean { if (newText != null && newText.isNotBlank()) { -// viewBinding.searchSuggestionsView.setText(R.string.search_suggestions_loading) + viewBinding.searchSuggestionsView.setText(R.string.search_suggestions_loading) Search.instance.suggestions(newText, object : ApiCallBack { override fun onResponse(t: SearchSuggestionsData) { val dataList = t.data - if (dataList.isNullOrEmpty()) { + if (dataList.isEmpty()) { viewBinding.recyclerView.isVisible = false -// viewBinding.searchSuggestionsView.setText(R.string.search_suggestions_null) + viewBinding.searchSuggestionsView.setText(R.string.search_suggestions_null) } else { val adapter = SearchSuggestionsAdapter( @@ -92,20 +92,20 @@ class SearchActivity : BaseActivity() { } viewBinding.recyclerView.adapter = adapter viewBinding.recyclerView.isVisible = true -// val s = String.format(getString(R.string.search_suggestions_number),dataList.size) -// viewBinding.searchSuggestionsView.text = s + val s = String.format(getString(R.string.search_suggestions_number),dataList.size) + viewBinding.searchSuggestionsView.text = s } } override fun onFailure(e: Exception) { viewBinding.recyclerView.isVisible = false -// viewBinding.searchSuggestionsView.setText(R.string.search_suggestions_null) + viewBinding.searchSuggestionsView.setText(R.string.search_suggestions_null) } }) } else { -// viewBinding.searchSuggestionsView.setText(R.string.search_suggestions_null) + viewBinding.searchSuggestionsView.setText(R.string.search_suggestions_null) viewBinding.recyclerView.isVisible = false } return true diff --git a/app/src/main/java/com/coldmint/rust/pro/UserHomePageActivity.kt b/app/src/main/java/com/coldmint/rust/pro/UserHomePageActivity.kt index c6e40f3..ee3c555 100644 --- a/app/src/main/java/com/coldmint/rust/pro/UserHomePageActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/UserHomePageActivity.kt @@ -55,7 +55,7 @@ class UserHomePageActivity : BaseActivity() { private fun initView() { // immersionBar { // transparentStatusBar().statusBarDarkFont(true) -// .navigationBarColor(R.color.white_200).navigationBarDarkIcon(true) +// .navigationBarDarkIcon(true) // } val thisIntent = intent diff --git a/app/src/main/java/com/coldmint/rust/pro/UserListActivity.kt b/app/src/main/java/com/coldmint/rust/pro/UserListActivity.kt index b985924..442049f 100644 --- a/app/src/main/java/com/coldmint/rust/pro/UserListActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/UserListActivity.kt @@ -7,6 +7,7 @@ import android.view.LayoutInflater import android.view.View import android.widget.Toast import androidx.core.view.isVisible +import androidx.recyclerview.widget.DividerItemDecoration import androidx.recyclerview.widget.LinearLayoutManager import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.checkbox.BooleanCallback @@ -67,6 +68,14 @@ class UserListActivity : BaseActivity() { getString(R.string.fans) } } + viewBinding.recyclerView.layoutManager = + LinearLayoutManager(this@UserListActivity) + viewBinding.recyclerView.addItemDecoration( + DividerItemDecoration( + this, + DividerItemDecoration.VERTICAL + ) + ) loadList(account, isFollowMode, canRemoveFans) } } @@ -90,8 +99,7 @@ class UserListActivity : BaseActivity() { viewBinding.loadLayout.isVisible = false viewBinding.recyclerView.isVisible = true val adapter = UserAdapter(this@UserListActivity, dataList) - viewBinding.recyclerView.layoutManager = - LinearLayoutManager(this@UserListActivity) + adapter.setItemEvent { i, itemUserBinding, viewHolder, data -> itemUserBinding.root.setOnClickListener { val intent = Intent( diff --git a/app/src/main/java/com/coldmint/rust/pro/WebModInfoActivity.kt b/app/src/main/java/com/coldmint/rust/pro/WebModInfoActivity.kt index dd43909..a0bd2e6 100644 --- a/app/src/main/java/com/coldmint/rust/pro/WebModInfoActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/WebModInfoActivity.kt @@ -25,6 +25,7 @@ import com.afollestad.materialdialogs.input.getInputField import com.afollestad.materialdialogs.input.input import com.bumptech.glide.Glide import com.bumptech.glide.request.RequestOptions +import com.coldmint.dialog.CoreDialog import com.coldmint.rust.core.ModClass import com.coldmint.rust.core.dataBean.ApiResponse import com.coldmint.rust.core.dataBean.mod.WebModCommentData @@ -76,7 +77,7 @@ class WebModInfoActivity : BaseActivity() { val token by lazy { AppSettings.getValue(AppSettings.Setting.Token, "") } - lateinit var adapter :ModPageDetailsAdapter + lateinit var adapter: ModPageDetailsAdapter private fun initView() { setReturnButton() @@ -99,6 +100,9 @@ class WebModInfoActivity : BaseActivity() { viewBinding.button.text = getString(R.string.installated) } adapter = ModPageDetailsAdapter(this, modId) + adapter.modName.observe(this) { + title = it + } viewBinding.viewPager2.adapter = adapter TabLayoutMediator(viewBinding.tabLayout, viewBinding.viewPager2) { tab, i -> tab.text = when (i) { @@ -116,16 +120,16 @@ class WebModInfoActivity : BaseActivity() { } } }.attach() -// viewBinding.button.setOnClickListener { -// val type = viewBinding.button.text -// val installation = getString(R.string.installation) -// when (type) { -// installation -> { -// downloadAction(t) -// } -// } -// -// } + viewBinding.button.setOnClickListener { + val type = viewBinding.button.text + val installation = getString(R.string.installation) + when (type) { + installation -> { + downloadAction(adapter.getLink()) + } + } + + } // viewBinding.modCommentRecyclerView.layoutManager = // LinearLayoutManager(this@WebModInfoActivity) // viewBinding.modCommentRecyclerView.addItemDecoration( @@ -275,8 +279,11 @@ class WebModInfoActivity : BaseActivity() { * 下载事件 * @param t WebModInfoData */ - fun downloadAction(t: WebModInfoData) { - val fileLink = ServerConfiguration.getRealLink(t.data.link) + fun downloadAction(link: String?) { + if (link == null) { + return + } + val fileLink = ServerConfiguration.getRealLink(link) when (AppOperator.getNetworkType(this)) { AppOperator.NetWorkType.NetWorkType_Moble -> { val useMobileNetWork = @@ -284,19 +291,16 @@ class WebModInfoActivity : BaseActivity() { if (useMobileNetWork) { downloadWork(fileLink) } else { - MaterialDialog(this).show { - title(R.string.using_mobile_networks).message(R.string.using_mobile_networks_msg) - .positiveButton(R.string.only_one) { - downloadWork(fileLink) - } - negativeButton(R.string.always_allow) { + CoreDialog(this).setTitle(R.string.using_mobile_networks) + .setMessage(R.string.using_mobile_networks_msg) + .setPositiveButton(R.string.only_one) { + downloadWork(fileLink) + }.setNegativeButton(R.string.always_allow) { AppSettings.setValue(AppSettings.Setting.UseMobileNetwork, true) downloadWork(fileLink) - } - neutralButton(R.string.dialog_cancel) { + }.setNeutralButton(R.string.dialog_cancel) { - } - } + }.show() } } AppOperator.NetWorkType.NetWorkType_Wifi -> { @@ -359,11 +363,6 @@ class WebModInfoActivity : BaseActivity() { val loadFileLayoutBinding = LoadFileLayoutBinding.inflate(layoutInflater) loadFileLayoutBinding.LinearProgressIndicator.max = 100 var progress = 0 - val materialDialog = MaterialDialog(this).show { - title(R.string.downlod).customView(view = loadFileLayoutBinding.root) - .cancelable(false) - .positiveButton(R.string.dialog_close) - } val fileLoader = FileLoader.getInstantiate(fileLink, targetFile.absolutePath) fileLoader.download(object : ProgressResponseBody.ResponseProgressListener { @@ -376,25 +375,15 @@ class WebModInfoActivity : BaseActivity() { progress = trueProgress.toFloat().toInt() runOnUiThread { val progressTip = String.format(tip, progress) - if (materialDialog.isShowing) { - loadFileLayoutBinding.LinearProgressIndicator.progress = progress - loadFileLayoutBinding.tipView.text = progressTip - } viewBinding.button.text = progressTip } } override fun downloadFail(exception: Exception?) { - if (materialDialog.isShowing) { - materialDialog.dismiss() - } viewBinding.button.setText(R.string.installation) } override fun downloadSuccess() { - if (materialDialog.isShowing) { - materialDialog.dismiss() - } viewBinding.button.isEnabled = false viewBinding.button.setText(R.string.installated) WebMod.instance.addDownloadNum(modId) diff --git a/app/src/main/java/com/coldmint/rust/pro/WorkManagementActivity.kt b/app/src/main/java/com/coldmint/rust/pro/WorkManagementActivity.kt index d40b6c2..365a75b 100644 --- a/app/src/main/java/com/coldmint/rust/pro/WorkManagementActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/WorkManagementActivity.kt @@ -8,6 +8,7 @@ import android.view.View import android.widget.PopupMenu import android.widget.Toast import androidx.core.view.isVisible +import androidx.recyclerview.widget.DividerItemDecoration import androidx.recyclerview.widget.LinearLayoutManager import com.afollestad.materialdialogs.MaterialDialog import com.coldmint.rust.core.dataBean.ApiResponse @@ -258,6 +259,12 @@ class WorkManagementActivity : BaseActivity() { title = getString(R.string.work_management) setReturnButton() viewBinding.recyclerView.layoutManager = LinearLayoutManager(this) + viewBinding.recyclerView.addItemDecoration( + DividerItemDecoration( + this, + DividerItemDecoration.VERTICAL + ) + ) } } diff --git a/app/src/main/java/com/coldmint/rust/pro/adapters/InsertCoinsAdapter.kt b/app/src/main/java/com/coldmint/rust/pro/adapters/InsertCoinsAdapter.kt new file mode 100644 index 0000000..1153858 --- /dev/null +++ b/app/src/main/java/com/coldmint/rust/pro/adapters/InsertCoinsAdapter.kt @@ -0,0 +1,52 @@ +package com.coldmint.rust.pro.adapters + +import android.content.Context +import android.view.LayoutInflater +import android.view.ViewGroup +import com.bumptech.glide.Glide +import com.coldmint.rust.core.dataBean.mod.InsertCoinHistoryData +import com.coldmint.rust.core.web.ServerConfiguration +import com.coldmint.rust.pro.R +import com.coldmint.rust.pro.base.BaseAdapter +import com.coldmint.rust.pro.databinding.ItemInsertCoinsBinding +import com.coldmint.rust.pro.tool.GlobalMethod + + +/** + * 投币记录适配器 + * @constructor + */ +class InsertCoinsAdapter(context: Context, dataList: MutableList) : + BaseAdapter(context, dataList) { + + private val insertCoinsTip by lazy { + context.getString(R.string.insert_coins_tip) + } + + override fun getViewBindingObject( + layoutInflater: LayoutInflater, + parent: ViewGroup, + viewType: Int + ): ItemInsertCoinsBinding { + return ItemInsertCoinsBinding.inflate(layoutInflater, parent, false) + } + + override fun onBingView( + data: InsertCoinHistoryData.Data, + viewBinding: ItemInsertCoinsBinding, + viewHolder: ViewHolder, + position: Int + ) { + val icon = data.headIcon + if (icon == null) { + Glide.with(context).load(R.drawable.head_icon).into(viewBinding.imageView) + } else { + Glide.with(context).load(ServerConfiguration.getRealLink(icon)) + .apply(GlobalMethod.getRequestOptions(true)).into(viewBinding.imageView) + } + viewBinding.numberOfCoinView.text = String.format(insertCoinsTip, data.number) + viewBinding.timeView.text = data.time + viewBinding.nameView.text = data.userName + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/coldmint/rust/pro/adapters/ModPageDetailsAdapter.kt b/app/src/main/java/com/coldmint/rust/pro/adapters/ModPageDetailsAdapter.kt index 1b3d761..c378f72 100644 --- a/app/src/main/java/com/coldmint/rust/pro/adapters/ModPageDetailsAdapter.kt +++ b/app/src/main/java/com/coldmint/rust/pro/adapters/ModPageDetailsAdapter.kt @@ -2,7 +2,9 @@ package com.coldmint.rust.pro.adapters import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentActivity +import androidx.lifecycle.MutableLiveData import androidx.viewpager2.adapter.FragmentStateAdapter +import com.coldmint.rust.core.dataBean.mod.WebModInfoData import com.coldmint.rust.core.tool.DebugHelper import com.coldmint.rust.pro.fragments.InsertCoinsFragment import com.coldmint.rust.pro.fragments.ModCommentsFragment @@ -21,6 +23,24 @@ class ModPageDetailsAdapter(fragmentActivity: FragmentActivity, val modId: Strin return 3 } + val modName: MutableLiveData by lazy { + MutableLiveData() + } + + + /** + * 获取下载链接 + * @return String? + */ + fun getLink(): String? { + return if (this::webModDetailsFragment.isInitialized) { + webModDetailsFragment.getLink() + } else { + DebugHelper.printLog("获取下载路径", "详情碎片未初始化,返回null", isError = true) + null + } + } + /** * 获取此模组是否对外开放 * @return Boolean @@ -38,7 +58,7 @@ class ModPageDetailsAdapter(fragmentActivity: FragmentActivity, val modId: Strin return when (position) { 0 -> { if (!this::webModDetailsFragment.isInitialized) { - webModDetailsFragment = WebModDetailsFragment(modId) + webModDetailsFragment = WebModDetailsFragment(modId, modName) } webModDetailsFragment } diff --git a/app/src/main/java/com/coldmint/rust/pro/fragments/FollowFragment.kt b/app/src/main/java/com/coldmint/rust/pro/fragments/FollowFragment.kt index 1c91e44..739ff2e 100644 --- a/app/src/main/java/com/coldmint/rust/pro/fragments/FollowFragment.kt +++ b/app/src/main/java/com/coldmint/rust/pro/fragments/FollowFragment.kt @@ -28,9 +28,7 @@ import com.coldmint.rust.pro.tool.AppSettings * @date 2021/12/28 10:23 */ class FollowFragment : BaseFragment() { - val selfAccount by lazy { - AppSettings.getValue(AppSettings.Setting.Account, "") - } + var oldSize: Int = 0 var lastIndex = 0 @@ -38,6 +36,7 @@ class FollowFragment : BaseFragment() { * 加载视图如果需要更新的话 */ fun loadViewIfNeed() { + val selfAccount = AppSettings.getValue(AppSettings.Setting.Account, "") if (selfAccount.isBlank()) { showTip(R.string.please_login_first) } else { @@ -166,6 +165,7 @@ class FollowFragment : BaseFragment() { */ fun loadDynamic(account: String) { if (account.isBlank()) { + val selfAccount = AppSettings.getValue(AppSettings.Setting.Account, "") Dynamic.instance.getFollowAllDynamic(selfAccount, object : ApiCallBack { override fun onResponse(t: DynamicItemDataBean) { diff --git a/app/src/main/java/com/coldmint/rust/pro/fragments/InsertCoinsDialog.kt b/app/src/main/java/com/coldmint/rust/pro/fragments/InsertCoinsDialog.kt new file mode 100644 index 0000000..5167b42 --- /dev/null +++ b/app/src/main/java/com/coldmint/rust/pro/fragments/InsertCoinsDialog.kt @@ -0,0 +1,71 @@ +package com.coldmint.rust.pro.fragments + +import android.content.Context +import android.view.LayoutInflater +import com.coldmint.dialog.BaseAppDialog +import com.coldmint.rust.core.dataBean.ApiResponse +import com.coldmint.rust.core.interfaces.ApiCallBack +import com.coldmint.rust.core.interfaces.FileFinderListener +import com.coldmint.rust.core.web.ServerConfiguration +import com.coldmint.rust.core.web.WebMod +import com.coldmint.rust.pro.databinding.DialogInsertCoinsBottomBinding +import com.coldmint.rust.pro.tool.AppSettings + +/** + * 投币对话框 + * @property viewBinding [@androidx.annotation.NonNull] DialogInsertCoinsBottomBinding + * @constructor + */ +class InsertCoinsDialog(context: Context, val modId: String) : + BaseAppDialog(context) { + + private val token by lazy { + AppSettings.getValue(AppSettings.Setting.Token, "") + } + + private val viewBinding by lazy { + DialogInsertCoinsBottomBinding.inflate(LayoutInflater.from(context)) + } + + private var callBackLister: ((Boolean) -> Unit)? = null + + /** + * 设置回调 + * Boolean是否成功 + * @param listener Function1? + */ + fun setCallBackListener(listener: ((Boolean) -> Unit)?): InsertCoinsDialog { + callBackLister = listener + return this + } + + init { + setView(viewBinding.root) + viewBinding.positiveButton.setOnClickListener { + val number = viewBinding.slider.value.toInt() + WebMod.instance.insertCoins(token, modId, number, object : ApiCallBack { + override fun onResponse(t: ApiResponse) { + if (t.code == ServerConfiguration.Success_Code) { + dismiss() + callBackLister?.invoke(true) + } else { + viewBinding.textview.text = t.message + callBackLister?.invoke(false) + } + } + + override fun onFailure(e: Exception) { + e.printStackTrace() + dismiss() + callBackLister?.invoke(false) + } + + }) + } + viewBinding.negativeButton.setOnClickListener { + dismiss() + } + } + + +} \ No newline at end of file diff --git a/app/src/main/java/com/coldmint/rust/pro/fragments/InsertCoinsFragment.kt b/app/src/main/java/com/coldmint/rust/pro/fragments/InsertCoinsFragment.kt index 77444d9..49ed464 100644 --- a/app/src/main/java/com/coldmint/rust/pro/fragments/InsertCoinsFragment.kt +++ b/app/src/main/java/com/coldmint/rust/pro/fragments/InsertCoinsFragment.kt @@ -4,16 +4,65 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.core.view.isVisible import androidx.fragment.app.Fragment +import androidx.recyclerview.widget.DividerItemDecoration +import androidx.recyclerview.widget.LinearLayoutManager +import com.coldmint.dialog.CoreDialog +import com.coldmint.dialog.InputDialog +import com.coldmint.rust.core.dataBean.mod.CoinStatusData +import com.coldmint.rust.core.dataBean.mod.InsertCoinHistoryData +import com.coldmint.rust.core.interfaces.ApiCallBack +import com.coldmint.rust.core.web.WebMod +import com.coldmint.rust.pro.R +import com.coldmint.rust.pro.adapters.InsertCoinsAdapter import com.coldmint.rust.pro.base.BaseFragment import com.coldmint.rust.pro.databinding.FragmentInsertCoinsBinding +import com.coldmint.rust.pro.tool.AppSettings /** * 投币碎片 */ class InsertCoinsFragment(val modId: String) : BaseFragment() { - override fun whenViewCreated(inflater: LayoutInflater, savedInstanceState: Bundle?) { + private val token by lazy { + AppSettings.getValue(AppSettings.Setting.Token, "") + } + override fun whenViewCreated(inflater: LayoutInflater, savedInstanceState: Bundle?) { + viewBinding.recyclerView.layoutManager = LinearLayoutManager(requireContext()) + viewBinding.recyclerView.addItemDecoration( + DividerItemDecoration( + requireContext(), + DividerItemDecoration.VERTICAL + ) + ) + viewBinding.swipeRefreshLayout.setOnRefreshListener { + loadList(false) + viewBinding.swipeRefreshLayout.isRefreshing = false + } + viewBinding.button.setOnClickListener { + InsertCoinsDialog(requireContext(), modId).setCallBackListener { + if (it) { + viewBinding.button.isEnabled = false + viewBinding.tipView.text = getString(R.string.insert_coins_ok) + loadList() + } + }.show() +// InputDialog(requireContext()).setTitle(R.string.insert_coins) +// .setMessage(R.string.insert_coins_num_tip) +// .setPositiveButton(R.string.dialog_ok) { it -> +// WebMod.instance.insertCoins(token, modId) +// false +// }.setNegativeButton(R.string.dialog_cancel) { +// +// }.show() + } + loadButton() + } + + override fun onResume() { + super.onResume() + loadList() } override fun getViewBindingObject(layoutInflater: LayoutInflater): FragmentInsertCoinsBinding { @@ -21,4 +70,65 @@ class InsertCoinsFragment(val modId: String) : BaseFragment { + override fun onResponse(t: InsertCoinHistoryData) { + val dataList = t.data + if (dataList.isNullOrEmpty()) { + viewBinding.recyclerView.isVisible = false + if (useLinearProgressIndicator) { + viewBinding.linearProgressIndicator.isVisible = false + } + viewBinding.loadLayout.isVisible = true + viewBinding.coinRecordsView.text = getString(R.string.coin_records) + } else { + viewBinding.recyclerView.adapter = + InsertCoinsAdapter(requireContext(), dataList) + val data = getString(R.string.coin_records) + "(" + dataList.size + ")" + viewBinding.coinRecordsView.text = data + viewBinding.recyclerView.isVisible = true + if (useLinearProgressIndicator) { + viewBinding.linearProgressIndicator.isVisible = false + } + viewBinding.loadLayout.isVisible = false + } + } + + override fun onFailure(e: Exception) { + e.printStackTrace() + viewBinding.recyclerView.isVisible = false + viewBinding.coinRecordsView.text = getString(R.string.coin_records) + if (useLinearProgressIndicator) { + viewBinding.linearProgressIndicator.isVisible = false + } + viewBinding.loadLayout.isVisible = true + } + + }) + } + + fun loadButton() { + WebMod.instance.getCoinStatus(token, modId, object : ApiCallBack { + override fun onResponse(t: CoinStatusData) { + viewBinding.button.isEnabled = !t.data + if (t.data) { + viewBinding.tipView.text = getString(R.string.insert_coins_ok) + } else { + viewBinding.tipView.text = getString(R.string.insert_coins_no) + } + } + + override fun onFailure(e: Exception) { + e.printStackTrace() + viewBinding.button.isEnabled = false + viewBinding.tipView.text = getString(R.string.insert_coins_no) + } + + }) + } + + } \ No newline at end of file diff --git a/app/src/main/java/com/coldmint/rust/pro/fragments/ModCommentsFragment.kt b/app/src/main/java/com/coldmint/rust/pro/fragments/ModCommentsFragment.kt index 332260b..06871e0 100644 --- a/app/src/main/java/com/coldmint/rust/pro/fragments/ModCommentsFragment.kt +++ b/app/src/main/java/com/coldmint/rust/pro/fragments/ModCommentsFragment.kt @@ -1,5 +1,6 @@ package com.coldmint.rust.pro.fragments +import android.content.Intent import android.os.Bundle import androidx.fragment.app.Fragment import android.view.LayoutInflater @@ -17,6 +18,7 @@ import com.coldmint.rust.core.tool.DebugHelper import com.coldmint.rust.core.web.ServerConfiguration import com.coldmint.rust.core.web.WebMod import com.coldmint.rust.pro.R +import com.coldmint.rust.pro.UserHomePageActivity import com.coldmint.rust.pro.adapters.CommentAdapter import com.coldmint.rust.pro.base.BaseFragment import com.coldmint.rust.pro.databinding.FragmentModCommentsBinding @@ -80,6 +82,21 @@ class ModCommentsFragment(val modId: String) : BaseFragment + itemCommentBinding.iconView.setOnClickListener { + gotoUserPage(data.account) + } + } + viewBinding.recyclerView.adapter = adapter } } @@ -120,6 +146,7 @@ class ModCommentsFragment(val modId: String) : BaseFragment() { - var developer: String? = null +class WebModDetailsFragment(val modId: String,val modNameLiveData: MutableLiveData) : BaseFragment() { + private var developer: String? = null //此模组是否对外开放 private var isOpen = false + private var link: String? = null + + + fun getLink(): String? { + return link + } + + + + /** * 获取此模组是否对外开放 * @return Boolean @@ -115,7 +126,9 @@ class WebModDetailsFragment(val modId: String) : BaseFragment diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index ae21470..03309e3 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -10,12 +10,12 @@ + android:layout_height="wrap_content"> diff --git a/app/src/main/res/layout/activity_search.xml b/app/src/main/res/layout/activity_search.xml index f4c871c..741645b 100644 --- a/app/src/main/res/layout/activity_search.xml +++ b/app/src/main/res/layout/activity_search.xml @@ -53,13 +53,13 @@ android:queryBackground="@null" android:queryHint="@string/search" /> - - - - - - - + + + + + + + + + + + + +