-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master'
- Loading branch information
Showing
29 changed files
with
323 additions
and
72 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.yapp.picon | ||
|
||
import android.app.Application | ||
import com.yapp.picon.data.di.* | ||
import com.yapp.picon.domain.di.useCaseModule | ||
import com.yapp.picon.presentation.di.viewModelModule | ||
import org.koin.android.ext.koin.androidContext | ||
import org.koin.core.context.startKoin | ||
|
||
class MainApplication : Application() { | ||
|
||
override fun onCreate() { | ||
super.onCreate() | ||
|
||
startKoin { | ||
androidContext(this@MainApplication) | ||
modules( | ||
listOf( | ||
networkModule, | ||
databaseModule, | ||
repositoryModule, | ||
localModule, | ||
remoteModule, | ||
useCaseModule, | ||
viewModelModule | ||
) | ||
) | ||
} | ||
} | ||
} |
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
18 changes: 18 additions & 0 deletions
18
Picon/app/src/main/java/com/yapp/picon/data/di/DatabaseModule.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.yapp.picon.data.di | ||
|
||
import androidx.room.Room | ||
import com.yapp.picon.data.source.searched.local.SearchedDatabase | ||
import org.koin.android.ext.koin.androidContext | ||
import org.koin.dsl.module | ||
|
||
val databaseModule = module { | ||
single { | ||
Room.databaseBuilder( | ||
androidContext(), | ||
SearchedDatabase::class.java, | ||
"searched.db" | ||
) | ||
.fallbackToDestructiveMigration() | ||
.build() | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Picon/app/src/main/java/com/yapp/picon/data/di/LocalModule.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,11 @@ | ||
package com.yapp.picon.data.di | ||
|
||
import com.yapp.picon.data.source.searched.SearchedDataSource | ||
import com.yapp.picon.data.source.searched.local.SearchedDatabase | ||
import com.yapp.picon.data.source.searched.local.SearchedLocalDataSource | ||
import org.koin.dsl.module | ||
|
||
val localModule = module { | ||
single { get<SearchedDatabase>().searchedDao() } | ||
single<SearchedDataSource> { SearchedLocalDataSource(get()) } | ||
} |
33 changes: 12 additions & 21 deletions
33
Picon/app/src/main/java/com/yapp/picon/data/di/NetworkModule.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 |
---|---|---|
@@ -1,28 +1,19 @@ | ||
package com.yapp.picon.data.di | ||
|
||
import com.yapp.picon.data.api.NaverApi | ||
import okhttp3.OkHttpClient | ||
import org.koin.dsl.module | ||
import retrofit2.Converter | ||
import retrofit2.Retrofit | ||
import retrofit2.converter.gson.GsonConverterFactory | ||
|
||
object NetworkModule { | ||
private const val NAVER_URL = "https://openapi.naver.com" | ||
val networkModule = module { | ||
factory { (baseUrl: String) -> | ||
Retrofit.Builder() | ||
.baseUrl(baseUrl) | ||
.addConverterFactory(get()) | ||
.build() | ||
} | ||
|
||
private val okHttpClient: OkHttpClient = OkHttpClient.Builder() | ||
.addInterceptor { | ||
it.proceed( | ||
it.request().newBuilder() | ||
.header("X-Naver-Client-Id", "MB0QmA3dWk5pHT2Mbz7_") | ||
.header("X-Naver-Client-Secret", "jgCRJfYDDT") | ||
.build() | ||
) | ||
} | ||
.build() | ||
|
||
val naverApi: NaverApi = Retrofit.Builder() | ||
.baseUrl(NAVER_URL) | ||
.addConverterFactory(GsonConverterFactory.create()) | ||
.client(okHttpClient) | ||
.build() | ||
.create(NaverApi::class.java) | ||
single { | ||
GsonConverterFactory.create() as Converter.Factory | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
Picon/app/src/main/java/com/yapp/picon/data/di/RemoteModule.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,13 @@ | ||
package com.yapp.picon.data.di | ||
|
||
import com.yapp.picon.data.api.NaverApi | ||
import com.yapp.picon.data.source.searched.NaverDataSource | ||
import com.yapp.picon.data.source.searched.remote.NaverRemoteDataSource | ||
import org.koin.core.parameter.parametersOf | ||
import org.koin.dsl.module | ||
import retrofit2.Retrofit | ||
|
||
val remoteModule = module { | ||
single<NaverApi> { get<Retrofit> { parametersOf("https://openapi.naver.com") }.create(NaverApi::class.java) } | ||
single<NaverDataSource> { NaverRemoteDataSource(get()) } | ||
} |
21 changes: 21 additions & 0 deletions
21
Picon/app/src/main/java/com/yapp/picon/data/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,21 @@ | ||
package com.yapp.picon.data.di | ||
|
||
import com.yapp.picon.data.source.searched.NaverRepository | ||
import com.yapp.picon.data.source.searched.NaverRepositoryImpl | ||
import com.yapp.picon.data.source.searched.SearchedRepository | ||
import com.yapp.picon.data.source.searched.SearchedRepositoryImpl | ||
import org.koin.dsl.module | ||
|
||
val repositoryModule = module { | ||
single<NaverRepository> { | ||
NaverRepositoryImpl( | ||
get() | ||
) | ||
} | ||
|
||
single<SearchedRepository> { | ||
SearchedRepositoryImpl( | ||
get() | ||
) | ||
} | ||
} |
31 changes: 0 additions & 31 deletions
31
Picon/app/src/main/java/com/yapp/picon/data/source/local/SearchedDatabase.kt
This file was deleted.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
Picon/app/src/main/java/com/yapp/picon/data/source/naver/NaverDataSource.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,7 @@ | ||
package com.yapp.picon.data.source.searched | ||
|
||
import com.yapp.picon.data.model.LocalResult | ||
|
||
interface NaverDataSource { | ||
suspend fun requestLocal(searchWord: String): LocalResult | ||
} |
7 changes: 7 additions & 0 deletions
7
Picon/app/src/main/java/com/yapp/picon/data/source/naver/NaverRepository.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,7 @@ | ||
package com.yapp.picon.data.source.searched | ||
|
||
import com.yapp.picon.data.model.LocalResult | ||
|
||
interface NaverRepository { | ||
suspend fun requestLocal(searchWord: String): LocalResult | ||
} |
9 changes: 9 additions & 0 deletions
9
Picon/app/src/main/java/com/yapp/picon/data/source/naver/NaverRepositoryImpl.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,9 @@ | ||
package com.yapp.picon.data.source.searched | ||
|
||
class NaverRepositoryImpl( | ||
private val remoteDataSource: NaverDataSource | ||
) : NaverRepository { | ||
|
||
override suspend fun requestLocal(searchWord: String) = | ||
remoteDataSource.requestLocal(searchWord) | ||
} |
13 changes: 13 additions & 0 deletions
13
Picon/app/src/main/java/com/yapp/picon/data/source/naver/remote/NaverRemoteDataSource.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,13 @@ | ||
package com.yapp.picon.data.source.searched.remote | ||
|
||
import com.yapp.picon.data.api.NaverApi | ||
import com.yapp.picon.data.model.LocalResult | ||
import com.yapp.picon.data.source.searched.NaverDataSource | ||
|
||
class NaverRemoteDataSource( | ||
private val retrofitService: NaverApi | ||
) : NaverDataSource { | ||
|
||
override suspend fun requestLocal(searchWord: String): LocalResult = | ||
retrofitService.requestLocal(searchWord) | ||
} |
9 changes: 9 additions & 0 deletions
9
Picon/app/src/main/java/com/yapp/picon/data/source/searched/SearchedDataSource.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,9 @@ | ||
package com.yapp.picon.data.source.searched | ||
|
||
import com.yapp.picon.domain.entity.SearchedEntity | ||
|
||
interface SearchedDataSource { | ||
suspend fun selectAll(): List<SearchedEntity> | ||
suspend fun insert(searchedEntity: SearchedEntity) | ||
suspend fun delete(title: String, mapX: String, mapY: String) | ||
} |
9 changes: 9 additions & 0 deletions
9
Picon/app/src/main/java/com/yapp/picon/data/source/searched/SearchedRepository.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,9 @@ | ||
package com.yapp.picon.data.source.searched | ||
|
||
import com.yapp.picon.domain.entity.SearchedEntity | ||
|
||
interface SearchedRepository { | ||
suspend fun selectAll(): List<SearchedEntity> | ||
suspend fun insert(searchedEntity: SearchedEntity) | ||
suspend fun delete(title: String, mapX: String, mapY: String) | ||
} |
17 changes: 17 additions & 0 deletions
17
Picon/app/src/main/java/com/yapp/picon/data/source/searched/SearchedRepositoryImpl.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,17 @@ | ||
package com.yapp.picon.data.source.searched | ||
|
||
import com.yapp.picon.domain.entity.SearchedEntity | ||
|
||
class SearchedRepositoryImpl( | ||
private val localDataSource: SearchedDataSource, | ||
) : SearchedRepository { | ||
|
||
override suspend fun selectAll(): List<SearchedEntity> = | ||
localDataSource.selectAll() | ||
|
||
override suspend fun insert(searchedEntity: SearchedEntity) = | ||
localDataSource.insert(searchedEntity) | ||
|
||
override suspend fun delete(title: String, mapX: String, mapY: String) = | ||
localDataSource.delete(title, mapX, mapY) | ||
} |
2 changes: 1 addition & 1 deletion
2
...yapp/picon/data/source/dao/SearchedDao.kt → ...data/source/searched/local/SearchedDao.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
10 changes: 10 additions & 0 deletions
10
Picon/app/src/main/java/com/yapp/picon/data/source/searched/local/SearchedDatabase.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,10 @@ | ||
package com.yapp.picon.data.source.searched.local | ||
|
||
import androidx.room.Database | ||
import androidx.room.RoomDatabase | ||
import com.yapp.picon.domain.entity.SearchedEntity | ||
|
||
@Database(entities = [SearchedEntity::class], version = 1, exportSchema = false) | ||
abstract class SearchedDatabase : RoomDatabase() { | ||
abstract fun searchedDao(): SearchedDao | ||
} |
18 changes: 18 additions & 0 deletions
18
Picon/app/src/main/java/com/yapp/picon/data/source/searched/local/SearchedLocalDataSource.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.yapp.picon.data.source.searched.local | ||
|
||
import com.yapp.picon.data.source.searched.SearchedDataSource | ||
import com.yapp.picon.domain.entity.SearchedEntity | ||
|
||
class SearchedLocalDataSource( | ||
private val dao: SearchedDao | ||
) : SearchedDataSource { | ||
|
||
override suspend fun selectAll(): List<SearchedEntity> = | ||
dao.selectAll() | ||
|
||
override suspend fun insert(searchedEntity: SearchedEntity) = | ||
dao.insert(searchedEntity) | ||
|
||
override suspend fun delete(title: String, mapX: String, mapY: String) = | ||
dao.delete(title, mapX, mapY) | ||
} |
22 changes: 22 additions & 0 deletions
22
Picon/app/src/main/java/com/yapp/picon/domain/di/UseCaseModule.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,22 @@ | ||
package com.yapp.picon.domain.di | ||
|
||
import com.yapp.picon.domain.usecase.* | ||
import org.koin.dsl.module | ||
|
||
val useCaseModule = module { | ||
single { | ||
SimpleJoinUseCase(get()) | ||
} | ||
single { | ||
GetLocalUseCase(get()) | ||
} | ||
single { | ||
GetAllSearedUseCase(get()) | ||
} | ||
single { | ||
InsertSearedUseCase(get()) | ||
} | ||
single { | ||
DeleteSearedUseCase(get()) | ||
} | ||
} |
Oops, something went wrong.