-
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.
* [simba/#28] feat::리사이클러뷰 구현 * [simba/#28] feat:: recyclerView->albumFragment 클릭 이벤트 구현 * [simba/#28] feat:: recyclerView->albumFragment 클릭 이벤트 구현 with 데이터 * [simba/#28] feat:: 6주차 구현 완료 * [simba/#28] feat:: 6주차 구현 (에러 존재) * [simba/#28] feat:: 6주차 구현
- Loading branch information
Showing
22 changed files
with
1,010 additions
and
255 deletions.
There are no files selected for viewing
314 changes: 314 additions & 0 deletions
314
...dea/shelf/Uncommitted_changes_before_Checkout_at_5_18_24,_7_44 PM_[Changes]/shelved.patch
Large diffs are not rendered by default.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
UMC_6th/.idea/shelf/Uncommitted_changes_before_Checkout_at_5_18_24__7_44PM__Changes_.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
...idea/shelf/Uncommitted_changes_before_Checkout_at_5_1_24,_6_28 PM_[Changes]/shelved.patch
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
UMC_6th/.idea/shelf/Uncommitted_changes_before_Checkout_at_5_1_24__6_28PM__Changes_.xml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.example.umc_6th | ||
|
||
import java.util.ArrayList | ||
|
||
data class Album( | ||
var title: String? = "", | ||
var singer: String? = "", | ||
var coverImg: Int? = null, | ||
var songs: ArrayList<Song>? = null | ||
) |
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
60 changes: 60 additions & 0 deletions
60
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,60 @@ | ||
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>() { | ||
|
||
interface MyItemClickListener{ | ||
fun onItemClick(album: Album) | ||
fun onRemoveAlbum(position: Int) | ||
fun onPlayAlbum(album: Album) | ||
} | ||
|
||
interface CommunicationInterface{ | ||
fun sendData(album: Album) | ||
} | ||
|
||
private lateinit var mItemClickListener : MyItemClickListener | ||
fun setMyItemClickListener(itemClickListener: MyItemClickListener){ | ||
mItemClickListener = itemClickListener | ||
} | ||
|
||
fun addItem(album: Album){ | ||
albumList.add(album) | ||
notifyDataSetChanged() | ||
} | ||
|
||
fun removeItem(position: Int){ | ||
albumList.removeAt(position) | ||
notifyDataSetChanged() | ||
} | ||
|
||
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{ | ||
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!!) | ||
} | ||
} | ||
} |
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,6 @@ | ||
package com.example.umc_6th | ||
|
||
object Constant { | ||
const val CHANNEL_ID = "ch123" | ||
const val MUSIC_NOTIFICATION_ID = 123 | ||
} |
62 changes: 62 additions & 0 deletions
62
UMC_6th/app/src/main/java/com/example/umc_6th/ForegroundService.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,62 @@ | ||
package com.example.umc_6th | ||
|
||
import android.annotation.SuppressLint | ||
import android.app.Notification | ||
import android.app.NotificationChannel | ||
import android.app.NotificationManager | ||
import android.app.PendingIntent | ||
import android.app.Service | ||
import android.content.Intent | ||
import android.os.Build | ||
import android.os.IBinder | ||
import androidx.annotation.RequiresApi | ||
|
||
class ForegroundService : Service() { | ||
|
||
override fun onBind(intent: Intent): IBinder? { | ||
return null | ||
} | ||
|
||
override fun onCreate() { | ||
super.onCreate() | ||
createNotificationChannel() | ||
} | ||
|
||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { | ||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){ | ||
showNotification() | ||
} | ||
return START_STICKY | ||
} | ||
|
||
@SuppressLint("ForegroundServiceType") | ||
@RequiresApi(Build.VERSION_CODES.O) | ||
private fun showNotification() { | ||
val notificationIntent = Intent(this,SongActivity::class.java) | ||
val pendingIntent = PendingIntent.getActivity( | ||
this,0,notificationIntent,PendingIntent.FLAG_IMMUTABLE | ||
) | ||
val notification = Notification | ||
.Builder(this, Constant.CHANNEL_ID) | ||
.setContentText("현재 음악이 재생 중 입니다.") | ||
.setSmallIcon(R.drawable.ic_flo_logo) | ||
.setContentIntent(pendingIntent) | ||
.build() | ||
|
||
startForeground(Constant.MUSIC_NOTIFICATION_ID, notification) | ||
} | ||
|
||
private fun createNotificationChannel() { | ||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){ | ||
val serviceChannel = NotificationChannel( | ||
Constant.CHANNEL_ID,"Service Channel", | ||
NotificationManager.IMPORTANCE_DEFAULT | ||
) | ||
val manager = getSystemService( | ||
NotificationManager::class.java | ||
) | ||
|
||
manager.createNotificationChannel(serviceChannel) | ||
} | ||
} | ||
} |
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
Oops, something went wrong.