Skip to content

Commit 8513e09

Browse files
committed
[FEAT/#400] restartApp 함수화
1 parent 10f69c4 commit 8513e09

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

core/network/src/main/java/com/terning/core/network/AuthInterceptor.kt

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,11 @@ class AuthInterceptor @Inject constructor(
5858
Timber.d(t.message)
5959
}
6060

61-
terningDataStore.clearInfo()
62-
63-
Handler(Looper.getMainLooper()).post {
64-
Toast.makeText(context, MESSAGE_TOKEN_EXPIRED, Toast.LENGTH_LONG).show()
65-
ProcessPhoenix.triggerRebirth(context)
66-
}
61+
restartApp(MESSAGE_TOKEN_EXPIRED)
6762
}
6863

6964
CODE_MANY_REQUESTS -> {
70-
Handler(Looper.getMainLooper()).post {
71-
Toast.makeText(context, MESSAGE_TOO_MANY_REQUESTS, Toast.LENGTH_LONG).show()
72-
}
65+
restartApp(MESSAGE_TOO_MANY_REQUESTS)
7366
}
7467
}
7568
return response
@@ -78,6 +71,15 @@ class AuthInterceptor @Inject constructor(
7871
private fun Request.Builder.newAuthBuilder() =
7972
this.addHeader(AUTHORIZATION, "$BEARER ${terningDataStore.accessToken}")
8073

74+
private fun restartApp(message: String) {
75+
terningDataStore.clearInfo()
76+
77+
Handler(Looper.getMainLooper()).post {
78+
Toast.makeText(context, message, Toast.LENGTH_LONG).show()
79+
ProcessPhoenix.triggerRebirth(context)
80+
}
81+
}
82+
8183
companion object {
8284
private const val CODE_TOKEN_EXPIRED = 401
8385
private const val CODE_MANY_REQUESTS = 429

0 commit comments

Comments
 (0)