diff --git a/.gradle/7.3.3/executionHistory/executionHistory.bin b/.gradle/7.3.3/executionHistory/executionHistory.bin index 917e169..571db6f 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 992011d..a3da5e6 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 e7a1e10..f3be0ca 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 1280dc9..de0cf88 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 429d338..41da9b0 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 03d2794..06eb3cc 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 a1b304e..0be0359 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 35f223d..dcd71bb 100644 Binary files a/.gradle/file-system.probe and b/.gradle/file-system.probe differ diff --git a/app/src/main/java/com/coldmint/rust/pro/ChangePasswordActivity.kt b/app/src/main/java/com/coldmint/rust/pro/ChangePasswordActivity.kt index 50549e8..4280843 100644 --- a/app/src/main/java/com/coldmint/rust/pro/ChangePasswordActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/ChangePasswordActivity.kt @@ -162,21 +162,23 @@ class ChangePasswordActivity : BaseActivity() { account, false ) && checkCode(code, false) && checkPassword( - passWord + passWord, false ) } private fun checkCode(code: String, updateView: Boolean = true): Boolean { return if (code.isBlank()) { - setErrorAndInput( - viewBinding.verificationCodeView, - String.format( - getString(R.string.please_input_value), - viewBinding.verificationCodeLayout.hint.toString() - ), - viewBinding.verificationCodeLayout - ) + if (updateView) { + setErrorAndInput( + viewBinding.verificationCodeView, + String.format( + getString(R.string.please_input_value), + viewBinding.verificationCodeLayout.hint.toString() + ), + viewBinding.verificationCodeLayout + ) + } false } else { if (updateView) { diff --git a/app/src/main/java/com/coldmint/rust/pro/LoginActivity.kt b/app/src/main/java/com/coldmint/rust/pro/LoginActivity.kt index d6615d1..f775ac1 100644 --- a/app/src/main/java/com/coldmint/rust/pro/LoginActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/LoginActivity.kt @@ -16,6 +16,7 @@ import android.text.style.ClickableSpan import android.util.Log import android.view.LayoutInflater import android.view.View +import androidx.core.view.isVisible import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.WhichButton import com.afollestad.materialdialogs.actions.setActionButtonEnabled @@ -46,7 +47,7 @@ class LoginActivity : BaseActivity() { .transparentNavigationBar().navigationBarDarkIcon(true) } Log.d("应用识别码", AppSettings.getValue(AppSettings.Setting.AppID, "无")) - + viewBinding.changeServerView.isVisible = BuildConfig.DEBUG viewBinding.changePasswordView.setOnClickListener { val intent = Intent(this, ChangePasswordActivity::class.java) startActivity(intent) @@ -216,14 +217,14 @@ class LoginActivity : BaseActivity() { ) } "请更改登录设备" -> { - viewBinding.button.isActivated = false + viewBinding.button.isEnabled = false verification( account, passWord, appId, object : ApiCallBack { override fun onResponse(t: ApiResponse) { - viewBinding.button.isActivated = true + viewBinding.button.isEnabled = true if (t.code == ServerConfiguration.Success_Code) { MaterialDialog(this@LoginActivity).show { title(R.string.verification).message( @@ -290,13 +291,8 @@ class LoginActivity : BaseActivity() { } override fun onFailure(e: Exception) { - viewBinding.button.isActivated = true + viewBinding.button.isEnabled = true isLogin = false - viewBinding.button.setBackgroundColor( - GlobalMethod.getColorPrimary( - this@LoginActivity - ) - ) viewBinding.button.setText(R.string.login) showInternetError(viewBinding.button, e) } @@ -316,7 +312,6 @@ class LoginActivity : BaseActivity() { override fun onFailure(e: Exception) { isLogin = false - viewBinding.button.setBackgroundColor(GlobalMethod.getColorPrimary(this@LoginActivity)) viewBinding.button.setText(R.string.login) showInternetError(viewBinding.button, e) } diff --git a/app/src/main/java/com/coldmint/rust/pro/MainActivity.kt b/app/src/main/java/com/coldmint/rust/pro/MainActivity.kt index e3b2e02..aa26d25 100644 --- a/app/src/main/java/com/coldmint/rust/pro/MainActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/MainActivity.kt @@ -34,6 +34,7 @@ import com.coldmint.rust.core.web.AppUpdate import com.coldmint.rust.core.web.ServerConfiguration import com.coldmint.rust.pro.databinding.ActivityMainBinding import com.coldmint.rust.pro.databinding.HeadLayoutBinding +import com.coldmint.rust.pro.fragments.UserGroupFragment import com.coldmint.rust.pro.viewmodel.StartViewModel import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.tabs.TabLayout @@ -266,6 +267,13 @@ class MainActivity : BaseActivity() { val codeTable = menu.findItem(R.id.code_table) val mod = menu.findItem(R.id.mod_item) val community = menu.findItem(R.id.community_item) + val group = menu.findItem(R.id.user_group) + group.setOnMenuItemClickListener { + viewBinding.drawerlayout.closeDrawer((GravityCompat.START)) + val userGroupFragment = UserGroupFragment() + userGroupFragment.show(supportFragmentManager, "userGroup") + false + } // val help = menu.findItem(R.id.help) //管理可见性 dataBase.isVisible = isActive diff --git a/app/src/main/java/com/coldmint/rust/pro/PackActivity.kt b/app/src/main/java/com/coldmint/rust/pro/PackActivity.kt index 52ba2b8..e8ba53f 100644 --- a/app/src/main/java/com/coldmint/rust/pro/PackActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/PackActivity.kt @@ -51,9 +51,8 @@ class PackActivity : BaseActivity() { private var needReturn: Boolean = false override fun whenCreateActivity(savedInstanceState: Bundle?, canUseView: Boolean) { - if (canUseView) - { - viewBinding.toolbar.title = getText(R.string.packmod) + if (canUseView) { + title = getText(R.string.packmod) setReturnButton() initData() initAction() @@ -146,12 +145,6 @@ class PackActivity : BaseActivity() { if (type == getString(R.string.packmod)) { sourceFileNum = 0 viewBinding.packCard.isVisible = true - viewBinding.packButton.setBackgroundColor( - GlobalMethod.getThemeColor( - this@PackActivity, - R.attr.colorPrimaryVariant - ) - ) viewBinding.packButton.setText(R.string.packing) viewBinding.packingTitle.setText(R.string.packmod) if (saveConfigurationData()) { @@ -171,8 +164,8 @@ class PackActivity : BaseActivity() { * @param result 是否解压成功 */ private fun resetButton(result: Boolean) { - viewBinding.packButton.setBackgroundColor(GlobalMethod.getColorPrimary(this@PackActivity)) if (result) { + viewBinding.packButton.setIconResource(R.drawable.ic_outline_share_24) viewBinding.packButton.setText(R.string.share_mod) if (needRecyclingFile && viewBinding.deleteSourceFile.isChecked) { val tip = String.format(getString(R.string.recovery_prompt), modName) diff --git a/app/src/main/java/com/coldmint/rust/pro/RustApplication.kt b/app/src/main/java/com/coldmint/rust/pro/RustApplication.kt index dbf6130..3f0b853 100644 --- a/app/src/main/java/com/coldmint/rust/pro/RustApplication.kt +++ b/app/src/main/java/com/coldmint/rust/pro/RustApplication.kt @@ -29,7 +29,6 @@ class RustApplication : Application() { DynamicColors.isDynamicColorAvailable() ) }.build() - CompletionItemConverter.init(this) DynamicColors.applyToActivitiesIfAvailable(this, options) //程序崩溃 CaocConfig.Builder.create() 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 dd2cca9..dd43909 100644 --- a/app/src/main/java/com/coldmint/rust/pro/WebModInfoActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/WebModInfoActivity.kt @@ -40,6 +40,7 @@ import com.coldmint.rust.core.web.ServerConfiguration import com.coldmint.rust.core.web.User import com.coldmint.rust.core.web.WebMod import com.coldmint.rust.pro.adapters.CommentAdapter +import com.coldmint.rust.pro.adapters.ModPageDetailsAdapter import com.coldmint.rust.pro.databinding.ActivityWebModInfoBinding import com.coldmint.rust.pro.tool.AppSettings import com.coldmint.rust.pro.base.BaseActivity @@ -47,7 +48,9 @@ import com.coldmint.rust.pro.databinding.LoadFileLayoutBinding import com.coldmint.rust.pro.dialog.CommentDialog import com.coldmint.rust.pro.tool.GlobalMethod import com.coldmint.rust.pro.tool.TextStyleMaker +import com.google.android.material.appbar.AppBarLayout import com.google.android.material.snackbar.Snackbar +import com.google.android.material.tabs.TabLayoutMediator import com.youth.banner.adapter.BannerImageAdapter import com.youth.banner.holder.BannerImageHolder import com.youth.banner.indicator.CircleIndicator @@ -73,10 +76,7 @@ class WebModInfoActivity : BaseActivity() { val token by lazy { AppSettings.getValue(AppSettings.Setting.Token, "") } - var developer: String? = null - - //此模组是否对外开放 - private var isOpen = false + lateinit var adapter :ModPageDetailsAdapter private fun initView() { setReturnButton() @@ -98,152 +98,179 @@ class WebModInfoActivity : BaseActivity() { viewBinding.button.isEnabled = false viewBinding.button.text = getString(R.string.installated) } - viewBinding.modCommentRecyclerView.layoutManager = - LinearLayoutManager(this@WebModInfoActivity) - viewBinding.modCommentRecyclerView.addItemDecoration( - DividerItemDecoration(this@WebModInfoActivity, DividerItemDecoration.VERTICAL) - ) - tip = getString(R.string.file_download_progress) - - } - } - - private fun initData() { - - if (token.isBlank()) { - viewBinding.progressBar.isVisible = false - viewBinding.tipView.isVisible = true - viewBinding.tipView.setText(R.string.please_login_first) - return - } - - loadModCommentList(modId) - - - WebMod.instance.getInfo(token, modId, object : ApiCallBack { - override fun onResponse(t: WebModInfoData) { - if (t.code == ServerConfiguration.Success_Code) { - developer = t.data.developer - isOpen = t.data.hidden == 0 - viewBinding.loadLayout.isVisible = false - viewBinding.relativeLayout.isVisible = true - val icon = t.data.icon - if (icon != null && icon.isNotBlank()) { - Glide.with(this@WebModInfoActivity) - .load(ServerConfiguration.getRealLink(icon)) - .apply(GlobalMethod.getRequestOptions()) - .into(viewBinding.iconView) + adapter = ModPageDetailsAdapter(this, modId) + viewBinding.viewPager2.adapter = adapter + TabLayoutMediator(viewBinding.tabLayout, viewBinding.viewPager2) { tab, i -> + tab.text = when (i) { + 0 -> { + getString(R.string.details) } - title = t.data.name - val screenshotListData = t.data.screenshots - if (screenshotListData != null && screenshotListData.isNotBlank()) { - val list = ArrayList() - val lineParser = LineParser() - lineParser.symbol = "," - lineParser.text = screenshotListData - lineParser.analyse { lineNum, lineData, isEnd -> - list.add(lineData) - true - } - val adapter = object : BannerImageAdapter(list) { - override fun onBindView( - holder: BannerImageHolder?, - data: String?, - position: Int, - size: Int - ) { - if (data != null && holder != null) { - Glide.with(this@WebModInfoActivity) - .load(ServerConfiguration.getRealLink(data)) - .apply(GlobalMethod.getRequestOptions()) - .into(holder.imageView) - } - } - } - viewBinding.banner.setAdapter(adapter) - viewBinding.banner.addBannerLifecycleObserver(this@WebModInfoActivity) - viewBinding.banner.indicator = CircleIndicator(this@WebModInfoActivity) - viewBinding.banner.setIndicatorSelectedColorRes(R.color.blue_500) - viewBinding.banner.isAutoLoop(false) - } else { - viewBinding.banner.isVisible = false + 1 -> { + getString(R.string.insert_coins) } - val tags = t.data.tags - val lineParser = LineParser(tags) - val tagList = ArrayList() - lineParser.symbol = "," - lineParser.analyse { lineNum, lineData, isEnd -> - val tag = lineData.subSequence(1, lineData.length - 1).toString() - tagList.add(tag) - true + 2 -> { + getString(R.string.discussion) } - if (tagList.size > 0) { - viewBinding.belongStackLabelView.labels = tagList - viewBinding.belongStackLabelView.setOnLabelClickListener { index, v, s -> - val bundle = Bundle() - bundle.putString("tag", s) - bundle.putString( - "title", - String.format(getString(R.string.tag_title), s) - ) - bundle.putString("action", "tag") - val thisIntent = - Intent(this@WebModInfoActivity, TagActivity::class.java) - thisIntent.putExtra("data", bundle) - startActivity(thisIntent) - } - } else { - viewBinding.belongStackLabelView.isVisible = false + else -> { + getString(R.string.title) } - viewBinding.titleView.text = t.data.name - TextStyleMaker.instance.load( - viewBinding.modInfoView, - t.data.describe - ) { type, data -> - TextStyleMaker.instance.clickEvent(this@WebModInfoActivity, type, data) - } - viewBinding.numView.text = - String.format( - getString(R.string.unit_and_downloadnum), - t.data.unitNumber, - t.data.downloadNumber, - t.data.versionName - ) - viewBinding.updateTimeView.text = - String.format(getString(R.string.recent_update), t.data.updateTime) - viewBinding.button.isVisible = true - if (t.data.hidden == 0) { - viewBinding.auditLayout.isVisible = false - } - loadDeveloperInfo(t.data.developer) - - viewBinding.button.setOnClickListener { - val type = viewBinding.button.text - val installation = getString(R.string.installation) - when (type) { - installation -> { - downloadAction(t) - } - } - - } - } else { - viewBinding.tipView.isVisible = true - viewBinding.tipView.text = t.message - viewBinding.progressBar.isVisible = false } - } - - override fun onFailure(e: Exception) { - viewBinding.progressBar.isVisible = false - viewBinding.tipView.isVisible = true - viewBinding.tipView.setText(R.string.network_error) - } - - }) - + }.attach() +// viewBinding.button.setOnClickListener { +// val type = viewBinding.button.text +// val installation = getString(R.string.installation) +// when (type) { +// installation -> { +// downloadAction(t) +// } +// } +// +// } +// viewBinding.modCommentRecyclerView.layoutManager = +// LinearLayoutManager(this@WebModInfoActivity) +// viewBinding.modCommentRecyclerView.addItemDecoration( +// DividerItemDecoration(this@WebModInfoActivity, DividerItemDecoration.VERTICAL) +// ) + tip = getString(R.string.file_download_progress) + } } +// private fun initData() { +// +// if (token.isBlank()) { +// viewBinding.progressBar.isVisible = false +// viewBinding.tipView.isVisible = true +// viewBinding.tipView.setText(R.string.please_login_first) +// return +// } +// +// loadModCommentList(modId) +// +// +// WebMod.instance.getInfo(token, modId, object : ApiCallBack { +// override fun onResponse(t: WebModInfoData) { +// if (t.code == ServerConfiguration.Success_Code) { +// developer = t.data.developer +// isOpen = t.data.hidden == 0 +// viewBinding.loadLayout.isVisible = false +// viewBinding.relativeLayout.isVisible = true +// val icon = t.data.icon +// if (icon != null && icon.isNotBlank()) { +// Glide.with(this@WebModInfoActivity) +// .load(ServerConfiguration.getRealLink(icon)) +// .apply(GlobalMethod.getRequestOptions()) +// .into(viewBinding.iconView) +// } +// title = t.data.name +// val screenshotListData = t.data.screenshots +// if (screenshotListData != null && screenshotListData.isNotBlank()) { +// val list = ArrayList() +// val lineParser = LineParser() +// lineParser.symbol = "," +// lineParser.text = screenshotListData +// lineParser.analyse { lineNum, lineData, isEnd -> +// list.add(lineData) +// true +// } +// val adapter = object : BannerImageAdapter(list) { +// override fun onBindView( +// holder: BannerImageHolder?, +// data: String?, +// position: Int, +// size: Int +// ) { +// if (data != null && holder != null) { +// Glide.with(this@WebModInfoActivity) +// .load(ServerConfiguration.getRealLink(data)) +// .apply(GlobalMethod.getRequestOptions()) +// .into(holder.imageView) +// } +// } +// } +// viewBinding.banner.setAdapter(adapter) +// viewBinding.banner.addBannerLifecycleObserver(this@WebModInfoActivity) +// viewBinding.banner.indicator = CircleIndicator(this@WebModInfoActivity) +// viewBinding.banner.setIndicatorSelectedColorRes(R.color.blue_500) +// viewBinding.banner.isAutoLoop(false) +// } else { +// viewBinding.banner.isVisible = false +// } +// val tags = t.data.tags +// val lineParser = LineParser(tags) +// val tagList = ArrayList() +// lineParser.symbol = "," +// lineParser.analyse { lineNum, lineData, isEnd -> +// val tag = lineData.subSequence(1, lineData.length - 1).toString() +// tagList.add(tag) +// true +// } +// if (tagList.size > 0) { +// viewBinding.belongStackLabelView.labels = tagList +// viewBinding.belongStackLabelView.setOnLabelClickListener { index, v, s -> +// val bundle = Bundle() +// bundle.putString("tag", s) +// bundle.putString( +// "title", +// String.format(getString(R.string.tag_title), s) +// ) +// bundle.putString("action", "tag") +// val thisIntent = +// Intent(this@WebModInfoActivity, TagActivity::class.java) +// thisIntent.putExtra("data", bundle) +// startActivity(thisIntent) +// } +// } else { +// viewBinding.belongStackLabelView.isVisible = false +// } +// viewBinding.titleView.text = t.data.name +// TextStyleMaker.instance.load( +// viewBinding.modInfoView, +// t.data.describe +// ) { type, data -> +// TextStyleMaker.instance.clickEvent(this@WebModInfoActivity, type, data) +// } +// viewBinding.numView.text = +// String.format( +// getString(R.string.unit_and_downloadnum), +// t.data.unitNumber, +// t.data.downloadNumber, +// t.data.versionName +// ) +// viewBinding.updateTimeView.text = +// String.format(getString(R.string.recent_update), t.data.updateTime) +// viewBinding.button.isVisible = true +// if (t.data.hidden == 0) { +// viewBinding.auditLayout.isVisible = false +// } +// loadDeveloperInfo(t.data.developer) +// +// viewBinding.button.setOnClickListener { +// val type = viewBinding.button.text +// val installation = getString(R.string.installation) +// when (type) { +// installation -> { +// downloadAction(t) +// } +// } +// +// } +// } else { +// viewBinding.tipView.isVisible = true +// viewBinding.tipView.text = t.message +// viewBinding.progressBar.isVisible = false +// } +// } +// +// override fun onFailure(e: Exception) { +// viewBinding.progressBar.isVisible = false +// viewBinding.tipView.isVisible = true +// viewBinding.tipView.setText(R.string.network_error) +// } +// +// }) +// +// } + /** * 下载事件 * @param t WebModInfoData @@ -291,12 +318,12 @@ class WebModInfoActivity : BaseActivity() { override fun onOptionsItemSelected(item: MenuItem): Boolean { when (item.itemId) { R.id.report_item -> { - if (isOpen) { + if (adapter.isOpen()) { val thisIntent = Intent(this, ReportActivity::class.java) val bundle = Bundle() bundle.putString("target", modId) bundle.putString("type", "mod") - bundle.putString("name", viewBinding.titleView.text.toString()) + bundle.putString("name", title.toString()) thisIntent.putExtra("data", bundle) startActivity(thisIntent) } else { @@ -315,10 +342,10 @@ class WebModInfoActivity : BaseActivity() { return super.onOptionsItemSelected(item) } - override fun onResume() { - super.onResume() - loadModCommentList(modId) - } +// override fun onResume() { +// super.onResume() +// loadModCommentList(modId) +// } /** @@ -378,79 +405,79 @@ class WebModInfoActivity : BaseActivity() { } } - /** - * 加载评论列表 - * @param modId String - */ - fun loadModCommentList(modId: String) { - viewBinding.commentLinearProgressIndicator.isVisible = true - WebMod.instance.getCommentsList(modId, object : ApiCallBack { - override fun onResponse(t: WebModCommentData) { - viewBinding.commentLinearProgressIndicator.isVisible = false - val data = t.data - if (data == null) { - viewBinding.modCommentRecyclerView.isVisible = false - } else { - val adapter = CommentAdapter(this@WebModInfoActivity, data) - viewBinding.discussion.text = - String.format(getString(R.string.discussion_num), data.size) - adapter.setItemEvent { i, itemCommentBinding, viewHolder, data -> - itemCommentBinding.iconView.setOnClickListener { - gotoUserPage(data.account) - } - } - viewBinding.modCommentRecyclerView.isVisible = true - viewBinding.modCommentRecyclerView.adapter = adapter - } - } - - override fun onFailure(e: Exception) { - viewBinding.commentLinearProgressIndicator.isVisible = false - viewBinding.modCommentRecyclerView.isVisible = false - } - - }) - } - - fun loadDeveloperInfo(userId: String) { - User.getSpaceInfo(userId, object : ApiCallBack { - override fun onResponse(t: SpaceInfoData) { - if (t.code == ServerConfiguration.Success_Code) { - val icon = t.data.headIcon - if (icon != null) { - Glide.with(this@WebModInfoActivity) - .load(ServerConfiguration.getRealLink(icon)) - .apply(GlobalMethod.getRequestOptions(true)) - .into(viewBinding.headIconView) - } - viewBinding.userNameView.text = t.data.userName - val info = String.format( - getString(R.string.fans_information), - ServerConfiguration.numberToString(t.data.fans), - ServerConfiguration.numberToString(t.data.follower), - ServerConfiguration.numberToString(t.data.praise) - ) - viewBinding.userInfoView.text = info - - viewBinding.cardView.postDelayed({ - viewBinding.cardView.isVisible = true - viewBinding.openUserSpace.setOnClickListener { - gotoUserPage(t.data.account) - } - }, 300) - } -// else { -// viewBinding.cardView.isVisible = false +// /** +// * 加载评论列表 +// * @param modId String +// */ +// fun loadModCommentList(modId: String) { +// viewBinding.commentLinearProgressIndicator.isVisible = true +// WebMod.instance.getCommentsList(modId, object : ApiCallBack { +// override fun onResponse(t: WebModCommentData) { +// viewBinding.commentLinearProgressIndicator.isVisible = false +// val data = t.data +// if (data == null) { +// viewBinding.modCommentRecyclerView.isVisible = false +// } else { +// val adapter = CommentAdapter(this@WebModInfoActivity, data) +// viewBinding.discussion.text = +// String.format(getString(R.string.discussion_num), data.size) +// adapter.setItemEvent { i, itemCommentBinding, viewHolder, data -> +// itemCommentBinding.iconView.setOnClickListener { +// gotoUserPage(data.account) +// } +// } +// viewBinding.modCommentRecyclerView.isVisible = true +// viewBinding.modCommentRecyclerView.adapter = adapter // } - - } - - override fun onFailure(e: Exception) { -// viewBinding.cardView.isVisible = false - } - - }) - } +// } +// +// override fun onFailure(e: Exception) { +// viewBinding.commentLinearProgressIndicator.isVisible = false +// viewBinding.modCommentRecyclerView.isVisible = false +// } +// +// }) +// } +// +// fun loadDeveloperInfo(userId: String) { +// User.getSpaceInfo(userId, object : ApiCallBack { +// override fun onResponse(t: SpaceInfoData) { +// if (t.code == ServerConfiguration.Success_Code) { +// val icon = t.data.headIcon +// if (icon != null) { +// Glide.with(this@WebModInfoActivity) +// .load(ServerConfiguration.getRealLink(icon)) +// .apply(GlobalMethod.getRequestOptions(true)) +// .into(viewBinding.headIconView) +// } +// viewBinding.userNameView.text = t.data.userName +// val info = String.format( +// getString(R.string.fans_information), +// ServerConfiguration.numberToString(t.data.fans), +// ServerConfiguration.numberToString(t.data.follower), +// ServerConfiguration.numberToString(t.data.praise) +// ) +// viewBinding.userInfoView.text = info +// +// viewBinding.cardView.postDelayed({ +// viewBinding.cardView.isVisible = true +// viewBinding.openUserSpace.setOnClickListener { +// gotoUserPage(t.data.account) +// } +// }, 300) +// } +//// else { +//// viewBinding.cardView.isVisible = false +//// } +// +// } +// +// override fun onFailure(e: Exception) { +//// viewBinding.cardView.isVisible = false +// } +// +// }) +// } /** @@ -468,46 +495,46 @@ class WebModInfoActivity : BaseActivity() { ) } - private fun initAction() { - viewBinding.sendDiscussion.setOnClickListener { - val account = AppSettings.getValue(AppSettings.Setting.Account, "") - if (account.isBlank()) { - showError(getString(R.string.please_login_first)) - return@setOnClickListener - } - - - CommentDialog(this).setCancelable(false) - .setSubmitFun { button, textInputLayout, s, alertDialog -> - button.isEnabled = false - WebMod.instance.sendComment( - AppSettings.getValue(AppSettings.Setting.Token, ""), - modId, - s, - object : ApiCallBack { - override fun onResponse(t: ApiResponse) { - if (t.code == ServerConfiguration.Success_Code) { - alertDialog.dismiss() - loadModCommentList(modId) - Snackbar.make( - viewBinding.button, - R.string.release_ok, - Snackbar.LENGTH_SHORT - ).show() - } else { - textInputLayout.error = t.message - } - } - - override fun onFailure(e: Exception) { - textInputLayout.error = e.toString() - } - - }) - }.show() - } - - } +// private fun initAction() { +// viewBinding.sendDiscussion.setOnClickListener { +// val account = AppSettings.getValue(AppSettings.Setting.Account, "") +// if (account.isBlank()) { +// showError(getString(R.string.please_login_first)) +// return@setOnClickListener +// } +// +// +// CommentDialog(this).setCancelable(false) +// .setSubmitFun { button, textInputLayout, s, alertDialog -> +// button.isEnabled = false +// WebMod.instance.sendComment( +// AppSettings.getValue(AppSettings.Setting.Token, ""), +// modId, +// s, +// object : ApiCallBack { +// override fun onResponse(t: ApiResponse) { +// if (t.code == ServerConfiguration.Success_Code) { +// alertDialog.dismiss() +// loadModCommentList(modId) +// Snackbar.make( +// viewBinding.button, +// R.string.release_ok, +// Snackbar.LENGTH_SHORT +// ).show() +// } else { +// textInputLayout.error = t.message +// } +// } +// +// override fun onFailure(e: Exception) { +// textInputLayout.error = e.toString() +// } +// +// }) +// }.show() +// } +// +// } override fun getViewBindingObject(layoutInflater: LayoutInflater): ActivityWebModInfoBinding { return ActivityWebModInfoBinding.inflate(layoutInflater) @@ -516,8 +543,8 @@ class WebModInfoActivity : BaseActivity() { override fun whenCreateActivity(savedInstanceState: Bundle?, canUseView: Boolean) { if (canUseView) { initView() - initData() - initAction() +// initData() +// initAction() } } } \ No newline at end of file diff --git a/app/src/main/java/com/coldmint/rust/pro/adapters/CommentAdapter.kt b/app/src/main/java/com/coldmint/rust/pro/adapters/CommentAdapter.kt index ea415a1..5da613f 100644 --- a/app/src/main/java/com/coldmint/rust/pro/adapters/CommentAdapter.kt +++ b/app/src/main/java/com/coldmint/rust/pro/adapters/CommentAdapter.kt @@ -42,7 +42,11 @@ class CommentAdapter(context: Context, dataList: MutableList TextStyleMaker.instance.clickEvent(context, type, data) } diff --git a/app/src/main/java/com/coldmint/rust/pro/adapters/DynamicAdapter.kt b/app/src/main/java/com/coldmint/rust/pro/adapters/DynamicAdapter.kt index 6f629bb..b94068f 100644 --- a/app/src/main/java/com/coldmint/rust/pro/adapters/DynamicAdapter.kt +++ b/app/src/main/java/com/coldmint/rust/pro/adapters/DynamicAdapter.kt @@ -29,7 +29,7 @@ import org.w3c.dom.Text * @author Cold Mint * @date 2021/12/28 18:29 */ -class DynamicAdapter( context: Context, dataList: MutableList) : +class DynamicAdapter(context: Context, dataList: MutableList) : BaseAdapter(context, dataList) { @@ -53,7 +53,11 @@ class DynamicAdapter( context: Context, dataList: MutableList TextStyleMaker.instance.clickEvent(context, type, data) @@ -69,8 +73,7 @@ class DynamicAdapter( context: Context, dataList: MutableList { - val account = AppSettings. - getValue(AppSettings.Setting.Account, "") + val account = AppSettings.getValue(AppSettings.Setting.Account, "") val appId = AppSettings .getValue(AppSettings.Setting.AppID, "") 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 new file mode 100644 index 0000000..1b3d761 --- /dev/null +++ b/app/src/main/java/com/coldmint/rust/pro/adapters/ModPageDetailsAdapter.kt @@ -0,0 +1,59 @@ +package com.coldmint.rust.pro.adapters + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentActivity +import androidx.viewpager2.adapter.FragmentStateAdapter +import com.coldmint.rust.core.tool.DebugHelper +import com.coldmint.rust.pro.fragments.InsertCoinsFragment +import com.coldmint.rust.pro.fragments.ModCommentsFragment +import com.coldmint.rust.pro.fragments.NullFragment +import com.coldmint.rust.pro.fragments.WebModDetailsFragment + +/** + * 模组详情页面适配器 + * @constructor + */ +class ModPageDetailsAdapter(fragmentActivity: FragmentActivity, val modId: String) : + FragmentStateAdapter(fragmentActivity) { + private lateinit var webModDetailsFragment: WebModDetailsFragment + private lateinit var modCommentsFragment: ModCommentsFragment + override fun getItemCount(): Int { + return 3 + } + + /** + * 获取此模组是否对外开放 + * @return Boolean + */ + fun isOpen(): Boolean { + return if (this::webModDetailsFragment.isInitialized) { + webModDetailsFragment.isOpen() + } else { + DebugHelper.printLog("获取模组公开状态", "详情碎片未初始化,返回false", isError = true) + false + } + } + + override fun createFragment(position: Int): Fragment { + return when (position) { + 0 -> { + if (!this::webModDetailsFragment.isInitialized) { + webModDetailsFragment = WebModDetailsFragment(modId) + } + webModDetailsFragment + } + 1 -> { + InsertCoinsFragment(modId) + } + 2 -> { + if (!this::modCommentsFragment.isInitialized) { + modCommentsFragment = ModCommentsFragment(modId) + } + modCommentsFragment + } + else -> { + NullFragment() + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/coldmint/rust/pro/adapters/UserGroupAdapter.kt b/app/src/main/java/com/coldmint/rust/pro/adapters/UserGroupAdapter.kt new file mode 100644 index 0000000..c4c6391 --- /dev/null +++ b/app/src/main/java/com/coldmint/rust/pro/adapters/UserGroupAdapter.kt @@ -0,0 +1,35 @@ +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.pro.base.BaseAdapter +import com.coldmint.rust.pro.databean.UserGroupData +import com.coldmint.rust.pro.databinding.ItemTemplateBinding +import com.coldmint.rust.pro.databinding.ItemUserBinding +import com.coldmint.rust.pro.databinding.ItemUserGroupBinding + +/** + * 用户群适配器 + */ +class UserGroupAdapter(context: Context, dataList: MutableList) : + BaseAdapter(context, dataList) { + override fun getViewBindingObject( + layoutInflater: LayoutInflater, + parent: ViewGroup, + viewType: Int + ): ItemUserGroupBinding { + return ItemUserGroupBinding.inflate(layoutInflater, parent, false) + } + + override fun onBingView( + data: UserGroupData, + viewBinding: ItemUserGroupBinding, + viewHolder: ViewHolder, + position: Int + ) { + viewBinding.imageView.setImageResource(data.iconRes) + viewBinding.titleView.setText(data.titleRes) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/coldmint/rust/pro/databean/UserGroupData.kt b/app/src/main/java/com/coldmint/rust/pro/databean/UserGroupData.kt new file mode 100644 index 0000000..ba4e1d0 --- /dev/null +++ b/app/src/main/java/com/coldmint/rust/pro/databean/UserGroupData.kt @@ -0,0 +1,3 @@ +package com.coldmint.rust.pro.databean + +data class UserGroupData(val iconRes: Int, val titleRes: Int) diff --git a/app/src/main/java/com/coldmint/rust/pro/fragments/CommunityFragment.kt b/app/src/main/java/com/coldmint/rust/pro/fragments/CommunityFragment.kt index 54cd35d..b473c61 100644 --- a/app/src/main/java/com/coldmint/rust/pro/fragments/CommunityFragment.kt +++ b/app/src/main/java/com/coldmint/rust/pro/fragments/CommunityFragment.kt @@ -15,7 +15,7 @@ import com.coldmint.rust.pro.databinding.* import com.google.android.material.tabs.TabLayout import com.google.android.material.tabs.TabLayoutMediator -class CommunityFragment : BaseFragment() { +class CommunityFragment : BaseFragment() { // 当请求时,此适配器返回一个 // representing an object in the collection. private val communityAdapter: CommunityAdapter by lazy { @@ -51,8 +51,8 @@ class CommunityFragment : BaseFragment() { } - override fun getViewBindingObject(layoutInflater: LayoutInflater): CommunityFragmentBinding { - return CommunityFragmentBinding.inflate(layoutInflater) + override fun getViewBindingObject(layoutInflater: LayoutInflater): FragmentCommunityBinding { + return FragmentCommunityBinding.inflate(layoutInflater) } override fun whenViewCreated(inflater: LayoutInflater, savedInstanceState: Bundle?) { diff --git a/app/src/main/java/com/coldmint/rust/pro/fragments/DatabaseFragment.kt b/app/src/main/java/com/coldmint/rust/pro/fragments/DatabaseFragment.kt index ba253b9..a8997d6 100644 --- a/app/src/main/java/com/coldmint/rust/pro/fragments/DatabaseFragment.kt +++ b/app/src/main/java/com/coldmint/rust/pro/fragments/DatabaseFragment.kt @@ -24,14 +24,14 @@ import com.coldmint.rust.pro.R import com.coldmint.rust.pro.tool.AppSettings import com.coldmint.rust.pro.adapters.DataSetAdapter import com.coldmint.rust.pro.base.BaseFragment -import com.coldmint.rust.pro.databinding.DatabaseFragmentBinding +import com.coldmint.rust.pro.databinding.FragmentDatabaseBinding import com.coldmint.rust.pro.databinding.DialogDatasetBinding import com.google.gson.Gson import java.io.File import java.util.concurrent.Executors import kotlin.collections.ArrayList -class DatabaseFragment : BaseFragment() { +class DatabaseFragment : BaseFragment() { override fun whenViewCreated(inflater: LayoutInflater, savedInstanceState: Bundle?) { @@ -165,7 +165,7 @@ class DatabaseFragment : BaseFragment() { } - override fun getViewBindingObject(layoutInflater: LayoutInflater): DatabaseFragmentBinding { - return DatabaseFragmentBinding.inflate(layoutInflater) + override fun getViewBindingObject(layoutInflater: LayoutInflater): FragmentDatabaseBinding { + return FragmentDatabaseBinding.inflate(layoutInflater) } } \ 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 new file mode 100644 index 0000000..77444d9 --- /dev/null +++ b/app/src/main/java/com/coldmint/rust/pro/fragments/InsertCoinsFragment.kt @@ -0,0 +1,24 @@ +package com.coldmint.rust.pro.fragments + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.coldmint.rust.pro.base.BaseFragment +import com.coldmint.rust.pro.databinding.FragmentInsertCoinsBinding + +/** + * 投币碎片 + */ +class InsertCoinsFragment(val modId: String) : BaseFragment() { + override fun whenViewCreated(inflater: LayoutInflater, savedInstanceState: Bundle?) { + + } + + override fun getViewBindingObject(layoutInflater: LayoutInflater): FragmentInsertCoinsBinding { + return FragmentInsertCoinsBinding.inflate(layoutInflater) + } + + +} \ No newline at end of file diff --git a/app/src/main/java/com/coldmint/rust/pro/fragments/LocalTemplateFragment.kt b/app/src/main/java/com/coldmint/rust/pro/fragments/LocalTemplateFragment.kt index 3edcb19..9f1d6ad 100644 --- a/app/src/main/java/com/coldmint/rust/pro/fragments/LocalTemplateFragment.kt +++ b/app/src/main/java/com/coldmint/rust/pro/fragments/LocalTemplateFragment.kt @@ -11,7 +11,7 @@ import com.coldmint.rust.pro.tool.AppSettings import com.coldmint.rust.core.LocalTemplatePackage import com.coldmint.rust.pro.adapters.TemplateListAdapter import com.coldmint.rust.pro.base.BaseFragment -import com.coldmint.rust.pro.databinding.TemplateFragemntBinding +import com.coldmint.rust.pro.databinding.FragmentLocalTemplateBinding import java.io.File import java.util.* import kotlin.collections.ArrayList @@ -20,7 +20,7 @@ import kotlin.collections.ArrayList * 本地模板碎片 * @property first Boolean */ -class LocalTemplateFragment : BaseFragment() { +class LocalTemplateFragment : BaseFragment() { private var first = true override fun onResume() { @@ -65,8 +65,8 @@ class LocalTemplateFragment : BaseFragment() { } } - override fun getViewBindingObject(layoutInflater: LayoutInflater): TemplateFragemntBinding { - return TemplateFragemntBinding.inflate(layoutInflater) + override fun getViewBindingObject(layoutInflater: LayoutInflater): FragmentLocalTemplateBinding { + return FragmentLocalTemplateBinding.inflate(layoutInflater) } override fun whenViewCreated(inflater: LayoutInflater, savedInstanceState: Bundle?) { 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 new file mode 100644 index 0000000..332260b --- /dev/null +++ b/app/src/main/java/com/coldmint/rust/pro/fragments/ModCommentsFragment.kt @@ -0,0 +1,135 @@ +package com.coldmint.rust.pro.fragments + +import android.os.Bundle +import androidx.fragment.app.Fragment +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.Toast +import androidx.core.view.isVisible +import androidx.recyclerview.widget.DividerItemDecoration +import androidx.recyclerview.widget.LinearLayoutManager +import com.coldmint.rust.core.ModClass +import com.coldmint.rust.core.dataBean.ApiResponse +import com.coldmint.rust.core.dataBean.mod.WebModCommentData +import com.coldmint.rust.core.interfaces.ApiCallBack +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.adapters.CommentAdapter +import com.coldmint.rust.pro.base.BaseFragment +import com.coldmint.rust.pro.databinding.FragmentModCommentsBinding +import com.coldmint.rust.pro.dialog.CommentDialog +import com.coldmint.rust.pro.tool.AppSettings +import com.google.android.material.snackbar.Snackbar + +/** + * 模组评论适配器 + */ +class ModCommentsFragment(val modId: String) : BaseFragment() { + override fun whenViewCreated(inflater: LayoutInflater, savedInstanceState: Bundle?) { + viewBinding.recyclerView.layoutManager = LinearLayoutManager(requireContext()) + viewBinding.recyclerView.addItemDecoration( + DividerItemDecoration( + requireContext(), + DividerItemDecoration.VERTICAL + ) + ) + viewBinding.swipeRefreshLayout.setOnRefreshListener { + loadCommentList(modId, false) + viewBinding.swipeRefreshLayout.isRefreshing = false + } + viewBinding.sendDiscussion.setOnClickListener { + val account = AppSettings.getValue(AppSettings.Setting.Account, "") + if (account.isBlank()) { + Toast.makeText(requireContext(), R.string.please_login_first, Toast.LENGTH_SHORT) + .show() + return@setOnClickListener + } + + + CommentDialog(requireContext()).setCancelable(false) + .setSubmitFun { button, textInputLayout, s, alertDialog -> + button.isEnabled = false + WebMod.instance.sendComment( + AppSettings.getValue(AppSettings.Setting.Token, ""), + modId, + s, + object : ApiCallBack { + override fun onResponse(t: ApiResponse) { + if (t.code == ServerConfiguration.Success_Code) { + alertDialog.dismiss() + loadCommentList(modId) + Snackbar.make( + viewBinding.sendDiscussion, + R.string.release_ok, + Snackbar.LENGTH_SHORT + ).show() + } else { + textInputLayout.error = t.message + } + } + + override fun onFailure(e: Exception) { + textInputLayout.error = e.toString() + } + + }) + }.show() + } + } + + override fun onResume() { + super.onResume() + loadCommentList(modId) + } + + /** + * 加载评论列表 + * @param modId String + */ + fun loadCommentList(modId: String, useLinearProgressIndicator: Boolean = true) { + val key = "加载评论列表" + if (useLinearProgressIndicator) { + viewBinding.linearProgressIndicator.isVisible = true + } + WebMod.instance.getCommentsList(modId, object : ApiCallBack { + override fun onResponse(t: WebModCommentData) { + val list = t.data + if (list.isNullOrEmpty()) { + DebugHelper.printLog(key, "为空", isError = true) + if (useLinearProgressIndicator) { + viewBinding.linearProgressIndicator.isVisible = false + } + viewBinding.recyclerView.isVisible = false + viewBinding.noContentLayout.isVisible = true + } else { + DebugHelper.printLog(key, "共${list.size}条数据") + if (useLinearProgressIndicator) { + viewBinding.linearProgressIndicator.isVisible = false + } + viewBinding.recyclerView.isVisible = true + viewBinding.noContentLayout.isVisible = false + viewBinding.recyclerView.adapter = CommentAdapter(requireContext(), list) + } + } + + override fun onFailure(e: Exception) { + DebugHelper.printLog(key, "加载失败", isError = true) + if (useLinearProgressIndicator) { + viewBinding.linearProgressIndicator.isVisible = false + } + viewBinding.recyclerView.isVisible = false + viewBinding.noContentLayout.isVisible = true + } + + }) + } + + override fun getViewBindingObject(layoutInflater: LayoutInflater): FragmentModCommentsBinding { + return FragmentModCommentsBinding.inflate(layoutInflater) + } + + +} \ No newline at end of file diff --git a/app/src/main/java/com/coldmint/rust/pro/fragments/ModFragment.kt b/app/src/main/java/com/coldmint/rust/pro/fragments/ModFragment.kt index 837191f..26a3eaa 100644 --- a/app/src/main/java/com/coldmint/rust/pro/fragments/ModFragment.kt +++ b/app/src/main/java/com/coldmint/rust/pro/fragments/ModFragment.kt @@ -2,23 +2,21 @@ package com.coldmint.rust.pro.fragments import android.annotation.SuppressLint import android.content.res.ColorStateList -import android.os.Build -import android.os.Bundle -import android.os.Handler -import android.os.Looper +import android.os.* import android.view.LayoutInflater import androidx.core.view.isVisible import androidx.recyclerview.widget.DividerItemDecoration import androidx.recyclerview.widget.LinearLayoutManager import com.coldmint.rust.core.ModClass import com.coldmint.rust.core.dataBean.ModConfigurationData +import com.coldmint.rust.core.tool.DebugHelper import com.coldmint.rust.core.tool.FileOperator import com.coldmint.rust.pro.R import com.coldmint.rust.pro.adapters.ModActionAdapter import com.coldmint.rust.pro.adapters.ModAdapter import com.coldmint.rust.pro.base.BaseFragment import com.coldmint.rust.pro.databinding.ModDialogBinding -import com.coldmint.rust.pro.databinding.ModFragmentBinding +import com.coldmint.rust.pro.databinding.FragmentModBinding import com.coldmint.rust.pro.databinding.ModListItemBinding import com.coldmint.rust.pro.tool.AppSettings import com.coldmint.rust.pro.tool.GlobalMethod @@ -27,11 +25,12 @@ import com.google.android.material.bottomsheet.BottomSheetDialog import com.google.android.material.snackbar.Snackbar import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Job +import kotlinx.coroutines.isActive import kotlinx.coroutines.launch import me.zhanghai.android.fastscroll.FastScrollerBuilder import java.io.File -class ModFragment : BaseFragment() { +class ModFragment : BaseFragment() { val viewModel: ModViewModel by lazy { ModViewModel() } @@ -193,27 +192,31 @@ class ModFragment : BaseFragment() { viewBinding.progressBar.isVisible = false viewBinding.modErrorIcon.isVisible = false viewBinding.modError.isVisible = false - modAdapter = ModAdapter(requireContext(), dataList) - FastScrollerBuilder(viewBinding.modList).useMd2Style() - .setPopupTextProvider(modAdapter).build() - modAdapter.setItemEvent { i, modListItemBinding, viewHolder, modClass -> + if (isAdded) { + modAdapter = ModAdapter(requireContext(), dataList) + FastScrollerBuilder(viewBinding.modList).useMd2Style() + .setPopupTextProvider(modAdapter).build() + modAdapter.setItemEvent { i, modListItemBinding, viewHolder, modClass -> - modListItemBinding.root.setOnClickListener { - onClickItemWork(modListItemBinding, modClass) - } + modListItemBinding.root.setOnClickListener { + onClickItemWork(modListItemBinding, modClass) + } - modListItemBinding.root.setOnLongClickListener { - modAdapter.showDeleteItemDialog( - modClass.modName, - viewHolder.adapterPosition, - onClickPositiveButton = { d, b -> - delFile(handler, modClass, viewHolder.adapterPosition) - false - }) - false + modListItemBinding.root.setOnLongClickListener { + modAdapter.showDeleteItemDialog( + modClass.modName, + viewHolder.adapterPosition, + onClickPositiveButton = { d, b -> + delFile(handler, modClass, viewHolder.adapterPosition) + false + }) + false + } } + viewBinding.modList.adapter = modAdapter + } else { + DebugHelper.printLog("加载模组列表", "没有附加到活动", isError = true) } - viewBinding.modList.adapter = modAdapter } } } @@ -328,8 +331,8 @@ class ModFragment : BaseFragment() { // viewBinding.progressBar.isVisible = false // } - override fun getViewBindingObject(layoutInflater: LayoutInflater): ModFragmentBinding { - return ModFragmentBinding.inflate(layoutInflater) + override fun getViewBindingObject(layoutInflater: LayoutInflater): FragmentModBinding { + return FragmentModBinding.inflate(layoutInflater) } override fun whenViewCreated(inflater: LayoutInflater, savedInstanceState: Bundle?) { diff --git a/app/src/main/java/com/coldmint/rust/pro/fragments/RecommendedFragment.kt b/app/src/main/java/com/coldmint/rust/pro/fragments/RecommendedFragment.kt index cff248e..0aef577 100644 --- a/app/src/main/java/com/coldmint/rust/pro/fragments/RecommendedFragment.kt +++ b/app/src/main/java/com/coldmint/rust/pro/fragments/RecommendedFragment.kt @@ -20,7 +20,7 @@ import com.coldmint.rust.pro.R import com.coldmint.rust.pro.WebModInfoActivity import com.coldmint.rust.pro.adapters.WebModAdapter import com.coldmint.rust.pro.base.BaseFragment -import com.coldmint.rust.pro.databinding.RecommendedFragmentBinding +import com.coldmint.rust.pro.databinding.FragmentRecommendedBinding import com.coldmint.rust.pro.tool.AppSettings import com.coldmint.rust.pro.tool.GlobalMethod import com.coldmint.rust.pro.tool.TextStyleMaker @@ -29,8 +29,9 @@ import com.youth.banner.adapter.BannerImageAdapter import com.youth.banner.holder.BannerImageHolder import com.youth.banner.indicator.CircleIndicator import com.youth.banner.transformer.AlphaPageTransformer +import com.youth.banner.transformer.DepthPageTransformer -class RecommendedFragment : BaseFragment() { +class RecommendedFragment : BaseFragment() { /** * 加载最近更新 @@ -177,8 +178,8 @@ class RecommendedFragment : BaseFragment() { } } }) - viewBinding.banner.setBannerGalleryEffect(16, 16, 8) - viewBinding.banner.addPageTransformer(AlphaPageTransformer()) +// viewBinding.banner.setBannerGalleryEffect(16, 16, 8) +// viewBinding.banner.addPageTransformer(DepthPageTransformer()) if (activity != null) { viewBinding.banner.addBannerLifecycleObserver(activity) viewBinding.banner.indicator = CircleIndicator(activity) @@ -221,8 +222,8 @@ class RecommendedFragment : BaseFragment() { loadBannerData() } - override fun getViewBindingObject(layoutInflater: LayoutInflater): RecommendedFragmentBinding { - return RecommendedFragmentBinding.inflate(layoutInflater) + override fun getViewBindingObject(layoutInflater: LayoutInflater): FragmentRecommendedBinding { + return FragmentRecommendedBinding.inflate(layoutInflater) } override fun whenViewCreated(inflater: LayoutInflater, savedInstanceState: Bundle?) { diff --git a/app/src/main/java/com/coldmint/rust/pro/fragments/UserGroupFragment.kt b/app/src/main/java/com/coldmint/rust/pro/fragments/UserGroupFragment.kt new file mode 100644 index 0000000..c92a56e --- /dev/null +++ b/app/src/main/java/com/coldmint/rust/pro/fragments/UserGroupFragment.kt @@ -0,0 +1,56 @@ +package com.coldmint.rust.pro.fragments + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.recyclerview.widget.LinearLayoutManager +import com.coldmint.rust.core.tool.AppOperator +import com.coldmint.rust.pro.R +import com.coldmint.rust.pro.adapters.UserGroupAdapter +import com.coldmint.rust.pro.databean.UserGroupData +import com.coldmint.rust.pro.databinding.FragmentUserGroupBinding +import com.google.android.material.bottomsheet.BottomSheetDialogFragment + +/** + * 用户群碎片 + * @property viewBinding FragmentUserGroupBinding + */ +class UserGroupFragment : BottomSheetDialogFragment() { + + private lateinit var viewBinding: FragmentUserGroupBinding + + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { + viewBinding = FragmentUserGroupBinding.inflate(inflater, container, false) + return viewBinding.root + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + viewBinding.recyclerView.layoutManager = LinearLayoutManager(requireContext()) + val dataList = ArrayList() + dataList.add(UserGroupData(R.drawable.ic_qq, R.string.qq_group)) + dataList.add(UserGroupData(R.drawable.ic_discord, R.string.discord_group)) + val adapter = UserGroupAdapter(requireContext(), dataList) + viewBinding.recyclerView.adapter = adapter + adapter.setItemEvent { i, itemUserGroupBinding, viewHolder, userGroupData -> + itemUserGroupBinding.root.setOnClickListener { + if (userGroupData.titleRes == R.string.qq_group) { + AppOperator.useBrowserAccessWebPage( + requireContext(), + "https://qun.qq.com/qqweb/qunpro/share?_wv=3&_wwv=128&appChannel=share&inviteCode=1W7Dpb0&businessType=9&from=246610&biz=ka" + ) + } else if (userGroupData.titleRes == R.string.discord_group) { + AppOperator.useBrowserAccessWebPage( + requireContext(), + "https://discord.gg/DTQDmVdVK3" + ) + } + } + } + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/coldmint/rust/pro/fragments/UserInfoFragment.kt b/app/src/main/java/com/coldmint/rust/pro/fragments/UserInfoFragment.kt index 038145e..908b17e 100644 --- a/app/src/main/java/com/coldmint/rust/pro/fragments/UserInfoFragment.kt +++ b/app/src/main/java/com/coldmint/rust/pro/fragments/UserInfoFragment.kt @@ -124,7 +124,12 @@ class UserInfoFragment : BaseFragment() { .apply(GlobalMethod.getRequestOptions(true)) .into(viewBinding.headIconView) } - viewBinding.emailView.text = t.data.email + viewBinding.coinView.text = String.format( + getString( + R.string.coin_number, + t.data.coinNumber + ) + ) loadRecyclerView(t.data.permission) } else { // Toast.makeText(requireContext(), t.toString(), Toast.LENGTH_SHORT).show() diff --git a/app/src/main/java/com/coldmint/rust/pro/fragments/WarehouseFragment.kt b/app/src/main/java/com/coldmint/rust/pro/fragments/WarehouseFragment.kt index 6378980..2f9cd6c 100644 --- a/app/src/main/java/com/coldmint/rust/pro/fragments/WarehouseFragment.kt +++ b/app/src/main/java/com/coldmint/rust/pro/fragments/WarehouseFragment.kt @@ -11,7 +11,6 @@ import com.coldmint.rust.pro.R import com.coldmint.rust.pro.adapters.WarehouseAdapter import com.coldmint.rust.pro.base.BaseAdapter import com.coldmint.rust.pro.base.BaseFragment -import com.coldmint.rust.pro.databinding.CommunityFragmentBinding import com.coldmint.rust.pro.databinding.FragmentWarehouseBinding import com.google.android.material.tabs.TabLayoutMediator diff --git a/app/src/main/java/com/coldmint/rust/pro/fragments/WebModDetailsFragment.kt b/app/src/main/java/com/coldmint/rust/pro/fragments/WebModDetailsFragment.kt new file mode 100644 index 0000000..5a80ae7 --- /dev/null +++ b/app/src/main/java/com/coldmint/rust/pro/fragments/WebModDetailsFragment.kt @@ -0,0 +1,232 @@ +package com.coldmint.rust.pro.fragments + +import android.content.Intent +import android.os.Bundle +import android.view.LayoutInflater +import androidx.core.view.isVisible +import com.bumptech.glide.Glide +import com.coldmint.rust.core.dataBean.mod.WebModInfoData +import com.coldmint.rust.core.dataBean.user.SpaceInfoData +import com.coldmint.rust.core.interfaces.ApiCallBack +import com.coldmint.rust.core.tool.LineParser +import com.coldmint.rust.core.web.ServerConfiguration +import com.coldmint.rust.core.web.User +import com.coldmint.rust.core.web.WebMod +import com.coldmint.rust.pro.R +import com.coldmint.rust.pro.TagActivity +import com.coldmint.rust.pro.UserHomePageActivity +import com.coldmint.rust.pro.base.BaseFragment +import com.coldmint.rust.pro.databinding.FragmentWebModDetailsBinding +import com.coldmint.rust.pro.tool.AppSettings +import com.coldmint.rust.pro.tool.GlobalMethod +import com.coldmint.rust.pro.tool.TextStyleMaker +import com.google.android.material.chip.Chip +import com.youth.banner.adapter.BannerImageAdapter +import com.youth.banner.holder.BannerImageHolder +import com.youth.banner.indicator.CircleIndicator + +/** + * 模组详情碎片 + */ +class WebModDetailsFragment(val modId: String) : BaseFragment() { + var developer: String? = null + + //此模组是否对外开放 + private var isOpen = false + + /** + * 获取此模组是否对外开放 + * @return Boolean + */ + fun isOpen(): Boolean { + return isOpen + } + + override fun whenViewCreated(inflater: LayoutInflater, savedInstanceState: Bundle?) { + loadInfo() + } + + override fun getViewBindingObject(layoutInflater: LayoutInflater): FragmentWebModDetailsBinding { + return FragmentWebModDetailsBinding.inflate(layoutInflater) + } + + + fun loadDeveloperInfo(userId: String) { + User.getSpaceInfo(userId, object : ApiCallBack { + override fun onResponse(t: SpaceInfoData) { + if (t.code == ServerConfiguration.Success_Code) { + val icon = t.data.headIcon + if (icon != null) { + Glide.with(requireContext()) + .load(ServerConfiguration.getRealLink(icon)) + .apply(GlobalMethod.getRequestOptions(true)) + .into(viewBinding.headIconView) + } + viewBinding.userNameView.text = t.data.userName + val info = String.format( + getString(R.string.fans_information), + ServerConfiguration.numberToString(t.data.fans), + ServerConfiguration.numberToString(t.data.follower), + ServerConfiguration.numberToString(t.data.praise) + ) + viewBinding.userInfoView.text = info + + viewBinding.cardView.postDelayed({ + viewBinding.cardView.isVisible = true + viewBinding.openUserSpace.setOnClickListener { + gotoUserPage(t.data.account) + } + }, 300) + } else { + viewBinding.cardView.isVisible = false + } + + } + + override fun onFailure(e: Exception) { + viewBinding.cardView.isVisible = false + } + + }) + } + + + /** + * 打开用户主页 + * @param userId String + */ + fun gotoUserPage(userId: String) { + val intent = Intent( + requireContext(), + UserHomePageActivity::class.java + ) + intent.putExtra("userId", userId) + startActivity( + intent + ) + } + + /** + * 加载页面信息 + */ + fun loadInfo() { + val token = AppSettings.getValue(AppSettings.Setting.Token, "") + WebMod.instance.getInfo(token, modId, object : ApiCallBack { + override fun onResponse(t: WebModInfoData) { + if (t.code == ServerConfiguration.Success_Code) { + developer = t.data.developer + isOpen = t.data.hidden == 0 + viewBinding.loadLayout.isVisible = false + viewBinding.contentLayout.isVisible = true + val icon = t.data.icon + if (icon != null && icon.isNotBlank()) { + Glide.with(requireContext()) + .load(ServerConfiguration.getRealLink(icon)) + .apply(GlobalMethod.getRequestOptions()) + .into(viewBinding.iconView) + } + val screenshotListData = t.data.screenshots + if (screenshotListData != null && screenshotListData.isNotBlank()) { + val list = ArrayList() + val lineParser = LineParser() + lineParser.symbol = "," + lineParser.text = screenshotListData + lineParser.analyse { lineNum, lineData, isEnd -> + list.add(lineData) + true + } + val adapter = object : BannerImageAdapter(list) { + override fun onBindView( + holder: BannerImageHolder?, + data: String?, + position: Int, + size: Int + ) { + if (data != null && holder != null) { + Glide.with(requireContext()) + .load(ServerConfiguration.getRealLink(data)) + .apply(GlobalMethod.getRequestOptions()) + .into(holder.imageView) + } + } + } + viewBinding.banner.setAdapter(adapter) + viewBinding.banner.addBannerLifecycleObserver(requireActivity()) + viewBinding.banner.indicator = CircleIndicator(requireActivity()) + viewBinding.banner.setIndicatorSelectedColorRes(R.color.blue_500) + viewBinding.banner.isAutoLoop(false) + } else { + viewBinding.banner.isVisible = false + } + val tags = t.data.tags + val lineParser = LineParser(tags) + val tagList = ArrayList() + lineParser.symbol = "," + lineParser.analyse { lineNum, lineData, isEnd -> + val tag = lineData.subSequence(1, lineData.length - 1).toString() + tagList.add(tag) + true + } + if (tagList.size > 0) { + tagList.forEach { + val chip = Chip(requireContext()) + chip.text = it + val s = it + chip.setOnClickListener { + val bundle = Bundle() + bundle.putString("tag", s) + bundle.putString( + "title", + String.format(getString(R.string.tag_title), s) + ) + bundle.putString("action", "tag") + val thisIntent = + Intent(requireContext(), TagActivity::class.java) + thisIntent.putExtra("data", bundle) + startActivity(thisIntent) + } + viewBinding.chipGroup.addView(chip) + } + } else { + viewBinding.chipGroup.isVisible = false + } + viewBinding.titleView.text = t.data.name + TextStyleMaker.instance.load( + viewBinding.modInfoView, + t.data.describe + ) { type, data -> + TextStyleMaker.instance.clickEvent(requireContext(), type, data) + } + viewBinding.numView.text = + String.format( + getString(R.string.unit_and_downloadnum), + t.data.unitNumber, + t.data.downloadNumber, + t.data.versionName + ) + viewBinding.updateTimeView.text = + String.format(getString(R.string.recent_update), t.data.updateTime) + if (t.data.hidden == 0) { + viewBinding.hideTextView.isVisible = false + } + loadDeveloperInfo(t.data.developer) + } else { + viewBinding.contentLayout.isVisible = false + viewBinding.loadLayout.isVisible = true + viewBinding.tipView.isVisible = true + viewBinding.tipView.text = t.message + viewBinding.progressBar.isVisible = false + } + } + + override fun onFailure(e: Exception) { + viewBinding.contentLayout.isVisible = false + viewBinding.loadLayout.isVisible = true + viewBinding.progressBar.isVisible = false + viewBinding.tipView.isVisible = true + viewBinding.tipView.setText(R.string.network_error) + } + + }) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/coldmint/rust/pro/viewmodel/StartViewModel.kt b/app/src/main/java/com/coldmint/rust/pro/viewmodel/StartViewModel.kt index 401ac36..dc19396 100644 --- a/app/src/main/java/com/coldmint/rust/pro/viewmodel/StartViewModel.kt +++ b/app/src/main/java/com/coldmint/rust/pro/viewmodel/StartViewModel.kt @@ -35,6 +35,7 @@ import com.coldmint.rust.pro.* import com.coldmint.rust.pro.base.BaseAndroidViewModel import com.coldmint.rust.pro.tool.AppSettings import com.coldmint.rust.pro.tool.BookmarkManager +import com.coldmint.rust.pro.tool.CompletionItemConverter import com.coldmint.rust.pro.tool.GlobalMethod import com.google.android.material.color.DynamicColors import com.google.android.material.dialog.MaterialAlertDialogBuilder @@ -118,6 +119,8 @@ class StartViewModel(application: Application) : BaseAndroidViewModel(applicatio initBookmark() //验证用户信息 verifyingUserInfo() + CompletionItemConverter.init(getApplication()) + } diff --git a/app/src/main/res/drawable/ic_discord.xml b/app/src/main/res/drawable/ic_discord.xml new file mode 100644 index 0000000..36a5bb1 --- /dev/null +++ b/app/src/main/res/drawable/ic_discord.xml @@ -0,0 +1,17 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_outline_free_breakfast_24.xml b/app/src/main/res/drawable/ic_outline_free_breakfast_24.xml new file mode 100644 index 0000000..47a9fa1 --- /dev/null +++ b/app/src/main/res/drawable/ic_outline_free_breakfast_24.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/ic_outline_share_24.xml b/app/src/main/res/drawable/ic_outline_share_24.xml new file mode 100644 index 0000000..4bf68f2 --- /dev/null +++ b/app/src/main/res/drawable/ic_outline_share_24.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/ic_qq.xml b/app/src/main/res/drawable/ic_qq.xml new file mode 100644 index 0000000..df9c132 --- /dev/null +++ b/app/src/main/res/drawable/ic_qq.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml index cdab11a..28557d5 100644 --- a/app/src/main/res/layout/activity_login.xml +++ b/app/src/main/res/layout/activity_login.xml @@ -83,30 +83,30 @@ android:layout_below="@id/checkbox" android:layout_marginTop="8dp"> - + android:text="@string/retrieve_password" /> - + android:visibility="gone" /> - + android:text="@string/register" /> \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index ae7b413..ae21470 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -48,8 +48,6 @@ android:name="androidx.navigation.fragment.NavHostFragment" android:layout_width="match_parent" android:layout_height="match_parent" - android:layout_marginHorizontal="16dp" - android:layout_marginTop="8dp" app:defaultNavHost="true" app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior" /> diff --git a/app/src/main/res/layout/activity_pack.xml b/app/src/main/res/layout/activity_pack.xml index c9e1f2a..01f42c4 100644 --- a/app/src/main/res/layout/activity_pack.xml +++ b/app/src/main/res/layout/activity_pack.xml @@ -267,6 +267,7 @@ android:layout_height="wrap_content" android:layout_gravity="bottom|right" android:layout_margin="16dp" + android:text="@string/packmod" app:icon="@drawable/zip" /> diff --git a/app/src/main/res/layout/activity_web_mod_info.xml b/app/src/main/res/layout/activity_web_mod_info.xml index ef1a908..387fe1a 100644 --- a/app/src/main/res/layout/activity_web_mod_info.xml +++ b/app/src/main/res/layout/activity_web_mod_info.xml @@ -6,7 +6,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" - tools:context=".ActivateActivity"> + tools:context=".WebModInfoActivity"> + + + + + + + + + + + - - + app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -