Skip to content

Commit

Permalink
[maro/#33] feat :: 7주차 구현 완료
Browse files Browse the repository at this point in the history
  • Loading branch information
leesumin0526 committed May 28, 2024
1 parent 31d11f9 commit f0a5e98
Show file tree
Hide file tree
Showing 23 changed files with 706 additions and 403 deletions.
69 changes: 61 additions & 8 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions UMC_6th/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ android {
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
jvmTarget = JavaVersion.VERSION_1_8.toString()
}

}

dependencies {

implementation("com.google.android.material:material:1.10.0")
implementation("androidx.room:room-migration:2.6.0")
implementation("androidx.room:room-runtime:2.6.0")
kapt("androidx.room:room-compiler:2.6.0")
Expand Down
14 changes: 10 additions & 4 deletions UMC_6th/app/src/main/java/com/example/umc_6th/Album.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
package com.example.umc_6th

import androidx.room.Entity
import androidx.room.PrimaryKey
import java.util.ArrayList

@Entity(tableName = "AlbumTable")
data class Album(
var title : String? = "",
var singer : String? = "",
var coverImage : Int? = null,
var songs: ArrayList<Song>? = null // 앨범 수록곡
@PrimaryKey(autoGenerate = false)
var id: Int = 0,
var title: String? = "",
var singer: String? = "",
var coverImg: Int? = null
)
42 changes: 32 additions & 10 deletions UMC_6th/app/src/main/java/com/example/umc_6th/AlbumFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.fragment.app.Fragment
import androidx.fragment.app.setFragmentResultListener
import com.example.umc_6th.databinding.FragmentAlbumBinding
import com.example.umc_6th.databinding.FragmentAlbumBinding.inflate
import com.example.umc_6th.databinding.FragmentSongBinding
import com.google.android.material.tabs.TabLayoutMediator
import com.google.gson.Gson

class AlbumFragment : Fragment() {
lateinit var binding: FragmentAlbumBinding

lateinit var binding : FragmentAlbumBinding
private var gson : Gson = Gson()

private val information = arrayListOf("수록곡","상세정보","영상")
Expand All @@ -23,10 +22,10 @@ class AlbumFragment : Fragment() {
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = FragmentAlbumBinding.inflate(inflater,container,false)
binding = inflate(inflater,container,false)

val albumToJson = arguments?.getString("album")
val album = gson.fromJson(albumToJson, Album::class.java)
val albumJson = arguments?.getString("album")
val album = gson.fromJson(albumJson, Album::class.java)
setInit(album)

binding.albumBackIv.setOnClickListener{
Expand All @@ -51,13 +50,36 @@ class AlbumFragment : Fragment() {
tab.text = information[position]
}.attach()


// binding.songLalacLayout.setOnClickListener{
// Toast.makeText(activity,"LILAC",Toast.LENGTH_SHORT).show()
// }
//
// binding.songFluLayout.setOnClickListener {
// Toast.makeText(activity,"FLU", Toast.LENGTH_SHORT).show()
// }
//
// binding.songCoinLayout.setOnClickListener {
// Toast.makeText(activity,"Coin", Toast.LENGTH_SHORT).show()
// }
//
// binding.songSpringLayout.setOnClickListener {
// Toast.makeText(activity,"봄 안녕 봄", Toast.LENGTH_SHORT).show()
// }
//
// binding.songCelebrityLayout.setOnClickListener {
// Toast.makeText(activity,"Celebrity", Toast.LENGTH_SHORT).show()
// }
//
// binding.songSingLayout.setOnClickListener {
// Toast.makeText(activity,"돌림노래 (Feat. DEAN)", Toast.LENGTH_SHORT).show()
// }
return binding.root
}

private fun setInit(album : Album) {
binding.albumAlbumIv.setImageResource(album.coverImage!!)
private fun setInit(album: Album){
binding.albumAlbumIv.setImageResource(album.coverImg!!)
binding.albumMusicTitleTv.text = album.title.toString()
binding.albumSingerNameTv.text = album.singer.toString()
}

}
}
64 changes: 38 additions & 26 deletions UMC_6th/app/src/main/java/com/example/umc_6th/AlbumRVAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,44 +5,56 @@ import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.example.umc_6th.databinding.ItemAlbumBinding

class AlbumRVAdapter(private val albumList: ArrayList<Album>) : RecyclerView.Adapter<AlbumRVAdapter.ViewHolder>(){
inner class ViewHolder(val binding: ItemAlbumBinding): RecyclerView.ViewHolder(binding.root){
fun bind(album: Album){
binding.itemAlbumTitleTv.text = album.title
binding.itemAlbumSingerTv.text = album.singer
binding.itemAlbumCoverImgIv.setImageResource(album.coverImage!!)
}
class AlbumRVAdapter(private val albumList:ArrayList<Album>) : RecyclerView.Adapter<AlbumRVAdapter.ViewHolder>() {

interface MyItemClickListener{
fun onItemClick(album: Album)
fun onRemoveAlbum(position: Int)
fun onPlayAlbum(album: Album)
}

override fun onCreateViewHolder(viewGroup: ViewGroup, viewType: Int): AlbumRVAdapter.ViewHolder {
val binding: ItemAlbumBinding = ItemAlbumBinding.inflate(LayoutInflater.from(viewGroup.context), viewGroup, false)
return ViewHolder(binding)
interface CommunicationInterface{
fun sendData(album: Album)
}

private lateinit var mItemClickListener : MyItemClickListener
fun setMyItemClickListener(itemClickListener: MyItemClickListener){
this.mItemClickListener = itemClickListener
}

override fun onBindViewHolder(holder: AlbumRVAdapter.ViewHolder, position: Int) {
holder.bind(albumList[position])
holder.itemView.setOnClickListener {
itemClickListener.onItemClick(albumList[position])
}
fun addItem(album: Album){
albumList.add(album)
notifyDataSetChanged()
}

holder.binding.itemAlbumPlayImgIv.setOnClickListener{
itemClickListener.onPlayAlbum(albumList[position])
}
fun removeItem(position: Int){
albumList.removeAt(position)
notifyDataSetChanged()
}

override fun getItemCount(): Int = albumList.size
override fun onCreateViewHolder(viewGroup: ViewGroup, viewType: Int): AlbumRVAdapter.ViewHolder {
val binding: ItemAlbumBinding = ItemAlbumBinding.inflate(LayoutInflater.from(viewGroup.context),viewGroup,false)

interface OnItemClickListener {
fun onItemClick(album : Album)
fun onPlayAlbum(album: Album)
return ViewHolder(binding)
}

private lateinit var itemClickListener : OnItemClickListener

fun setItemClickListener(onItemClickListener: OnItemClickListener) {
this.itemClickListener = onItemClickListener
override fun onBindViewHolder(holder: AlbumRVAdapter.ViewHolder, position: Int) {
holder.bind(albumList[position])
holder.itemView.setOnClickListener{
mItemClickListener.onItemClick(albumList[position]) }
// holder.binding.itemAlbumTitleTv.setOnClickListener{mItemClickListener.onRemoveAlbum(position)}
holder.binding.itemAlbumPlayImgIv.setOnClickListener{
mItemClickListener.onPlayAlbum(albumList[position])
}
}

override fun getItemCount(): Int = albumList.size

inner class ViewHolder(val binding:ItemAlbumBinding): RecyclerView.ViewHolder(binding.root){
fun bind(album: Album){
binding.itemAlbumTitleTv.text = album.title
binding.itemAlbumSingerTv.text = album.singer
binding.itemAlbumCoverImgIv.setImageResource(album.coverImg!!)
}
}
}
16 changes: 0 additions & 16 deletions UMC_6th/app/src/main/java/com/example/umc_6th/AlbumVPAdpter.kt

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@

package com.example.umc_6th

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import com.example.umc_6th.databinding.FragmentDetailBinding

class DetailFragment : Fragment() {
class DetailFragment : Fragment(){

lateinit var binding: FragmentDetailBinding
lateinit var binding : FragmentDetailBinding

override fun onCreateView(
inflater: LayoutInflater,
Expand All @@ -20,4 +21,4 @@ class DetailFragment : Fragment() {

return binding.root
}
}
}
Loading

0 comments on commit f0a5e98

Please sign in to comment.