-
Notifications
You must be signed in to change notification settings - Fork 0
[네트워크 모듈 개선 v2] 네트워크 쓰레드 제어 #42
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
Changes from all commits
c436d5b
64757b4
374a682
da6462f
8b7102d
f9edf4e
535fc77
b5aa6e1
6418988
f8b11ee
5ab224b
e9a850e
65c33e3
a01ed27
84080f9
4762424
4936872
f422c84
5e3156b
5b16175
03125bb
68dfc95
b8fa8d7
fb6a08c
ecacd29
fd22e89
f21e298
bad75f6
df56276
accf676
710643e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,61 @@ | ||
# Built application files | ||
*.apk | ||
*.ap_ | ||
|
||
# Files for the Dalvik VM | ||
*.dex | ||
|
||
# Java class files | ||
*.class | ||
|
||
# Generated files | ||
bin/ | ||
gen/ | ||
|
||
# Gradle files | ||
.gradle/ | ||
build/ | ||
|
||
# Local configuration file (sdk path, etc) | ||
local.properties | ||
|
||
# Proguard folder generated by Eclipse | ||
proguard/ | ||
|
||
# Log Files | ||
*.log | ||
|
||
# Android Studio Navigation editor temp files | ||
.navigation/ | ||
|
||
# Android Studio captures folder | ||
captures/ | ||
|
||
# User-specific configurations | ||
.idea/ | ||
.idea/libraries/ | ||
.idea/workspace.xml | ||
.idea/tasks.xml | ||
.idea/.name | ||
.idea/compiler.xml | ||
.idea/copyright/profiles_settings.xml | ||
.idea/encodings.xml | ||
.idea/misc.xml | ||
.idea/modules.xml | ||
.idea/scopes/scope_settings.xml | ||
.idea/vcs.xml | ||
.idea/caches/ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/caches | ||
/.idea/libraries | ||
/.idea/modules.xml | ||
/.idea/workspace.xml | ||
/.idea/navEditor.xml | ||
/.idea/assetWizardSettings.xml | ||
|
||
# OS-specific files | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild | ||
.cxx | ||
local.properties | ||
/.idea | ||
/.gradle | ||
.DS_Store? | ||
._* | ||
.Spotlight-V100 | ||
.Trashes | ||
ehthumbs.db | ||
Thumbs.db | ||
|
||
app/release/output.json | ||
|
||
detekt/detekt.** |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
17.0.8 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
Build Date 2023년 07월 12일 수요일 13:53:38 | ||
Version Name: 0.0.5 | ||
Branch: develop | ||
Build Date 2023년 12월 03일 일요일 10:13:10 | ||
Version Name: 0.0.6 | ||
Branch: feature/refactor_network | ||
|
||
Message: commit ff91368b76f29aa698d7c74f5242f2fb3748af84 | ||
Update generate-release-note.yml | ||
Message: commit df562762cd1ce4b2d4bcb7664c9979f139174ee3 | ||
chore: 네트워크 개선 v2 | ||
- 테스트 했던 Delay 들 줄임 | ||
|
||
Author: Sieun Ju | ||
|
||
Author: sieunju |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ import io.reactivex.rxjava3.core.Single | |
interface LoginManager { | ||
fun setToken(token: String) | ||
fun getToken(): String | ||
fun isLogin() : Boolean | ||
fun rxIsLogin() : Single<Boolean> | ||
fun isLogin(): Boolean | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [ktlint] standard:blank-line-before-declaration reported by reviewdog 🐶 |
||
fun rxIsLogin(): Single<Boolean> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [ktlint] standard:blank-line-before-declaration reported by reviewdog 🐶 |
||
fun getTokenExpiredMs(): Long | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [ktlint] standard:blank-line-before-declaration reported by reviewdog 🐶 |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
package com.hmju.core.login_manager | ||
|
||
import android.content.Context | ||
import android.content.SharedPreferences | ||
import android.util.Base64 | ||
import androidx.core.content.edit | ||
import com.hmju.core.pref.PreferenceManager | ||
import com.hmju.core.rxbus.LoginEvent | ||
import com.hmju.core.rxbus.RxBus | ||
import dagger.hilt.android.qualifiers.ApplicationContext | ||
import io.reactivex.rxjava3.core.Single | ||
import org.json.JSONObject | ||
import javax.inject.Inject | ||
import kotlin.random.Random | ||
|
||
|
@@ -15,33 +16,40 @@ import kotlin.random.Random | |
* Created by juhongmin on 2022/01/12 | ||
*/ | ||
class LoginManagerImpl @Inject constructor( | ||
@ApplicationContext private val context: Context | ||
private val prefManager: PreferenceManager | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [ktlint] standard:trailing-comma-on-declaration-site reported by reviewdog 🐶 |
||
) : LoginManager { | ||
|
||
private val pref: SharedPreferences = | ||
context.getSharedPreferences("til_pref", Context.MODE_PRIVATE) | ||
private var expiredMs: Long = 0 | ||
private var userToken: String = "" | ||
|
||
companion object { | ||
const val KEY_TOKEN = "user_token" | ||
const val KEY_NICK_NAME = "user_nick_name" | ||
private fun getTokenExpiredMs(token: String): Long { | ||
return try { | ||
val startIdx = token.indexOf(".") | ||
val endIdx = token.lastIndexOf(".") | ||
val bytes = Base64.decode(token.substring(startIdx, endIdx), Base64.DEFAULT) | ||
val json = JSONObject(String(bytes, Charsets.UTF_8)) | ||
json.getLong("exp") * 1000 | ||
} catch (ex: Exception) { | ||
System.currentTimeMillis() | ||
} | ||
} | ||
|
||
private var userToken: String = "" | ||
|
||
@Synchronized | ||
override fun setToken(token: String) { | ||
with(pref.edit()) { | ||
putString(KEY_TOKEN, token) | ||
apply() | ||
// Test | ||
RxBus.publish(LoginEvent(Random.nextBoolean(), token)) | ||
// 토큰 전처리 가공 | ||
prefManager.getPref().edit { | ||
expiredMs = getTokenExpiredMs(token) | ||
userToken = token | ||
putLong(PreferenceManager.KEY_TOKEN_EXPIRED_MS, expiredMs) | ||
putString(PreferenceManager.KEY_TOKEN, userToken) | ||
} | ||
|
||
userToken = token | ||
RxBus.publish(LoginEvent(Random.nextBoolean(), token)) | ||
} | ||
|
||
override fun getToken(): String { | ||
if (userToken.isEmpty()) { | ||
userToken = pref.getString(KEY_TOKEN, "") ?: "" | ||
userToken = prefManager.getString(PreferenceManager.KEY_TOKEN) | ||
} | ||
return userToken | ||
} | ||
|
@@ -53,4 +61,8 @@ class LoginManagerImpl @Inject constructor( | |
override fun rxIsLogin(): Single<Boolean> { | ||
return Single.just(getToken().isNotEmpty()) | ||
} | ||
|
||
override fun getTokenExpiredMs(): Long { | ||
return expiredMs | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,6 @@ open class BaseJSend { | |
|
||
@SerialName("message") | ||
val message: String? = null | ||
|
||
open val isValid : Boolean = false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [ktlint] standard:colon-spacing reported by reviewdog 🐶 |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,19 @@ package com.hmju.core.model.base | |
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [ktlint] standard:no-consecutive-blank-lines reported by reviewdog 🐶 |
||
/** | ||
* Description : JSend JSON | ||
* { | ||
* "status" : true or false, | ||
* "message" : String (에러인경우 사용자에게 표시하는 에러 메시지), | ||
* "data" : { | ||
* "payload" : [] | ||
* } | ||
* } | ||
* | ||
* Created by juhongmin on 09/01/22 | ||
*/ | ||
@Serializable | ||
data class JSendList<T : Any>( | ||
@SerialName("data") | ||
|
@@ -14,8 +27,7 @@ data class JSendList<T : Any>( | |
val list: List<T> = listOf() | ||
) | ||
|
||
val isValid: Boolean | ||
get() = depthData != null | ||
override val isValid: Boolean get() = depthData != null | ||
|
||
val payload: List<T> | ||
get() = depthData?.list ?: listOf() | ||
|
Uh oh!
There was an error while loading. Please reload this page.