Code Cleanup
This commit is contained in:
parent
170e51a595
commit
8607b0d4ee
6 changed files with 12 additions and 34 deletions
|
@ -142,7 +142,7 @@ dependencies {
|
||||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version"
|
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version"
|
||||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlin_coroutines_version"
|
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlin_coroutines_version"
|
||||||
|
|
||||||
def koin_version = '3.1.4'
|
def koin_version = '3.1.5'
|
||||||
implementation "io.insert-koin:koin-core:$koin_version"
|
implementation "io.insert-koin:koin-core:$koin_version"
|
||||||
implementation "io.insert-koin:koin-android:$koin_version"
|
implementation "io.insert-koin:koin-android:$koin_version"
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ class MusicSeekSkipTouchListener(val activity: FragmentActivity, val next: Boole
|
||||||
|
|
||||||
var job: Job? = null
|
var job: Job? = null
|
||||||
var counter = 0
|
var counter = 0
|
||||||
|
var wasSeeking = false
|
||||||
|
|
||||||
private val gestureDetector = GestureDetector(activity, object :
|
private val gestureDetector = GestureDetector(activity, object :
|
||||||
GestureDetector.SimpleOnGestureListener() {
|
GestureDetector.SimpleOnGestureListener() {
|
||||||
|
@ -26,6 +27,7 @@ class MusicSeekSkipTouchListener(val activity: FragmentActivity, val next: Boole
|
||||||
counter = 0
|
counter = 0
|
||||||
while (isActive) {
|
while (isActive) {
|
||||||
delay(500)
|
delay(500)
|
||||||
|
wasSeeking = true
|
||||||
var seekingDuration = MusicPlayerRemote.songProgressMillis
|
var seekingDuration = MusicPlayerRemote.songProgressMillis
|
||||||
if (next) {
|
if (next) {
|
||||||
seekingDuration += 5000 * (counter.floorDiv(2) + 1)
|
seekingDuration += 5000 * (counter.floorDiv(2) + 1)
|
||||||
|
@ -38,15 +40,6 @@ class MusicSeekSkipTouchListener(val activity: FragmentActivity, val next: Boole
|
||||||
}
|
}
|
||||||
return super.onDown(e)
|
return super.onDown(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onSingleTapConfirmed(e: MotionEvent?): Boolean {
|
|
||||||
if (next) {
|
|
||||||
MusicPlayerRemote.playNextSong()
|
|
||||||
} else {
|
|
||||||
MusicPlayerRemote.back()
|
|
||||||
}
|
|
||||||
return super.onSingleTapConfirmed(e)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
@SuppressLint("ClickableViewAccessibility")
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
|
@ -54,6 +47,14 @@ class MusicSeekSkipTouchListener(val activity: FragmentActivity, val next: Boole
|
||||||
val action = event?.actionMasked
|
val action = event?.actionMasked
|
||||||
if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
|
if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
|
||||||
job?.cancel()
|
job?.cancel()
|
||||||
|
if (!wasSeeking) {
|
||||||
|
if (next) {
|
||||||
|
MusicPlayerRemote.playNextSong()
|
||||||
|
} else {
|
||||||
|
MusicPlayerRemote.back()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
wasSeeking = false
|
||||||
}
|
}
|
||||||
return gestureDetector.onTouchEvent(event)
|
return gestureDetector.onTouchEvent(event)
|
||||||
}
|
}
|
||||||
|
|
|
@ -245,6 +245,7 @@ class HomeFragment :
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadSuggestions(songs: List<Song>) {
|
private fun loadSuggestions(songs: List<Song>) {
|
||||||
|
if (songs.isEmpty()) return
|
||||||
val images = listOf(
|
val images = listOf(
|
||||||
binding.suggestions.image1,
|
binding.suggestions.image1,
|
||||||
binding.suggestions.image2,
|
binding.suggestions.image2,
|
||||||
|
|
|
@ -147,21 +147,6 @@ class PlayerAlbumCoverFragment : AbsMusicServiceFragment(R.layout.fragment_playe
|
||||||
setOnClickListener {
|
setOnClickListener {
|
||||||
goToLyrics(requireActivity())
|
goToLyrics(requireActivity())
|
||||||
}
|
}
|
||||||
setOnFlingXListener { velocityX ->
|
|
||||||
when {
|
|
||||||
velocityX < 0 -> {
|
|
||||||
MusicPlayerRemote.playNextSong()
|
|
||||||
true
|
|
||||||
}
|
|
||||||
velocityX > 0 -> {
|
|
||||||
MusicPlayerRemote.playPreviousSong()
|
|
||||||
true
|
|
||||||
}
|
|
||||||
else -> {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,6 @@ class CoverLrcView @JvmOverloads constructor(
|
||||||
private var mDefaultLabel: String? = null
|
private var mDefaultLabel: String? = null
|
||||||
private var mLrcPadding = 0f
|
private var mLrcPadding = 0f
|
||||||
private var mOnPlayClickListener: OnPlayClickListener? = null
|
private var mOnPlayClickListener: OnPlayClickListener? = null
|
||||||
private var mOnFlingXListener: OnFlingXListener? = null
|
|
||||||
private var mAnimator: ValueAnimator? = null
|
private var mAnimator: ValueAnimator? = null
|
||||||
private var mGestureDetector: GestureDetector? = null
|
private var mGestureDetector: GestureDetector? = null
|
||||||
private var mScroller: Scroller? = null
|
private var mScroller: Scroller? = null
|
||||||
|
@ -132,9 +131,6 @@ class CoverLrcView @JvmOverloads constructor(
|
||||||
velocityX: Float,
|
velocityX: Float,
|
||||||
velocityY: Float
|
velocityY: Float
|
||||||
): Boolean {
|
): Boolean {
|
||||||
if (mOnFlingXListener != null && abs(velocityX) > abs(velocityY)) {
|
|
||||||
return mOnFlingXListener!!.onFlingX(velocityX)
|
|
||||||
}
|
|
||||||
if (hasLrc()) {
|
if (hasLrc()) {
|
||||||
mScroller!!.fling(
|
mScroller!!.fling(
|
||||||
0,
|
0,
|
||||||
|
@ -320,10 +316,6 @@ class CoverLrcView @JvmOverloads constructor(
|
||||||
mOnPlayClickListener = onPlayClickListener
|
mOnPlayClickListener = onPlayClickListener
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setOnFlingXListener(onFlingXListener: OnFlingXListener) {
|
|
||||||
mOnFlingXListener = onFlingXListener
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 设置歌词为空时屏幕中央显示的文字,如“暂无歌词” */
|
/** 设置歌词为空时屏幕中央显示的文字,如“暂无歌词” */
|
||||||
fun setLabel(label: String?) {
|
fun setLabel(label: String?) {
|
||||||
runOnUi {
|
runOnUi {
|
||||||
|
|
|
@ -8,7 +8,6 @@ buildscript {
|
||||||
preference_version = '1.2.0-rc01'
|
preference_version = '1.2.0-rc01'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
google()
|
google()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue