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