Skip to content
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

Merged
merged 4 commits into from
Jan 21, 2024

Conversation

yangsooplus
Copy link
Member

💡 Issue

🌱 Key changes

  • DownloadManager를 이용한 파일 다운로드
  • BroadcastReceiver를 등록하여 다운로드 완료시 스낵바 노출

📸 스크린샷

default.mp4

@yangsooplus yangsooplus self-assigned this Jan 21, 2024
@yangsooplus yangsooplus changed the title feat: 엑셀 파일 다운로드 Feature/mz 145 엑셀 파일 다운로드 Jan 21, 2024
private val tokenRepository: TokenRepository,
) : ExcelRepository {
override suspend fun downloadEnvelopExcel(): Long {
val token = tokenRepository.getAccessToken().firstOrNull() ?: return -1L
Copy link
Member

Choose a reason for hiding this comment

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

null인 경우에는 UnknownException을 throw하는게 더 좋을거같아요!

Copy link
Member Author

Choose a reason for hiding this comment

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

그러네요 여기서 -1L을 리턴해버리면 저장된 토큰이 없는 오류와 다운로드 중 발생한 오류인지 구분할 수 없어서 Exception throw 하는게 맞다고 생각이 드네여
반영했습니다~!
d86f0d7

Comment on lines +58 to +74
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,
)
Copy link
Member

Choose a reason for hiding this comment

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

MyInfoScreen으로 이동 못하나유?

Copy link
Member Author

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가 일어나면 리시버가 해제되지 않은 상태에서 새 리시버가 중복으로 등록될 위험이 있어서요~!

@yangsooplus yangsooplus merged commit 2df6410 into develop Jan 21, 2024
1 check passed
@yangsooplus yangsooplus deleted the feature/MZ-145-export branch January 21, 2024 09:40
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.

[Feat] 엑셀파일 내보내기
2 participants