修复bug。
This commit is contained in:
parent
df2a59334c
commit
c1c5d8a210
|
@ -371,7 +371,7 @@ class EditModInfoActivity : BaseActivity<ActivityEditModInfoBinding>() {
|
|||
iconFile.delete()
|
||||
}
|
||||
val bitmap = BitmapFactory.decodeFile(newIconFile.absolutePath)
|
||||
if (bitmap.height == bitmap.width) {
|
||||
if (bitmap != null && bitmap.height == bitmap.width) {
|
||||
if (FileOperator.copyFile(newIconFile, iconFile)) {
|
||||
Glide.with(this@EditModInfoActivity).load(newIconFile)
|
||||
.apply(GlobalMethod.getRequestOptions())
|
||||
|
|
|
@ -17,6 +17,7 @@ import com.coldmint.rust.core.tool.FileOperator
|
|||
import com.coldmint.rust.core.tool.FileOperator.copyFile
|
||||
import com.coldmint.rust.pro.databinding.ActivityImporterBinding
|
||||
import com.coldmint.rust.pro.tool.AppSettings
|
||||
import com.coldmint.rust.pro.tool.EventRecord
|
||||
import com.coldmint.rust.pro.tool.GlobalMethod
|
||||
import com.coldmint.rust.pro.viewmodel.StartViewModel
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
|
@ -38,7 +39,7 @@ class ImporterActivity : BaseActivity<ActivityImporterBinding>() {
|
|||
setTitle(R.string.file_importer)
|
||||
val account = AppSettings.getValue(AppSettings.Setting.Account, "")
|
||||
if (account.isNotBlank()) {
|
||||
firebaseAnalytics.setUserId(account)
|
||||
EventRecord.setUserId(account)
|
||||
}
|
||||
startViewModel.initAllData()
|
||||
GlobalMethod.requestStoragePermissions(this) {
|
||||
|
|
|
@ -30,6 +30,7 @@ import com.coldmint.rust.pro.base.BaseActivity
|
|||
import com.coldmint.rust.pro.databinding.ActivityLoginBinding
|
||||
import com.coldmint.rust.pro.tool.AppSettings
|
||||
import com.coldmint.rust.pro.tool.EmailAutoCompleteHelper
|
||||
import com.coldmint.rust.pro.tool.EventRecord
|
||||
import com.coldmint.rust.pro.tool.GlobalMethod
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import com.gyf.immersionbar.ktx.immersionBar
|
||||
|
@ -124,10 +125,8 @@ class LoginActivity : BaseActivity<ActivityLoginBinding>() {
|
|||
viewBinding.button.setText(R.string.login)
|
||||
if (userData.code == ServerConfiguration.Success_Code) {
|
||||
//记录登录事件
|
||||
val bundle = Bundle()
|
||||
bundle.putString("账号", userData.data.account)
|
||||
firebaseAnalytics.logEvent(GlobalMethod.Event_LOGIN, bundle)
|
||||
firebaseAnalytics.setUserId(userData.data.account)
|
||||
EventRecord.setUserId(account)
|
||||
EventRecord.login()
|
||||
AppSettings.forceSetValue(AppSettings.Setting.PassWord, passWord)
|
||||
AppSettings.forceSetValue(
|
||||
AppSettings.Setting.Account,
|
||||
|
|
|
@ -39,6 +39,7 @@ 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.tool.EventRecord
|
||||
import com.coldmint.rust.pro.viewmodel.StartViewModel
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
|
@ -642,7 +643,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||
opIntent.putExtra("userId", account)
|
||||
startActivity(opIntent)
|
||||
}
|
||||
firebaseAnalytics.setUserId(account)
|
||||
EventRecord.setUserId(account)
|
||||
}
|
||||
|
||||
startViewModel.needLoginLiveData.observe(this) {
|
||||
|
|
|
@ -22,6 +22,7 @@ import com.coldmint.rust.core.interfaces.LineParserEvent
|
|||
import com.coldmint.rust.core.tool.FileFinder2
|
||||
import com.coldmint.rust.core.tool.FileOperator
|
||||
import com.coldmint.rust.pro.databinding.ActivityPackBinding
|
||||
import com.coldmint.rust.pro.tool.EventRecord
|
||||
import java.io.File
|
||||
import java.lang.StringBuilder
|
||||
import java.text.SimpleDateFormat
|
||||
|
@ -307,7 +308,10 @@ class PackActivity : BaseActivity<ActivityPackBinding>() {
|
|||
}
|
||||
|
||||
override fun whenCompressionComplete(result: Boolean) {
|
||||
handler.post { resetButton(result) }
|
||||
handler.post {
|
||||
EventRecord.packMod(targetFile.name)
|
||||
resetButton(result)
|
||||
}
|
||||
}
|
||||
}, object : CompressionInterceptor {
|
||||
override val sourceFileRule: String
|
||||
|
|
|
@ -34,7 +34,6 @@ import java.util.*
|
|||
abstract class BaseActivity<ViewBingType : ViewBinding> :
|
||||
AppCompatActivity() {
|
||||
|
||||
protected lateinit var firebaseAnalytics: FirebaseAnalytics
|
||||
|
||||
abstract fun whenCreateActivity(savedInstanceState: Bundle?, canUseView: Boolean)
|
||||
|
||||
|
@ -50,7 +49,6 @@ abstract class BaseActivity<ViewBingType : ViewBinding> :
|
|||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
firebaseAnalytics = Firebase.analytics
|
||||
WindowCompat.setDecorFitsSystemWindows(window, false)
|
||||
super.onCreate(savedInstanceState)
|
||||
whenCreateActivity(savedInstanceState, false)
|
||||
|
|
|
@ -16,6 +16,7 @@ abstract class BaseFragment<T : ViewBinding> : Fragment() {
|
|||
protected lateinit var firebaseAnalytics: FirebaseAnalytics
|
||||
|
||||
val viewBinding: T by lazy {
|
||||
val layoutInflater = LayoutInflater.from(requireActivity())
|
||||
getViewBindingObject(layoutInflater)
|
||||
}
|
||||
|
||||
|
|
|
@ -164,6 +164,7 @@ class InstalledTemplateFragment : BaseFragment<FragmentInstalledTemplateBinding>
|
|||
}
|
||||
}
|
||||
viewModel.setLoadCallBack {
|
||||
if (isAdded) {
|
||||
mTemplateAdapter = TemplateAdapter(
|
||||
requireContext(),
|
||||
viewModel.getGroupData(),
|
||||
|
@ -175,6 +176,7 @@ class InstalledTemplateFragment : BaseFragment<FragmentInstalledTemplateBinding>
|
|||
mTemplateAdapter.setCreatePath(path)
|
||||
LogCat.d("创建目录观察者", "模板适配器设置目录为${path}。")
|
||||
}
|
||||
}
|
||||
viewModel.loadTemplate(requireContext())
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ import com.coldmint.rust.pro.base.BaseFragment
|
|||
import com.coldmint.rust.pro.databean.CommunityServiceInfo
|
||||
import com.coldmint.rust.pro.databinding.FragmentUserInfoBinding
|
||||
import com.coldmint.rust.pro.tool.AppSettings
|
||||
import com.coldmint.rust.pro.tool.EventRecord
|
||||
import com.coldmint.rust.pro.tool.GlobalMethod
|
||||
|
||||
class UserInfoFragment : BaseFragment<FragmentUserInfoBinding>() {
|
||||
|
@ -169,10 +170,8 @@ class UserInfoFragment : BaseFragment<FragmentUserInfoBinding>() {
|
|||
|
||||
override fun whenViewCreated(inflater: LayoutInflater, savedInstanceState: Bundle?) {
|
||||
viewBinding.logOutButton.setOnClickListener {
|
||||
val bundle = Bundle()
|
||||
bundle.putString("账号", account)
|
||||
firebaseAnalytics.setUserId(null);
|
||||
firebaseAnalytics.logEvent(GlobalMethod.Event_LOGOUT, bundle)
|
||||
EventRecord.logout()
|
||||
EventRecord.setUserId(null)
|
||||
AppSettings.setValue(AppSettings.Setting.LoginStatus, false)
|
||||
// GlobalMethod.isActive = false
|
||||
AppSettings.setValue(
|
||||
|
|
56
app/src/main/java/com/coldmint/rust/pro/tool/EventRecord.kt
Normal file
56
app/src/main/java/com/coldmint/rust/pro/tool/EventRecord.kt
Normal file
|
@ -0,0 +1,56 @@
|
|||
package com.coldmint.rust.pro.tool
|
||||
|
||||
import android.os.Bundle
|
||||
import com.google.firebase.analytics.ktx.analytics
|
||||
import com.google.firebase.ktx.Firebase
|
||||
|
||||
/**
|
||||
* 事件记录类
|
||||
*/
|
||||
object EventRecord {
|
||||
const val Event_LOGOUT = "logout"
|
||||
|
||||
//打包Mod
|
||||
const val Event_PACK_MOD = "pack_mod"
|
||||
const val Event_LOGIN = "login"
|
||||
|
||||
private val firebaseAnalytics = Firebase.analytics
|
||||
private var account: String? = null
|
||||
|
||||
/**
|
||||
* 设置用户id
|
||||
*/
|
||||
fun setUserId(userId: String?) {
|
||||
account = userId
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录
|
||||
*/
|
||||
fun login() {
|
||||
val bundle = Bundle()
|
||||
bundle.putString("account", account)
|
||||
firebaseAnalytics.logEvent(Event_LOGIN, bundle)
|
||||
firebaseAnalytics.setUserId(account)
|
||||
}
|
||||
|
||||
/**
|
||||
* 登出
|
||||
*/
|
||||
fun logout() {
|
||||
val bundle = Bundle()
|
||||
bundle.putString("account", account)
|
||||
firebaseAnalytics.logEvent(Event_LOGOUT, bundle)
|
||||
}
|
||||
|
||||
/**
|
||||
* 打包模组
|
||||
*/
|
||||
fun packMod(targetFileName: String) {
|
||||
val bundle = Bundle()
|
||||
bundle.putString("account", account)
|
||||
bundle.putString("fileName", targetFileName)
|
||||
firebaseAnalytics.logEvent(Event_PACK_MOD, bundle)
|
||||
firebaseAnalytics.setUserId(account)
|
||||
}
|
||||
}
|
|
@ -47,8 +47,7 @@ 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"
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -116,11 +116,16 @@ class TemplateMakerViewModel : BaseViewModel() {
|
|||
TemplatePhp.instance.getTemplate(path ?: "", object : ApiCallBack<WebTemplateData> {
|
||||
override fun onResponse(t: WebTemplateData) {
|
||||
if (t.code == ServerConfiguration.Success_Code) {
|
||||
try {
|
||||
json = JSONObject(t.data.content)
|
||||
val code = json!!.getString("data")
|
||||
val jsonArray = json!!.getJSONArray("action")
|
||||
parsingSourceCode(code, jsonArray, func)
|
||||
LogCat.d(key, "已加载远程模板 ${path} 。")
|
||||
}catch (e:Exception){
|
||||
e.printStackTrace()
|
||||
LogCat.d(key, "远程模板加载异常。"+e.toString())
|
||||
}
|
||||
} else {
|
||||
LogCat.e(key, "远程模板响应: ${t.message}")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user