修复了无法下载模组的问题
This commit is contained in:
parent
2d49c2822a
commit
46eeda943a
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -125,7 +125,8 @@ class WebModInfoActivity : BaseActivity<ActivityWebModInfoBinding>() {
|
||||||
val icon = t.data.icon
|
val icon = t.data.icon
|
||||||
if (icon != null && icon.isNotBlank()) {
|
if (icon != null && icon.isNotBlank()) {
|
||||||
Glide.with(this@WebModInfoActivity)
|
Glide.with(this@WebModInfoActivity)
|
||||||
.load(ServerConfiguration.getRealLink(icon)).apply(GlobalMethod.getRequestOptions())
|
.load(ServerConfiguration.getRealLink(icon))
|
||||||
|
.apply(GlobalMethod.getRequestOptions())
|
||||||
.into(viewBinding.iconView)
|
.into(viewBinding.iconView)
|
||||||
}
|
}
|
||||||
title = t.data.name
|
title = t.data.name
|
||||||
|
@ -148,7 +149,8 @@ class WebModInfoActivity : BaseActivity<ActivityWebModInfoBinding>() {
|
||||||
) {
|
) {
|
||||||
if (data != null && holder != null) {
|
if (data != null && holder != null) {
|
||||||
Glide.with(this@WebModInfoActivity)
|
Glide.with(this@WebModInfoActivity)
|
||||||
.load(ServerConfiguration.getRealLink(data)).apply(GlobalMethod.getRequestOptions())
|
.load(ServerConfiguration.getRealLink(data))
|
||||||
|
.apply(GlobalMethod.getRequestOptions())
|
||||||
.into(holder.imageView)
|
.into(holder.imageView)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -331,51 +333,55 @@ class WebModInfoActivity : BaseActivity<ActivityWebModInfoBinding>() {
|
||||||
* @param fileLink String
|
* @param fileLink String
|
||||||
*/
|
*/
|
||||||
fun downloadWork(fileLink: String) {
|
fun downloadWork(fileLink: String) {
|
||||||
viewBinding.button.setText(R.string.installation_ing)
|
GlobalMethod.requestStoragePermissions(this) {
|
||||||
val loadFileLayoutBinding = LoadFileLayoutBinding.inflate(layoutInflater)
|
if (it) {
|
||||||
loadFileLayoutBinding.LinearProgressIndicator.max = 100
|
viewBinding.button.setText(R.string.installation_ing)
|
||||||
var progress = 0
|
val loadFileLayoutBinding = LoadFileLayoutBinding.inflate(layoutInflater)
|
||||||
val materialDialog = MaterialDialog(this).show {
|
loadFileLayoutBinding.LinearProgressIndicator.max = 100
|
||||||
title(R.string.downlod).customView(view = loadFileLayoutBinding.root).cancelable(false)
|
var progress = 0
|
||||||
.positiveButton(R.string.dialog_close)
|
val materialDialog = MaterialDialog(this).show {
|
||||||
}
|
title(R.string.downlod).customView(view = loadFileLayoutBinding.root)
|
||||||
|
.cancelable(false)
|
||||||
|
.positiveButton(R.string.dialog_close)
|
||||||
|
}
|
||||||
|
|
||||||
val fileLoader = FileLoader.getInstantiate(fileLink, targetFile.absolutePath)
|
val fileLoader = FileLoader.getInstantiate(fileLink, targetFile.absolutePath)
|
||||||
fileLoader.download(object : ProgressResponseBody.ResponseProgressListener {
|
fileLoader.download(object : ProgressResponseBody.ResponseProgressListener {
|
||||||
override fun update(bytesRead: Long, contentLength: Long, done: Boolean) {
|
override fun update(bytesRead: Long, contentLength: Long, done: Boolean) {
|
||||||
//计算百分比并更新ProgressBar
|
//计算百分比并更新ProgressBar
|
||||||
val numberFormat = NumberFormat.getNumberInstance()
|
val numberFormat = NumberFormat.getNumberInstance()
|
||||||
numberFormat.maximumFractionDigits = 2
|
numberFormat.maximumFractionDigits = 2
|
||||||
val trueProgress =
|
val trueProgress =
|
||||||
numberFormat.format(bytesRead.toDouble() / contentLength.toDouble() * 100)
|
numberFormat.format(bytesRead.toDouble() / contentLength.toDouble() * 100)
|
||||||
progress = trueProgress.toFloat().toInt()
|
progress = trueProgress.toFloat().toInt()
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
val progressTip = String.format(tip, progress)
|
val progressTip = String.format(tip, progress)
|
||||||
if (materialDialog.isShowing) {
|
if (materialDialog.isShowing) {
|
||||||
loadFileLayoutBinding.LinearProgressIndicator.progress = progress
|
loadFileLayoutBinding.LinearProgressIndicator.progress = progress
|
||||||
loadFileLayoutBinding.tipView.text = progressTip
|
loadFileLayoutBinding.tipView.text = progressTip
|
||||||
|
}
|
||||||
|
viewBinding.button.text = progressTip
|
||||||
|
}
|
||||||
}
|
}
|
||||||
viewBinding.button.text = progressTip
|
|
||||||
}
|
override fun downloadFail(exception: Exception?) {
|
||||||
|
if (materialDialog.isShowing) {
|
||||||
|
materialDialog.dismiss()
|
||||||
|
}
|
||||||
|
viewBinding.button.setText(R.string.installation)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun downloadSuccess() {
|
||||||
|
if (materialDialog.isShowing) {
|
||||||
|
materialDialog.dismiss()
|
||||||
|
}
|
||||||
|
viewBinding.button.setText(R.string.installated)
|
||||||
|
WebMod.instance.addDownloadNum(modId)
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
override fun downloadFail(exception: Exception?) {
|
|
||||||
if (materialDialog.isShowing) {
|
|
||||||
materialDialog.dismiss()
|
|
||||||
}
|
|
||||||
viewBinding.button.setText(R.string.installation)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun downloadSuccess() {
|
|
||||||
if (materialDialog.isShowing) {
|
|
||||||
materialDialog.dismiss()
|
|
||||||
}
|
|
||||||
viewBinding.button.setText(R.string.installated)
|
|
||||||
WebMod.instance.addDownloadNum(modId)
|
|
||||||
}
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -419,7 +425,8 @@ class WebModInfoActivity : BaseActivity<ActivityWebModInfoBinding>() {
|
||||||
val icon = t.data.headIcon
|
val icon = t.data.headIcon
|
||||||
if (icon != null) {
|
if (icon != null) {
|
||||||
Glide.with(this@WebModInfoActivity)
|
Glide.with(this@WebModInfoActivity)
|
||||||
.load(ServerConfiguration.getRealLink(icon)).apply(GlobalMethod.getRequestOptions(true))
|
.load(ServerConfiguration.getRealLink(icon))
|
||||||
|
.apply(GlobalMethod.getRequestOptions(true))
|
||||||
.into(viewBinding.headIconView)
|
.into(viewBinding.headIconView)
|
||||||
}
|
}
|
||||||
viewBinding.userNameView.text = t.data.userName
|
viewBinding.userNameView.text = t.data.userName
|
||||||
|
|
|
@ -35,7 +35,7 @@ class CompileLogAdapter(val context: Context, analysisResults: MutableList<Analy
|
||||||
position: Int
|
position: Int
|
||||||
) {
|
) {
|
||||||
// viewBinding.logInfoView.movementMethod = LinkMovementMethod.getInstance()
|
// viewBinding.logInfoView.movementMethod = LinkMovementMethod.getInstance()
|
||||||
viewBinding.logInfoView.text = data.text
|
viewBinding.logInfoView.text = data.errorInfo
|
||||||
if (data.icon == null) {
|
if (data.icon == null) {
|
||||||
viewBinding.imageView.isVisible = false
|
viewBinding.imageView.isVisible = false
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -210,7 +210,7 @@ class ModActionAdapter(
|
||||||
compileConfiguration.getAnalysisResult()
|
compileConfiguration.getAnalysisResult()
|
||||||
.forEach {
|
.forEach {
|
||||||
if (it.errorType == CompileConfiguration.ErrorType.Warning) {
|
if (it.errorType == CompileConfiguration.ErrorType.Warning) {
|
||||||
warningList.add(it.text)
|
warningList.add("【" + it.lineData + "】" + it.errorInfo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FileOperator.writeFile(
|
FileOperator.writeFile(
|
||||||
|
@ -231,7 +231,7 @@ class ModActionAdapter(
|
||||||
compileConfiguration.getAnalysisResult()
|
compileConfiguration.getAnalysisResult()
|
||||||
.forEach {
|
.forEach {
|
||||||
if (it.errorType == CompileConfiguration.ErrorType.Error) {
|
if (it.errorType == CompileConfiguration.ErrorType.Error) {
|
||||||
errorList.add(it.text)
|
errorList.add("【" + it.lineData + "】" + it.errorInfo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FileOperator.writeFile(
|
FileOperator.writeFile(
|
||||||
|
|
|
@ -135,6 +135,11 @@ class ModFragment : BaseFragment<ModFragmentBinding>() {
|
||||||
) {
|
) {
|
||||||
executorService.submit {
|
executorService.submit {
|
||||||
val targetFile = modClass.modFile
|
val targetFile = modClass.modFile
|
||||||
|
val errorFolder =
|
||||||
|
File(AppSettings.dataRootDirectory + "/modErrorReport/" + modClass.modName)
|
||||||
|
if (errorFolder.exists()) {
|
||||||
|
FileOperator.delete_files(errorFolder)
|
||||||
|
}
|
||||||
val dataBasePath = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
val dataBasePath = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
requireActivity().applicationContext.dataDir.absolutePath + "/databases/"
|
requireActivity().applicationContext.dataDir.absolutePath + "/databases/"
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -13,7 +13,8 @@ import com.coldmint.rust.core.dataBean.CompileConfiguration
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
data class AnalysisResult(
|
data class AnalysisResult(
|
||||||
val text: String,
|
val lineData: String,
|
||||||
|
val errorInfo: String,
|
||||||
var icon: Drawable? = null,
|
var icon: Drawable? = null,
|
||||||
var function: ((View) -> Unit)? = null,
|
var function: ((View) -> Unit)? = null,
|
||||||
val errorType: CompileConfiguration.ErrorType
|
val errorType: CompileConfiguration.ErrorType
|
||||||
|
|
|
@ -33,8 +33,10 @@ data class CompileConfiguration(
|
||||||
private val arrayList: ArrayList<AnalysisResult> = ArrayList(),
|
private val arrayList: ArrayList<AnalysisResult> = ArrayList(),
|
||||||
private val errorIcon: Drawable? = context.getDrawable(R.drawable.error),
|
private val errorIcon: Drawable? = context.getDrawable(R.drawable.error),
|
||||||
private val warningIcon: Drawable? = context.getDrawable(R.drawable.warning),
|
private val warningIcon: Drawable? = context.getDrawable(R.drawable.warning),
|
||||||
|
private val lineData: StringBuilder = StringBuilder(),
|
||||||
//错误记录映射记录表()
|
//错误记录映射记录表()
|
||||||
private var errorRecordMap: HashMap<CodeIndex, ErrorRecord>? = null
|
private
|
||||||
|
var errorRecordMap: HashMap<CodeIndex, ErrorRecord>? = null
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
|
||||||
|
@ -54,9 +56,12 @@ data class CompileConfiguration(
|
||||||
when (codeBlockType) {
|
when (codeBlockType) {
|
||||||
CodeBlockType.Key -> {
|
CodeBlockType.Key -> {
|
||||||
keyBuilder.append(string)
|
keyBuilder.append(string)
|
||||||
|
lineData.append(string)
|
||||||
|
lineData.append(':')
|
||||||
}
|
}
|
||||||
CodeBlockType.Value -> {
|
CodeBlockType.Value -> {
|
||||||
valueBuilder.append(string)
|
valueBuilder.append(string)
|
||||||
|
lineData.append(string)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,6 +79,14 @@ data class CompileConfiguration(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取行内容
|
||||||
|
* @return String
|
||||||
|
*/
|
||||||
|
fun getLineData(): String {
|
||||||
|
return lineData.toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取Value
|
* 获取Value
|
||||||
|
@ -123,7 +136,7 @@ data class CompileConfiguration(
|
||||||
val info: String,
|
val info: String,
|
||||||
var function: ((View) -> Unit)? = null,
|
var function: ((View) -> Unit)? = null,
|
||||||
val errorType: ErrorType = ErrorType.Warning,
|
val errorType: ErrorType = ErrorType.Warning,
|
||||||
var verifyFunction: ((CompileConfiguration) -> Boolean)? = null
|
var verifyFunction: ((CompileConfiguration) -> Boolean)? = null,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -180,6 +193,7 @@ data class CompileConfiguration(
|
||||||
if (!canAddError) {
|
if (!canAddError) {
|
||||||
arrayList.add(
|
arrayList.add(
|
||||||
AnalysisResult(
|
AnalysisResult(
|
||||||
|
getLineData(),
|
||||||
"程序错误:未经许可的方法被调用。$errorRecord",
|
"程序错误:未经许可的方法被调用。$errorRecord",
|
||||||
errorIcon, errorType = ErrorType.General
|
errorIcon, errorType = ErrorType.General
|
||||||
)
|
)
|
||||||
|
@ -192,7 +206,11 @@ data class CompileConfiguration(
|
||||||
line + 1
|
line + 1
|
||||||
)
|
)
|
||||||
val analysisResult =
|
val analysisResult =
|
||||||
AnalysisResult(location + errorRecord.info, errorType = errorRecord.errorType)
|
AnalysisResult(
|
||||||
|
getLineData(),
|
||||||
|
location + errorRecord.info,
|
||||||
|
errorType = errorRecord.errorType
|
||||||
|
)
|
||||||
analysisResult.function = errorRecord.function
|
analysisResult.function = errorRecord.function
|
||||||
when (errorRecord.errorType) {
|
when (errorRecord.errorType) {
|
||||||
ErrorType.Error -> {
|
ErrorType.Error -> {
|
||||||
|
@ -218,7 +236,7 @@ data class CompileConfiguration(
|
||||||
* @param string String
|
* @param string String
|
||||||
*/
|
*/
|
||||||
fun addInfo(string: String) {
|
fun addInfo(string: String) {
|
||||||
val analysisResult = AnalysisResult(string, errorType = ErrorType.General)
|
val analysisResult = AnalysisResult(getLineData(), string, errorType = ErrorType.General)
|
||||||
arrayList.add(analysisResult)
|
arrayList.add(analysisResult)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,6 +265,7 @@ data class CompileConfiguration(
|
||||||
codeBlockType = CodeBlockType.Key
|
codeBlockType = CodeBlockType.Key
|
||||||
keyBuilder.clear()
|
keyBuilder.clear()
|
||||||
valueBuilder.clear()
|
valueBuilder.clear()
|
||||||
|
lineData.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.coldmint.rust.core.web
|
||||||
|
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
|
import android.util.Log
|
||||||
import com.coldmint.rust.core.dataBean.ApiResponse
|
import com.coldmint.rust.core.dataBean.ApiResponse
|
||||||
import com.coldmint.rust.core.dataBean.OrderDataBean
|
import com.coldmint.rust.core.dataBean.OrderDataBean
|
||||||
import com.coldmint.rust.core.dataBean.OrderListDataBean
|
import com.coldmint.rust.core.dataBean.OrderListDataBean
|
||||||
|
@ -59,6 +60,7 @@ class ActivationApp 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 finalApiResponse =
|
val finalApiResponse =
|
||||||
gson.fromJson(data, ApiResponse::class.java)
|
gson.fromJson(data, ApiResponse::class.java)
|
||||||
handler.post {
|
handler.post {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user