Skip to content

Commit

Permalink
kuring-71 [수정] WebViewNotice를 주고받는 intent key를 WebViewNotice로 옮김
Browse files Browse the repository at this point in the history
  • Loading branch information
mwy3055 committed Nov 18, 2023
1 parent 39e17f1 commit 9754cd6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ data class WebViewNotice(
val url: String,
val articleId: String,
val category: String,
): Serializable
): Serializable {
companion object {
const val EXTRA_KEY = "webview_notice"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class NoticeWebActivity : AppCompatActivity() {
setContentView(binding.root)

// Deprecated되지 않은 다른 함수가 API 33 이상에서만 사용할 수 있어서 부득이하게 deprecated 함수를 사용
val webViewNotice = intent.getSerializableExtra(WEB_VIEW_NOTICE) as? WebViewNotice
val webViewNotice = intent.getSerializableExtra(WebViewNotice.EXTRA_KEY) as? WebViewNotice
?: throw IllegalStateException("WebViewNotice should not be null.")
Timber.e("web view notice: $webViewNotice")

Expand Down Expand Up @@ -114,8 +114,6 @@ class NoticeWebActivity : AppCompatActivity() {
}

companion object {
const val WEB_VIEW_NOTICE = "webview_notice"

fun start(activity: Activity, url: String?, articleId: String?, category: String?) {
if (url == null || articleId == null || category == null) {
throw IllegalArgumentException("intent parameters shouldn't be null: $url, $articleId, $category")
Expand Down Expand Up @@ -143,7 +141,7 @@ class NoticeWebActivity : AppCompatActivity() {
}
Timber.d("url: $url, articleId: $articleId, category: $category")
return Intent(context, NoticeWebActivity::class.java).apply {
putExtra(WEB_VIEW_NOTICE, WebViewNotice(url, articleId, category))
putExtra(WebViewNotice.EXTRA_KEY, WebViewNotice(url, articleId, category))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class NoticeWebViewModel @Inject constructor(

private val disposable = CompositeDisposable()
private val webViewNotice =
savedStateHandle.get(NoticeWebActivity.WEB_VIEW_NOTICE) as? WebViewNotice
savedStateHandle.get(WebViewNotice.EXTRA_KEY) as? WebViewNotice

private val _isSaved = MutableStateFlow(false)
val isSaved: StateFlow<Boolean>
Expand Down

0 comments on commit 9754cd6

Please sign in to comment.