修复崩溃问题,添加FireBase的事件分析。
This commit is contained in:
parent
7a4b00199e
commit
9322cedcad
13
.gitignore
vendored
13
.gitignore
vendored
|
@ -48,3 +48,16 @@ Thumbs.db
|
|||
*.mov
|
||||
*.wmv
|
||||
|
||||
# Files for the Dalvik VM
|
||||
*.dex
|
||||
|
||||
# Java class files
|
||||
*.class
|
||||
|
||||
# Gradle build files
|
||||
.gradle/
|
||||
build/
|
||||
release/
|
||||
|
||||
# Local configuration file (sdk path, etc)
|
||||
local.properties
|
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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -123,6 +123,11 @@ class LoginActivity : BaseActivity<ActivityLoginBinding>() {
|
|||
isLogin = false
|
||||
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)
|
||||
AppSettings.forceSetValue(AppSettings.Setting.PassWord, passWord)
|
||||
AppSettings.forceSetValue(
|
||||
AppSettings.Setting.Account,
|
||||
|
|
|
@ -642,6 +642,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||
opIntent.putExtra("userId", account)
|
||||
startActivity(opIntent)
|
||||
}
|
||||
firebaseAnalytics.setUserId(account)
|
||||
}
|
||||
|
||||
startViewModel.needLoginLiveData.observe(this) {
|
||||
|
|
|
@ -197,10 +197,10 @@ class UserHomePageActivity : BaseActivity<ActivityUserHomePageBinding>() {
|
|||
|
||||
val gender = spaceInfoData.data.gender
|
||||
if (gender > 0) {
|
||||
Glide.with(this).load(R.drawable.boy).apply(GlobalMethod.getRequestOptions())
|
||||
Glide.with(application).load(R.drawable.boy).apply(GlobalMethod.getRequestOptions())
|
||||
.into(viewBinding.genderView)
|
||||
} else {
|
||||
Glide.with(this).load(R.drawable.girl).apply(GlobalMethod.getRequestOptions())
|
||||
Glide.with(application).load(R.drawable.girl).apply(GlobalMethod.getRequestOptions())
|
||||
.into(viewBinding.genderView)
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@ class UnitAdapter(
|
|||
) : BaseAdapter<UnitItemBinding, SourceFile>(context, dataList), PopupTextProvider {
|
||||
|
||||
|
||||
|
||||
private val language: String by lazy {
|
||||
AppSettings.getValue(
|
||||
AppSettings.Setting.AppLanguage,
|
||||
|
@ -72,20 +71,14 @@ class UnitAdapter(
|
|||
}
|
||||
viewBinding.unitTimeView.text = formatter.format(sourceFile.file.lastModified())
|
||||
val imageView = viewBinding.iconView
|
||||
val drawable = sourceFile.getIcon()
|
||||
if (drawable != null) {
|
||||
Glide.with(context).load(drawable).apply(
|
||||
RequestOptions().override(200).diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
||||
).into(imageView)
|
||||
val path = sourceFile.getIcon()
|
||||
if (path != null) {
|
||||
Glide.with(context).load(path).apply(GlobalMethod.getRequestOptions()).into(imageView)
|
||||
} else {
|
||||
Glide.with(context).load(
|
||||
GlobalMethod.tintDrawable(
|
||||
Glide.with(context).load( GlobalMethod.tintDrawable(
|
||||
context.getDrawable(R.drawable.image),
|
||||
ColorStateList.valueOf(GlobalMethod.getColorPrimary(context))
|
||||
)
|
||||
).apply(
|
||||
RequestOptions().override(200).diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
||||
).into(imageView)
|
||||
)).apply(GlobalMethod.getRequestOptions().override(200)).into(imageView)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
viewBinding.unitDescribeView.text = e.toString()
|
||||
|
@ -93,7 +86,11 @@ class UnitAdapter(
|
|||
}
|
||||
|
||||
override fun getPopupText(position: Int): String {
|
||||
return getInitial(dataList[position].getName(language)).toString()
|
||||
return if (dataList.size > position) {
|
||||
getInitial(dataList[position].getName(language)).toString()
|
||||
} else {
|
||||
"#"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -24,6 +24,9 @@ import com.google.android.material.color.DynamicColors
|
|||
import com.google.android.material.color.DynamicColorsOptions
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import com.google.android.material.textfield.TextInputLayout
|
||||
import com.google.firebase.analytics.FirebaseAnalytics
|
||||
import com.google.firebase.analytics.ktx.analytics
|
||||
import com.google.firebase.ktx.Firebase
|
||||
import com.hjq.language.MultiLanguages
|
||||
import java.util.*
|
||||
|
||||
|
@ -31,6 +34,7 @@ import java.util.*
|
|||
abstract class BaseActivity<ViewBingType : ViewBinding> :
|
||||
AppCompatActivity() {
|
||||
|
||||
protected lateinit var firebaseAnalytics: FirebaseAnalytics
|
||||
|
||||
abstract fun whenCreateActivity(savedInstanceState: Bundle?, canUseView: Boolean)
|
||||
|
||||
|
@ -46,6 +50,7 @@ abstract class BaseActivity<ViewBingType : ViewBinding> :
|
|||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
firebaseAnalytics = Firebase.analytics
|
||||
WindowCompat.setDecorFitsSystemWindows(window, false)
|
||||
super.onCreate(savedInstanceState)
|
||||
whenCreateActivity(savedInstanceState, false)
|
||||
|
|
|
@ -8,8 +8,12 @@ import android.widget.Toast
|
|||
import androidx.fragment.app.Fragment
|
||||
import androidx.viewbinding.ViewBinding
|
||||
import com.coldmint.rust.pro.tool.AppSettings
|
||||
import com.google.firebase.analytics.FirebaseAnalytics
|
||||
import com.google.firebase.analytics.ktx.analytics
|
||||
import com.google.firebase.ktx.Firebase
|
||||
|
||||
abstract class BaseFragment<T : ViewBinding> : Fragment() {
|
||||
protected lateinit var firebaseAnalytics: FirebaseAnalytics
|
||||
|
||||
val viewBinding: T by lazy {
|
||||
getViewBindingObject(layoutInflater)
|
||||
|
@ -53,6 +57,7 @@ abstract class BaseFragment<T : ViewBinding> : Fragment() {
|
|||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
firebaseAnalytics = Firebase.analytics
|
||||
whenViewCreated(layoutInflater, savedInstanceState)
|
||||
}
|
||||
}
|
|
@ -25,6 +25,9 @@ class CommunityFragment : BaseFragment<FragmentCommunityBinding>() {
|
|||
|
||||
|
||||
fun loadTab() {
|
||||
if (!isAdded) {
|
||||
return
|
||||
}
|
||||
val mainActivity = requireActivity() as MainActivity
|
||||
val tabLayout: TabLayout? = mainActivity.tabLayout
|
||||
if (tabLayout != null) {
|
||||
|
@ -52,9 +55,6 @@ class CommunityFragment : BaseFragment<FragmentCommunityBinding>() {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
override fun getViewBindingObject(layoutInflater: LayoutInflater): FragmentCommunityBinding {
|
||||
return FragmentCommunityBinding.inflate(layoutInflater)
|
||||
}
|
||||
|
|
|
@ -168,6 +168,10 @@ 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)
|
||||
AppSettings.setValue(AppSettings.Setting.LoginStatus, false)
|
||||
// GlobalMethod.isActive = false
|
||||
AppSettings.setValue(
|
||||
|
|
|
@ -99,7 +99,6 @@ class EditViewModel(application: Application) : BaseAndroidViewModel(application
|
|||
fun getNowOpenFilePath(): String {
|
||||
val temPath = nowFilePath
|
||||
return if (temPath == null) {
|
||||
throw NullPointerException("无法获取最近打开的文件,请先打开文件")
|
||||
""
|
||||
} else {
|
||||
temPath
|
||||
|
|
|
@ -119,10 +119,10 @@ class SourceFile(text: String) {
|
|||
fun findResourceFiles(value: String?, checkExists: Boolean): Array<File>? {
|
||||
var value = value
|
||||
if (modclass == null || !this::file.isInitialized) {
|
||||
DebugHelper.printLog("搜索资源文件","无法搜索,因为没有初始化文件或模组类。", isError = true)
|
||||
DebugHelper.printLog("搜索资源文件", "无法搜索,因为没有初始化文件或模组类。", isError = true)
|
||||
return null
|
||||
}
|
||||
DebugHelper.printLog("搜索资源文件","准备开始 文件路径${file.absolutePath}值${value}")
|
||||
DebugHelper.printLog("搜索资源文件", "准备开始 文件路径${file.absolutePath}值${value}")
|
||||
val none = "NONE"
|
||||
val auto = "AUTO"
|
||||
val shared = "SHARED:"
|
||||
|
@ -139,15 +139,22 @@ class SourceFile(text: String) {
|
|||
if (checkExists) {
|
||||
if (target.exists()) {
|
||||
result.add(target)
|
||||
}else{
|
||||
DebugHelper.printLog("搜索资源文件","文件${file.absolutePath}解析Root路径为 ${target.absolutePath} 文件不存在!", isError = true)
|
||||
} else {
|
||||
DebugHelper.printLog(
|
||||
"搜索资源文件",
|
||||
"文件${file.absolutePath}解析Root路径为 ${target.absolutePath} 文件不存在!",
|
||||
isError = true
|
||||
)
|
||||
}
|
||||
} else {
|
||||
result.add(target)
|
||||
}
|
||||
DebugHelper.printLog("搜索资源文件","文件${file.absolutePath}解析Root路径为 ${target.absolutePath}")
|
||||
DebugHelper.printLog(
|
||||
"搜索资源文件",
|
||||
"文件${file.absolutePath}解析Root路径为 ${target.absolutePath}"
|
||||
)
|
||||
} else if (value.contains(",")) {
|
||||
DebugHelper.printLog("搜索资源文件","文件${file.absolutePath}启用多文件解析。")
|
||||
DebugHelper.printLog("搜索资源文件", "文件${file.absolutePath}启用多文件解析。")
|
||||
val lineParser = LineParser(value)
|
||||
lineParser.needTrim = true
|
||||
lineParser.symbol = ","
|
||||
|
@ -163,13 +170,20 @@ class SourceFile(text: String) {
|
|||
if (checkExists) {
|
||||
if (target.exists()) {
|
||||
result.add(target)
|
||||
}else{
|
||||
DebugHelper.printLog("搜索资源文件","文件${file.absolutePath} 多文件分割 第${lineNum}个文件 ${target.absolutePath} 不存在!", isError = true)
|
||||
} else {
|
||||
DebugHelper.printLog(
|
||||
"搜索资源文件",
|
||||
"文件${file.absolutePath} 多文件分割 第${lineNum}个文件 ${target.absolutePath} 不存在!",
|
||||
isError = true
|
||||
)
|
||||
}
|
||||
} else {
|
||||
result.add(target)
|
||||
}
|
||||
DebugHelper.printLog("搜索资源文件","文件${file.absolutePath} 多文件分割 第${lineNum}个文件 ${target.absolutePath}")
|
||||
DebugHelper.printLog(
|
||||
"搜索资源文件",
|
||||
"文件${file.absolutePath} 多文件分割 第${lineNum}个文件 ${target.absolutePath}"
|
||||
)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
@ -183,13 +197,20 @@ class SourceFile(text: String) {
|
|||
if (checkExists) {
|
||||
if (target.exists()) {
|
||||
result.add(target)
|
||||
}else{
|
||||
DebugHelper.printLog("搜索资源文件","文件${file.absolutePath} 解析常规文件 ${target.absolutePath} 不存在!", isError = true)
|
||||
} else {
|
||||
DebugHelper.printLog(
|
||||
"搜索资源文件",
|
||||
"文件${file.absolutePath} 解析常规文件 ${target.absolutePath} 不存在!",
|
||||
isError = true
|
||||
)
|
||||
}
|
||||
} else {
|
||||
result.add(target)
|
||||
}
|
||||
DebugHelper.printLog("搜索资源文件","文件${file.absolutePath} 解析常规文件 ${target.absolutePath}")
|
||||
DebugHelper.printLog(
|
||||
"搜索资源文件",
|
||||
"文件${file.absolutePath} 解析常规文件 ${target.absolutePath}"
|
||||
)
|
||||
}
|
||||
if (result.size > 0) {
|
||||
result.toTypedArray()
|
||||
|
@ -459,6 +480,7 @@ class SourceFile(text: String) {
|
|||
* @param section 节
|
||||
*/
|
||||
fun writeValueOrAddKey(key: String, value: String, section: String) {
|
||||
|
||||
//先尝试改
|
||||
val modify = writeValueFromSection(key, value, section)
|
||||
if (!modify) {
|
||||
|
@ -481,6 +503,7 @@ class SourceFile(text: String) {
|
|||
* @return Boolean 是否修改成功
|
||||
*/
|
||||
fun writeValueFromSection(key: String, value: String, section: String): Boolean {
|
||||
try {
|
||||
var key = key
|
||||
var section = section
|
||||
key = "\n$key:"
|
||||
|
@ -518,6 +541,10 @@ class SourceFile(text: String) {
|
|||
return true
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
return false
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
|
@ -525,12 +552,12 @@ class SourceFile(text: String) {
|
|||
* 获取单位图标
|
||||
* @return Drawable?
|
||||
*/
|
||||
fun getIcon(): Drawable? {
|
||||
var mainIcon: Drawable? = null
|
||||
fun getIcon(): String? {
|
||||
var mainIcon: String? = null
|
||||
val baseImages = findResourceFilesFromSection("image", "graphics", true)
|
||||
if (baseImages != null && baseImages.isNotEmpty()) {
|
||||
val file = baseImages[0]
|
||||
mainIcon = Drawable.createFromPath(file.absolutePath)
|
||||
mainIcon = file.absolutePath
|
||||
}
|
||||
return mainIcon
|
||||
}
|
||||
|
|
|
@ -117,8 +117,6 @@ object FileOperator {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 调用app打开文件
|
||||
*
|
||||
|
@ -638,6 +636,7 @@ object FileOperator {
|
|||
if (target.exists()) {
|
||||
result = if (target.isDirectory) {
|
||||
val files = target.listFiles()
|
||||
if (files != null) {
|
||||
for (mfile in files) {
|
||||
if (mfile.isDirectory) {
|
||||
delete_files(mfile)
|
||||
|
@ -645,6 +644,7 @@ object FileOperator {
|
|||
mfile.delete()
|
||||
}
|
||||
}
|
||||
}
|
||||
target.delete()
|
||||
} else {
|
||||
target.delete()
|
||||
|
|
Loading…
Reference in New Issue
Block a user