-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEAT/#9] 6주차 과제 #10
base: develop
Are you sure you want to change the base?
[FEAT/#9] 6주차 과제 #10
Changes from 5 commits
78d9996
2408d56
f28a361
2b3d814
0ef1e95
72ef765
c98baea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,15 +16,17 @@ import androidx.navigation.NavHostController | |
import androidx.navigation.compose.NavHost | ||
import androidx.navigation.compose.composable | ||
import androidx.navigation.compose.rememberNavController | ||
import dagger.hilt.android.AndroidEntryPoint | ||
import org.sopt.and.feature.nav.BottomNavigation | ||
import org.sopt.and.feature.signin.SignInScreen | ||
import org.sopt.and.feature.signup.SignUpScreen | ||
import org.sopt.and.ui.theme.ANDANDROIDTheme | ||
import org.sopt.and.utils.KeyStorage.AUTH_PREFS | ||
import org.sopt.and.utils.KeyStorage.HOME | ||
import org.sopt.and.utils.KeyStorage.SIGN_IN | ||
import org.sopt.and.utils.KeyStorage.SIGN_UP | ||
import org.sopt.and.core.utils.KeyStorage.AUTH_PREFS | ||
import org.sopt.and.core.utils.KeyStorage.HOME | ||
import org.sopt.and.core.utils.KeyStorage.SIGN_IN | ||
import org.sopt.and.core.utils.KeyStorage.SIGN_UP | ||
Comment on lines
+24
to
+27
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 보통 core 패키징에는 어떤 친구들을 넣어두시는지 궁금합니다 ~ |
||
|
||
@AndroidEntryPoint | ||
class MainActivity : ComponentActivity() { | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package org.sopt.and | ||
|
||
import android.app.Application | ||
import dagger.hilt.android.HiltAndroidApp | ||
|
||
@HiltAndroidApp | ||
class WavveApplication : Application() |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.sopt.and.data.datasource | ||
|
||
import org.sopt.and.data.dto.request.RequestSignInDto | ||
import org.sopt.and.data.dto.request.RequestSignUpDto | ||
import org.sopt.and.data.dto.response.BaseResponse | ||
import org.sopt.and.data.dto.response.ResponseHobbyDto | ||
import org.sopt.and.data.dto.response.ResponseSignInDto | ||
import org.sopt.and.data.dto.response.ResponseSignUpDto | ||
|
||
interface AuthDataSource { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Auth기능과 getBobby 구현이 한 DataSource파일에 합쳐진 것 같아서 나중에는 분리해서 제작하는 것도 좋아보여요! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 오 넵 참고할게요-! 감사합니다 |
||
suspend fun signUp(request: RequestSignUpDto): BaseResponse<ResponseSignUpDto> | ||
|
||
suspend fun signIn(request: RequestSignInDto): BaseResponse<ResponseSignInDto> | ||
|
||
suspend fun getHobby(request: String): BaseResponse<ResponseHobbyDto> | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.sopt.and.data.datasourceimpl | ||
|
||
import org.sopt.and.data.datasource.AuthDataSource | ||
import org.sopt.and.data.dto.request.RequestSignInDto | ||
import org.sopt.and.data.dto.request.RequestSignUpDto | ||
import org.sopt.and.data.dto.response.BaseResponse | ||
import org.sopt.and.data.dto.response.ResponseHobbyDto | ||
import org.sopt.and.data.dto.response.ResponseSignInDto | ||
import org.sopt.and.data.dto.response.ResponseSignUpDto | ||
import org.sopt.and.data.service.AuthService | ||
import javax.inject.Inject | ||
|
||
class AuthDataSourceImpl @Inject constructor( | ||
private val authService: AuthService | ||
) : AuthDataSource { | ||
override suspend fun signUp(request: RequestSignUpDto): BaseResponse<ResponseSignUpDto> = | ||
authService.signUp(request) | ||
|
||
override suspend fun signIn(request: RequestSignInDto): BaseResponse<ResponseSignInDto> = | ||
authService.signIn(request) | ||
|
||
override suspend fun getHobby(request: String): BaseResponse<ResponseHobbyDto> = | ||
authService.getHobby(request) | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,18 @@ | ||||||||||||||||||
package org.sopt.and.data.di | ||||||||||||||||||
|
||||||||||||||||||
import dagger.Module | ||||||||||||||||||
import dagger.Provides | ||||||||||||||||||
import dagger.hilt.InstallIn | ||||||||||||||||||
import dagger.hilt.components.SingletonComponent | ||||||||||||||||||
import org.sopt.and.data.service.AuthService | ||||||||||||||||||
import retrofit2.Retrofit | ||||||||||||||||||
import javax.inject.Singleton | ||||||||||||||||||
|
||||||||||||||||||
@Module | ||||||||||||||||||
@InstallIn(SingletonComponent::class) | ||||||||||||||||||
object ApiModule { | ||||||||||||||||||
@Provides | ||||||||||||||||||
@Singleton | ||||||||||||||||||
fun provideAuthService(retrofit: Retrofit): AuthService = | ||||||||||||||||||
retrofit.create(AuthService::class.java) | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
이런식으로만 작성하셔도 될겁니다 |
||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.sopt.and.data.di | ||
|
||
import dagger.Binds | ||
import dagger.Module | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import org.sopt.and.data.datasource.AuthDataSource | ||
import org.sopt.and.data.datasourceimpl.AuthDataSourceImpl | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
abstract class DataSourceModule { | ||
@Binds | ||
@Singleton | ||
abstract fun bindsAuthDataSource(authDataSourceImpl: AuthDataSourceImpl): AuthDataSource | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package org.sopt.and.data.di | ||
|
||
import android.content.Context | ||
import android.content.SharedPreferences | ||
import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.android.qualifiers.ApplicationContext | ||
import dagger.hilt.components.SingletonComponent | ||
import kotlinx.serialization.ExperimentalSerializationApi | ||
import kotlinx.serialization.json.Json | ||
import okhttp3.MediaType.Companion.toMediaType | ||
import okhttp3.OkHttpClient | ||
import okhttp3.logging.HttpLoggingInterceptor | ||
import org.sopt.and.BuildConfig | ||
import retrofit2.Retrofit | ||
import java.util.concurrent.TimeUnit | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
object NetworkModule { | ||
@Provides | ||
@Singleton | ||
fun providesOkHttpClient( | ||
loggingInterceptor: HttpLoggingInterceptor, | ||
// authInterceptor: Interceptor | ||
): OkHttpClient = | ||
OkHttpClient.Builder().apply { | ||
connectTimeout(10, TimeUnit.SECONDS) | ||
writeTimeout(10, TimeUnit.SECONDS) | ||
readTimeout(10, TimeUnit.SECONDS) | ||
// addInterceptor(authInterceptor) | ||
}.build() | ||
|
||
@Provides | ||
@Singleton | ||
fun providesJson(): Json = | ||
Json { | ||
isLenient = true | ||
prettyPrint = true | ||
explicitNulls = false | ||
ignoreUnknownKeys = true | ||
} | ||
|
||
@Provides | ||
@Singleton | ||
fun provideLoggingInterceptor(): HttpLoggingInterceptor = HttpLoggingInterceptor().apply { | ||
level = HttpLoggingInterceptor.Level.BODY | ||
} | ||
|
||
@ExperimentalSerializationApi | ||
@Provides | ||
@Singleton | ||
fun provideRetrofit( | ||
okHttpClient: OkHttpClient, | ||
json: Json | ||
): Retrofit { | ||
return Retrofit.Builder() | ||
.baseUrl(BuildConfig.BASE_URL) | ||
.client(okHttpClient) | ||
.addConverterFactory(json.asConverterFactory("application/json".toMediaType())) | ||
.build() | ||
} | ||
|
||
@Provides | ||
@Singleton | ||
fun provideSharedPreferences( | ||
@ApplicationContext context: Context | ||
): SharedPreferences { | ||
return context.getSharedPreferences("APP_PREFS", Context.MODE_PRIVATE) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sharedPreferences 객체를 di를 활용하면 요렇게 관리해줄 수 있군요!! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Network에 관련된 친구라고 보기는 애매해서 따로 Module을 분리해주어도 좋을 것 같네요 |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.sopt.and.data.di | ||
|
||
import dagger.Binds | ||
import dagger.Module | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import org.sopt.and.data.repositoryimpl.AuthRepositoryImpl | ||
import org.sopt.and.domain.repository.AuthRepository | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
abstract class RepositoryModule { | ||
@Binds | ||
@Singleton | ||
abstract fun bindAuthRepository(authRepositoryImpl: AuthRepositoryImpl): AuthRepository | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 친구를 왜 추가해야할까요?
추가를 하지 않고도 할 수 있는데 어떻게 수정하면 좋을까요?