Skip to content

Commit 8273be9

Browse files
committed
Feat: 3주차 미션 Activity 간 데이터 전달 및 이미지 변경 기능 추가
1 parent efd9e10 commit 8273be9

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

Heather/FLOClone/app/src/main/java/com/example/floclone/MainActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class MainActivity : AppCompatActivity() {
3838
val intent = Intent(this, SongActivity::class.java)
3939
intent.putExtra("title", song.title)
4040
intent.putExtra("singer", song.singer)
41-
songActivityLauncher.launch(intent) // ActivityResultLauncher를 통해 SongActivity 실행
41+
songActivityLauncher.launch(intent)
4242
}
4343

4444
initBottomNavigation()

Heather/FLOClone/app/src/main/java/com/example/floclone/SongActivity.kt

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
package com.example.floclone
22

33
import android.content.Intent
4+
import android.graphics.PorterDuff
45
import android.os.Bundle
56
import android.view.View
7+
import android.widget.TextView
68
import androidx.appcompat.app.AppCompatActivity
9+
import androidx.core.content.ContextCompat
710
import com.example.floclone.databinding.ActivitySongBinding
811

912
class SongActivity : AppCompatActivity() {
1013

1114
lateinit var binding: ActivitySongBinding
15+
private var isRepeatActive = false
16+
private var isRandomActive = false
17+
1218

1319
override fun onCreate(savedInstanceState: Bundle?) {
1420
super.onCreate(savedInstanceState)
@@ -18,7 +24,7 @@ class SongActivity : AppCompatActivity() {
1824

1925
// 내리기 버튼 클릭 시 현재 액티비티 종료
2026
binding.songDownIb.setOnClickListener {
21-
returnSongTitle() // 노래 제목 반환
27+
returnSongTitle() // 앨범 제목 반환
2228
finish()
2329
}
2430

@@ -29,6 +35,32 @@ class SongActivity : AppCompatActivity() {
2935
setPlayerStatus(true)
3036
}
3137

38+
// 반복 재생 버튼 클릭 리스너 추가
39+
binding.songRepeatIv.setOnClickListener {
40+
isRepeatActive = !isRepeatActive
41+
if (isRepeatActive) {
42+
binding.songRepeatIv.setColorFilter(
43+
ContextCompat.getColor(this, R.color.select_color),
44+
PorterDuff.Mode.SRC_IN
45+
)
46+
} else {
47+
binding.songRepeatIv.clearColorFilter()
48+
}
49+
}
50+
51+
// 랜덤 재생 버튼 클릭 리스너 추가
52+
binding.songRandomIv.setOnClickListener {
53+
isRandomActive = !isRandomActive
54+
if (isRandomActive) {
55+
binding.songRandomIv.setColorFilter(
56+
ContextCompat.getColor(this, R.color.select_color),
57+
PorterDuff.Mode.SRC_IN
58+
)
59+
} else {
60+
binding.songRandomIv.clearColorFilter()
61+
}
62+
}
63+
3264
// MainActivity에서 전달받은 노래 제목과 가수 이름으로 TextView 값 변경
3365
if (intent.hasExtra("title") && intent.hasExtra("singer")) {
3466
binding.songMusicTitleTv.text = intent.getStringExtra("title")

0 commit comments

Comments
 (0)