-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD/#1] 프로젝트 초기 세팅
- Loading branch information
Showing
86 changed files
with
1,652 additions
and
105 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 was deleted.
Oops, something went wrong.
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,25 @@ | ||
package com.terning.point | ||
|
||
import android.app.Application | ||
import androidx.appcompat.app.AppCompatDelegate | ||
import dagger.hilt.android.HiltAndroidApp | ||
import timber.log.Timber | ||
|
||
@HiltAndroidApp | ||
class MyApp : Application() { | ||
|
||
override fun onCreate() { | ||
super.onCreate() | ||
|
||
initTimber() | ||
setDayMode() | ||
} | ||
|
||
private fun initTimber() { | ||
if (BuildConfig.DEBUG) Timber.plant(Timber.DebugTree()) | ||
} | ||
|
||
private fun setDayMode() { | ||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO) | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
app/src/main/java/com/terning/point/di/DataSourceModule.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,18 @@ | ||
package com.terning.point.di | ||
|
||
import com.terning.data.datasource.MockDataSource | ||
import com.terning.data.datasourceimpl.MockDataSourceImpl | ||
import dagger.Binds | ||
import dagger.Module | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
abstract class DataSourceModule { | ||
|
||
@Binds | ||
@Singleton | ||
abstract fun bindMockDataSource(mockDataSourceImpl: MockDataSourceImpl): MockDataSource | ||
} |
18 changes: 18 additions & 0 deletions
18
app/src/main/java/com/terning/point/di/RepositoryModule.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,18 @@ | ||
package com.terning.point.di | ||
|
||
import com.terning.data.repositoryimpl.MockRepositoryImpl | ||
import com.terning.domain.repository.MockRepository | ||
import dagger.Binds | ||
import dagger.Module | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
abstract class RepositoryModule { | ||
|
||
@Binds | ||
@Singleton | ||
abstract fun bindMockRepository(mockRepositoryImpl: MockRepositoryImpl): MockRepository | ||
} |
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,78 @@ | ||
package com.terning.point.di | ||
|
||
import com.terning.core.extension.isJsonArray | ||
import com.terning.core.extension.isJsonObject | ||
import com.terning.point.BuildConfig | ||
import com.terning.point.di.qualifier.OPEN | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import kotlinx.serialization.json.Json | ||
import okhttp3.Interceptor | ||
import okhttp3.MediaType.Companion.toMediaType | ||
import okhttp3.OkHttpClient | ||
import okhttp3.logging.HttpLoggingInterceptor | ||
import org.json.JSONObject | ||
import retrofit2.Converter | ||
import retrofit2.Retrofit | ||
import retrofit2.converter.kotlinx.serialization.asConverterFactory | ||
import timber.log.Timber | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
object RetrofitModule { | ||
private const val APPLICATION_JSON = "application/json" | ||
|
||
@Provides | ||
@Singleton | ||
fun provideJson(): Json = Json { | ||
ignoreUnknownKeys = true | ||
prettyPrint = true | ||
} | ||
|
||
@Provides | ||
@Singleton | ||
fun provideJsonConverter(json: Json): Converter.Factory = | ||
json.asConverterFactory(APPLICATION_JSON.toMediaType()) | ||
|
||
@Provides | ||
@Singleton | ||
fun provideHttpLoggingInterceptor(): Interceptor = HttpLoggingInterceptor { message -> | ||
when { | ||
message.isJsonObject() -> | ||
Timber.tag("okhttp").d(JSONObject(message).toString(4)) | ||
|
||
message.isJsonArray() -> | ||
Timber.tag("okhttp").d(JSONObject(message).toString(4)) | ||
|
||
else -> { | ||
Timber.tag("okhttp").d("CONNECTION INFO -> $message") | ||
} | ||
} | ||
}.apply { | ||
level = HttpLoggingInterceptor.Level.BODY | ||
} | ||
|
||
@Provides | ||
@Singleton | ||
fun provideOkHttpClient( | ||
loggingInterceptor: Interceptor | ||
): OkHttpClient = OkHttpClient.Builder() | ||
.addInterceptor(loggingInterceptor) | ||
.build() | ||
|
||
@Provides | ||
@Singleton | ||
@OPEN | ||
fun provideOpenRetrofit( | ||
client: OkHttpClient, | ||
factory: Converter.Factory | ||
): Retrofit = Retrofit.Builder() | ||
.baseUrl(BuildConfig.OPEN_BASE_URL) | ||
.addConverterFactory(factory) | ||
.client(client) | ||
.build() | ||
|
||
} |
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 com.terning.point.di | ||
|
||
import com.terning.data.service.MockService | ||
import com.terning.point.di.qualifier.OPEN | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import retrofit2.Retrofit | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
object ServiceModule { | ||
|
||
@Provides | ||
@Singleton | ||
fun provideMockService(@OPEN retrofit: Retrofit): MockService = | ||
retrofit.create(MockService::class.java) | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
app/src/main/java/com/terning/point/di/qualifier/RetrofitQualifier.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,8 @@ | ||
package com.terning.point.di.qualifier | ||
|
||
|
||
import javax.inject.Qualifier | ||
|
||
@Qualifier | ||
@Retention(AnnotationRetention.BINARY) | ||
annotation class OPEN |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.