-
Notifications
You must be signed in to change notification settings - Fork 0
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
6aee73c
commit 3ace96d
Showing
9 changed files
with
275 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.example.umc_6th | ||
|
||
data class Album( | ||
var title : String? = "", | ||
var singer : String? = "", | ||
var coverImage : Int? = null, | ||
var songs: ArrayList<Song>? = null // 앨범 수록곡 | ||
) |
48 changes: 48 additions & 0 deletions
48
UMC_6th/app/src/main/java/com/example/umc_6th/AlbumRVAdapter.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,48 @@ | ||
package com.example.umc_6th | ||
|
||
import android.view.LayoutInflater | ||
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!!) | ||
} | ||
} | ||
|
||
override fun onCreateViewHolder(viewGroup: ViewGroup, viewType: Int): AlbumRVAdapter.ViewHolder { | ||
val binding: ItemAlbumBinding = ItemAlbumBinding.inflate(LayoutInflater.from(viewGroup.context), viewGroup, false) | ||
return ViewHolder(binding) | ||
} | ||
|
||
|
||
override fun onBindViewHolder(holder: AlbumRVAdapter.ViewHolder, position: Int) { | ||
holder.bind(albumList[position]) | ||
holder.itemView.setOnClickListener { | ||
itemClickListener.onItemClick(albumList[position]) | ||
} | ||
|
||
holder.binding.itemAlbumPlayImgIv.setOnClickListener{ | ||
itemClickListener.onItemClick(albumList[position]) | ||
} | ||
} | ||
|
||
override fun getItemCount(): Int = albumList.size | ||
|
||
interface OnItemClickListener { | ||
fun onItemClick(album : Album) | ||
fun onPlayAlbum(album: Album) | ||
} | ||
|
||
private lateinit var itemClickListener : OnItemClickListener | ||
|
||
fun setItemClickListener(onItemClickListener: OnItemClickListener) { | ||
this.itemClickListener = onItemClickListener | ||
} | ||
|
||
|
||
} |
5 changes: 5 additions & 0 deletions
5
UMC_6th/app/src/main/java/com/example/umc_6th/CommunicationInterface.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,5 @@ | ||
package com.example.umc_6th | ||
|
||
interface CommunicationInterface { | ||
fun sendData(album : Album) | ||
} |
76 changes: 76 additions & 0 deletions
76
UMC_6th/app/src/main/java/com/example/umc_6th/LockerAlbumRVAdapter.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,76 @@ | ||
package com.example.umc_6th | ||
|
||
import android.util.SparseBooleanArray | ||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.example.umc_6th.databinding.ItemLockerAlbumBinding | ||
|
||
class LockerAlbumRVAdapter (private val albumList: ArrayList<Album>) : RecyclerView.Adapter<LockerAlbumRVAdapter.ViewHolder>() { | ||
private val switchStatus = SparseBooleanArray() | ||
|
||
override fun onCreateViewHolder( | ||
parent: ViewGroup, | ||
viewType: Int): | ||
LockerAlbumRVAdapter.ViewHolder { | ||
val binding : ItemLockerAlbumBinding = ItemLockerAlbumBinding.inflate(LayoutInflater.from(parent.context), parent, false) | ||
|
||
return ViewHolder(binding) | ||
} | ||
|
||
override fun onBindViewHolder(holder: LockerAlbumRVAdapter.ViewHolder, position: Int) { | ||
holder.bind(albumList[position]) | ||
holder.itemView.setOnClickListener { | ||
itemClickListener.onItemClick(albumList[position]) | ||
} | ||
|
||
holder.binding.itemLockerAlbumMoreIv.setOnClickListener { | ||
itemClickListener.onRemoveAlbum(position) | ||
} | ||
|
||
val switch = holder.binding.switchRV | ||
switch.isChecked = switchStatus[position] | ||
switch.setOnClickListener { | ||
if (switch.isChecked) { | ||
switchStatus.put(position, true) | ||
} | ||
else { | ||
switchStatus.put(position, false) | ||
} | ||
|
||
notifyItemChanged(position) | ||
} | ||
} | ||
|
||
override fun getItemCount(): Int = albumList.size | ||
|
||
inner class ViewHolder(val binding: ItemLockerAlbumBinding) : RecyclerView.ViewHolder(binding.root){ | ||
fun bind(album : Album){ | ||
binding.itemLockerAlbumTitleTv.text = album.title | ||
binding.itemLockerAlbumSingerTv.text = album.singer | ||
binding.itemLockerAlbumCoverImgIv.setImageResource(album.coverImage!!) | ||
} | ||
} | ||
|
||
interface OnItemClickListener{ | ||
fun onItemClick(album: Album) | ||
fun onRemoveAlbum(position: Int) | ||
} | ||
|
||
private lateinit var itemClickListener : OnItemClickListener | ||
|
||
fun setItemClickListener(onItemClickListener: OnItemClickListener) { | ||
this.itemClickListener = onItemClickListener | ||
} | ||
|
||
fun addItem(album : Album){ | ||
albumList.add(album) | ||
notifyDataSetChanged() | ||
} | ||
|
||
fun removeItem(position : Int){ | ||
albumList.removeAt(position) | ||
notifyDataSetChanged() | ||
} | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
UMC_6th/app/src/main/java/com/example/umc_6th/MusicFileFragment.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,19 @@ | ||
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 com.example.umc_6th.databinding.FragmentMusicFileBinding | ||
|
||
class MusicFileFragment: Fragment() { | ||
|
||
lateinit var binding: FragmentMusicFileBinding | ||
|
||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { | ||
binding = FragmentMusicFileBinding.inflate(inflater, container, false) | ||
|
||
return binding.root | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,14 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context=".MusicFileFragment"> | ||
|
||
<!-- TODO: Update blank fragment layout --> | ||
<TextView | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:text="@string/hello_blank_fragment" /> | ||
|
||
</FrameLayout> |
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,93 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginVertical="10dp"> | ||
|
||
<androidx.cardview.widget.CardView | ||
android:id="@+id/item_album_cover_img_cardView" | ||
android:layout_width="50dp" | ||
android:layout_height="50dp" | ||
android:layout_marginLeft="20dp" | ||
app:cardCornerRadius="7dp" | ||
app:cardElevation="0dp" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent"> | ||
|
||
<ImageView | ||
android:id="@+id/item_locker_album_cover_img_iv" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:scaleType="fitCenter" | ||
android:src="@drawable/img_album_exp2" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
</androidx.cardview.widget.CardView> | ||
|
||
<ImageView | ||
android:id="@+id/item_locker_album_more_iv" | ||
android:layout_width="40dp" | ||
android:layout_height="40dp" | ||
android:layout_marginRight="20dp" | ||
android:src="@drawable/btn_player_more" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
<Switch | ||
android:id="@+id/switchRV" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:switchMinWidth="50dp" | ||
android:switchPadding="20dp" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toStartOf="@+id/item_locker_album_play_img_iv" | ||
app:layout_constraintRight_toRightOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
<ImageView | ||
android:id="@+id/item_locker_album_play_img_iv" | ||
android:layout_width="40dp" | ||
android:layout_height="40dp" | ||
android:src="@drawable/btn_miniplayer_play" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toStartOf="@+id/item_locker_album_more_iv" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
<LinearLayout | ||
android:layout_width="wrap_content" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical" | ||
android:layout_marginLeft="10dp" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintStart_toEndOf="@+id/item_album_cover_img_cardView" | ||
app:layout_constraintTop_toTopOf="parent"> | ||
|
||
<TextView | ||
android:id="@+id/item_locker_album_title_tv" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="LILAC" | ||
android:textColor="@color/black" | ||
android:textSize="15sp" | ||
android:textStyle="bold" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintStart_toEndOf="@+id/item_album_cover_img_cardView" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
<TextView | ||
android:id="@+id/item_locker_album_singer_tv" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="아이유 (IU)" | ||
android:textColor="#a8a8a8" | ||
android:textSize="12sp" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintStart_toEndOf="@+id/item_album_cover_img_cardView" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
</LinearLayout> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |