修复崩溃问题,在代码表内添加demo字段。
This commit is contained in:
parent
b5ce0d7dc2
commit
660122ad0a
|
@ -36,6 +36,10 @@ class ImporterActivity : BaseActivity<ActivityImporterBinding>() {
|
|||
|
||||
private fun initView() {
|
||||
setTitle(R.string.file_importer)
|
||||
val account = AppSettings.getValue(AppSettings.Setting.Account, "")
|
||||
if (account.isNotBlank()) {
|
||||
firebaseAnalytics.setUserId(account)
|
||||
}
|
||||
startViewModel.initAllData()
|
||||
GlobalMethod.requestStoragePermissions(this) {
|
||||
if (it) {
|
||||
|
@ -385,53 +389,71 @@ class ImporterActivity : BaseActivity<ActivityImporterBinding>() {
|
|||
}
|
||||
return@Runnable
|
||||
}
|
||||
val parcelFileDescriptor = contentResolver.openFileDescriptor(uri!!, "r")
|
||||
if (parcelFileDescriptor != null) {
|
||||
val fileDescriptor = parcelFileDescriptor.fileDescriptor
|
||||
val inputStream = FileInputStream(fileDescriptor)
|
||||
val newFile = File(outputDirectory.absolutePath + "/" + fileName)
|
||||
if (newFile.exists()) {
|
||||
handler.post {
|
||||
MaterialAlertDialogBuilder(this).setTitle(R.string.import_name)
|
||||
.setCancelable(false)
|
||||
.setMessage(
|
||||
String.format(
|
||||
getString(R.string.covers_the_import_mod),
|
||||
fileName
|
||||
)
|
||||
).setPositiveButton(
|
||||
R.string.dialog_ok
|
||||
) { dialog, which ->
|
||||
newFile.delete()
|
||||
importMod(outputDirectory)
|
||||
}
|
||||
.setNegativeButton(R.string.dialog_cancel, null).show()
|
||||
try {
|
||||
val parcelFileDescriptor = contentResolver.openFileDescriptor(uri!!, "r")
|
||||
if (parcelFileDescriptor != null) {
|
||||
val fileDescriptor = parcelFileDescriptor.fileDescriptor
|
||||
val inputStream = FileInputStream(fileDescriptor)
|
||||
val newFile = File(outputDirectory.absolutePath + "/" + fileName)
|
||||
if (newFile.exists()) {
|
||||
handler.post {
|
||||
MaterialAlertDialogBuilder(this).setTitle(R.string.import_name)
|
||||
.setCancelable(false)
|
||||
.setMessage(
|
||||
String.format(
|
||||
getString(R.string.covers_the_import_mod),
|
||||
fileName
|
||||
)
|
||||
).setPositiveButton(
|
||||
R.string.dialog_ok
|
||||
) { dialog, which ->
|
||||
newFile.delete()
|
||||
importMod(outputDirectory)
|
||||
}
|
||||
.setNegativeButton(R.string.dialog_cancel, null).show()
|
||||
}
|
||||
return@Runnable
|
||||
}
|
||||
return@Runnable
|
||||
}
|
||||
handler.post {
|
||||
viewBinding.okButton.setText(R.string.importing)
|
||||
viewBinding.okButton.setBackgroundColor(
|
||||
GlobalMethod.getThemeColor(
|
||||
this,
|
||||
R.attr.colorPrimaryVariant
|
||||
)
|
||||
)
|
||||
}
|
||||
val result = copyFile(inputStream, newFile)
|
||||
if (result) {
|
||||
handler.post {
|
||||
viewBinding.okButton.setText(R.string.importing)
|
||||
viewBinding.okButton.setBackgroundColor(
|
||||
GlobalMethod.getThemeColor(
|
||||
this,
|
||||
R.attr.colorPrimaryVariant
|
||||
)
|
||||
)
|
||||
}
|
||||
val result = copyFile(inputStream, newFile)
|
||||
if (result) {
|
||||
handler.post {
|
||||
handler.post {
|
||||
viewBinding.okButton.setBackgroundColor(
|
||||
GlobalMethod.getColorPrimary(
|
||||
this
|
||||
)
|
||||
)
|
||||
viewBinding.okButton.isVisible = false
|
||||
Snackbar.make(
|
||||
viewBinding.okButton,
|
||||
String.format(
|
||||
getString(R.string.import_complete),
|
||||
fileName
|
||||
), Snackbar.LENGTH_LONG
|
||||
).show()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
handler.post {
|
||||
viewBinding.okButton.setBackgroundColor(
|
||||
GlobalMethod.getColorPrimary(
|
||||
this
|
||||
)
|
||||
)
|
||||
viewBinding.okButton.isVisible = false
|
||||
viewBinding.okButton.setText(R.string.import_name)
|
||||
Snackbar.make(
|
||||
viewBinding.okButton,
|
||||
String.format(
|
||||
getString(R.string.import_complete),
|
||||
getString(R.string.import_failed),
|
||||
fileName
|
||||
), Snackbar.LENGTH_LONG
|
||||
).show()
|
||||
|
@ -439,26 +461,16 @@ class ImporterActivity : BaseActivity<ActivityImporterBinding>() {
|
|||
}
|
||||
} else {
|
||||
handler.post {
|
||||
viewBinding.okButton.setBackgroundColor(
|
||||
GlobalMethod.getColorPrimary(
|
||||
this
|
||||
)
|
||||
)
|
||||
viewBinding.okButton.setText(R.string.import_name)
|
||||
Snackbar.make(
|
||||
viewBinding.okButton,
|
||||
String.format(
|
||||
getString(R.string.import_failed),
|
||||
fileName
|
||||
), Snackbar.LENGTH_LONG
|
||||
).show()
|
||||
Toast.makeText(this, "parcelFileDescriptor为空", Toast.LENGTH_SHORT)
|
||||
.show()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
handler.post {
|
||||
Toast.makeText(this, "parcelFileDescriptor为空", Toast.LENGTH_SHORT)
|
||||
.show()
|
||||
}
|
||||
}catch (e:Exception){
|
||||
e.printStackTrace()
|
||||
Snackbar.make(
|
||||
viewBinding.okButton,
|
||||
e.toString(), Snackbar.LENGTH_LONG
|
||||
).show()
|
||||
}
|
||||
}).start()
|
||||
}
|
||||
|
|
|
@ -21,9 +21,20 @@ import java.util.*
|
|||
|
||||
class RustApplication : Application() {
|
||||
|
||||
companion object {
|
||||
private lateinit var instanceObject: RustApplication
|
||||
|
||||
/**
|
||||
* 获取实例对象
|
||||
*/
|
||||
fun getInstance(): RustApplication {
|
||||
return instanceObject
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
instanceObject = this
|
||||
AppSettings.initAppSettings(this)
|
||||
//动态颜色
|
||||
val options = DynamicColorsOptions.Builder()
|
||||
|
@ -35,7 +46,7 @@ class RustApplication : Application() {
|
|||
)
|
||||
}.build()
|
||||
DynamicColors.applyToActivitiesIfAvailable(this, options)
|
||||
LogCat.attachObserver(object : LogCatObserver{
|
||||
LogCat.attachObserver(object : LogCatObserver {
|
||||
override fun onReceiveLog(msg: String) {
|
||||
Firebase.crashlytics.log(msg)
|
||||
}
|
||||
|
|
|
@ -28,7 +28,8 @@ class UserInfoFragment : BaseFragment<FragmentUserInfoBinding>() {
|
|||
* 加载列表
|
||||
*/
|
||||
fun loadRecyclerView(permission: Int) {
|
||||
val layoutManager = GridLayoutManager(requireContext(), 4)
|
||||
|
||||
val layoutManager = GridLayoutManager(RustApplication.getInstance(), 4)
|
||||
viewBinding.recyclerView.layoutManager = layoutManager
|
||||
val dataList = ArrayList<CommunityServiceInfo>()
|
||||
dataList.add(CommunityServiceInfo(R.string.work_management, R.drawable.work_management))
|
||||
|
@ -45,7 +46,7 @@ class UserInfoFragment : BaseFragment<FragmentUserInfoBinding>() {
|
|||
dataList.add(CommunityServiceInfo(R.string.order_manager, R.drawable.order_manager))
|
||||
}
|
||||
}
|
||||
val adapter = CommunityServiceAdapter(requireContext(), dataList)
|
||||
val adapter = CommunityServiceAdapter(RustApplication.getInstance(), dataList)
|
||||
adapter.setItemEvent { i, itemServiceBinding, viewHolder, communityServiceInfo ->
|
||||
itemServiceBinding.root.setOnClickListener {
|
||||
when (communityServiceInfo.titleRes) {
|
||||
|
|
|
@ -47,6 +47,9 @@ object GlobalMethod {
|
|||
const val DEFAULT_GAME_PACKAGE = "com.corrodinggames.rts"
|
||||
const val DEBUG_SIGN = "963dfd616924b27f9247a35e45bc130a"
|
||||
const val RELEASE_SIGN = "5320b24894fe7ed449842a81a2dfceda"
|
||||
const val Event_LOGOUT = "logOut"
|
||||
const val Event_LOGIN = "logIn"
|
||||
|
||||
|
||||
/**
|
||||
* 转dp
|
||||
|
|
|
@ -13,6 +13,7 @@ data class CodeInfo(
|
|||
@PrimaryKey val code: String,
|
||||
@ColumnInfo(name = "translate") val translate: String,
|
||||
@ColumnInfo(name = "description") val description: String,
|
||||
@ColumnInfo(name = "demo") val demo: String = "",
|
||||
@ColumnInfo(name = "type") val type: String,
|
||||
@ColumnInfo(name = "add_version") val addVersion: Int,
|
||||
@ColumnInfo(name = "remove_version") val removeVersion: Int = 1,
|
||||
|
|
|
@ -145,25 +145,29 @@ object AppOperator {
|
|||
*/
|
||||
@SuppressLint("QueryPermissionsNeeded")
|
||||
fun openApp(context: Context, packageName: String) {
|
||||
var mainAct: String? = null
|
||||
val pkgMag = context.packageManager
|
||||
val intent = Intent(Intent.ACTION_MAIN)
|
||||
intent.addCategory(Intent.CATEGORY_LAUNCHER)
|
||||
intent.flags = Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED or Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
@SuppressLint("WrongConstant") val list =
|
||||
pkgMag.queryIntentActivities(intent, PackageManager.GET_ACTIVITIES)
|
||||
for (i in list.indices) {
|
||||
val info = list[i]
|
||||
if (info.activityInfo.packageName == packageName) {
|
||||
mainAct = info.activityInfo.name
|
||||
break
|
||||
try {
|
||||
var mainAct: String? = null
|
||||
val pkgMag = context.packageManager
|
||||
val intent = Intent(Intent.ACTION_MAIN)
|
||||
intent.addCategory(Intent.CATEGORY_LAUNCHER)
|
||||
intent.flags = Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED or Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
@SuppressLint("WrongConstant") val list =
|
||||
pkgMag.queryIntentActivities(intent, PackageManager.GET_ACTIVITIES)
|
||||
for (i in list.indices) {
|
||||
val info = list[i]
|
||||
if (info.activityInfo.packageName == packageName) {
|
||||
mainAct = info.activityInfo.name
|
||||
break
|
||||
}
|
||||
}
|
||||
if (mainAct!!.isEmpty()) {
|
||||
return
|
||||
}
|
||||
intent.component = ComponentName(packageName, mainAct)
|
||||
context.startActivity(intent)
|
||||
}catch (e:Exception){
|
||||
e.printStackTrace()
|
||||
}
|
||||
if (mainAct!!.isEmpty()) {
|
||||
return
|
||||
}
|
||||
intent.component = ComponentName(packageName, mainAct)
|
||||
context.startActivity(intent)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue
Block a user