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