path
stringlengths 4
280
| owner
stringlengths 2
39
| repo_id
int64 21.1k
879M
| is_fork
bool 2
classes | languages_distribution
stringlengths 13
1.95k
⌀ | content
stringlengths 7
482k
| issues
int64 0
13.9k
| main_language
stringclasses 121
values | forks
stringlengths 1
5
| stars
int64 0
111k
| commit_sha
stringlengths 40
40
| size
int64 7
482k
| name
stringlengths 1
100
| license
stringclasses 93
values |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
App_007_login/app/src/main/java/com/callor/login/data/LoginRepository.kt
|
ETS-Android1
| 497,193,642 | false |
{"Java": 182193, "Kotlin": 94685}
|
package com.callor.login.data
import com.callor.login.data.model.LoggedInUser
/**
* Class that requests authentication and user information from the remote data source and
* maintains an in-memory cache of login status and user credentials information.
*/
class LoginRepository {
// in-memory cache of the loggedInUser object
var user: LoggedInUser? = null
private set
val isLoggedIn: Boolean
get() = user != null
init {
// If user credentials will be cached in local storage, it is recommended it be encrypted
// @see https://developer.android.com/training/articles/keystore
user = null
}
fun logout() {
user = null
}
fun login(username: String, password: String): Result<LoggedInUser> {
// handle login
// 로그인을 수행한 uesrId 와 password 로 DB 로부터 데이터를 조회하고
// 그 결과를 result 담아서 return 하는 구조
// val result = dataSource.login(username, password)
// 로그인 정보와 관계없이 사용자 ID 와 사용자 이름을 임의로 세팅한 결과를 생성하기
// 사용자 정보가 담긴 LoggedInUser 클래스로 생성한 객체를 Result.Success 클래스에
// 생성자로 주입하여 result 객체를 선언 및 생성
val result = Result.Success( LoggedInUser(userId="callor", displayName = "홍길동") )
if (result is Result.Success) {
setLoggedInUser(result.data)
}
return result
}
private fun setLoggedInUser(loggedInUser: LoggedInUser) {
this.user = loggedInUser
// If user credentials will be cached in local storage, it is recommended it be encrypted
// @see https://developer.android.com/training/articles/keystore
}
}
| 1 | null |
1
| 1 |
864be6b1d7072d63a78506b9f971968dbefc17b7
| 1,616 |
Biz_Android_505_2021_07
|
Apache License 2.0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.