Skip to content

Commit

Permalink
[Maro/#28] feat :: 6주차 구현 (#29)
Browse files Browse the repository at this point in the history
* [maro/#28] feat :: RecyclerView item

* [maro/#28] feat && fix :: 앨범 상세 정보 개발 && 앱 꺼짐 에러 수정

* [maro/#28] feat :: 보관함 개발

* [maro/#28] feat && fix :: 보관함 switch on/off 에러 해결 && 삭제 기능 추가

* [maro/#28] feat :: 선택 앨범 정보로 변경 실패

* [maro/#28] feat :: 파일 추가

* [maro/#28] fix :: onPlayAlbum 에러 수정

* [maro/#28] fix :: 6주차 구현 완료
  • Loading branch information
leesumin0526 authored May 21, 2024
1 parent 82f6178 commit b7fa9e7
Show file tree
Hide file tree
Showing 21 changed files with 713 additions and 337 deletions.
109 changes: 85 additions & 24 deletions .idea/workspace.xml

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

13 changes: 11 additions & 2 deletions UMC_6th/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
Expand All @@ -12,19 +16,24 @@
android:supportsRtl="true"
android:theme="@style/Theme.UMC_6th"
tools:targetApi="31">
<service
android:name=".ForegroundService"
android:enabled="true"
android:exported="true"></service>

<activity
android:name=".MainActivity"
android:exported="true"
android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity
android:name=".SongActivity"
android:exported="true"/>
android:exported="true" />
</application>

</manifest>
8 changes: 8 additions & 0 deletions UMC_6th/app/src/main/java/com/example/umc_6th/Album.kt
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 // 앨범 수록곡
)
22 changes: 18 additions & 4 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 @@ -11,17 +11,24 @@ 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
private var gson : Gson = Gson()

private val information = arrayListOf("수록곡","상세정보","영상")
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = inflate(inflater,container,false)
binding = FragmentAlbumBinding.inflate(inflater,container,false)

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

binding.albumBackIv.setOnClickListener{
(context as MainActivity).supportFragmentManager.beginTransaction().
replace(R.id.main_frm,HomeFragment()).
Expand All @@ -33,10 +40,10 @@ class AlbumFragment : Fragment() {


setFragmentResultListener("TitleInfo") { requestKey, bundle ->
binding.albumTitleTv.text = bundle.getString("title")
binding.albumMusicTitleTv.text = bundle.getString("title")
}
setFragmentResultListener("SingerInfo") { requestKey, bundle ->
binding.albumSingerTv.text = bundle.getString("singer")
binding.albumSingerNameTv.text = bundle.getString("singer")
}

TabLayoutMediator(binding.albumContentTb,binding.albumContentVp){
Expand All @@ -46,4 +53,11 @@ class AlbumFragment : Fragment() {

return binding.root
}
}

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

}
48 changes: 48 additions & 0 deletions UMC_6th/app/src/main/java/com/example/umc_6th/AlbumRVAdapter.kt
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.onPlayAlbum(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
}


}
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)
}
Loading

0 comments on commit b7fa9e7

Please sign in to comment.