-
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.
* [nunu/#33] 7주차 구현1 - homeFragment에 recycler View 구현 - Song Activity에 DB 연결 및 타이머 스레드 수정(이전/다음 곡 재생에 따른 타이머와 재생/정지에 따른 타이머) - Album, Song Dao와 Database 구현 * [nunu/#33] feat: 7주차 구현2 - 좋아요 기능 커스텀 toast 구현 * [nunu/#33] feat: 7주차 구현3 - 좋아요 한 곡 데이터베이스 및 보관함 업데이트 * [nunu/#33] feat: 7주차 구현4 - Main<-> Song activity 간 연동을 위한 SharedPreferenceHelper 구현 - 근데 연동 안됨 ㅠㅠ... * [nunu/#33] 7주차 구현 - 앨범 fragment 바인딩 - foreground 설정 * [nunu/#33] 7주차 구현6 - sharedPreference 통해서 SongActivity-> MainActivity 간 데이터 공유 성공 - MainActivity -> SongActivity 간 데이터 공유 필요 * [nunu/#33] 7주차 구현7 - MainActivity -> SongActivity 간 songId 데이터 공유( 근데, id가 서로 다름.. 그래서 -1 해줘서 보내줌.) * [nunu/#33] 7주차 구현8 - album 연결 - 모든 좋아요된 음악 전체 해제 구현( bottomSheetDialog 구현)
- Loading branch information
1 parent
a4cb646
commit 95d668e
Showing
38 changed files
with
1,260 additions
and
157 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
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 |
---|---|---|
@@ -1,8 +1,13 @@ | ||
package com.example.umc_6th | ||
|
||
|
||
import androidx.room.Entity | ||
import androidx.room.PrimaryKey | ||
|
||
@Entity(tableName = "AlbumTable") | ||
data class Album( | ||
var title : String? = "", | ||
var artist : String? = "", | ||
var coverImage : Int? = null, | ||
var songs: ArrayList<Song>? = null | ||
@PrimaryKey(autoGenerate = false) var id: Int = 0, // album의 pk는 임의로 지정해주기 위해 autogenerate 안씁니다. | ||
var title: String? = "", | ||
var artist: String? = "", | ||
var coverImg: Int? = 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.example.umc_6th | ||
|
||
import androidx.room.* | ||
|
||
@Dao | ||
interface AlbumDao { | ||
@Insert | ||
fun insert(album: Album) | ||
|
||
@Update | ||
fun update(album: Album) | ||
|
||
@Delete | ||
fun delete(album: Album) | ||
|
||
@Query("SELECT * FROM AlbumTable") // 테이블의 모든 값을 가져와라 | ||
fun getAlbums(): List<Album> | ||
|
||
@Query("SELECT * FROM AlbumTable WHERE id = :id") | ||
fun getAlbum(id: Int): Album | ||
} |
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,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.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 | ||
} | ||
@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.