Skip to content

Commit

Permalink
chore: ktlintFormat
Browse files Browse the repository at this point in the history
  • Loading branch information
jinukeu committed Oct 22, 2023
1 parent df02f04 commit 74170e6
Show file tree
Hide file tree
Showing 25 changed files with 244 additions and 251 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import timber.log.Timber

@HiltAndroidApp
class SuwikiApplication : Application() {
override fun onCreate() {
super.onCreate()
if (BuildConfig.DEBUG) Timber.plant(Timber.DebugTree())
}
override fun onCreate() {
super.onCreate()
if (BuildConfig.DEBUG) Timber.plant(Timber.DebugTree())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ import com.suwiki.core.database.dao.OpenMajorDao
import com.suwiki.core.database.model.OpenMajorEntity

@Database(
entities = [OpenMajorEntity::class],
version = 1,
autoMigrations = [
AutoMigration(from = 1, to = 2, spec = OpenMajorDatabase.RenameTableAutoMigration::class),
],
exportSchema = true,
entities = [OpenMajorEntity::class],
version = 1,
autoMigrations = [
AutoMigration(from = 1, to = 2, spec = OpenMajorDatabase.RenameTableAutoMigration::class),
],
exportSchema = true,
)
abstract class OpenMajorDatabase : RoomDatabase() {
abstract fun openMajorDao(): OpenMajorDao
abstract fun openMajorDao(): OpenMajorDao

@RenameTable(fromTableName = "OpenMajorData", toTableName = "OpenMajorEntity")
class RenameTableAutoMigration : AutoMigrationSpec
}
@RenameTable(fromTableName = "OpenMajorData", toTableName = "OpenMajorEntity")
class RenameTableAutoMigration : AutoMigrationSpec
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import javax.inject.Singleton
@InstallIn(SingletonComponent::class)
object ApiModule {

@Singleton
@Provides
fun provideAuthApi(@NormalRetrofit retrofit: Retrofit): AuthApi {
return retrofit.create(AuthApi::class.java)
}
@Singleton
@Provides
fun provideAuthApi(@NormalRetrofit retrofit: Retrofit): AuthApi {
return retrofit.create(AuthApi::class.java)
}
}
6 changes: 3 additions & 3 deletions data/openmajor/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed
plugins {
id("suwiki.android.data")
id("suwiki.android.data")
}

android {
namespace = "com.suwiki.data.openmajor"
namespace = "com.suwiki.data.openmajor"
}

dependencies {
implementation(projects.domain.openmajor)
implementation(projects.domain.openmajor)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import com.suwiki.core.model.openmajor.OpenMajor
import kotlinx.coroutines.flow.Flow

interface LocalOpenMajorDataSource {
suspend fun getLocalOpenMajorVersion(): Flow<Float>
suspend fun setLocalOpenMajorVersion(version: Float)
suspend fun getLocalOpenMajorList(): List<OpenMajor>
suspend fun saveAllOpenMajors(majors: List<OpenMajor>)
suspend fun deleteAllOpenMajors()
suspend fun getLocalOpenMajorVersion(): Flow<Float>
suspend fun setLocalOpenMajorVersion(version: Float)
suspend fun getLocalOpenMajorList(): List<OpenMajor>
suspend fun saveAllOpenMajors(majors: List<OpenMajor>)
suspend fun deleteAllOpenMajors()
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.suwiki.data.openmajor.datasource

interface RemoteOpenMajorDataSource {
suspend fun getOpenMajorVersion(): Float
suspend fun getOpenMajorList(): List<String>
suspend fun getBookmarkedMajorList(): List<String>
suspend fun bookmarkMajor(majorName: String)
suspend fun removeBookmarkMajor(majorName: String)
suspend fun getOpenMajorVersion(): Float
suspend fun getOpenMajorList(): List<String>
suspend fun getBookmarkedMajorList(): List<String>
suspend fun bookmarkMajor(majorName: String)
suspend fun removeBookmarkMajor(majorName: String)
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
abstract class RemoteRepositoryModule {
abstract class RepositoryModule {

@Singleton
@Binds
abstract fun bindOpenMajorRepository(
openMajorRepositoryImpl: OpenMajorRepositoryImpl,
): OpenMajorRepository
@Singleton
@Binds
abstract fun bindOpenMajorRepository(
openMajorRepositoryImpl: OpenMajorRepositoryImpl,
): OpenMajorRepository
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,41 +12,41 @@ import kotlinx.coroutines.flow.flowOn
import javax.inject.Inject

class OpenMajorRepositoryImpl @Inject constructor(
private val localOpenMajorDataSource: LocalOpenMajorDataSource,
private val remoteOpenMajorDataSource: RemoteOpenMajorDataSource,
private val localOpenMajorDataSource: LocalOpenMajorDataSource,
private val remoteOpenMajorDataSource: RemoteOpenMajorDataSource,
) : OpenMajorRepository {
override suspend fun getOpenMajorList(): Flow<List<String>> = flow {
emit(localOpenMajorDataSource.getLocalOpenMajorList().map { it.name })

val localVersion = localOpenMajorDataSource.getLocalOpenMajorVersion().firstOrNull() ?: 0f
val remoteVersion = remoteOpenMajorDataSource.getOpenMajorVersion()

if (remoteVersion > localVersion) {
val remoteOpenMajorList = remoteOpenMajorDataSource.getOpenMajorList()

emit(remoteOpenMajorList)

with(localOpenMajorDataSource) {
deleteAllOpenMajors()
saveAllOpenMajors(
remoteOpenMajorList.mapIndexed { index, major ->
OpenMajor(id = index, name = major)
},
)
setLocalOpenMajorVersion(remoteVersion)
}
}
}.flowOn(Dispatchers.IO)

override suspend fun getBookmarkedOpenMajorList(): List<String> {
return remoteOpenMajorDataSource.getBookmarkedMajorList()
override suspend fun getOpenMajorList(): Flow<List<String>> = flow {
emit(localOpenMajorDataSource.getLocalOpenMajorList().map { it.name })

val localVersion = localOpenMajorDataSource.getLocalOpenMajorVersion().firstOrNull() ?: 0f
val remoteVersion = remoteOpenMajorDataSource.getOpenMajorVersion()

if (remoteVersion > localVersion) {
val remoteOpenMajorList = remoteOpenMajorDataSource.getOpenMajorList()

emit(remoteOpenMajorList)

with(localOpenMajorDataSource) {
deleteAllOpenMajors()
saveAllOpenMajors(
remoteOpenMajorList.mapIndexed { index, major ->
OpenMajor(id = index, name = major)
},
)
setLocalOpenMajorVersion(remoteVersion)
}
}
}.flowOn(Dispatchers.IO)

override suspend fun bookmarkMajor(majorName: String) {
remoteOpenMajorDataSource.bookmarkMajor(majorName)
}
override suspend fun getBookmarkedOpenMajorList(): List<String> {
return remoteOpenMajorDataSource.getBookmarkedMajorList()
}

override suspend fun removeBookmarkMajor(majorName: String) {
remoteOpenMajorDataSource.removeBookmarkMajor(majorName)
}
override suspend fun bookmarkMajor(majorName: String) {
remoteOpenMajorDataSource.bookmarkMajor(majorName)
}

override suspend fun removeBookmarkMajor(majorName: String) {
remoteOpenMajorDataSource.removeBookmarkMajor(majorName)
}
}
6 changes: 3 additions & 3 deletions domain/openmajor/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed
plugins {
id("suwiki.java.library")
id("suwiki.java.library")
}

dependencies {
implementation(libs.kotlinx.coroutines.core)
implementation(libs.hilt.core)
implementation(libs.kotlinx.coroutines.core)
implementation(libs.hilt.core)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package com.suwiki.domain.openmajor.repository
import kotlinx.coroutines.flow.Flow

interface OpenMajorRepository {
suspend fun getOpenMajorList(): Flow<List<String>>
suspend fun getBookmarkedOpenMajorList(): List<String>
suspend fun bookmarkMajor(majorName: String)
suspend fun removeBookmarkMajor(majorName: String)
suspend fun getOpenMajorList(): Flow<List<String>>
suspend fun getBookmarkedOpenMajorList(): List<String>
suspend fun bookmarkMajor(majorName: String)
suspend fun removeBookmarkMajor(majorName: String)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import com.suwiki.domain.openmajor.repository.OpenMajorRepository
import javax.inject.Inject

class GetBookmarkedOpenMajorListUseCase @Inject constructor(
private val openMajorRepository: OpenMajorRepository,
private val openMajorRepository: OpenMajorRepository,
) {
suspend operator fun invoke(): Result<List<String>> = kotlin.runCatching {
openMajorRepository.getBookmarkedOpenMajorList()
}
suspend operator fun invoke(): Result<List<String>> = kotlin.runCatching {
openMajorRepository.getBookmarkedOpenMajorList()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ import kotlinx.coroutines.flow.Flow
import javax.inject.Inject

class GetOpenMajorListUseCase @Inject constructor(
private val openMajorRepository: OpenMajorRepository,
private val openMajorRepository: OpenMajorRepository,
) {
/**
* 가장 먼저 LocalOpenMajorList를 emit합니다.
* 그 이후 LocalVersion과 RemoteVersion을 비교한 후
* 만약 RemoteVersion이 더 크다면 최신 데이터가 존재하는 것이므로
* RemoteOpenMajorList를 받아온 후 emit합니다.
*
* 그 이후 LocalVersion과 LocalOpenMajorList를 최신화 합니다.
*/
suspend operator fun invoke(): Flow<List<String>> {
return openMajorRepository.getOpenMajorList()
}
/**
* 가장 먼저 LocalOpenMajorList를 emit합니다.
* 그 이후 LocalVersion과 RemoteVersion을 비교한 후
* 만약 RemoteVersion이 더 크다면 최신 데이터가 존재하는 것이므로
* RemoteOpenMajorList를 받아온 후 emit합니다.
*
* 그 이후 LocalVersion과 LocalOpenMajorList를 최신화 합니다.
*/
suspend operator fun invoke(): Flow<List<String>> {
return openMajorRepository.getOpenMajorList()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import com.suwiki.domain.openmajor.repository.OpenMajorRepository
import javax.inject.Inject

class RegisterBookmarkUseCase @Inject constructor(
private val openMajorRepository: OpenMajorRepository,
private val openMajorRepository: OpenMajorRepository,
) {
suspend operator fun invoke(request: String): Result<Unit> = kotlin.runCatching {
openMajorRepository.bookmarkMajor(
request,
)
}
suspend operator fun invoke(request: String): Result<Unit> = kotlin.runCatching {
openMajorRepository.bookmarkMajor(
request,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import com.suwiki.domain.openmajor.repository.OpenMajorRepository
import javax.inject.Inject

class UnRegisterBookmarkUseCase @Inject constructor(
private val openMajorRepository: OpenMajorRepository,
private val openMajorRepository: OpenMajorRepository,
) {
suspend operator fun invoke(request: String): Result<Unit> = kotlin.runCatching {
openMajorRepository.removeBookmarkMajor(
request,
)
}
suspend operator fun invoke(request: String): Result<Unit> = kotlin.runCatching {
openMajorRepository.removeBookmarkMajor(
request,
)
}
}
6 changes: 3 additions & 3 deletions domain/user/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed
plugins {
id("suwiki.java.library")
id("suwiki.java.library")
}

dependencies {
implementation(libs.kotlinx.coroutines.core)
implementation(libs.hilt.core)
implementation(libs.kotlinx.coroutines.core)
implementation(libs.hilt.core)
}
30 changes: 15 additions & 15 deletions local/openmajor/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed
plugins {
id("suwiki.android.library")
id("suwiki.android.hilt")
id("com.google.devtools.ksp")
id("suwiki.android.library")
id("suwiki.android.hilt")
id("com.google.devtools.ksp")
}

android {
namespace = "com.suwiki.local.openmajor"
namespace = "com.suwiki.local.openmajor"
}

dependencies {
implementation(projects.core.model)
implementation(projects.data.openmajor)
implementation(projects.core.database)
implementation(projects.core.model)
implementation(projects.data.openmajor)
implementation(projects.core.database)

ksp(libs.room.compiler)
implementation(libs.room.runtime)
implementation(libs.room.ktx)
ksp(libs.room.compiler)
implementation(libs.room.runtime)
implementation(libs.room.ktx)

implementation(libs.bundles.coroutine)
implementation(libs.androidx.datastore.core)
implementation(libs.androidx.datastore.preferences)
implementation(libs.bundles.coroutine)
implementation(libs.androidx.datastore.core)
implementation(libs.androidx.datastore.preferences)

testImplementation(libs.junit4)
androidTestImplementation(libs.junit)
testImplementation(libs.junit4)
androidTestImplementation(libs.junit)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import com.suwiki.core.database.model.OpenMajorEntity
import com.suwiki.core.model.openmajor.OpenMajor

fun OpenMajorEntity.toModel() = OpenMajor(
id = id,
name = name,
id = id,
name = name,
)

fun OpenMajor.toEntity() = OpenMajorEntity(name)
Loading

0 comments on commit 74170e6

Please sign in to comment.