-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/mz 145 엑셀 파일 다운로드 #80
Conversation
private val tokenRepository: TokenRepository, | ||
) : ExcelRepository { | ||
override suspend fun downloadEnvelopExcel(): Long { | ||
val token = tokenRepository.getAccessToken().firstOrNull() ?: return -1L |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
null인 경우에는 UnknownException을 throw하는게 더 좋을거같아요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
그러네요 여기서 -1L을 리턴해버리면 저장된 토큰이 없는 오류와 다운로드 중 발생한 오류인지 구분할 수 없어서 Exception throw 하는게 맞다고 생각이 드네여
반영했습니다~!
d86f0d7
broadcastReceiver = object : BroadcastReceiver() { | ||
override fun onReceive(context: Context, intent: Intent?) { | ||
if (intent?.action == INTENT_ACTION_DOWNLOAD_COMPLETE) { | ||
val id = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1L) | ||
if (id != -1L) { | ||
viewModel.onShowSnackbar(SnackbarToken(message = context.getString(com.susu.feature.mypage.R.string.snackbar_success_export))) | ||
} | ||
} | ||
} | ||
} | ||
|
||
ContextCompat.registerReceiver( | ||
this, | ||
broadcastReceiver, | ||
IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE), | ||
ContextCompat.RECEIVER_EXPORTED, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MyInfoScreen으로 이동 못하나유?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MainActivity의 onDestry()에서 BroadcastReceiver 등록을 해제하기 위해 여기에 위치해있습니당
configuration change가 일어나면 리시버가 해제되지 않은 상태에서 새 리시버가 중복으로 등록될 위험이 있어서요~!
💡 Issue
🌱 Key changes
DownloadManager
를 이용한 파일 다운로드BroadcastReceiver
를 등록하여 다운로드 완료시 스낵바 노출📸 스크린샷
default.mp4