From 1d38c635ddf4736f70a7c1d915490e8c96c2feb4 Mon Sep 17 00:00:00 2001
From: ocean <503259349@qq.com>
Date: Thu, 18 Jul 2024 18:19:02 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=BA=9Bbug?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/proguard-rules.pro | 4 +
app/src/main/AndroidManifest.xml | 4 +
.../music/activity/MoSingerDetailsActivity.kt | 18 ++++-
.../offline/music/fragment/SearchFragment.kt | 79 ++++++++++---------
4 files changed, 63 insertions(+), 42 deletions(-)
diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro
index b074b2c..f28f3a6 100644
--- a/app/proguard-rules.pro
+++ b/app/proguard-rules.pro
@@ -45,3 +45,7 @@
-keep class * extends com.google.gson.TypeAdapter {
*;
}
+
+-keep class org.chromium.** { *; }
+-keep class androidx.media3.datasource.cronet.** { *; }
+-keep class androidx.media3.exoplayer.scheduler.PlatformScheduler$PlatformSchedulerService { *; }
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 5eda91a..9ae704b 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -124,6 +124,10 @@
+
\ No newline at end of file
diff --git a/app/src/main/java/melody/offline/music/activity/MoSingerDetailsActivity.kt b/app/src/main/java/melody/offline/music/activity/MoSingerDetailsActivity.kt
index 1f7a6be..c48fd4f 100644
--- a/app/src/main/java/melody/offline/music/activity/MoSingerDetailsActivity.kt
+++ b/app/src/main/java/melody/offline/music/activity/MoSingerDetailsActivity.kt
@@ -92,10 +92,17 @@ class MoSingerDetailsActivity : MoBaseActivity() {
showLoadingUi()
Innertube.moSingerListPage(browseId)
?.onSuccess {
+ if (isFinishing || isDestroyed) {
+ return
+ }
showDataUi()
- Glide.with(this)
- .load(it.thumbnail)
- .into(binding.singerImg)
+ try {
+ Glide.with(this)
+ .load(it.thumbnail)
+ .into(binding.singerImg)
+ } catch (e: Exception) {
+ e.printStackTrace()
+ }
binding.singerName.text = it.title
if (it.description.isNullOrEmpty()) {
binding.singerDesc.visibility = View.GONE
@@ -144,4 +151,9 @@ class MoSingerDetailsActivity : MoBaseActivity() {
binding.loadingLayout.visibility = View.GONE
binding.noContentLayout.visibility = View.VISIBLE
}
+
+ override fun onDestroy() {
+ super.onDestroy()
+ Glide.with(this).clear(binding.singerImg)
+ }
}
\ No newline at end of file
diff --git a/app/src/main/java/melody/offline/music/fragment/SearchFragment.kt b/app/src/main/java/melody/offline/music/fragment/SearchFragment.kt
index b9da6d8..7ca236e 100644
--- a/app/src/main/java/melody/offline/music/fragment/SearchFragment.kt
+++ b/app/src/main/java/melody/offline/music/fragment/SearchFragment.kt
@@ -194,53 +194,54 @@ class SearchFragment : MoBaseFragment(), TextWatcher,
}
is Request.SearchData -> {
- val input = it.input
- if (input.isNotEmpty()) {
- AnalysisUtil.logEvent(AnalysisUtil.SEARCH_TRIGGER)
- LolAdWrapper.shared.showAdTiming(
- requireActivity(), AdPlacement.INST_SEARCH
- )
- showLoadingLayout()
- binding.contentLayout.removeAllViews()
- binding.searchEdit.clearFocus()
+ if (isAdded) {
+ val input = it.input
+ if (input.isNotEmpty()) {
+ AnalysisUtil.logEvent(AnalysisUtil.SEARCH_TRIGGER)
+ LolAdWrapper.shared.showAdTiming(
+ requireActivity(), AdPlacement.INST_SEARCH
+ )
+ showLoadingLayout()
+ binding.contentLayout.removeAllViews()
+ binding.searchEdit.clearFocus()
- searchHistorySet.clear()
- searchHistorySet.addAll(appStore.searchHistoryStore)
- if (!appStore.searchHistoryStore.contains(input)) {//把不存在的记录保存到集合中
- searchHistorySet.add(input)
- }
- appStore.searchHistoryStore = searchHistorySet
- updateHistoryUi()
- AnalysisUtil.logEvent(AnalysisUtil.SEARCH_RESULT_PV)
- Innertube.moSearchPage(SearchBody(query = input))
- ?.onSuccess { result ->
- AnalysisUtil.logEvent(AnalysisUtil.SEARCH_RESULT_SUCCESS_ACTION)
- showResultContent()
- for (dataPage: Innertube.SearchDataPage in result) {
- LogTag.LogD(TAG, "moSearchPage dataPage->$dataPage")
- if (dataPage.type == 1) {//type为1的是最佳结果。
- binding.contentLayout.addView(
- SearchResultOptimalView(
- requireActivity(), dataPage
- )
- )
- } else if (dataPage.type == 2) {//type为2的是其他搜索结果。
- if (dataPage.searchResultList.isNotEmpty()) {//如何数据集合为空就不添加view
+ searchHistorySet.clear()
+ searchHistorySet.addAll(appStore.searchHistoryStore)
+ if (!appStore.searchHistoryStore.contains(input)) {//把不存在的记录保存到集合中
+ searchHistorySet.add(input)
+ }
+ appStore.searchHistoryStore = searchHistorySet
+ updateHistoryUi()
+ AnalysisUtil.logEvent(AnalysisUtil.SEARCH_RESULT_PV)
+ Innertube.moSearchPage(SearchBody(query = input))
+ ?.onSuccess { result ->
+ AnalysisUtil.logEvent(AnalysisUtil.SEARCH_RESULT_SUCCESS_ACTION)
+ showResultContent()
+ for (dataPage: Innertube.SearchDataPage in result) {
+ LogTag.LogD(TAG, "moSearchPage dataPage->$dataPage")
+ if (dataPage.type == 1) {//type为1的是最佳结果。
binding.contentLayout.addView(
- SearchResultOtherView(
+ SearchResultOptimalView(
requireActivity(), dataPage
)
)
+ } else if (dataPage.type == 2) {//type为2的是其他搜索结果。
+ if (dataPage.searchResultList.isNotEmpty()) {//如何数据集合为空就不添加view
+ binding.contentLayout.addView(
+ SearchResultOtherView(
+ requireActivity(), dataPage
+ )
+ )
+ }
}
}
+ }?.onFailure {
+ showNoContentLayout()
}
- }?.onFailure {
- showNoContentLayout()
- }
-
- LolAdWrapper.shared.loadAdIfNotCached(
- requireActivity(), AdPlacement.INST_SEARCH
- )
+ LolAdWrapper.shared.loadAdIfNotCached(
+ requireActivity(), AdPlacement.INST_SEARCH
+ )
+ }
}
}
}