搜索建议完成

This commit is contained in:
coldmint 2022-07-10 00:33:10 +08:00
parent 0d153622cb
commit 3a691b33aa
34 changed files with 661 additions and 257 deletions

Binary file not shown.

View File

@ -11,6 +11,7 @@
android:name="android.permission.MANAGE_EXTERNAL_STORAGE" android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
tools:ignore="ScopedStorage" /> tools:ignore="ScopedStorage" />
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application <application
android:name=".RustApplication" android:name=".RustApplication"
@ -23,6 +24,10 @@
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/Theme.rust.Concept" android:theme="@style/Theme.rust.Concept"
android:usesCleartextTraffic="true"> android:usesCleartextTraffic="true">
<activity
android:name=".SearchActivity"
android:exported="false" />
<provider <provider
android:name="androidx.core.content.FileProvider" android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileProvider" android:authorities="${applicationId}.fileProvider"
@ -44,24 +49,24 @@
android:name="notch.config" android:name="notch.config"
android:value="portrait|landscape" /> <!-- Activity注册 --> android:value="portrait|landscape" /> <!-- Activity注册 -->
<activity <activity
android:screenOrientation="portrait"
android:name=".CreationWizardActivity" android:name=".CreationWizardActivity"
android:exported="false" /> android:exported="false"
android:screenOrientation="portrait" />
<activity <activity
android:name=".TurretDesignActivity" android:name=".TurretDesignActivity"
android:screenOrientation="portrait" android:exported="false"
android:exported="false" /> android:screenOrientation="portrait" />
<activity <activity
android:name=".BrowserActivity" android:name=".BrowserActivity"
android:exported="false" android:exported="false"
android:screenOrientation="portrait" android:label="@string/built_in_browser"
android:label="@string/built_in_browser" /> <!-- 适配全面屏 --> android:screenOrientation="portrait" /> <!-- 适配全面屏 -->
<activity <activity
android:name=".OrderListActivity" android:name=".OrderListActivity"
android:exported="false" android:exported="false"
android:screenOrientation="portrait" /> android:screenOrientation="portrait" />
<activity <activity
android:name=".SearchActivity" android:name=".SearchResultActivity"
android:exported="false" android:exported="false"
android:screenOrientation="portrait" /> android:screenOrientation="portrait" />
<activity <activity
@ -120,8 +125,6 @@
android:name=".WebModInfoActivity" android:name=".WebModInfoActivity"
android:exported="false" android:exported="false"
android:screenOrientation="portrait" /> android:screenOrientation="portrait" />
<activity <activity
android:name=".ErrorActivity" android:name=".ErrorActivity"
android:exported="false" android:exported="false"

View File

@ -21,7 +21,6 @@ import androidx.navigation.ui.*
import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.MaterialDialog
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.coldmint.dialog.CoreDialog import com.coldmint.dialog.CoreDialog
import com.coldmint.dialog.InputDialog
import com.coldmint.rust.core.CompressionManager import com.coldmint.rust.core.CompressionManager
import com.coldmint.rust.core.TemplatePackage import com.coldmint.rust.core.TemplatePackage
import com.coldmint.rust.core.dataBean.AppUpdateData import com.coldmint.rust.core.dataBean.AppUpdateData
@ -452,46 +451,46 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
/** /**
* 初始化搜索项目事件 * 初始化搜索项目事件
*/ */
private fun initSearchItem(newSearchView: SearchView) { // private fun initSearchItem(newSearchView: SearchView) {
val navigationIcon = viewBinding.toolbar.navigationIcon // val navigationIcon = viewBinding.toolbar.navigationIcon
var oldTile: CharSequence = viewBinding.toolbar.title // var oldTile: CharSequence = viewBinding.toolbar.title
val hideView: (collapsed: Boolean) -> Unit = { // val hideView: (collapsed: Boolean) -> Unit = {
if (it) { // if (it) {
newSearchView.onActionViewCollapsed() // newSearchView.onActionViewCollapsed()
} // }
viewBinding.toolbar.navigationIcon = navigationIcon // viewBinding.toolbar.navigationIcon = navigationIcon
viewBinding.toolbar.title = oldTile // viewBinding.toolbar.title = oldTile
} // }
newSearchView.queryHint = getString(R.string.search_hint) // newSearchView.queryHint = getString(R.string.search_hint)
newSearchView.setOnCloseListener { // newSearchView.setOnCloseListener {
hideView.invoke(false) // hideView.invoke(false)
return@setOnCloseListener false // return@setOnCloseListener false
} // }
newSearchView.setOnSearchClickListener { // newSearchView.setOnSearchClickListener {
oldTile = viewBinding.toolbar.title // oldTile = viewBinding.toolbar.title
viewBinding.toolbar.navigationIcon = null // viewBinding.toolbar.navigationIcon = null
viewBinding.toolbar.title = getString(R.string.search) // viewBinding.toolbar.title = getString(R.string.search)
} // }
//
newSearchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener { // newSearchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
override fun onQueryTextSubmit(query: String?): Boolean { // override fun onQueryTextSubmit(query: String?): Boolean {
hideView.invoke(true) // hideView.invoke(true)
val key = query // val key = query
if (key != null) { // if (key != null) {
val goIntent = Intent(this@MainActivity, SearchActivity::class.java) // val goIntent = Intent(this@MainActivity, SearchResultActivity::class.java)
goIntent.putExtra("key", key) // goIntent.putExtra("key", key)
startActivity(goIntent) // startActivity(goIntent)
} // }
return false // return false
} // }
//
override fun onQueryTextChange(newText: String?): Boolean { // override fun onQueryTextChange(newText: String?): Boolean {
return false // return false
} // }
//
}) // })
searchView = newSearchView // searchView = newSearchView
} // }
/** /**
* 导入模板 * 导入模板
@ -643,8 +642,8 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
override fun onCreateOptionsMenu(menu: Menu): Boolean { override fun onCreateOptionsMenu(menu: Menu): Boolean {
val inflater = menuInflater val inflater = menuInflater
inflater.inflate(R.menu.menu_main, menu) inflater.inflate(R.menu.menu_main, menu)
val searchView = menu.findItem(R.id.app_bar_search).actionView as SearchView // val searchView = menu.findItem(R.id.app_bar_search).actionView as SearchView
initSearchItem(searchView) // initSearchItem(searchView)
return true return true
} }
@ -655,6 +654,9 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
} }
override fun onOptionsItemSelected(item: MenuItem): Boolean { override fun onOptionsItemSelected(item: MenuItem): Boolean {
if (item.itemId == R.id.search) {
startActivity(Intent(this, SearchActivity::class.java))
}
return false return false
} }

View File

@ -866,7 +866,7 @@ class ReleaseModActivity : BaseActivity<ActivityReleaseModBinding>() {
.positiveButton(R.string.dialog_ok).cancelable(false) .positiveButton(R.string.dialog_ok).cancelable(false)
} }
WebMod.instance.releaseMod(appSettings.getValue(AppSettings.Setting.AppID, ""), modId, WebMod.instance.releaseMod(appSettings.getValue(AppSettings.Setting.AppID, ""), modId,
account, appSettings.getValue(AppSettings.Setting.Token, ""),
modName, modName,
modDescribe, modDescribe,
tagsBuilder.toString(), tagsBuilder.toString(),

View File

@ -22,15 +22,15 @@ import com.google.android.material.snackbar.Snackbar
* @date 2022/1/9 16:50 * @date 2022/1/9 16:50
*/ */
class ReviewModActivity : BaseActivity<ActivityReviewModBinding>() { class ReviewModActivity : BaseActivity<ActivityReviewModBinding>() {
val account: String by lazy { val token by lazy {
appSettings.getValue(AppSettings.Setting.Account, "") AppSettings.getInstance(this).getValue(AppSettings.Setting.Token, "")
} }
override fun whenCreateActivity(savedInstanceState: Bundle?, canUseView: Boolean) { override fun whenCreateActivity(savedInstanceState: Bundle?, canUseView: Boolean) {
if (canUseView) { if (canUseView) {
viewBinding.toolbar.title = getText(R.string.review_mod) viewBinding.toolbar.title = getText(R.string.review_mod)
setReturnButton() setReturnButton()
if (account.isBlank()) { if (token.isBlank()) {
showInfoToView(resId = R.string.please_login_first) showInfoToView(resId = R.string.please_login_first)
return return
} }
@ -65,7 +65,7 @@ class ReviewModActivity : BaseActivity<ActivityReviewModBinding>() {
} }
itemAuditModBinding.consentView.setOnClickListener { itemAuditModBinding.consentView.setOnClickListener {
WebMod.instance.auditMod( WebMod.instance.auditMod(
account, token,
data.id, data.id,
true, true,
object : ApiCallBack<ApiResponse> { object : ApiCallBack<ApiResponse> {
@ -93,8 +93,9 @@ class ReviewModActivity : BaseActivity<ActivityReviewModBinding>() {
}) })
} }
itemAuditModBinding.refusedView.setOnClickListener { itemAuditModBinding.refusedView.setOnClickListener {
WebMod.instance.auditMod( WebMod.instance.auditMod(
account, token,
data.id, data.id,
false, false,
object : ApiCallBack<ApiResponse> { object : ApiCallBack<ApiResponse> {

View File

@ -1,85 +1,84 @@
package com.coldmint.rust.pro package com.coldmint.rust.pro
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle import android.os.Bundle
import androidx.appcompat.widget.SearchView
import androidx.core.view.isVisible import androidx.core.view.isVisible
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import com.coldmint.rust.core.dataBean.SearchResultDataBean import com.coldmint.rust.core.dataBean.SearchSuggestionsData
import com.coldmint.rust.core.interfaces.ApiCallBack import com.coldmint.rust.core.interfaces.ApiCallBack
import com.coldmint.rust.core.web.Search import com.coldmint.rust.core.web.Search
import com.coldmint.rust.core.web.ServerConfiguration import com.coldmint.rust.pro.adapters.SearchSuggestionsAdapter
import com.coldmint.rust.pro.adapters.SearchResultAdapter
import com.coldmint.rust.pro.base.BaseActivity import com.coldmint.rust.pro.base.BaseActivity
import com.coldmint.rust.pro.databinding.ActivitySearchBinding import com.coldmint.rust.pro.databinding.ActivitySearchBinding
/** /**
* 搜索activity * 搜索界面
*/ */
class SearchActivity : BaseActivity<ActivitySearchBinding>() { class SearchActivity : BaseActivity<ActivitySearchBinding>() {
lateinit var keyWord: String
override fun whenCreateActivity(savedInstanceState: Bundle?, canUseView: Boolean) { override fun whenCreateActivity(savedInstanceState: Bundle?, canUseView: Boolean) {
if (canUseView) { title = getString(R.string.search)
setReturnButton() setReturnButton()
loadData(keyWord)
title = String.format(getString(R.string.search_mod_key), keyWord)
viewBinding.recyclerView.layoutManager = LinearLayoutManager(this) viewBinding.recyclerView.layoutManager = LinearLayoutManager(this)
} else {
val thisIntent = intent viewBinding.searchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener,
val key = thisIntent.getStringExtra("key") android.widget.SearchView.OnQueryTextListener {
if (key == null) { override fun onQueryTextSubmit(query: String?): Boolean {
showError("key为null") if (query != null && query.isNotBlank()) {
return val intent = Intent(this@SearchActivity, SearchResultActivity::class.java)
} intent.putExtra("key", query)
keyWord = key startActivity(intent)
} }
return true
} }
/** override fun onQueryTextChange(newText: String?): Boolean {
* 加载数据 if (newText != null && newText.isNotBlank()) {
* @param keyWord String Search.instance.suggestions(newText,
*/ object : ApiCallBack<SearchSuggestionsData> {
fun loadData(keyWord: String) { override fun onResponse(t: SearchSuggestionsData) {
Search.instance.searchAll(keyWord, object : ApiCallBack<SearchResultDataBean> { val dataList = t.data
override fun onResponse(t: SearchResultDataBean) { if (dataList.isNullOrEmpty()) {
if (t.code == ServerConfiguration.Success_Code) { viewBinding.recyclerView.isVisible = false
val list = t.data
if (list != null && list.isNotEmpty()) {
val adapter = SearchResultAdapter(this@SearchActivity, keyWord, list)
viewBinding.progressBar.isVisible = false
viewBinding.tipView.isVisible = false
viewBinding.recyclerView.isVisible = true
viewBinding.recyclerView.adapter = adapter
title = String.format(
getString(R.string.search_mod_key),
keyWord
) + "(" + list.size + ")"
} else { } else {
showInfoToView(t.message) val adapter =
SearchSuggestionsAdapter(
this@SearchActivity,
newText,
dataList
)
adapter.setItemEvent { i, itemSearchSuggestionsBinding, viewHolder, s ->
itemSearchSuggestionsBinding.root.setOnClickListener {
val intent = Intent(
this@SearchActivity,
SearchResultActivity::class.java
)
intent.putExtra("key", s)
startActivity(intent)
} }
} else { }
showInfoToView(t.message) viewBinding.recyclerView.adapter = adapter
viewBinding.recyclerView.isVisible = true
} }
} }
override fun onFailure(e: Exception) { override fun onFailure(e: Exception) {
showInfoToView(this@SearchActivity.getString(R.string.network_error)) viewBinding.recyclerView.isVisible = false
}
})
} else {
viewBinding.recyclerView.isVisible = false
}
return true
} }
}) })
} }
/**
* 显示信息到视图
* @param text String
*/
fun showInfoToView(text: String) {
viewBinding.tipView.isVisible = true
viewBinding.tipView.text = text
viewBinding.progressBar.isVisible = false
viewBinding.recyclerView.isVisible = false
}
override fun getViewBindingObject(): ActivitySearchBinding { override fun getViewBindingObject(): ActivitySearchBinding {
return ActivitySearchBinding.inflate(layoutInflater) return ActivitySearchBinding.inflate(layoutInflater)
} }
} }

View File

@ -0,0 +1,109 @@
package com.coldmint.rust.pro
import android.os.Bundle
import androidx.core.view.isVisible
import com.coldmint.rust.core.dataBean.user.SearchResultDataBean
import com.coldmint.rust.core.interfaces.ApiCallBack
import com.coldmint.rust.core.web.Search
import com.coldmint.rust.core.web.ServerConfiguration
import com.coldmint.rust.pro.adapters.SearchPageAdapter
import com.coldmint.rust.pro.base.BaseActivity
import com.coldmint.rust.pro.databinding.ActivitySearchResultBinding
import com.google.android.material.tabs.TabLayoutMediator
/**
* 搜索activity
*/
class SearchResultActivity : BaseActivity<ActivitySearchResultBinding>() {
lateinit var keyWord: String
val typeMap by lazy {
val map = HashMap<String, Int>()
map["mod"] = R.string.search_type_mod
map["user"] = R.string.search_type_user
map["dynamic"] = R.string.search_type_dynamic
map["mod_comments"] = R.string.search_type_mod_comments
map["mod_versions"] = R.string.search_type_mod_versions
map["purchase_plan"] = R.string.search_type_purchase_plan
map
}
override fun whenCreateActivity(savedInstanceState: Bundle?, canUseView: Boolean) {
if (canUseView) {
setReturnButton()
loadData(keyWord)
title = String.format(getString(R.string.search_mod_key), keyWord)
} else {
val thisIntent = intent
val key = thisIntent.getStringExtra("key")
if (key == null) {
showError("key为null")
return
}
keyWord = key
}
}
/**
* 加载数据
* @param keyWord String
*/
fun loadData(keyWord: String) {
Search.instance.searchAll(keyWord, object : ApiCallBack<SearchResultDataBean> {
override fun onResponse(t: SearchResultDataBean) {
if (t.code == ServerConfiguration.Success_Code) {
val list = t.data.total
if (list.isNotEmpty()) {
val adapter = SearchPageAdapter(this@SearchResultActivity, keyWord, t.data)
viewBinding.viewPager2.adapter = adapter
TabLayoutMediator(viewBinding.tabLayout, viewBinding.viewPager2) { tab, i ->
tab.text = if (i == 0) {
getString(R.string.search_type_mod_all) + "(" + t.data.total.size + ")"
} else {
val typeData = t.data.type[i - 1]
val id = typeMap[typeData.typeName] ?: -1
val name = if (id == -1) {
typeData.typeName
} else {
getString(id)
}
name + "(" + typeData.num + ")"
}
}.attach()
viewBinding.progressBar.isVisible = false
viewBinding.tipView.isVisible = false
viewBinding.contentLayout.isVisible = true
title = String.format(
getString(R.string.search_mod_key),
keyWord
)
} else {
showInfoToView(t.message)
}
} else {
showInfoToView(t.message)
}
}
override fun onFailure(e: Exception) {
showInfoToView(this@SearchResultActivity.getString(R.string.network_error))
}
})
}
/**
* 显示信息到视图
* @param text String
*/
fun showInfoToView(text: String) {
viewBinding.tipView.isVisible = true
viewBinding.tipView.text = text
viewBinding.progressBar.isVisible = false
viewBinding.contentLayout.isVisible = false
}
override fun getViewBindingObject(): ActivitySearchResultBinding {
return ActivitySearchResultBinding.inflate(layoutInflater)
}
}

View File

@ -68,8 +68,8 @@ class WebModInfoActivity : BaseActivity<ActivityWebModInfoBinding>() {
val modFilePath = "$modFolderPath$modId.rwmod" val modFilePath = "$modFolderPath$modId.rwmod"
File(modFilePath) File(modFilePath)
} }
val account by lazy { val token by lazy {
appSettings.getValue(AppSettings.Setting.Account, "") appSettings.getValue(AppSettings.Setting.Token, "")
} }
var developer: String? = null var developer: String? = null
@ -105,7 +105,7 @@ class WebModInfoActivity : BaseActivity<ActivityWebModInfoBinding>() {
private fun initData() { private fun initData() {
if (account.isBlank()) { if (token.isBlank()) {
viewBinding.progressBar.isVisible = false viewBinding.progressBar.isVisible = false
viewBinding.tipView.isVisible = true viewBinding.tipView.isVisible = true
viewBinding.tipView.setText(R.string.please_login_first) viewBinding.tipView.setText(R.string.please_login_first)
@ -115,7 +115,7 @@ class WebModInfoActivity : BaseActivity<ActivityWebModInfoBinding>() {
loadModCommentList(modId) loadModCommentList(modId)
WebMod.instance.getInfo(account, modId, object : ApiCallBack<WebModInfoData> { WebMod.instance.getInfo(token, modId, object : ApiCallBack<WebModInfoData> {
override fun onResponse(t: WebModInfoData) { override fun onResponse(t: WebModInfoData) {
if (t.code == ServerConfiguration.Success_Code) { if (t.code == ServerConfiguration.Success_Code) {
developer = t.data.developer developer = t.data.developer
@ -287,18 +287,6 @@ class WebModInfoActivity : BaseActivity<ActivityWebModInfoBinding>() {
when (item.itemId) { when (item.itemId) {
R.id.report_item -> { R.id.report_item -> {
if (isOpen) { if (isOpen) {
//不能举报自己的模组
if (developer != null && developer == account) {
Snackbar.make(
viewBinding.button,
R.string.unable_to_report2,
Snackbar.LENGTH_SHORT
).setAction(R.string.open) {
val gotoIntent =
Intent(this, WorkManagementActivity::class.java)
startActivity(gotoIntent)
}.show()
} else {
val thisIntent = Intent(this, ReportActivity::class.java) val thisIntent = Intent(this, ReportActivity::class.java)
val bundle = Bundle() val bundle = Bundle()
bundle.putString("target", modId) bundle.putString("target", modId)
@ -306,7 +294,6 @@ class WebModInfoActivity : BaseActivity<ActivityWebModInfoBinding>() {
bundle.putString("name", viewBinding.titleView.text.toString()) bundle.putString("name", viewBinding.titleView.text.toString())
thisIntent.putExtra("data", bundle) thisIntent.putExtra("data", bundle)
startActivity(thisIntent) startActivity(thisIntent)
}
} else { } else {
//不能举报未公开的模组 //不能举报未公开的模组
Snackbar.make( Snackbar.make(
@ -492,8 +479,7 @@ class WebModInfoActivity : BaseActivity<ActivityWebModInfoBinding>() {
val text = inputField.text.toString() val text = inputField.text.toString()
if (!text.isBlank()) { if (!text.isBlank()) {
WebMod.instance.sendComment( WebMod.instance.sendComment(
account, appSettings.getValue(AppSettings.Setting.Token, ""),
appSettings.getValue(AppSettings.Setting.AppID, ""),
modId, modId,
text, text,
object : ApiCallBack<ApiResponse> { object : ApiCallBack<ApiResponse> {

View File

@ -175,7 +175,11 @@ class WorkManagementActivity : BaseActivity<ActivityWorkmangementBinding>() {
.positiveButton(R.string.dialog_ok) .positiveButton(R.string.dialog_ok)
.positiveButton { .positiveButton {
WebMod.instance.afreshAuditMod( WebMod.instance.afreshAuditMod(
data.developer, AppSettings.getInstance(this@WorkManagementActivity)
.getValue(
AppSettings.Setting.Token,
""
),
data.id, data.id,
object : object :
ApiCallBack<ApiResponse> { ApiCallBack<ApiResponse> {

View File

@ -0,0 +1,29 @@
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.dataBean.user.SearchResultDataBean
import com.coldmint.rust.pro.fragments.SearchResultFragment
class SearchPageAdapter(
fragmentActivity: FragmentActivity, val keyword: String,
val data: SearchResultDataBean.Data
) : FragmentStateAdapter(fragmentActivity) {
override fun getItemCount(): Int {
return data.type.size + 1
}
override fun createFragment(position: Int): Fragment {
val typeName = if (position == 0) {
"all"
} else {
data.type[position - 1].typeName
}
return SearchResultFragment(keyword, data, typeName)
}
}

View File

@ -2,26 +2,17 @@ package com.coldmint.rust.pro.adapters
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.graphics.Color
import android.graphics.Typeface
import android.os.Bundle import android.os.Bundle
import android.text.SpannableStringBuilder
import android.text.Spanned
import android.text.style.ForegroundColorSpan
import android.text.style.StyleSpan
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.Toast
import androidx.core.view.isVisible import androidx.core.view.isVisible
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.bumptech.glide.request.RequestOptions import com.coldmint.rust.core.dataBean.user.SearchResultDataBean
import com.coldmint.rust.core.dataBean.SearchResultDataBean
import com.coldmint.rust.core.web.ServerConfiguration import com.coldmint.rust.core.web.ServerConfiguration
import com.coldmint.rust.pro.UserHomePageActivity import com.coldmint.rust.pro.UserHomePageActivity
import com.coldmint.rust.pro.WebModInfoActivity import com.coldmint.rust.pro.WebModInfoActivity
import com.coldmint.rust.pro.base.BaseAdapter import com.coldmint.rust.pro.base.BaseAdapter
import com.coldmint.rust.pro.databinding.ItemSearchResultBinding import com.coldmint.rust.pro.databinding.ItemSearchResultBinding
import com.coldmint.rust.pro.edit.RustAutoComplete2
import com.coldmint.rust.pro.tool.GlobalMethod import com.coldmint.rust.pro.tool.GlobalMethod
import com.coldmint.rust.pro.tool.TextStyleMaker import com.coldmint.rust.pro.tool.TextStyleMaker
import java.util.* import java.util.*
@ -35,9 +26,9 @@ import java.util.*
class SearchResultAdapter( class SearchResultAdapter(
val context: Context, val context: Context,
val keyWord: String, val keyWord: String,
dataList: MutableList<SearchResultDataBean.Data> dataList: MutableList<SearchResultDataBean.Data.Total>
) : ) :
BaseAdapter<ItemSearchResultBinding, SearchResultDataBean.Data>(context, dataList) { BaseAdapter<ItemSearchResultBinding, SearchResultDataBean.Data.Total>(context, dataList) {
override fun getViewBindingObject( override fun getViewBindingObject(
@ -49,7 +40,7 @@ class SearchResultAdapter(
} }
override fun onBingView( override fun onBingView(
data: SearchResultDataBean.Data, data: SearchResultDataBean.Data.Total,
viewBinding: ItemSearchResultBinding, viewBinding: ItemSearchResultBinding,
viewHolder: ViewHolder<ItemSearchResultBinding>, viewHolder: ViewHolder<ItemSearchResultBinding>,
position: Int position: Int

View File

@ -0,0 +1,35 @@
package com.coldmint.rust.pro.adapters
import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import com.coldmint.rust.pro.base.BaseAdapter
import com.coldmint.rust.pro.databinding.ItemSearchSuggestionsBinding
/**
* 搜索建议适配器
* @constructor
*/
class SearchSuggestionsAdapter(
context: Context,
val keyword: String,
dataList: MutableList<String>
) :
BaseAdapter<ItemSearchSuggestionsBinding, String>(context, dataList) {
override fun getViewBindingObject(
layoutInflater: LayoutInflater,
parent: ViewGroup,
viewType: Int
): ItemSearchSuggestionsBinding {
return ItemSearchSuggestionsBinding.inflate(layoutInflater, parent, false)
}
override fun onBingView(
data: String,
viewBinding: ItemSearchSuggestionsBinding,
viewHolder: ViewHolder<ItemSearchSuggestionsBinding>,
position: Int
) {
viewBinding.titleView.text = createSpannableString(data,keyword)
}
}

View File

@ -37,7 +37,7 @@ abstract class BaseAdapter<ViewBindingType : ViewBinding, DataType>(
Handler(Looper.getMainLooper()) Handler(Looper.getMainLooper())
} }
private val spannableStringBuilder: SpannableStringBuilder = SpannableStringBuilder() private val spannableStringBuilder: SpannableStringBuilder = SpannableStringBuilder()
private val colorSpan: ForegroundColorSpan = ForegroundColorSpan(Color.parseColor("#2196F3")) private val colorSpan: ForegroundColorSpan = ForegroundColorSpan(Color.parseColor("#e91e63"))
private val bold = StyleSpan(Typeface.BOLD) private val bold = StyleSpan(Typeface.BOLD)

View File

@ -0,0 +1,50 @@
package com.coldmint.rust.pro.fragments
import android.os.Bundle
import android.view.LayoutInflater
import androidx.recyclerview.widget.LinearLayoutManager
import com.coldmint.rust.core.dataBean.user.SearchResultDataBean
import com.coldmint.rust.pro.adapters.SearchResultAdapter
import com.coldmint.rust.pro.base.BaseFragment
import com.coldmint.rust.pro.databinding.FragmentSearchResultBinding
/**
* 搜索结果碎片
* @property keyword String
* @property dataList MutableList<Data>
* @constructor
*/
class SearchResultFragment(
val keyword: String,
val data: SearchResultDataBean.Data,
val typeName: String
) :
BaseFragment<FragmentSearchResultBinding>() {
override fun whenViewCreated(inflater: LayoutInflater, savedInstanceState: Bundle?) {
val adapter = SearchResultAdapter(requireContext(), keyword, filterList())
viewBinding.recyclerView.adapter = adapter
viewBinding.recyclerView.layoutManager = LinearLayoutManager(requireContext())
}
/**
* 过滤列表(为all返回所有)
* @return MutableList<SearchResultDataBean.Data.Total>
*/
fun filterList(): MutableList<SearchResultDataBean.Data.Total> {
if (typeName == "all") {
return data.total
}
val list = ArrayList<SearchResultDataBean.Data.Total>()
data.total.forEach {
if (it.type == typeName) {
list.add(it)
}
}
return list
}
override fun getViewBindingObject(): FragmentSearchResultBinding {
return FragmentSearchResultBinding.inflate(layoutInflater)
}
}

View File

@ -21,6 +21,7 @@ import com.coldmint.rust.pro.tool.AppSettings
import com.coldmint.rust.pro.tool.GlobalMethod import com.coldmint.rust.pro.tool.GlobalMethod
class UserInfoFragment : BaseFragment<FragmentUserInfoBinding>() { class UserInfoFragment : BaseFragment<FragmentUserInfoBinding>() {
lateinit var token: String
lateinit var account: String lateinit var account: String
/** /**
@ -103,8 +104,8 @@ class UserInfoFragment : BaseFragment<FragmentUserInfoBinding>() {
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
if (account.isNotBlank()) { if (token.isNotBlank()) {
User.getUserActivationInfo(account, object : ApiCallBack<ActivationInfo> { User.getUserActivationInfo(token, object : ApiCallBack<ActivationInfo> {
override fun onFailure(e: Exception) { override fun onFailure(e: Exception) {
@ -127,9 +128,8 @@ class UserInfoFragment : BaseFragment<FragmentUserInfoBinding>() {
} }
loadRecyclerView(t.data.permission) loadRecyclerView(t.data.permission)
} else { } else {
viewBinding.nameView.text = account viewBinding.nameView.text = t.data.userName
loadRecyclerView(3) loadRecyclerView(3)
// viewBinding.expirationTimeView.text = t.message
} }
} }
@ -138,6 +138,7 @@ class UserInfoFragment : BaseFragment<FragmentUserInfoBinding>() {
} }
override fun whenViewCreated(inflater: LayoutInflater, savedInstanceState: Bundle?) { override fun whenViewCreated(inflater: LayoutInflater, savedInstanceState: Bundle?) {
token = appSettings.getValue(AppSettings.Setting.Token, "")
account = appSettings.getValue(AppSettings.Setting.Account, "") account = appSettings.getValue(AppSettings.Setting.Account, "")
viewBinding.myHomeView.setOnClickListener { viewBinding.myHomeView.setOnClickListener {
val intent = Intent( val intent = Intent(

View File

@ -6,7 +6,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:fitsSystemWindows="true" android:fitsSystemWindows="true"
tools:context=".OrderListActivity"> tools:context=".ActivateActivity">
<com.google.android.material.appbar.AppBarLayout <com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -21,35 +21,48 @@
</com.google.android.material.appbar.AppBarLayout> </com.google.android.material.appbar.AppBarLayout>
<LinearLayout <androidx.core.widget.NestedScrollView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginLeft="16dp" android:layout_marginLeft="8dp"
android:layout_marginRight="16dp" android:layout_marginTop="8dp"
android:gravity="center" android:layout_marginRight="8dp"
android:orientation="vertical"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"> app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
<com.google.android.material.card.MaterialCardView
<ProgressBar style="@style/Widget.Material3.CardView.Elevated"
android:id="@+id/progressBar" android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:indeterminate="true" /> android:layout_margin="8dp">
<TextView <LinearLayout
android:id="@+id/tipView" android:animateLayoutChanges="true"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/loading_data" android:layout_margin="8dp"
android:visibility="gone" /> android:orientation="vertical">
<SearchView
android:id="@+id/searchView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:iconifiedByDefault="false"
android:queryBackground="@null"
android:queryHint="@string/search" />
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView" android:id="@+id/recyclerView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:visibility="gone" /> android:visibility="gone" />
</LinearLayout> </LinearLayout>
</com.google.android.material.card.MaterialCardView>
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout> </androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -0,0 +1,73 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:card_view="http://schemas.android.com/tools"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".OrderListActivity">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize" />
</com.google.android.material.appbar.AppBarLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:gravity="center"
android:orientation="vertical"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
<ProgressBar
android:id="@+id/progressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminate="true" />
<TextView
android:id="@+id/tipView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/loading_data"
android:visibility="gone" />
<LinearLayout
android:visibility="gone"
android:id="@+id/contentLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.google.android.material.tabs.TabLayout
android:id="@+id/tabLayout"
app:tabMode="scrollable"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/viewPager2"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
</LinearLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent" />

View File

@ -1,18 +1,17 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" <com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:card_view="http://schemas.android.com/apk/res-auto" xmlns:card_view="http://schemas.android.com/apk/res-auto"
style="@style/Widget.Material3.CardView.Elevated"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="8dp" android:layout_margin="8dp">
app:cardElevation="2dp"
card_view:cardCornerRadius="2dp">
<RelativeLayout <RelativeLayout
android:id="@+id/rootLayout" android:id="@+id/rootLayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="8dp"> android:padding="16dp">
<ImageView <ImageView
android:id="@+id/imageView" android:id="@+id/imageView"
@ -22,24 +21,25 @@
<TextView <TextView
android:id="@+id/titleView" android:id="@+id/titleView"
style="@style/TextAppearance.Material3.BodyLarge"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignTop="@id/imageView" android:layout_alignTop="@id/imageView"
android:layout_marginLeft="8dp" android:layout_marginStart="8dp"
android:layout_toRightOf="@id/imageView" android:layout_toEndOf="@id/imageView"
android:text="@string/mod_title" android:text="@string/mod_title" />
android:textSize="18sp" />
<TextView <TextView
android:id="@+id/contentView" android:id="@+id/contentView"
style="@style/TextAppearance.Material3.BodyMedium"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@id/titleView" android:layout_below="@id/titleView"
android:layout_marginLeft="8dp" android:layout_marginStart="8dp"
android:layout_marginTop="8dp" android:layout_marginTop="16dp"
android:layout_toRightOf="@id/imageView" android:layout_toEndOf="@id/imageView"
android:text="@string/no_content" /> android:text="@string/no_content" />
</RelativeLayout> </RelativeLayout>
</androidx.cardview.widget.CardView> </com.google.android.material.card.MaterialCardView>

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp">
<TextView
android:layout_centerVertical="true"
android:id="@+id/titleView"
style="@style/TextAppearance.Material3.BodyMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_marginStart="8dp"
android:layout_toStartOf="@id/imageView"
android:text="@string/title" />
<ImageView
android:layout_centerVertical="true"
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginEnd="8dp"
android:src="@drawable/ic_baseline_chevron_right_24" />
</RelativeLayout>

View File

@ -4,8 +4,7 @@
<item <item
app:showAsAction="always" app:showAsAction="always"
android:id="@+id/app_bar_search" android:id="@+id/search"
android:icon="@drawable/ic_search_black_24dp" android:icon="@drawable/ic_search_black_24dp"
android:title="Search" android:title="@string/search" />
app:actionViewClass="android.widget.SearchView" />
</menu> </menu>

View File

@ -846,4 +846,12 @@
<string name="dynamic_color_tip">跟随设备壁纸更换主题色。</string> <string name="dynamic_color_tip">跟随设备壁纸更换主题色。</string>
<string name="dynamic_color_disabled">此设备不支持动态颜色。</string> <string name="dynamic_color_disabled">此设备不支持动态颜色。</string>
<string name="title">标题</string> <string name="title">标题</string>
<string name="search_type_mod">模组</string>
<string name="search_type_user">用户</string>
<string name="search_type_dynamic">动态</string>
<string name="search_type_mod_comments">模组评论</string>
<string name="search_type_mod_versions">模组更新日志</string>
<string name="search_type_purchase_plan">套餐</string>
<string name="search_type_mod_all">全部</string>
</resources> </resources>

View File

@ -1,33 +0,0 @@
package com.coldmint.rust.core.dataBean
import com.google.gson.annotations.SerializedName
/**
* 搜索记录
* @property code Int
* @property `data` List<Data>
* @property message String
* @constructor
*/
data class SearchResultDataBean(
@SerializedName("code")
val code: Int,
@SerializedName("data")
val `data`: MutableList<Data>?,
@SerializedName("message")
val message: String
) {
data class Data(
@SerializedName("content")
val content: String,
@SerializedName("icon")
val icon: String?,
@SerializedName("id")
val id: String,
@SerializedName("title")
val title: String,
@SerializedName("type")
val type: String
)
}

View File

@ -0,0 +1,20 @@
package com.coldmint.rust.core.dataBean
import com.google.gson.annotations.SerializedName
/**
* 搜索建议
* @property code Int
* @property `data` List<String>
* @property message String
* @constructor
*/
data class SearchSuggestionsData(
@SerializedName("code")
val code: Int,
@SerializedName("data")
val `data`: MutableList<String>,
@SerializedName("message")
val message: String
)

View File

@ -0,0 +1,40 @@
package com.coldmint.rust.core.dataBean.user
import com.google.gson.annotations.SerializedName
data class SearchResultDataBean(
@SerializedName("code")
val code: Int,
@SerializedName("data")
val `data`: Data,
@SerializedName("message")
val message: String
) {
data class Data(
@SerializedName("total")
val total: MutableList<Total>,
@SerializedName("type")
val type: List<Type>
) {
data class Total(
@SerializedName("content")
val content: String,
@SerializedName("icon")
val icon: String?,
@SerializedName("id")
val id: String,
@SerializedName("title")
val title: String,
@SerializedName("type")
val type: String
)
data class Type(
@SerializedName("num")
val num: Int,
@SerializedName("typeName")
val typeName: String
)
}
}

View File

@ -2,8 +2,8 @@ package com.coldmint.rust.core.web
import android.os.Handler import android.os.Handler
import android.os.Looper import android.os.Looper
import com.coldmint.rust.core.dataBean.SearchResultDataBean import com.coldmint.rust.core.dataBean.SearchSuggestionsData
import com.coldmint.rust.core.dataBean.mod.WebModListData import com.coldmint.rust.core.dataBean.user.SearchResultDataBean
import com.coldmint.rust.core.interfaces.ApiCallBack import com.coldmint.rust.core.interfaces.ApiCallBack
import com.google.gson.Gson import com.google.gson.Gson
import okhttp3.* import okhttp3.*
@ -59,4 +59,46 @@ class Search private constructor() {
}) })
} }
/**
* 搜索建议
* @param key String 关键字
* @param apiCallBack ApiCallBack<SearchResultDataBean>
*/
fun suggestions(key: String, apiCallBack: ApiCallBack<SearchSuggestionsData>) {
val okHttpClient = ServerConfiguration.initOkHttpClient()
val requestBodyBuilder: FormBody.Builder =
FormBody.Builder().add("key", key)
val requestBody = requestBodyBuilder.build()
val request =
Request.Builder()
.url(ServerConfiguration.website + "php/search.php?action=suggestions")
.post(requestBody).build()
val call = okHttpClient.newCall(request)
val handler = Handler(Looper.getMainLooper())
val gson = Gson()
call.enqueue(object : Callback {
override fun onFailure(call: Call, e: IOException) {
e.printStackTrace()
handler.post { apiCallBack.onFailure(e) }
}
override fun onResponse(call: Call, response: Response) {
try {
val data = response.body!!.string()
val finalSearchSuggestionsData =
gson.fromJson(data, SearchSuggestionsData::class.java)
handler.post {
apiCallBack.onResponse(finalSearchSuggestionsData)
}
} catch (e: Exception) {
e.printStackTrace()
handler.post {
apiCallBack.onFailure(e)
}
}
}
})
}
} }

View File

@ -190,20 +190,20 @@ class WebMod private constructor() {
//audit //audit
/** /**
* 审核模组 * 审核模组
* @param account String 账号管理员 * @param token String 令牌管理员
* @param modId String 模组id * @param modId String 模组id
* @param state Boolean 通过状态 * @param state Boolean 通过状态
* @param apiCallBack ApiCallBack<ApiResponse> 回调接口 * @param apiCallBack ApiCallBack<ApiResponse> 回调接口
*/ */
fun auditMod( fun auditMod(
account: String, token: String,
modId: String, modId: String,
state: Boolean, state: Boolean,
apiCallBack: ApiCallBack<ApiResponse> apiCallBack: ApiCallBack<ApiResponse>
) { ) {
val okHttpClient = ServerConfiguration.initOkHttpClient() val okHttpClient = ServerConfiguration.initOkHttpClient()
val requestBodyBuilder: FormBody.Builder = val requestBodyBuilder: FormBody.Builder =
FormBody.Builder().add("account", account).add("modId", modId) FormBody.Builder().add("token", token).add("modId", modId)
.add("state", state.toString()) .add("state", state.toString())
val requestBody = requestBodyBuilder.build() val requestBody = requestBodyBuilder.build()
val request = val request =
@ -239,14 +239,14 @@ class WebMod private constructor() {
/** /**
* 重新审核模组 * 重新审核模组
* @param account String 账号 * @param token String 令牌
* @param modId String 模组id * @param modId String 模组id
* @param apiCallBack ApiCallBack<ApiResponse> 回调接口 * @param apiCallBack ApiCallBack<ApiResponse> 回调接口
*/ */
fun afreshAuditMod(account: String, modId: String, apiCallBack: ApiCallBack<ApiResponse>) { fun afreshAuditMod(token: String, modId: String, apiCallBack: ApiCallBack<ApiResponse>) {
val okHttpClient = ServerConfiguration.initOkHttpClient() val okHttpClient = ServerConfiguration.initOkHttpClient()
val requestBodyBuilder: FormBody.Builder = val requestBodyBuilder: FormBody.Builder =
FormBody.Builder().add("account", account).add("modId", modId) FormBody.Builder().add("token", token).add("modId", modId)
val requestBody = requestBodyBuilder.build() val requestBody = requestBodyBuilder.build()
val request = val request =
Request.Builder() Request.Builder()
@ -515,22 +515,20 @@ class WebMod private constructor() {
/** /**
* 发布评论 * 发布评论
* @param account String 账号 * @param token String token
* @param appId String appid
* @param modId String 模组id * @param modId String 模组id
* @param content String 评论内容 * @param content String 评论内容
* @param apiCallBack ApiCallBack<ApiResponse> 结果 * @param apiCallBack ApiCallBack<ApiResponse> 结果
*/ */
fun sendComment( fun sendComment(
account: String, token: String,
appId: String,
modId: String, modId: String,
content: String, content: String,
apiCallBack: ApiCallBack<ApiResponse> apiCallBack: ApiCallBack<ApiResponse>
) { ) {
val okHttpClient = ServerConfiguration.initOkHttpClient() val okHttpClient = ServerConfiguration.initOkHttpClient()
val requestBody: FormBody = val requestBody: FormBody =
FormBody.Builder().add("account", account).add("appId", appId).add("modId", modId) FormBody.Builder().add("token", token).add("modId", modId)
.add("content", content).build() .add("content", content).build()
val request = val request =
Request.Builder().url(ServerConfiguration.website + "php/mod.php?action=comments") Request.Builder().url(ServerConfiguration.website + "php/mod.php?action=comments")
@ -565,13 +563,13 @@ class WebMod private constructor() {
/** /**
* 查看模组信息 * 查看模组信息
* @param account String 账号 * @param token String 令牌
* @param modId String 模组Id * @param modId String 模组Id
*/ */
fun getInfo(account: String, modId: String, apiCallBack: ApiCallBack<WebModInfoData>) { fun getInfo(token: String, modId: String, apiCallBack: ApiCallBack<WebModInfoData>) {
val okHttpClient = ServerConfiguration.initOkHttpClient() val okHttpClient = ServerConfiguration.initOkHttpClient()
val requestBody: FormBody = val requestBody: FormBody =
FormBody.Builder().add("account", account).add("modId", modId).build() FormBody.Builder().add("token", token).add("modId", modId).build()
val request = val request =
Request.Builder().url(ServerConfiguration.website + "php/mod.php?action=getInfo") Request.Builder().url(ServerConfiguration.website + "php/mod.php?action=getInfo")
.post(requestBody).build() .post(requestBody).build()
@ -587,6 +585,7 @@ class WebMod private constructor() {
override fun onResponse(call: Call, response: Response) { override fun onResponse(call: Call, response: Response) {
try { try {
val data = response.body!!.string() val data = response.body!!.string()
Log.d("模组信息",data)
val finalWebModInfoData = val finalWebModInfoData =
gson.fromJson(data, WebModInfoData::class.java) gson.fromJson(data, WebModInfoData::class.java)
handler.post { handler.post {
@ -871,7 +870,7 @@ class WebMod private constructor() {
/** /**
* 发布模组 * 发布模组
* @param account String 账号 * @param token String 账号
* @param modName String 模组名称 * @param modName String 模组名称
* @param describe String 描述 * @param describe String 描述
* @param tags String 标签 * @param tags String 标签
@ -881,7 +880,7 @@ class WebMod private constructor() {
fun releaseMod( fun releaseMod(
appId: String, appId: String,
modId: String, modId: String,
account: String, token: String,
modName: String, modName: String,
describe: String, describe: String,
tags: String, tags: String,
@ -896,7 +895,7 @@ class WebMod private constructor() {
val builder = val builder =
MultipartBody.Builder().setType(MultipartBody.FORM).addFormDataPart("appID", appId) MultipartBody.Builder().setType(MultipartBody.FORM).addFormDataPart("appID", appId)
.addFormDataPart("modId", modId) .addFormDataPart("modId", modId)
.addFormDataPart("account", account).addFormDataPart("modName", modName) .addFormDataPart("token", token).addFormDataPart("modName", modName)
.addFormDataPart("describe", describe).addFormDataPart("tags", tags) .addFormDataPart("describe", describe).addFormDataPart("tags", tags)
.addFormDataPart("versionName", versionName) .addFormDataPart("versionName", versionName)
.addFormDataPart("unitNumber", unitNum.toString()) .addFormDataPart("unitNumber", unitNum.toString())
@ -958,6 +957,7 @@ class WebMod private constructor() {
val body = response.body val body = response.body
if (body != null) { if (body != null) {
val data = body.string() val data = body.string()
Log.d("发布模组响应",data)
val finalApiResponse = gson.fromJson(data, ApiResponse::class.java) val finalApiResponse = gson.fromJson(data, ApiResponse::class.java)
handler.post { handler.post {
apiCallBack.onResponse(finalApiResponse) apiCallBack.onResponse(finalApiResponse)