generated from GO-SOPT-ANDROID/android-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
2주차 세미나 과제
- Loading branch information
Showing
52 changed files
with
2,214 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
194 changes: 194 additions & 0 deletions
194
app/src/main/java/org/android/go/sopt/data/entity/MockRepoDto.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,194 @@ | ||
package org.android.go.sopt.data.entity | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
import org.android.go.sopt.domain.model.Repo | ||
|
||
@Serializable | ||
data class MockRepoDto( | ||
@SerialName("allow_forking") | ||
val allowForking: Boolean, | ||
@SerialName("archive_url") | ||
val archiveUrl: String, | ||
val archived: Boolean, | ||
@SerialName("assignees_url") | ||
val assigneesUrl: String, | ||
@SerialName("blobs_url") | ||
val blobsUrl: String, | ||
@SerialName("branches_url") | ||
val branchesUrl: String, | ||
@SerialName("clone_url") | ||
val cloneUrl: String, | ||
@SerialName("collaborators_url") | ||
val collaboratorsUrl: String, | ||
@SerialName("comments_url") | ||
val commentsUrl: String, | ||
@SerialName("commits_url") | ||
val commitsUrl: String, | ||
@SerialName("compare_url") | ||
val compareUrl: String, | ||
@SerialName("contents_url") | ||
val contentsUrl: String, | ||
@SerialName("contributors_url") | ||
val contributorsUrl: String, | ||
@SerialName("created_at") | ||
val createdAt: String, | ||
@SerialName("default_branch") | ||
val defaultBranch: String, | ||
@SerialName("deployments_url") | ||
val deploymentsUrl: String, | ||
val description: String, | ||
val disabled: Boolean, | ||
@SerialName("downloads_url") | ||
val downloadsUrl: String, | ||
@SerialName("events_url") | ||
val eventsUrl: String, | ||
val fork: Boolean, | ||
val forks: Int, | ||
@SerialName("forks_count") | ||
val forksCount: Int, | ||
@SerialName("forks_url") | ||
val forksUrl: String, | ||
@SerialName("full_name") | ||
val fullName: String, | ||
@SerialName("git_commits_url") | ||
val gitCommitsUrl: String, | ||
@SerialName("git_refs_url") | ||
val gitRefsUrl: String, | ||
@SerialName("git_tags_url") | ||
val gitTagsUrl: String, | ||
@SerialName("git_url") | ||
val gitUrl: String, | ||
@SerialName("has_discussions") | ||
val hasDiscussions: Boolean, | ||
@SerialName("has_downloads") | ||
val hasDownloads: Boolean, | ||
@SerialName("has_issues") | ||
val hasIssues: Boolean, | ||
@SerialName("has_pages") | ||
val hasPages: Boolean, | ||
@SerialName("has_projects") | ||
val hasProjects: Boolean, | ||
@SerialName("has_wiki") | ||
val hasWiki: Boolean, | ||
val homepage: String, | ||
@SerialName("hooks_url") | ||
val hooksUrl: String, | ||
@SerialName("html_url") | ||
val htmlUrl: String, | ||
val id: Int, | ||
@SerialName("is_template") | ||
val isTemplate: Boolean, | ||
@SerialName("issue_comment_url") | ||
val issueCommentUrl: String, | ||
@SerialName("issue_events_url") | ||
val issueEventsUrl: String, | ||
@SerialName("issues_url") | ||
val issuesUrl: String, | ||
@SerialName("keys_url") | ||
val keysUrl: String, | ||
@SerialName("labels_url") | ||
val labelsUrl: String, | ||
val language: String?, | ||
@SerialName("languages_url") | ||
val languagesUrl: String, | ||
val license: String?, | ||
@SerialName("merges_url") | ||
val mergesUrl: String, | ||
@SerialName("milestones_url") | ||
val milestonesUrl: String, | ||
@SerialName("mirror_url") | ||
val mirrorUrl: String?, | ||
val name: String, | ||
@SerialName("node_id") | ||
val nodeId: String, | ||
@SerialName("notifications_url") | ||
val notificationsUrl: String, | ||
@SerialName("open_issues") | ||
val openIssues: Int, | ||
@SerialName("open_issues_count") | ||
val openIssuesCount: Int, | ||
val owner: Owner, | ||
@SerialName("private") | ||
val isPrivate: Boolean, | ||
@SerialName("pulls_url") | ||
val pullsUrl: String, | ||
@SerialName("pushed_at") | ||
val pushedAt: String, | ||
@SerialName("releases_url") | ||
val releasesUrl: String, | ||
val size: Int, | ||
@SerialName("ssh_url") | ||
val sshUrl: String, | ||
@SerialName("stargazers_count") | ||
val stargazersCount: Int, | ||
@SerialName("stargazers_url") | ||
val stargazersUrl: String, | ||
@SerialName("statuses_url") | ||
val statusesUrl: String, | ||
@SerialName("subscribers_url") | ||
val subscribersUrl: String, | ||
@SerialName("subscription_url") | ||
val subscriptionUrl: String, | ||
@SerialName("svn_url") | ||
val svnUrl: String, | ||
@SerialName("tags_url") | ||
val tagsUrl: String, | ||
@SerialName("teams_url") | ||
val teamsUrl: String, | ||
val topics: List<String>, | ||
@SerialName("trees_url") | ||
val treesUrl: String, | ||
@SerialName("updated_at") | ||
val updatedAt: String, | ||
val url: String, | ||
val visibility: String, | ||
val watchers: Int, | ||
@SerialName("watchers_count") | ||
val watchersCount: Int, | ||
@SerialName("web_commit_signoff_required") | ||
val webCommitSignoffRequired: Boolean, | ||
) { | ||
@Serializable | ||
data class Owner( | ||
@SerialName("avatar_url") | ||
val avatarUrl: String, | ||
@SerialName("events_url") | ||
val eventsUrl: String, | ||
@SerialName("followers_url") | ||
val followersUrl: String, | ||
@SerialName("following_url") | ||
val followingUrl: String, | ||
@SerialName("gists_url") | ||
val gistsUrl: String, | ||
@SerialName("gravatar_id") | ||
val gravatarId: String, | ||
@SerialName("html_url") | ||
val htmlUrl: String, | ||
val id: Int, | ||
val login: String, | ||
@SerialName("node_id") | ||
val nodeId: String, | ||
@SerialName("organizations_url") | ||
val organizationsUrl: String, | ||
@SerialName("received_events_url") | ||
val receivedEventsUrl: String, | ||
@SerialName("repos_url") | ||
val reposUrl: String, | ||
@SerialName("site_admin") | ||
val siteAdmin: Boolean, | ||
@SerialName("starred_url") | ||
val starredUrl: String, | ||
@SerialName("subscriptions_url") | ||
val subscriptionsUrl: String, | ||
val type: String, | ||
val url: String, | ||
) | ||
|
||
fun toRepo() = Repo( | ||
id = id, | ||
image = owner.avatarUrl, | ||
name = name, | ||
owner = owner.login, | ||
) | ||
} |
4 changes: 2 additions & 2 deletions
4
app/src/main/java/org/android/go/sopt/data/repository/AuthRepositoryImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
app/src/main/java/org/android/go/sopt/data/repository/RepoRepositoryImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.android.go.sopt.data.repository | ||
|
||
import org.android.go.sopt.data.source.RepoDataSource | ||
import org.android.go.sopt.domain.model.Repo | ||
import org.android.go.sopt.domain.repository.RepoRepository | ||
import javax.inject.Inject | ||
|
||
class RepoRepositoryImpl @Inject constructor( | ||
private val repoDataSource: RepoDataSource, | ||
) : RepoRepository { | ||
override suspend fun getRepoList(): Result<List<Repo>> = runCatching { | ||
repoDataSource.getRepoList().map { repo -> repo.toRepo() } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
app/src/main/java/org/android/go/sopt/data/source/RepoDataSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.android.go.sopt.data.source | ||
|
||
import kotlinx.serialization.decodeFromString | ||
import kotlinx.serialization.json.Json | ||
import org.android.go.sopt.data.entity.MockRepoDto | ||
import org.android.go.sopt.util.AssetLoader | ||
import javax.inject.Inject | ||
|
||
class RepoDataSource @Inject constructor( | ||
private val assetLoader: AssetLoader, | ||
) { | ||
fun getRepoList(): Array<MockRepoDto> { | ||
return assetLoader.getJsonString(FILE_FAKE_REPO_LIST)?.let { jsonString -> | ||
Json.decodeFromString<Array<MockRepoDto>>(jsonString) | ||
} ?: emptyArray() | ||
} | ||
|
||
companion object { | ||
private const val FILE_FAKE_REPO_LIST = "fake_repo_list.json" | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
app/src/main/java/org/android/go/sopt/di/AssetLoaderModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.android.go.sopt.di | ||
|
||
import android.content.Context | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.android.qualifiers.ApplicationContext | ||
import dagger.hilt.components.SingletonComponent | ||
import org.android.go.sopt.util.AssetLoader | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
object AssetLoaderModule { | ||
@Provides | ||
@Singleton | ||
fun providesAssetLoader(@ApplicationContext context: Context): AssetLoader = | ||
AssetLoader(context) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.android.go.sopt.domain.model | ||
|
||
data class Repo( | ||
val id: Int, | ||
val image: String, | ||
val name: String, | ||
val owner: String, | ||
) |
2 changes: 1 addition & 1 deletion
2
...a/org/android/go/sopt/data/entity/User.kt → .../org/android/go/sopt/domain/model/User.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
.../android/go/sopt/domain/AuthRepository.kt → .../sopt/domain/repository/AuthRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.