This commit is contained in:
ocean 2024-07-30 17:33:01 +08:00
parent 2fc9fc93b1
commit a5f6d1045b
9 changed files with 96 additions and 13 deletions

View File

@ -35,13 +35,13 @@ android {
"proguard-rules.pro" "proguard-rules.pro"
) )
} }
debug { // debug {
isMinifyEnabled = true // isMinifyEnabled = true
proguardFiles( // proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"), // getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro" // "proguard-rules.pro"
) // )
} // }
} }
compileOptions { compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8 sourceCompatibility = JavaVersion.VERSION_1_8

View File

@ -33,6 +33,7 @@ import melody.offline.music.innertube.Innertube
import melody.offline.music.innertube.requests.moPlaylistPage import melody.offline.music.innertube.requests.moPlaylistPage
import melody.offline.music.service.MyDownloadService import melody.offline.music.service.MyDownloadService
import melody.offline.music.service.ViewModelMain import melody.offline.music.service.ViewModelMain
import melody.offline.music.sp.AppStore
import melody.offline.music.util.AnalysisUtil import melody.offline.music.util.AnalysisUtil
import melody.offline.music.util.DownloadUtil import melody.offline.music.util.DownloadUtil
import melody.offline.music.util.LogTag import melody.offline.music.util.LogTag
@ -399,9 +400,19 @@ class MoListDetailsActivity : MoBaseActivity(), DetailsListAdapter.OnItemMoreCli
size = size size = size
) )
} }
myList.clear() myList.clear()
myList.addAll(mapList)
val localData = JSONObject(appStore.hideFixedSongsJson)
val namesArray = localData.getJSONArray("fixed_songs")
for (myContent in mapList) {
val videoId = myContent.videoId
for (i in 0 until namesArray.length()) {
if (videoId != (namesArray.getString(i))) {
//ID不相等添加这条数据
myList.add(myContent)
}
}
}
adapter?.notifyDataSetChanged() adapter?.notifyDataSetChanged()
} else { } else {
showNoContentUi() showNoContentUi()

View File

@ -532,8 +532,20 @@ class MoPlayDetailsActivity : MoBaseActivity(), Player.Listener {
val mediaItemAt = meController.getMediaItemAt(index) val mediaItemAt = meController.getMediaItemAt(index)
allMediaItems.add(mediaItemAt) allMediaItems.add(mediaItemAt)
} }
playList.clear() playList.clear()
playList.addAll(allMediaItems)
val localData = JSONObject(appStore.hideFixedSongsJson)
val namesArray = localData.getJSONArray("fixed_songs")
for (myContent in allMediaItems) {
val videoId = myContent.mediaId
for (i in 0 until namesArray.length()) {
if (videoId != (namesArray.getString(i))) {
//ID不相等添加这条数据
playList.add(myContent)
}
}
}
detailsPlayListAdapter?.notifyDataSetChanged() detailsPlayListAdapter?.notifyDataSetChanged()
} }
} }

View File

@ -13,6 +13,7 @@ import melody.offline.music.innertube.requests.moSearchPage
import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.isActive import kotlinx.coroutines.isActive
import kotlinx.coroutines.selects.select import kotlinx.coroutines.selects.select
import org.json.JSONObject
class MoSearchMoreActivity : MoBaseActivity() { class MoSearchMoreActivity : MoBaseActivity() {
private val requests: Channel<Request> = Channel(Channel.UNLIMITED) private val requests: Channel<Request> = Channel(Channel.UNLIMITED)
@ -129,8 +130,20 @@ class MoSearchMoreActivity : MoBaseActivity() {
binding.title.text = title binding.title.text = title
} }
currentContinuation = myResult.continuation currentContinuation = myResult.continuation
list.clear() list.clear()
list.addAll(myResult.searchResultList)
val localData = JSONObject(appStore.hideFixedSongsJson)
val namesArray = localData.getJSONArray("fixed_songs")
for (myContent in myResult.searchResultList) {
val videoId = myContent.videoId
for (i in 0 until namesArray.length()) {
if (videoId != (namesArray.getString(i))) {
//ID不相等添加这条数据
list.add(myContent)
}
}
}
} else { } else {
showNoContentUi() showNoContentUi()
} }

View File

@ -12,8 +12,10 @@ import melody.offline.music.activity.MoPlayDetailsActivity
import melody.offline.music.databinding.MusicResponsiveItemBinding import melody.offline.music.databinding.MusicResponsiveItemBinding
import melody.offline.music.innertube.models.MusicCarouselShelfRenderer import melody.offline.music.innertube.models.MusicCarouselShelfRenderer
import melody.offline.music.media.MediaControllerManager import melody.offline.music.media.MediaControllerManager
import melody.offline.music.sp.AppStore
import melody.offline.music.util.AnalysisUtil import melody.offline.music.util.AnalysisUtil
import melody.offline.music.util.LogTag import melody.offline.music.util.LogTag
import org.json.JSONObject
class ResponsiveListAdapter( class ResponsiveListAdapter(
private val context: Context, private val context: Context,

View File

@ -12,6 +12,15 @@ object Constants {
"赵六" "赵六"
] ]
} }
"""
const val KEY_HIDE_FIXED_SONGS_JSON = "key_hide_fixed_songs_json"
const val DEFAULT_HIDE_FIXED_SONGS_JSON = """
{
"fixed_songs": [
"赵六"
]
}
""" """
const val KEY_SHOULD_ENTER_MUSIC_JSON = "key_should_enter_music_json" const val KEY_SHOULD_ENTER_MUSIC_JSON = "key_should_enter_music_json"

