File tree Expand file tree Collapse file tree
core/network/src/main/java/com/terning/core/network Expand file tree Collapse file tree Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments