Skip to content

Commit

Permalink
메뉴 수정 시, 초기 데이터 초기화 (#147)
Browse files Browse the repository at this point in the history
  • Loading branch information
kymjaehong committed Dec 17, 2023
2 parents 0cf856a + aa5a943 commit b17a9f0
Show file tree
Hide file tree
Showing 109 changed files with 1,915 additions and 448 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ ktlint_standard_annotation = disabled
ktlint_standard_wrapping = disabled
ktlint_standard_argument-list-wrapping = disabled
ktlint_standard_multiline-if-else = disabled
ktlint_standard_trailing-comma-on-call-site = disabled
ktlint_standard_trailing-comma-on-declaration-site = disabled
ktlint_standard_no_blank_line_in_list = disabled

[*.{kt,kts}]
ij_kotlin_allow_trailing_comma = true
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
android:name=".App"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.Eggeum"
android:roundIcon="@mipmap/ic_launcher_round"
android:theme="@style/Theme.Eggeum"
tools:ignore="MissingApplicationIcon">

<provider
Expand All @@ -36,10 +36,10 @@
android:name=".IntroActivity"
android:exported="true"
android:theme="@style/Theme.Eggeum.Splash">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.MAIN" />-->
<!-- <category android:name="android.intent.category.LAUNCHER" />-->
<!-- </intent-filter>-->
</activity>

</application>
Expand Down
4 changes: 2 additions & 2 deletions build-logic/src/main/kotlin/internal/android.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.getByType
import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension

internal fun Project.configureAndroid(extension: CommonExtension<*, *, *, *>) {
internal fun Project.configureAndroid(extension: CommonExtension<*, *, *, *, *>) {
extension.apply {
compileSdk = ApplicationConstants.CompileSdk

Expand Down Expand Up @@ -54,7 +54,7 @@ internal val Project.isAndroidProject: Boolean
get() = pluginManager.hasPlugin(Plugins.AndroidApplication) ||
pluginManager.hasPlugin(Plugins.AndroidLibrary)

internal val Project.androidExtensions: CommonExtension<*, *, *, *>
internal val Project.androidExtensions: CommonExtension<*, *, *, *, *>
get() {
return if (pluginManager.hasPlugin(Plugins.AndroidApplication)) {
extensions.getByType<BaseAppModuleExtension>()
Expand Down
2 changes: 1 addition & 1 deletion build-logic/src/main/kotlin/internal/gmd.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import com.android.build.api.dsl.CommonExtension
import com.android.build.api.dsl.ManagedVirtualDevice
import org.gradle.kotlin.dsl.create

internal fun configureGmd(extension: CommonExtension<*, *, *, *>) {
internal fun configureGmd(extension: CommonExtension<*, *, *, *, *>) {
extension.testOptions {
managedDevices {
devices {
Expand Down
2 changes: 1 addition & 1 deletion build-logic/src/main/kotlin/public-extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ import com.android.build.api.dsl.CommonExtension
import org.gradle.api.plugins.ExtensionAware
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions

fun CommonExtension<*, *, *, *>.kotlinOptions(block: KotlinJvmOptions.() -> Unit) {
fun CommonExtension<*, *, *, *, *>.kotlinOptions(block: KotlinJvmOptions.() -> Unit) {
(this as ExtensionAware).extensions.configure("kotlinOptions", block)
}
19 changes: 17 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ plugins {
alias(libs.plugins.kotlin.ktlint)
alias(libs.plugins.gradle.dependency.handler.extensions)
alias(libs.plugins.google.gms) apply false
alias(libs.plugins.gradle.android.application) apply false
alias(libs.plugins.gradle.android.library) apply false
alias(libs.plugins.android.application) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.google.secrets) apply false
alias(libs.plugins.kotlinx.serialization) apply false
alias(libs.plugins.android.hilt) apply false
Expand Down Expand Up @@ -76,3 +76,18 @@ allprojects {
tasks.register("cleanAll", type = Delete::class) {
allprojects.map(Project::getBuildDir).forEach(::delete)
}

tasks.register("clean", type = Delete::class) {
rootProject.buildDir.delete()
}

tasks.register("bundleRelease", type = Exec::class) {
commandLine(project.rootDir.resolve("gradlew"), "bundle")
workingDir = project.rootDir
}

tasks.register("release") {
dependsOn(tasks["clean"])
dependsOn(tasks["bundleRelease"])
mustRunAfter(tasks["clean"])
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Designed and developed by Wedemy 2023.
*
* Licensed under the MIT.
* Please see full license: https://github.com/Wedemy/eggeum-android/blob/main/LICENSE
*/

package us.wedemy.eggeum.android.data.datasource.file

import us.wedemy.eggeum.android.data.model.file.FileResponse

public interface FileDataSource {
public suspend fun uploadImageFile(uri: String): FileResponse?
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Designed and developed by Wedemy 2023.
*
* Licensed under the MIT.
* Please see full license: https://github.com/Wedemy/eggeum-android/blob/main/LICENSE
*/

package us.wedemy.eggeum.android.data.datasource.file

import android.content.Context
import android.net.Uri
import javax.inject.Inject
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.MultipartBody
import okhttp3.RequestBody.Companion.asRequestBody
import us.wedemy.eggeum.android.data.model.file.FileResponse
import us.wedemy.eggeum.android.data.service.FileService
import us.wedemy.eggeum.android.data.util.FileManager
import us.wedemy.eggeum.android.data.util.safeRequest

public class FileDataSourceImpl @Inject constructor(
private val context: Context,
private val service: FileService,
private val fileManager: FileManager,
) : FileDataSource {
override suspend fun uploadImageFile(uri: String): FileResponse? {
val imageFile = fileManager.getFileForUploadImageFormat(context, Uri.parse(uri))!!
val imageRequestBody = imageFile.asRequestBody("image/*".toMediaTypeOrNull())

return safeRequest {
service.uploadImageFile(
MultipartBody.Part.createFormData(
name = "file",
filename = imageFile.name,
body = imageRequestBody,
),
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,59 @@

package us.wedemy.eggeum.android.data.datasource.login

import java.net.UnknownHostException
import javax.inject.Inject
import retrofit2.HttpException
import timber.log.Timber
import us.wedemy.eggeum.android.data.extensions.toAlertMessage
import us.wedemy.eggeum.android.data.model.login.LoginRequest
import us.wedemy.eggeum.android.data.model.login.LoginResponse
import us.wedemy.eggeum.android.data.model.login.SignUpRequest
import us.wedemy.eggeum.android.data.model.login.SignUpResponse
import us.wedemy.eggeum.android.data.service.LoginService
import us.wedemy.eggeum.android.data.util.ExceptionWrapper
import us.wedemy.eggeum.android.data.util.safeRequest
import us.wedemy.eggeum.android.domain.util.LoginApiResponseNotFound

@Suppress("TooGenericExceptionCaught")
public class LoginRemoteDataSourceImpl @Inject constructor(
private val service: LoginService,
) : LoginRemoteDataSource {
public override suspend fun login(loginRequest: LoginRequest): LoginResponse? {
return safeRequest {
service.login(loginRequest)
try {
val response = service.login(loginRequest)
if (response.isSuccessful) {
return response.body()
} else if (response.code() == 404) {
throw LoginApiResponseNotFound
} else {
val errorBody = response.errorBody()?.string() ?: "Unknown error"
Timber.d(Exception(errorBody))
throw ExceptionWrapper(
statusCode = response.code(),
message = Exception(errorBody).toAlertMessage(),
cause = Exception(errorBody),
)
}
} catch (exception: HttpException) {
Timber.d(exception)
throw ExceptionWrapper(
statusCode = exception.code(),
message = exception.response()?.errorBody()?.string() ?: exception.message(),
cause = exception,
)
} catch (exception: UnknownHostException) {
Timber.d(exception)
throw ExceptionWrapper(
message = exception.toAlertMessage(),
cause = exception,
)
} catch (exception: Exception) {
Timber.d(exception)
throw ExceptionWrapper(
message = exception.toAlertMessage(),
cause = exception,
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import us.wedemy.eggeum.android.data.model.notice.NoticeResponse
public interface NoticeDataSource {
public suspend fun getNotice(noticeId: Int): NoticeResponse?

public suspend fun getNoticeList(
public fun getNoticeList(
search: String?,
page: Int?,
size: Int?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class NoticeDataSourceImpl @Inject constructor(
}
}

override suspend fun getNoticeList(
override fun getNoticeList(
search: String?,
page: Int?,
size: Int?,
Expand All @@ -41,7 +41,6 @@ public class NoticeDataSourceImpl @Inject constructor(
config = PagingConfig(
pageSize = Constants.PAGING_SIZE,
enablePlaceholders = false,
maxSize = Constants.PAGING_SIZE * 3,
),
pagingSourceFactory = pagingSourceFactory,
).flow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import us.wedemy.eggeum.android.data.model.place.UpsertPlaceRequest
public interface PlaceDataSource {
public suspend fun getPlace(placeId: Int): PlaceResponse?

public suspend fun getPlaceList(
public fun getPlaceList(
distance: Int?,
endDate: String?,
latitude: Int?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class PlaceDataSourceImpl @Inject constructor(
}
}

override suspend fun getPlaceList(
override fun getPlaceList(
distance: Int?,
endDate: String?,
latitude: Int?,
Expand All @@ -46,7 +46,6 @@ public class PlaceDataSourceImpl @Inject constructor(
config = PagingConfig(
pageSize = Constants.PAGING_SIZE,
enablePlaceholders = false,
maxSize = Constants.PAGING_SIZE * 3,
),
pagingSourceFactory = pagingSourceFactory,
).flow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import us.wedemy.eggeum.android.data.model.report.ReportResponse
public interface ReportDataSource {
public suspend fun getReport(reportId: Int): ReportResponse?

public suspend fun getReportList(
public fun getReportList(
page: Int?,
size: Int?,
sort: String?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class ReportDataSourceImpl @Inject constructor(
}
}

override suspend fun getReportList(
override fun getReportList(
page: Int?,
size: Int?,
sort: String?,
Expand All @@ -41,7 +41,6 @@ public class ReportDataSourceImpl @Inject constructor(
config = PagingConfig(
pageSize = Constants.PAGING_SIZE,
enablePlaceholders = false,
maxSize = Constants.PAGING_SIZE * 3,
),
pagingSourceFactory = pagingSourceFactory,
).flow
Expand Down
25 changes: 25 additions & 0 deletions data/src/main/kotlin/us/wedemy/eggeum/android/data/di/AppModule.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Designed and developed by Wedemy 2023.
*
* Licensed under the MIT.
* Please see full license: https://github.com/Wedemy/eggeum-android/blob/main/LICENSE
*/

package us.wedemy.eggeum.android.data.di

import android.content.Context
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
internal object AppModule {

@Provides
@Singleton
internal fun provideApplicationContext(@ApplicationContext context: Context): Context = context
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton
import us.wedemy.eggeum.android.data.datasource.file.FileDataSource
import us.wedemy.eggeum.android.data.datasource.file.FileDataSourceImpl
import us.wedemy.eggeum.android.data.datasource.login.LoginLocalDataSource
import us.wedemy.eggeum.android.data.datasource.login.LoginLocalDataSourceImpl
import us.wedemy.eggeum.android.data.datasource.login.LoginRemoteDataSource
Expand Down Expand Up @@ -51,4 +53,8 @@ internal abstract class DataSourceModule {
@Binds
@Singleton
abstract fun bindUserDataSource(userDataSourceImpl: UserDataSourceImpl): UserDataSource

@Binds
@Singleton
abstract fun bindFileDataSource(fileDataSourceImpl: FileDataSourceImpl): FileDataSource
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package us.wedemy.eggeum.android.data.di

import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton
import us.wedemy.eggeum.android.data.util.FileManager

@Module
@InstallIn(SingletonComponent::class)
public object FileManagerModule {

@Provides
@Singleton
public fun provideFileManager(): FileManager {
return FileManager
}
}
Loading

0 comments on commit b17a9f0

Please sign in to comment.