From d3c31159dbb00177bbaabc554127d1127988e72a Mon Sep 17 00:00:00 2001 From: b1urrrr Date: Fri, 12 May 2023 19:29:40 +0900 Subject: [PATCH] =?UTF-8?q?[MOVE/#8]=20=ED=8C=A8=ED=82=A4=EC=A7=80=20?= =?UTF-8?q?=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/entity/{ => local}/MockRepoDto.kt | 22 ++++++++++++++++++- .../model => data/entity/local}/User.kt | 2 +- .../{ => response}/wrapper/BaseResponse.kt | 4 ++-- .../data/repository/AuthRepositoryImpl.kt | 20 ++++++++--------- .../data/repository/RepoRepositoryImpl.kt | 2 +- .../go/sopt/data/service/AuthService.kt | 2 +- .../data/source/{ => local}/RepoDataSource.kt | 4 ++-- .../SharedPrefDataSource.kt} | 10 ++++----- .../source/{ => remote}/AuthDataSource.kt | 4 ++-- .../sopt/domain/repository/AuthRepository.kt | 4 ++-- .../sopt/presentation/login/LoginActivity.kt | 2 +- .../sopt/presentation/login/LoginViewModel.kt | 2 +- .../main/gallery/GalleryFragment.kt | 1 - .../presentation/main/home/HomeFragment.kt | 4 ++-- .../main/profile/ProfileViewModel.kt | 2 +- .../presentation/signup/SignupViewModel.kt | 2 +- 16 files changed, 52 insertions(+), 35 deletions(-) rename app/src/main/java/org/android/go/sopt/data/entity/{ => local}/MockRepoDto.kt (90%) rename app/src/main/java/org/android/go/sopt/{domain/model => data/entity/local}/User.kt (88%) rename app/src/main/java/org/android/go/sopt/data/entity/remote/{ => response}/wrapper/BaseResponse.kt (73%) rename app/src/main/java/org/android/go/sopt/data/source/{ => local}/RepoDataSource.kt (84%) rename app/src/main/java/org/android/go/sopt/data/source/{LocalPrefDataSource.kt => local/SharedPrefDataSource.kt} (83%) rename app/src/main/java/org/android/go/sopt/data/source/{ => remote}/AuthDataSource.kt (80%) diff --git a/app/src/main/java/org/android/go/sopt/data/entity/MockRepoDto.kt b/app/src/main/java/org/android/go/sopt/data/entity/local/MockRepoDto.kt similarity index 90% rename from app/src/main/java/org/android/go/sopt/data/entity/MockRepoDto.kt rename to app/src/main/java/org/android/go/sopt/data/entity/local/MockRepoDto.kt index 6d6ffc3..82431b8 100644 --- a/app/src/main/java/org/android/go/sopt/data/entity/MockRepoDto.kt +++ b/app/src/main/java/org/android/go/sopt/data/entity/local/MockRepoDto.kt @@ -1,4 +1,4 @@ -package org.android.go.sopt.data.entity +package org.android.go.sopt.data.entity.local import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @@ -10,6 +10,7 @@ data class MockRepoDto( val allowForking: Boolean, @SerialName("archive_url") val archiveUrl: String, + @SerialName("archived") val archived: Boolean, @SerialName("assignees_url") val assigneesUrl: String, @@ -37,13 +38,17 @@ data class MockRepoDto( val defaultBranch: String, @SerialName("deployments_url") val deploymentsUrl: String, + @SerialName("description") val description: String, + @SerialName("disabled") val disabled: Boolean, @SerialName("downloads_url") val downloadsUrl: String, @SerialName("events_url") val eventsUrl: String, + @SerialName("fork") val fork: Boolean, + @SerialName("forks") val forks: Int, @SerialName("forks_count") val forksCount: Int, @@ -71,11 +76,13 @@ data class MockRepoDto( val hasProjects: Boolean, @SerialName("has_wiki") val hasWiki: Boolean, + @SerialName("homepage") val homepage: String, @SerialName("hooks_url") val hooksUrl: String, @SerialName("html_url") val htmlUrl: String, + @SerialName("id") val id: Int, @SerialName("is_template") val isTemplate: Boolean, @@ -89,9 +96,11 @@ data class MockRepoDto( val keysUrl: String, @SerialName("labels_url") val labelsUrl: String, + @SerialName("language") val language: String?, @SerialName("languages_url") val languagesUrl: String, + @SerialName("license") val license: String?, @SerialName("merges_url") val mergesUrl: String, @@ -99,6 +108,7 @@ data class MockRepoDto( val milestonesUrl: String, @SerialName("mirror_url") val mirrorUrl: String?, + @SerialName("name") val name: String, @SerialName("node_id") val nodeId: String, @@ -108,6 +118,7 @@ data class MockRepoDto( val openIssues: Int, @SerialName("open_issues_count") val openIssuesCount: Int, + @SerialName("owner") val owner: Owner, @SerialName("private") val isPrivate: Boolean, @@ -117,6 +128,7 @@ data class MockRepoDto( val pushedAt: String, @SerialName("releases_url") val releasesUrl: String, + @SerialName("size") val size: Int, @SerialName("ssh_url") val sshUrl: String, @@ -136,13 +148,17 @@ data class MockRepoDto( val tagsUrl: String, @SerialName("teams_url") val teamsUrl: String, + @SerialName("topics") val topics: List, @SerialName("trees_url") val treesUrl: String, @SerialName("updated_at") val updatedAt: String, + @SerialName("url") val url: String, + @SerialName("visibility") val visibility: String, + @SerialName("watchers") val watchers: Int, @SerialName("watchers_count") val watchersCount: Int, @@ -165,7 +181,9 @@ data class MockRepoDto( val gravatarId: String, @SerialName("html_url") val htmlUrl: String, + @SerialName("id") val id: Int, + @SerialName("login") val login: String, @SerialName("node_id") val nodeId: String, @@ -181,7 +199,9 @@ data class MockRepoDto( val starredUrl: String, @SerialName("subscriptions_url") val subscriptionsUrl: String, + @SerialName("type") val type: String, + @SerialName("url") val url: String, ) diff --git a/app/src/main/java/org/android/go/sopt/domain/model/User.kt b/app/src/main/java/org/android/go/sopt/data/entity/local/User.kt similarity index 88% rename from app/src/main/java/org/android/go/sopt/domain/model/User.kt rename to app/src/main/java/org/android/go/sopt/data/entity/local/User.kt index c970f4e..d648e0e 100644 --- a/app/src/main/java/org/android/go/sopt/domain/model/User.kt +++ b/app/src/main/java/org/android/go/sopt/data/entity/local/User.kt @@ -1,4 +1,4 @@ -package org.android.go.sopt.domain.model +package org.android.go.sopt.data.entity.local import android.os.Parcelable import kotlinx.parcelize.Parcelize diff --git a/app/src/main/java/org/android/go/sopt/data/entity/remote/wrapper/BaseResponse.kt b/app/src/main/java/org/android/go/sopt/data/entity/remote/response/wrapper/BaseResponse.kt similarity index 73% rename from app/src/main/java/org/android/go/sopt/data/entity/remote/wrapper/BaseResponse.kt rename to app/src/main/java/org/android/go/sopt/data/entity/remote/response/wrapper/BaseResponse.kt index caab5ce..0a2ac9f 100644 --- a/app/src/main/java/org/android/go/sopt/data/entity/remote/wrapper/BaseResponse.kt +++ b/app/src/main/java/org/android/go/sopt/data/entity/remote/response/wrapper/BaseResponse.kt @@ -1,4 +1,4 @@ -package org.android.go.sopt.data.entity.remote.wrapper +package org.android.go.sopt.data.entity.remote.response.wrapper import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @@ -10,5 +10,5 @@ data class BaseResponse( @SerialName("message") val message: String, @SerialName("data") - val data: T, + val data: T? = null, ) diff --git a/app/src/main/java/org/android/go/sopt/data/repository/AuthRepositoryImpl.kt b/app/src/main/java/org/android/go/sopt/data/repository/AuthRepositoryImpl.kt index 16990e1..75d0eaf 100644 --- a/app/src/main/java/org/android/go/sopt/data/repository/AuthRepositoryImpl.kt +++ b/app/src/main/java/org/android/go/sopt/data/repository/AuthRepositoryImpl.kt @@ -2,34 +2,34 @@ package org.android.go.sopt.data.repository import org.android.go.sopt.data.entity.remote.request.RequestPostSignUpDto import org.android.go.sopt.data.entity.remote.response.ResponsePostSignUpDto -import org.android.go.sopt.data.source.AuthDataSource -import org.android.go.sopt.data.source.LocalPrefDataSource -import org.android.go.sopt.domain.model.User +import org.android.go.sopt.data.source.local.SharedPrefDataSource +import org.android.go.sopt.data.source.remote.AuthDataSource +import org.android.go.sopt.data.entity.local.User import org.android.go.sopt.domain.repository.AuthRepository import javax.inject.Inject class AuthRepositoryImpl @Inject constructor( private val authDataSource: AuthDataSource, - private val localPrefDataSource: LocalPrefDataSource, + private val sharedPrefDataSource: SharedPrefDataSource, ) : AuthRepository { - override suspend fun postSignup(requestPostSignUpDto: RequestPostSignUpDto): Result = + override suspend fun postSignup(requestPostSignUpDto: RequestPostSignUpDto): Result = runCatching { authDataSource.postSignup(requestPostSignUpDto).data } override fun setAutoLogin(isAutoLogin: Boolean) { - localPrefDataSource.isAutoLogin = isAutoLogin + sharedPrefDataSource.isAutoLogin = isAutoLogin } - override fun getAutoLogin(): Boolean = localPrefDataSource.isAutoLogin + override fun getAutoLogin(): Boolean = sharedPrefDataSource.isAutoLogin override fun setSignedUpUser(user: User) { - localPrefDataSource.signedUpUser = user + sharedPrefDataSource.signedUpUser = user } - override fun getSignedUpUser(): User? = localPrefDataSource.signedUpUser + override fun getSignedUpUser(): User? = sharedPrefDataSource.signedUpUser override fun clearLocalPref() { - localPrefDataSource.clearLocalPref() + sharedPrefDataSource.clearLocalPref() } } diff --git a/app/src/main/java/org/android/go/sopt/data/repository/RepoRepositoryImpl.kt b/app/src/main/java/org/android/go/sopt/data/repository/RepoRepositoryImpl.kt index 733d6e1..25cf5d4 100644 --- a/app/src/main/java/org/android/go/sopt/data/repository/RepoRepositoryImpl.kt +++ b/app/src/main/java/org/android/go/sopt/data/repository/RepoRepositoryImpl.kt @@ -1,6 +1,6 @@ package org.android.go.sopt.data.repository -import org.android.go.sopt.data.source.RepoDataSource +import org.android.go.sopt.data.source.local.RepoDataSource import org.android.go.sopt.domain.model.Repo import org.android.go.sopt.domain.repository.RepoRepository import javax.inject.Inject diff --git a/app/src/main/java/org/android/go/sopt/data/service/AuthService.kt b/app/src/main/java/org/android/go/sopt/data/service/AuthService.kt index 68197f8..9dd01c1 100644 --- a/app/src/main/java/org/android/go/sopt/data/service/AuthService.kt +++ b/app/src/main/java/org/android/go/sopt/data/service/AuthService.kt @@ -2,7 +2,7 @@ package org.android.go.sopt.data.service import org.android.go.sopt.data.entity.remote.request.RequestPostSignUpDto import org.android.go.sopt.data.entity.remote.response.ResponsePostSignUpDto -import org.android.go.sopt.data.entity.remote.wrapper.BaseResponse +import org.android.go.sopt.data.entity.remote.response.wrapper.BaseResponse import retrofit2.http.Body import retrofit2.http.POST diff --git a/app/src/main/java/org/android/go/sopt/data/source/RepoDataSource.kt b/app/src/main/java/org/android/go/sopt/data/source/local/RepoDataSource.kt similarity index 84% rename from app/src/main/java/org/android/go/sopt/data/source/RepoDataSource.kt rename to app/src/main/java/org/android/go/sopt/data/source/local/RepoDataSource.kt index 0da411f..377c9dd 100644 --- a/app/src/main/java/org/android/go/sopt/data/source/RepoDataSource.kt +++ b/app/src/main/java/org/android/go/sopt/data/source/local/RepoDataSource.kt @@ -1,8 +1,8 @@ -package org.android.go.sopt.data.source +package org.android.go.sopt.data.source.local import kotlinx.serialization.decodeFromString import kotlinx.serialization.json.Json -import org.android.go.sopt.data.entity.MockRepoDto +import org.android.go.sopt.data.entity.local.MockRepoDto import org.android.go.sopt.util.AssetLoader import javax.inject.Inject diff --git a/app/src/main/java/org/android/go/sopt/data/source/LocalPrefDataSource.kt b/app/src/main/java/org/android/go/sopt/data/source/local/SharedPrefDataSource.kt similarity index 83% rename from app/src/main/java/org/android/go/sopt/data/source/LocalPrefDataSource.kt rename to app/src/main/java/org/android/go/sopt/data/source/local/SharedPrefDataSource.kt index def0dc7..ef5fdf0 100644 --- a/app/src/main/java/org/android/go/sopt/data/source/LocalPrefDataSource.kt +++ b/app/src/main/java/org/android/go/sopt/data/source/local/SharedPrefDataSource.kt @@ -1,15 +1,15 @@ -package org.android.go.sopt.data.source +package org.android.go.sopt.data.source.local import android.content.SharedPreferences import androidx.core.content.edit import com.google.gson.Gson import com.google.gson.GsonBuilder -import org.android.go.sopt.domain.model.User +import org.android.go.sopt.data.entity.local.User import javax.inject.Inject import javax.inject.Singleton @Singleton -class LocalPrefDataSource @Inject constructor( +class SharedPrefDataSource @Inject constructor( private val prefs: SharedPreferences, ) { var isAutoLogin: Boolean @@ -30,9 +30,7 @@ class LocalPrefDataSource @Inject constructor( } } - fun clearLocalPref() { - prefs.edit { clear() } - } + fun clearLocalPref() = prefs.edit { clear() } companion object { const val PREF_IS_AUTO_LOGIN = "IS_AUTO_LOGIN" diff --git a/app/src/main/java/org/android/go/sopt/data/source/AuthDataSource.kt b/app/src/main/java/org/android/go/sopt/data/source/remote/AuthDataSource.kt similarity index 80% rename from app/src/main/java/org/android/go/sopt/data/source/AuthDataSource.kt rename to app/src/main/java/org/android/go/sopt/data/source/remote/AuthDataSource.kt index 3afabdf..0c448a9 100644 --- a/app/src/main/java/org/android/go/sopt/data/source/AuthDataSource.kt +++ b/app/src/main/java/org/android/go/sopt/data/source/remote/AuthDataSource.kt @@ -1,8 +1,8 @@ -package org.android.go.sopt.data.source +package org.android.go.sopt.data.source.remote import org.android.go.sopt.data.entity.remote.request.RequestPostSignUpDto import org.android.go.sopt.data.entity.remote.response.ResponsePostSignUpDto -import org.android.go.sopt.data.entity.remote.wrapper.BaseResponse +import org.android.go.sopt.data.entity.remote.response.wrapper.BaseResponse import org.android.go.sopt.data.service.AuthService import javax.inject.Inject diff --git a/app/src/main/java/org/android/go/sopt/domain/repository/AuthRepository.kt b/app/src/main/java/org/android/go/sopt/domain/repository/AuthRepository.kt index efc1edf..69082ea 100644 --- a/app/src/main/java/org/android/go/sopt/domain/repository/AuthRepository.kt +++ b/app/src/main/java/org/android/go/sopt/domain/repository/AuthRepository.kt @@ -2,10 +2,10 @@ package org.android.go.sopt.domain.repository import org.android.go.sopt.data.entity.remote.request.RequestPostSignUpDto import org.android.go.sopt.data.entity.remote.response.ResponsePostSignUpDto -import org.android.go.sopt.domain.model.User +import org.android.go.sopt.data.entity.local.User interface AuthRepository { - suspend fun postSignup(requestPostSignUpDto: RequestPostSignUpDto): Result + suspend fun postSignup(requestPostSignUpDto: RequestPostSignUpDto): Result fun setAutoLogin(isAutoLogin: Boolean) diff --git a/app/src/main/java/org/android/go/sopt/presentation/login/LoginActivity.kt b/app/src/main/java/org/android/go/sopt/presentation/login/LoginActivity.kt index 903d411..ad7ae88 100644 --- a/app/src/main/java/org/android/go/sopt/presentation/login/LoginActivity.kt +++ b/app/src/main/java/org/android/go/sopt/presentation/login/LoginActivity.kt @@ -9,7 +9,7 @@ import androidx.activity.viewModels import dagger.hilt.android.AndroidEntryPoint import org.android.go.sopt.R import org.android.go.sopt.databinding.ActivityLoginBinding -import org.android.go.sopt.domain.model.User +import org.android.go.sopt.data.entity.local.User import org.android.go.sopt.presentation.main.MainActivity import org.android.go.sopt.presentation.signup.SignupActivity import org.android.go.sopt.util.state.LocalUiState.Failure diff --git a/app/src/main/java/org/android/go/sopt/presentation/login/LoginViewModel.kt b/app/src/main/java/org/android/go/sopt/presentation/login/LoginViewModel.kt index 49b4a65..1453c78 100644 --- a/app/src/main/java/org/android/go/sopt/presentation/login/LoginViewModel.kt +++ b/app/src/main/java/org/android/go/sopt/presentation/login/LoginViewModel.kt @@ -4,7 +4,7 @@ import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import dagger.hilt.android.lifecycle.HiltViewModel -import org.android.go.sopt.domain.model.User +import org.android.go.sopt.data.entity.local.User import org.android.go.sopt.domain.repository.AuthRepository import org.android.go.sopt.util.state.LocalUiState import org.android.go.sopt.util.state.LocalUiState.Failure diff --git a/app/src/main/java/org/android/go/sopt/presentation/main/gallery/GalleryFragment.kt b/app/src/main/java/org/android/go/sopt/presentation/main/gallery/GalleryFragment.kt index fe7cc9e..70936b4 100644 --- a/app/src/main/java/org/android/go/sopt/presentation/main/gallery/GalleryFragment.kt +++ b/app/src/main/java/org/android/go/sopt/presentation/main/gallery/GalleryFragment.kt @@ -30,7 +30,6 @@ class GalleryFragment : BindingFragment(R.layout.fragmen override fun onDestroyView() { super.onDestroyView() - _binding = null imageAdapter = null } diff --git a/app/src/main/java/org/android/go/sopt/presentation/main/home/HomeFragment.kt b/app/src/main/java/org/android/go/sopt/presentation/main/home/HomeFragment.kt index d00592d..03d50f4 100644 --- a/app/src/main/java/org/android/go/sopt/presentation/main/home/HomeFragment.kt +++ b/app/src/main/java/org/android/go/sopt/presentation/main/home/HomeFragment.kt @@ -7,10 +7,10 @@ import androidx.recyclerview.widget.ConcatAdapter import dagger.hilt.android.AndroidEntryPoint import org.android.go.sopt.R import org.android.go.sopt.databinding.FragmentHomeBinding -import org.android.go.sopt.util.state.LocalUiState.Failure -import org.android.go.sopt.util.state.LocalUiState.Success import org.android.go.sopt.util.binding.BindingFragment import org.android.go.sopt.util.extension.showSnackbar +import org.android.go.sopt.util.state.LocalUiState.Failure +import org.android.go.sopt.util.state.LocalUiState.Success @AndroidEntryPoint class HomeFragment : BindingFragment(R.layout.fragment_home) { diff --git a/app/src/main/java/org/android/go/sopt/presentation/main/profile/ProfileViewModel.kt b/app/src/main/java/org/android/go/sopt/presentation/main/profile/ProfileViewModel.kt index 43314dc..eb55d05 100644 --- a/app/src/main/java/org/android/go/sopt/presentation/main/profile/ProfileViewModel.kt +++ b/app/src/main/java/org/android/go/sopt/presentation/main/profile/ProfileViewModel.kt @@ -3,7 +3,7 @@ package org.android.go.sopt.presentation.main.profile import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import dagger.hilt.android.lifecycle.HiltViewModel -import org.android.go.sopt.domain.model.User +import org.android.go.sopt.data.entity.local.User import org.android.go.sopt.domain.repository.AuthRepository import javax.inject.Inject diff --git a/app/src/main/java/org/android/go/sopt/presentation/signup/SignupViewModel.kt b/app/src/main/java/org/android/go/sopt/presentation/signup/SignupViewModel.kt index 74b509c..5fee5c3 100644 --- a/app/src/main/java/org/android/go/sopt/presentation/signup/SignupViewModel.kt +++ b/app/src/main/java/org/android/go/sopt/presentation/signup/SignupViewModel.kt @@ -7,7 +7,7 @@ import androidx.lifecycle.viewModelScope import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.launch import org.android.go.sopt.data.entity.remote.request.RequestPostSignUpDto -import org.android.go.sopt.domain.model.User +import org.android.go.sopt.data.entity.local.User import org.android.go.sopt.domain.repository.AuthRepository import org.android.go.sopt.util.safeValueOf import org.android.go.sopt.util.state.RemoteUiState