Skip to content

Conversation

@yeran27
Copy link

@yeran27 yeran27 commented Jul 1, 2025

No description provided.

Copy link

@skdud0629 skdud0629 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수고하셨습니다! 중복된 로직 신경 써주시면 좋을 것 같습니다:)


override fun onResume() {
super.onResume()
if (hasPermission()) showMusicList()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oncreate에서 해당 로직을 사용하셨는데 onResume에서도 사용하는 이유가 있을까요? 생명주기에 다시 생각해보셨으면 좋겠습니다.

recyclerView.visibility = View.VISIBLE
permissionMessage.visibility = View.GONE
openSettingsButton.visibility = View.GONE
requestPermissionButton.visibility = View.GONE

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Visibility를 변경하는 로직은 따로 빼주는 게 좋을 것 같네요 중복되는 부분이 많습니다.

else
Manifest.permission.READ_EXTERNAL_STORAGE
permissionLauncher.launch(permission)
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

권한 체크하는 로직이 중복되었네요.

val pendingIntent = PendingIntent.getActivity(
this, 0, notifIntent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
)
val notification = NotificationCompat.Builder(this, "music_channel")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

채널 id는 상수를 사용해주세요.

import android.os.IBinder
import androidx.core.app.NotificationCompat

class MusicService : Service() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
class MusicService : Service() {
class MusicService : BindService() {

Copy link

@JaeYoung290 JaeYoung290 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

과제하시느라 수고 많으셨습니다!

val idIdx = it.getColumnIndex(MediaStore.Audio.Media._ID)
val titleIdx = it.getColumnIndex(MediaStore.Audio.Media.TITLE)
val artistIdx = it.getColumnIndex(MediaStore.Audio.Media.ARTIST)
val durationIdx = it.getColumnIndex(MediaStore.Audio.Media.DURATION)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getColumnIndex는 해당 column이 없을 경우 -1을 반환하는 함수입니다 이때에 대한 예외 처리 로직도 추가해주시면 좋을 것 같습니다

recyclerView.visibility = View.GONE
permissionMessage.visibility = View.GONE
openSettingsButton.visibility = View.GONE
requestPermissionButton.visibility = View.GONE

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

위의 뷰를 초기화하는 4개 줄은 xml에서 visibility에 초기값을 주는 방식으로 개선해도 괜찮을 것으로 보입니다

android:padding="12dp">

<TextView
android:id="@+id/textTitle"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xml의 네이밍 컨벤션은 lower camel case를 권장드립니다

setContentView(R.layout.activity_main)

recyclerView = findViewById(R.id.MusicRecyclerView)
permissionMessage = findViewById(R.id.text1)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

메인 xml layout에서는 text1이 없는 것으로 보이는 데 어떤 텍스트뷰일까요?

ActivityResultContracts.RequestPermission()
) { granted ->
if (granted) showMusicList()
else showPermissionUI()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

현재 코드에서는 뷰를 조절하는 것으로 권한 관련 UI를 표시하는 것으로 보입니다 visible로 조절하는 것 보다는 shouldShowRequestPermissionRationale() 등으로 분기처리 해주시는 것을 권장드립니다

openSettingsButton.visibility = View.GONE
requestPermissionButton.visibility = View.GONE
loadMusicList()
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

showPermissionUI와 showMusicList에서 UI 관련 코드가 중복되었는데 이럴때는 따로 확장 함수로 구현하시는 것을 추천드립니다

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants