This repository has been archived by the owner on Apr 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d9516ad
commit 9eeafba
Showing
10 changed files
with
125 additions
and
95 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
24 changes: 0 additions & 24 deletions
24
app/src/main/kotlin/com/absinthe/kage/adapter/DeviceAdapter.kt
This file was deleted.
Oops, something went wrong.
28 changes: 0 additions & 28 deletions
28
app/src/main/kotlin/com/absinthe/kage/adapter/MusicListAdapter.kt
This file was deleted.
Oops, something went wrong.
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
46 changes: 46 additions & 0 deletions
46
app/src/main/kotlin/com/absinthe/kage/viewholder/DeviceInfoItemViewBinder.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,46 @@ | ||
package com.absinthe.kage.viewholder | ||
|
||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.Button | ||
import android.widget.TextView | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.absinthe.kage.R | ||
import com.absinthe.kage.device.DeviceManager | ||
import com.absinthe.kage.device.model.DeviceInfo | ||
import com.drakeet.multitype.ItemViewBinder | ||
|
||
class DeviceInfoItemViewBinder : ItemViewBinder<DeviceInfo, DeviceInfoItemViewBinder.ViewHolder>() { | ||
|
||
override fun onCreateViewHolder(inflater: LayoutInflater, parent: ViewGroup): ViewHolder { | ||
val root = inflater.inflate(R.layout.item_device, parent, false) | ||
return ViewHolder(root) | ||
} | ||
|
||
override fun onBindViewHolder(holder: ViewHolder, item: DeviceInfo) { | ||
holder.deviceName.text = item.name | ||
holder.deviceIp.text = item.ip | ||
|
||
when (item.state) { | ||
DeviceInfo.STATE_IDLE -> holder.btnConnect.text = holder.itemView.context.getString(R.string.connect_state_connect) | ||
DeviceInfo.STATE_CONNECTING -> holder.btnConnect.text = holder.itemView.context.getString(R.string.connect_state_connecting) | ||
DeviceInfo.STATE_CONNECTED -> holder.btnConnect.text = holder.itemView.context.getString(R.string.connect_state_connected) | ||
} | ||
|
||
holder.btnConnect.setOnClickListener { | ||
if (!item.isConnected) { | ||
DeviceManager.onlineDevice(item) | ||
DeviceManager.connectDevice(item) | ||
} else { | ||
DeviceManager.disConnectDevice() | ||
} | ||
} | ||
} | ||
|
||
class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { | ||
val deviceName: TextView = itemView.findViewById(R.id.tv_device_name) | ||
val deviceIp: TextView = itemView.findViewById(R.id.tv_device_ip) | ||
val btnConnect: Button = itemView.findViewById(R.id.btn_connect) | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
app/src/main/kotlin/com/absinthe/kage/viewholder/LocalMusicViewBinder.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,53 @@ | ||
package com.absinthe.kage.viewholder | ||
|
||
import android.content.Intent | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.ImageView | ||
import android.widget.TextView | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.absinthe.kage.R | ||
import com.absinthe.kage.media.audio.LocalMusic | ||
import com.absinthe.kage.media.audio.MusicHelper | ||
import com.absinthe.kage.ui.media.MusicActivity | ||
import com.blankj.utilcode.util.ConvertUtils | ||
import com.bumptech.glide.Glide | ||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners | ||
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions | ||
import com.bumptech.glide.request.RequestOptions | ||
import com.drakeet.multitype.ItemViewBinder | ||
|
||
class LocalMusicViewBinder : ItemViewBinder<LocalMusic, LocalMusicViewBinder.ViewHolder>() { | ||
|
||
override fun onCreateViewHolder(inflater: LayoutInflater, parent: ViewGroup): ViewHolder { | ||
val root = inflater.inflate(R.layout.item_music, parent, false) | ||
return ViewHolder(root) | ||
} | ||
|
||
override fun onBindViewHolder(holder: ViewHolder, item: LocalMusic) { | ||
holder.musicName.text = item.title | ||
holder.artist.text = item.artist | ||
|
||
Glide.with(holder.itemView.context) | ||
.load(MusicHelper.getAlbumArt(item.albumId.toLong())) | ||
.transition(DrawableTransitionOptions.withCrossFade()) | ||
.apply(RequestOptions.bitmapTransform(RoundedCorners(ConvertUtils.dp2px(3f)))) | ||
.placeholder(R.drawable.ic_album) | ||
.into(holder.ivAlbum) | ||
|
||
holder.itemView.setOnClickListener { | ||
val intent = Intent(holder.itemView.context, MusicActivity::class.java).apply { | ||
putExtra(MusicActivity.EXTRA_MUSIC_INFO, item) | ||
putExtra(MusicActivity.EXTRA_DEVICE_TYPE, MusicActivity.TYPE_SENDER) | ||
} | ||
holder.itemView.context.startActivity(intent) | ||
} | ||
} | ||
|
||
class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { | ||
val musicName: TextView = itemView.findViewById(R.id.tv_music_name) | ||
val artist: TextView = itemView.findViewById(R.id.tv_artist) | ||
val ivAlbum: ImageView = itemView.findViewById(R.id.iv_album) | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...he/kage/adapter/SpacesItemDecoration.java → ...kage/viewholder/SpacesItemDecoration.java
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