-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix playback failed because of substring display time when pausing
- Loading branch information
Showing
18 changed files
with
160 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 4 additions & 2 deletions
6
...loudmusic/src/main/java/moe/lz233/meizugravity/cloudmusic/logic/network/ServiceCreator.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...music/logic/network/RequestInterceptor.kt → ...network/interceptor/RequestInterceptor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
neteasecloudmusic/src/main/java/moe/lz233/meizugravity/cloudmusic/utils/ktx/Boolean.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package moe.lz233.meizugravity.cloudmusic.utils.ktx | ||
|
||
fun Boolean.toInt() = if (this) 1 else 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
neteasecloudmusic/src/main/java/moe/lz233/meizugravity/cloudmusic/view/ChanSwitch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package moe.lz233.meizugravity.cloudmusic.view | ||
|
||
import android.content.Context | ||
import android.content.res.TypedArray | ||
import android.util.AttributeSet | ||
import androidx.appcompat.widget.AppCompatButton | ||
import androidx.core.content.ContextCompat | ||
import moe.lz233.meizugravity.cloudmusic.App | ||
import moe.lz233.meizugravity.cloudmusic.R | ||
import moe.lz233.meizugravity.cloudmusic.utils.ktx.toInt | ||
|
||
class ChanSwitch @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : AppCompatButton(context, attrs) { | ||
|
||
private var valueType = -1 | ||
private var key: String? | ||
private var value: List<String> | ||
private var valueDefault: String | ||
private var defaultBoolean = false | ||
private var baseText: String? | ||
private var optionText: List<String> | ||
|
||
init { | ||
background = ContextCompat.getDrawable(getContext(), R.drawable.button_background) | ||
val typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.ChanSwitch) | ||
key = typedArray.getString(R.styleable.ChanSwitch_key) | ||
value = typedArray.getValueAndType().split('|') | ||
valueDefault = value[typedArray.getInteger(R.styleable.ChanSwitch_valueDefault, 0)] | ||
baseText = typedArray.getString(R.styleable.ChanSwitch_baseText) | ||
optionText = typedArray.getString(R.styleable.ChanSwitch_optionText).toString().split('|') | ||
refreshText() | ||
setOnClickListener { | ||
when (valueType) { | ||
0 -> App.editor.putBoolean(key, !App.sp.getBoolean(key, defaultBoolean)).commit() | ||
1 -> App.editor.putString(key, value[(value.indexOf(App.sp.getString(key, valueDefault) + 1)) % value.size]).commit() | ||
2 -> App.editor.putInt(key, value[(value.indexOf(App.sp.getInt(key, valueDefault.toInt()).toString()) + 1) % value.size].toInt()).commit() | ||
} | ||
refreshText() | ||
} | ||
typedArray.recycle() | ||
} | ||
|
||
private fun refreshText() { | ||
text = when (valueType) { | ||
0 -> "$baseText:${optionText[1 - App.sp.getBoolean(key, defaultBoolean).toInt()]}" | ||
2 -> "$baseText:${optionText[value.indexOf(App.sp.getInt(key, valueDefault.toInt()).toString())]}" | ||
else -> "$baseText:${optionText[value.indexOf(App.sp.getString(key, valueDefault))]}" | ||
} | ||
} | ||
|
||
private fun TypedArray.getValueAndType(): String = when { | ||
getBoolean(R.styleable.ChanSwitch_valueIsBoolean, false) -> { | ||
valueType = 0 | ||
defaultBoolean = getBoolean(R.styleable.ChanSwitch_valueDefaultBoolean, false) | ||
"" | ||
} | ||
getString(R.styleable.ChanSwitch_valueString) != null -> { | ||
valueType = 1 | ||
getString(R.styleable.ChanSwitch_valueString).toString() | ||
} | ||
getString(R.styleable.ChanSwitch_valueInteger) != null -> { | ||
valueType = 2 | ||
getString(R.styleable.ChanSwitch_valueInteger).toString() | ||
} | ||
else -> { | ||
valueType = -1 | ||
"" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,13 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources></resources> | ||
<resources> | ||
<declare-styleable name="ChanSwitch"> | ||
<attr name="key" format="string" /> | ||
<attr name="valueIsBoolean" format="boolean" /> | ||
<attr name="valueString" format="string" /> | ||
<attr name="valueInteger" format="string" /> | ||
<attr name="valueDefault" format="integer" /> | ||
<attr name="valueDefaultBoolean" format="boolean" /> | ||
<attr name="baseText" format="string" /> | ||
<attr name="optionText" format="string" /> | ||
</declare-styleable> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters