修改服务器地址,提升程序稳定性。

This commit is contained in:
Cold-Mint 2023-05-18 22:37:49 +08:00
parent dd8b2117f3
commit c6cc1bc212
5 changed files with 138 additions and 104 deletions

View File

@ -124,11 +124,15 @@ class ApplicationListAdapter(
apkFolder.mkdirs()
}
handler.post {
try {
materialDialog.show {
title(R.string.export_apk_title).message(
R.string.export_apk_load
).positiveButton(R.string.dialog_close).cancelable(false)
}
} catch (e: Exception) {
e.printStackTrace()
}
}
val path = folder + "/" + appName + "_" + data.versionName + ".apk"
val result =
@ -146,12 +150,16 @@ class ApplicationListAdapter(
}
} else {
handler.post {
try {
materialDialog.dismiss()
Snackbar.make(
viewBinding.root,
context.getString(R.string.export_apk_failure),
Snackbar.LENGTH_SHORT
).show()
} catch (e: Exception) {
e.printStackTrace()
}
}
}
}.start()

View File

@ -659,6 +659,7 @@ class ModActionAdapter(
}
}
handler.post {
try {
materialDialog.dismiss()
val modClass = ModClass(unzip_path)
if (!modClass.hasInfo()) {
@ -667,6 +668,11 @@ class ModActionAdapter(
repairThread.start()
}
mModFragment.loadModList()
}catch (e: Exception) {
//此处try-catch用于处理某些情况下materialDialog.dismiss()无法获取上下文环境的问题。
// https://console.firebase.google.com/project/rust-assistant-58ca5/crashlytics/app/android:com.coldmint.rust.pro/issues/6daf3a4848ba02f1fb7eee1b8498f9e6?hl=zh-cn&time=last-seven-days&sessionEventKey=645E56A60377000134A21E1A97CE75C2_1810764589804755675
e.printStackTrace()
}
}
} else {
handler.post {

View File

@ -128,9 +128,11 @@ class AllUnitsFragment(
historyDao.update(newHistoryRecord)
}
useHandler.post {
if (isAdded) {
whenAddComplete.invoke()
}
}
}
if (useThread) {
executorService.submit {
funData.invoke()
@ -146,16 +148,19 @@ class AllUnitsFragment(
*/
fun loadFiles(file: File? = modClass?.modFile) {
if (file == null) {
Snackbar.make(viewBinding.unitList,R.string.file_not_exist,Snackbar.LENGTH_SHORT).show()
Snackbar.make(viewBinding.unitList, R.string.file_not_exist, Snackbar.LENGTH_SHORT)
.show()
return
}
val handler = Handler(Looper.getMainLooper())
executorService.submit {
handler.post {
if (isAdded) {
viewBinding.swipeRefreshLayout.isVisible = false
viewBinding.progressBar.isVisible = true
viewBinding.unitError.isVisible = false
}
}
dataList.clear()
val fileFinder2 = FileFinder2(file)
val data = modClass!!.modConfigurationManager?.readData()
@ -193,6 +198,7 @@ class AllUnitsFragment(
notFindUnits(handler)
} else {
handler.post {
if (isAdded) {
viewBinding.swipeRefreshLayout.isVisible = true
viewBinding.progressBar.isVisible = false
viewBinding.unitError.isVisible = false
@ -216,6 +222,7 @@ class AllUnitsFragment(
}
}
}
}
/**
@ -225,6 +232,7 @@ class AllUnitsFragment(
fun notFindUnits(handler: Handler? = null, key: String? = null, searchMode: Boolean = false) {
val temHandler = handler ?: Handler(Looper.getMainLooper())
temHandler.post {
if (isAdded) {
viewBinding.swipeRefreshLayout.isVisible = false
viewBinding.progressBar.isVisible = false
viewBinding.unitError.isVisible = true
@ -253,6 +261,7 @@ class AllUnitsFragment(
whenNumberChanged?.invoke(0)
}
}
}
/**
@ -262,10 +271,12 @@ class AllUnitsFragment(
val handler = Handler(Looper.getMainLooper())
executorService.submit {
handler.post {
if (isAdded) {
viewBinding.swipeRefreshLayout.isVisible = false
viewBinding.progressBar.isVisible = true
viewBinding.unitError.isVisible = false
}
}
dataList.clear()
val data = modClass!!.modConfigurationManager?.readData()
val sourceFileFilteringRule = data?.sourceFileFilteringRule ?: ".+\\.ini|.+\\.template"
@ -324,6 +335,7 @@ class AllUnitsFragment(
notFindUnits(handler, searchMode = true)
} else {
handler.post {
if (isAdded) {
viewBinding.swipeRefreshLayout.isVisible = true
viewBinding.progressBar.isVisible = false
viewBinding.unitError.isVisible = true
@ -331,7 +343,8 @@ class AllUnitsFragment(
viewBinding.unitError.setOnClickListener {
loadFiles()
}
val adapter = UnitAdapter(requireContext(), dataList, configuration.unitName)
val adapter =
UnitAdapter(requireContext(), dataList, configuration.unitName)
adapter.setItemEvent { i, unitItemBinding, viewHolder, sourceFileClass ->
unitItemBinding.root.setOnClickListener {
openEditActivity(sourceFileClass)
@ -349,6 +362,7 @@ class AllUnitsFragment(
}
}
}
}
/**
* 过滤数据
@ -372,6 +386,7 @@ class AllUnitsFragment(
notFindUnits(handler, key)
} else {
handler.post {
if (isAdded) {
viewBinding.swipeRefreshLayout.isVisible = true
viewBinding.progressBar.isVisible = false
viewBinding.unitError.isVisible = true
@ -398,6 +413,7 @@ class AllUnitsFragment(
}
}
}
}
override fun getViewBindingObject(layoutInflater: LayoutInflater): FragmentAllUnitsBinding {
return FragmentAllUnitsBinding.inflate(layoutInflater)

View File

@ -41,11 +41,15 @@ class BannerManager private constructor() {
override fun onResponse(call: Call, response: Response) {
try {
val data = response.body!!.string()
val finalBannerItemDataBean =
val finalBannerItemDataBean: BannerItemDataBean? =
gson.fromJson(data, BannerItemDataBean::class.java)
if (finalBannerItemDataBean == null) {
handler.post { apiCallBack.onFailure(IOException()) }
} else {
handler.post {
apiCallBack.onResponse(finalBannerItemDataBean)
}
}
} catch (e: Exception) {
e.printStackTrace()
handler.post {

View File

@ -26,7 +26,7 @@ object ServerConfiguration {
//电脑查 ip [ipconfig]
private const val testIp = "http://10.0.2.2/"
const val defaultIp = "http://39.105.229.249/"
const val defaultIp = "https://rust.coldmint.top/"
var website = defaultIp
const val Success_Code = 0
const val Error_Code = 1