View File

@ -136,6 +136,10 @@ class RemoteConfig {
val hideJson = value.asString() val hideJson = value.asString()
appStore.hideSingerOrSongJson = hideJson appStore.hideSingerOrSongJson = hideJson
} }
if (TextUtils.equals(Constants.KEY_HIDE_FIXED_SONGS_JSON, key)) {
val fixedSongs = value.asString()
appStore.hideFixedSongsJson = fixedSongs
}
} catch (ignore: Exception) { } catch (ignore: Exception) {
} }

View File

@ -69,11 +69,18 @@ class AppStore(context: Context) {
key = Constants.KEY_HIDE_DOWNLOAD_BTN, defaultValue = Constants.DEFAULT_HIDE_DOWNLOAD_BTN key = Constants.KEY_HIDE_DOWNLOAD_BTN, defaultValue = Constants.DEFAULT_HIDE_DOWNLOAD_BTN
) )
//根据配置隐藏对应的搜索
var hideSingerOrSongJson: String by store.string( var hideSingerOrSongJson: String by store.string(
key = Constants.KEY_HIDE_SINGER_OR_SONG_JSON, key = Constants.KEY_HIDE_SINGER_OR_SONG_JSON,
defaultValue = Constants.DEFAULT_HIDE_SINGER_OR_SONG_JSON defaultValue = Constants.DEFAULT_HIDE_SINGER_OR_SONG_JSON
) )
//根据配置隐藏对应的歌曲
var hideFixedSongsJson: String by store.string(
key = Constants.KEY_HIDE_FIXED_SONGS_JSON,
defaultValue = Constants.DEFAULT_HIDE_FIXED_SONGS_JSON
)
companion object { companion object {
private const val FILE_NAME = "music_oo_app" private const val FILE_NAME = "music_oo_app"
const val SEARCH_HISTORY = "search_history" const val SEARCH_HISTORY = "search_history"

View File

@ -2,6 +2,7 @@ package melody.offline.music.view
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.content.Context import android.content.Context
import android.view.View
import android.widget.TextView import android.widget.TextView
import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
@ -10,6 +11,7 @@ import melody.offline.music.R
import melody.offline.music.adapter.ResponsiveListAdapter import melody.offline.music.adapter.ResponsiveListAdapter
import melody.offline.music.innertube.Innertube import melody.offline.music.innertube.Innertube
import melody.offline.music.innertube.models.MusicCarouselShelfRenderer import melody.offline.music.innertube.models.MusicCarouselShelfRenderer
import melody.offline.music.sp.AppStore
import melody.offline.music.util.AnalysisUtil import melody.offline.music.util.AnalysisUtil
import melody.offline.music.util.LogTag import melody.offline.music.util.LogTag
@ -25,8 +27,31 @@ class MusicResponsiveListView(context: Context, homePage: Innertube.HomePage) :
title?.text = homePage.title title?.text = homePage.title
val rv = contentView?.findViewById<RecyclerView>(R.id.rv) val rv = contentView?.findViewById<RecyclerView>(R.id.rv)
val myContentList: MutableList<MusicCarouselShelfRenderer.Content> = mutableListOf()
adapter = ResponsiveListAdapter(context, homePage.contents) val localData = JSONObject(AppStore(context).hideFixedSongsJson)
val namesArray = localData.getJSONArray("fixed_songs")
for (myContent in homePage.contents) {
val watchEndpoint = myContent.musicResponsiveListItemRenderer
?.flexColumns
?.firstOrNull()
?.musicResponsiveListItemFlexColumnRenderer
?.text
?.runs
?.firstOrNull()
?.navigationEndpoint
?.watchEndpoint
val videoId = watchEndpoint?.videoId
for (i in 0 until namesArray.length()) {
if (videoId != (namesArray.getString(i))) {
//ID不相等添加这条数据
myContentList.add(myContent)
}
}
}
adapter = ResponsiveListAdapter(context, myContentList)
adapter?.setOnItemClickListener(object : ResponsiveListAdapter.OnItemClickListener { adapter?.setOnItemClickListener(object : ResponsiveListAdapter.OnItemClickListener {
override fun onItemClick(position: Int) { override fun onItemClick(position: Int) {
val jsonObject = JSONObject() val jsonObject = JSONObject()
@ -37,7 +62,7 @@ class MusicResponsiveListView(context: Context, homePage: Innertube.HomePage) :
}) })
adapter?.setOnItemMoreClickListener(object : ResponsiveListAdapter.OnItemMoreClickListener { adapter?.setOnItemMoreClickListener(object : ResponsiveListAdapter.OnItemMoreClickListener {
override fun onItemMoreClick(position: Int) { override fun onItemMoreClick(position: Int) {
val bean = homePage.contents[position] val bean = myContentList[position]
if (moreClickListener != null) { if (moreClickListener != null) {
moreClickListener?.onMoreClick(bean) moreClickListener?.onMoreClick(bean)
} }