Skip to content
This repository has been archived by the owner on Aug 23, 2024. It is now read-only.

Commit

Permalink
v2.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Moriafly committed Jan 24, 2021
1 parent cf4b629 commit 2de0d70
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 6 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ android {
applicationId "com.dirror.music"
minSdkVersion 23
targetSdkVersion 30
versionCode 290
versionName "2.4.0-beta"
versionCode 291
versionName "2.4.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

Expand Down
1 change: 1 addition & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

-keep class com.dirror.music.music.** { *; }
-keep class com.dirror.music.data.** { *; }
-keep class com.dirror.music.room.** { *; }

-ignorewarnings

Expand Down
Binary file renamed app/release/2.3.6.apk → app/release/2.4.0.apk
Binary file not shown.
4 changes: 2 additions & 2 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
{
"type": "SINGLE",
"filters": [],
"versionCode": 283,
"versionName": "2.3.6",
"versionCode": 291,
"versionName": "2.4.0",
"outputFile": "app-release.apk"
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@ import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.graphics.Bitmap
import android.view.View
import androidx.activity.viewModels
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.content.ContextCompat
import androidx.core.graphics.drawable.toBitmap
import androidx.recyclerview.widget.LinearLayoutManager
import com.bumptech.glide.Glide
import com.bumptech.glide.request.RequestOptions
import com.dirror.music.MyApplication
import com.dirror.music.R
import com.dirror.music.adapter.DetailPlaylistAdapter
Expand All @@ -19,8 +24,10 @@ import com.dirror.music.music.standard.SongPicture
import com.dirror.music.music.standard.data.SOURCE_NETEASE
import com.dirror.music.ui.base.BaseActivity
import com.dirror.music.ui.dialog.PlaylistDialog
import com.dirror.music.ui.dialog.SongMenuDialog
import com.dirror.music.ui.viewmodel.PlaylistViewModel
import com.dirror.music.util.*
import jp.wasabeef.glide.transformations.BlurTransformation

/**
* 新版 Playlist
Expand All @@ -37,6 +44,7 @@ class PlaylistActivity2: BaseActivity() {

// 音乐广播接收
private lateinit var musicBroadcastReceiver: MusicBroadcastReceiver
private lateinit var updatePlaylistReceiver: UpdatePlaylistReceiver

private var detailPlaylistAdapter = DetailPlaylistAdapter(ArrayList(), this)

Expand Down Expand Up @@ -72,13 +80,30 @@ class PlaylistActivity2: BaseActivity() {
playlistViewModel.updatePlaylist()

binding.rvPlaylist.layoutManager = LinearLayoutManager(this@PlaylistActivity2)

var rvPlaylistScrollY = 0
binding.rvPlaylist.setOnScrollChangeListener { _, _, _, _, oldScrollY ->
rvPlaylistScrollY += oldScrollY
if (rvPlaylistScrollY < 0) {
if (binding.titleBar.text == getString(R.string.playlist)) {
binding.titleBar.setTitleBarText(binding.tvName.text.toString())
}
} else {
binding.titleBar.setTitleBarText(getString(R.string.playlist))
}
}
}

override fun initBroadcastReceiver() {
val intentFilter = IntentFilter() // Intent 过滤器
var intentFilter = IntentFilter() // Intent 过滤器
intentFilter.addAction("com.dirror.music.MUSIC_BROADCAST") // 只接收 "com.dirror.foyou.MUSIC_BROADCAST" 标识广播
musicBroadcastReceiver = MusicBroadcastReceiver() //
registerReceiver(musicBroadcastReceiver, intentFilter) // 注册接收器

intentFilter = IntentFilter()
intentFilter.addAction(SongMenuDialog.BROADCAST_UPDATE_PLAYLIST)
updatePlaylistReceiver = UpdatePlaylistReceiver()
registerReceiver(updatePlaylistReceiver, intentFilter) // 注册接收器
}

override fun initListener() {
Expand Down Expand Up @@ -122,6 +147,9 @@ class PlaylistActivity2: BaseActivity() {
tag.observe(this@PlaylistActivity2, {
if (tag.value == PLAYLIST_TAG_MY_FAVORITE) {
binding.tvName.text = getString(R.string.my_favorite_songs)
ContextCompat.getDrawable(this@PlaylistActivity2, R.drawable.ic_bq_love_music_filter)?.let { it1 ->
setPicture(it1.toBitmap())
}
}
})
}
Expand All @@ -135,6 +163,12 @@ class PlaylistActivity2: BaseActivity() {
}
}

inner class UpdatePlaylistReceiver: BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
playlistViewModel.updatePlaylist()
}
}

private fun refreshPlayState() {
if (MyApplication.musicBinderInterface?.getPlayState() == true) {
binding.includePlay.ivPlay.setImageResource(R.drawable.ic_bq_control_pause)
Expand Down Expand Up @@ -167,6 +201,21 @@ class PlaylistActivity2: BaseActivity() {
super.onDestroy()
// 解绑
unregisterReceiver(musicBroadcastReceiver)
unregisterReceiver(updatePlaylistReceiver)
}

/**
* 设置图片
*/
private fun setPicture(bitmap: Bitmap) {
runOnMainThread {
binding.ivCover.setImageBitmap(bitmap)
Glide.with(MyApplication.context)
.load(bitmap)
.placeholder(binding.ivBackground.drawable)
.apply(RequestOptions.bitmapTransform(BlurTransformation(50, 10)))
.into(binding.ivBackground)
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class PlayerMenuMoreDialog(context: Context) : BaseBottomSheetDialog(context) {
// 播放历史
itemPlayHistory.setOnClickListener {
it.context.startActivity(Intent(it.context, PlayHistoryActivity::class.java))
dismiss()
}
// 反馈
itemFeedback.setOnClickListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.dirror.music.databinding.DialogSongMenuBinding
import com.dirror.music.music.local.MyFavorite
import com.dirror.music.music.standard.data.StandardSongData
import com.dirror.music.ui.base.BaseBottomSheetDialog
import com.dirror.music.util.BroadcastUtil
import com.dirror.music.util.toast

class SongMenuDialog
Expand All @@ -18,6 +19,10 @@ class SongMenuDialog
private val songData: StandardSongData,
private val tag: Int = PLAYLIST_TAG_NORMAL) : BaseBottomSheetDialog(context) {

companion object {
const val BROADCAST_UPDATE_PLAYLIST = "com.dirror.music.UPDATE_PLAYLIST"
}

private var binding = DialogSongMenuBinding.inflate(layoutInflater)

init {
Expand Down Expand Up @@ -49,6 +54,7 @@ class SongMenuDialog
if (tag == PLAYLIST_TAG_MY_FAVORITE) {
MyFavorite.deleteById(songData.id)
toast("删除成功")
BroadcastUtil.send(this@SongMenuDialog.context, BROADCAST_UPDATE_PLAYLIST)
dismiss()
}
}
Expand Down
14 changes: 14 additions & 0 deletions app/src/main/java/com/dirror/music/util/BroadcastUtil.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.dirror.music.util

import android.content.Context
import android.content.Intent

object BroadcastUtil {

fun send(context: Context, action: String) {
val intent = Intent(action)
intent.setPackage(context.packageName)
context.sendBroadcast(intent)
}

}
2 changes: 1 addition & 1 deletion app/src/main/java/com/dirror/music/util/UpdateUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ object UpdateUtil {
UpdateDialog(activity, updateData).show()
} else {
if (showLastedToast) {
toast("已是最新版本\n服务器版本:${updateData.code}")
toast("已是最新版本\n服务器版本:${updateData.name}(${updateData.code})")
}
}
}
Expand Down

0 comments on commit 2de0d70

Please sign in to comment.