Skip to content

Commit

Permalink
[MOVE/#8] 패키지 정리
Browse files Browse the repository at this point in the history
  • Loading branch information
b1urrrr committed May 12, 2023
1 parent ebaa9b0 commit d3c3115
Show file tree
Hide file tree
Showing 16 changed files with 52 additions and 35 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -89,16 +96,19 @@ 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,
@SerialName("milestones_url")
val milestonesUrl: String,
@SerialName("mirror_url")
val mirrorUrl: String?,
@SerialName("name")
val name: String,
@SerialName("node_id")
val nodeId: String,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -136,13 +148,17 @@ data class MockRepoDto(
val tagsUrl: String,
@SerialName("teams_url")
val teamsUrl: String,
@SerialName("topics")
val topics: List<String>,
@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,
Expand All @@ -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,
Expand All @@ -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,
)

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -10,5 +10,5 @@ data class BaseResponse<T>(
@SerialName("message")
val message: String,
@SerialName("data")
val data: T,
val data: T? = null,
)
Original file line number Diff line number Diff line change
Expand Up @@ -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<ResponsePostSignUpDto> =
override suspend fun postSignup(requestPostSignUpDto: RequestPostSignUpDto): Result<ResponsePostSignUpDto?> =
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()
}
}
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ResponsePostSignUpDto>
suspend fun postSignup(requestPostSignUpDto: RequestPostSignUpDto): Result<ResponsePostSignUpDto?>

fun setAutoLogin(isAutoLogin: Boolean)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class GalleryFragment : BindingFragment<FragmentGalleryBinding>(R.layout.fragmen

override fun onDestroyView() {
super.onDestroyView()
_binding = null
imageAdapter = null
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<FragmentHomeBinding>(R.layout.fragment_home) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d3c3115

Please sign in to comment.