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 saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.