Skip to content

Commit

Permalink
🎨 :: Ktlint
Browse files Browse the repository at this point in the history
ktlint
  • Loading branch information
bhindor committed Apr 6, 2023
1 parent 060bfff commit 226a1ed
Show file tree
Hide file tree
Showing 92 changed files with 129 additions and 205 deletions.
2 changes: 1 addition & 1 deletion buildSrc/src/main/java/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ object Libraries {
const val GLIDE = "com.github.bumptech.glide:glide:${Version.GLIDE}"
const val GLIDE_COMPILER = "com.github.bumptech.glide:compiler:${Version.GLIDE}"

const val TAPLAYOUT = "com.android.support.design:${Version.TAP}"
//const val TABLAYOUT = "com.android.support:design:${Version.TAB}"
object AndroidX {
const val APP_COMPAT = "androidx.appcompat:appcompat:${Version.APP_COMPAT}"
const val MATERIAL = "com.google.android.material:material:${Version.MATERIAL}"
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/java/Version.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ object Version {
const val RETROFIT = "2.9.0"
const val OKHTTP = "4.9.0"

const val TAP = "29.0.0"
//const val TAB = "28.0.0"
}
2 changes: 1 addition & 1 deletion data/src/main/java/co/dasa/data/base/BaseCache.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ import co.dasa.data.database.RoomDatabase

open class BaseCache(application: Application) {
protected val database = RoomDatabase.getInstance(application)!!
}
}
2 changes: 1 addition & 1 deletion data/src/main/java/co/dasa/data/base/BaseDataSource.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ package co.dasa.data.base
interface BaseDataSource<REMOTE, CACHE> {
val remote: REMOTE
val cache: CACHE
}
}
8 changes: 6 additions & 2 deletions data/src/main/java/co/dasa/data/base/remote/BaseDao.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package co.dasa.data.base.remote

import androidx.room.*
import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Update

@Dao
interface BaseDao<ET> {
Expand All @@ -15,4 +19,4 @@ interface BaseDao<ET> {

@Delete
suspend fun delete(entity: ET)
}
}
2 changes: 1 addition & 1 deletion data/src/main/java/co/dasa/data/base/remote/BaseRemote.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ package com.stac.data.base.remote

abstract class BaseRemote<API> {
abstract val api: API
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,17 @@ package com.stac.data.base.remote
import co.dasa.data.network.url.DasaUrl
import com.google.gson.GsonBuilder
import okhttp3.OkHttpClient
import okhttp3.ResponseBody
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Converter
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import retrofit2.converter.scalars.ScalarsConverterFactory
import java.lang.reflect.Type
import java.util.concurrent.Executors

abstract class RetrofitRemote<SV> : BaseRemote<SV>() {
protected fun <T> createApi(service: Class<T>): T {
return RETROFIT.create(service)
}


private val RETROFIT: Retrofit = Retrofit.Builder()
.client(client)
.baseUrl(DasaUrl.SERVER_HOST)
Expand All @@ -33,6 +29,4 @@ abstract class RetrofitRemote<SV> : BaseRemote<SV>() {
val okHttpBuilder = OkHttpClient().newBuilder().addInterceptor(interceptor)
return okHttpBuilder.build()
}


}
}
11 changes: 6 additions & 5 deletions data/src/main/java/co/dasa/data/database/RoomDatabase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@ abstract class RoomDatabase : androidx.room.RoomDatabase() {
.setQueryCallback({ sqlQuery, bindArgs ->
println("SQL Query: $sqlQuery SQL Args: $bindArgs")
}, Executors.newSingleThreadExecutor())
.fallbackToDestructiveMigration()
.allowMainThreadQueries()
.build()
.fallbackToDestructiveMigration()
.allowMainThreadQueries()
.build()
}
return instance
}
return instance
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ class AccountCache @Inject constructor(application: Application) : BaseCache(app
suspend fun insertAccount(accountEntity: AccountEntity) = accountDao.insert(accountEntity)

suspend fun deleteAccount() = database.accountDao().deleteAccount()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ class TokenCache @Inject constructor(application: Application) : BaseCache(appli
suspend fun insertToken(tokenEntity: TokenEntity) = tokenDao.insert(tokenEntity)
suspend fun deleteToken() = tokenDao.deleteToken()
suspend fun getToken(): TokenEntity = tokenDao.getToken()
}
}
2 changes: 1 addition & 1 deletion data/src/main/java/co/dasa/data/database/dao/AccountDao.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ interface AccountDao : BaseDao<AccountEntity> {

@Query("DELETE FROM account_table")
suspend fun deleteAccount()
}
}
2 changes: 1 addition & 1 deletion data/src/main/java/co/dasa/data/database/dao/TokenDao.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ interface TokenDao : BaseDao<TokenEntity> {

@Query("DELETE FROM token_table")
suspend fun deleteToken()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ data class TokenEntity(
val refreshToken: String
) {
constructor(token: String, refreshToken: String) : this(0, token, refreshToken)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ class AccountDataSource @Inject constructor(
suspend fun insertAccount(accountEntity: AccountEntity) = cache.insertAccount(accountEntity)

suspend fun deleteAccount() = cache.deleteAccount()
}
}
6 changes: 3 additions & 3 deletions data/src/main/java/co/dasa/data/datasource/AuthDataSource.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class AuthDataSource @Inject constructor(

suspend fun login(loginRequest: LoginRequest): LoginData = remote.login(loginRequest)

suspend fun joinUser(joinUserRequest: JoinUserRequest)= remote.joinUser(joinUserRequest)
suspend fun joinUser(joinUserRequest: JoinUserRequest) = remote.joinUser(joinUserRequest)

suspend fun joinOwner(joinOwnerRequest: JoinOwnerRequest)= remote.joinOwner(joinOwnerRequest)
}
suspend fun joinOwner(joinOwnerRequest: JoinOwnerRequest) = remote.joinOwner(joinOwnerRequest)
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ class EducationDataSource @Inject constructor(
) : BaseDataSource<EducationRemote, Any> {

suspend fun getEducationAll(page: Int): EducationDatas = remote.getEducationAll(page)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ class TokenDataSource @Inject constructor(
null
}
}
}
}
2 changes: 1 addition & 1 deletion data/src/main/java/co/dasa/data/mapper/TokenMapper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ fun Token.toEntity(): TokenEntity = TokenEntity(
idx = 0,
token = this.token,
refreshToken = this.refreshToken
)
)
4 changes: 1 addition & 3 deletions data/src/main/java/co/dasa/data/network/api/AuthApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import co.dasa.domain.request.auth.JoinOwnerRequest
import co.dasa.domain.request.auth.JoinUserRequest
import co.dasa.domain.request.auth.LoginRequest
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.POST

interface AuthApi {
Expand All @@ -24,5 +23,4 @@ interface AuthApi {
suspend fun joinOwner(
@Body joinOwnerRequest: JoinOwnerRequest
)

}
}
5 changes: 2 additions & 3 deletions data/src/main/java/co/dasa/data/network/api/EducationApi.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package co.dasa.data.network.api

import co.dasa.domain.model.education.EducationDatas
import co.dasa.data.network.url.DasaUrl
import co.dasa.domain.model.education.EducationDatas
import retrofit2.http.GET
import retrofit2.http.Query

Expand All @@ -12,5 +12,4 @@ interface EducationApi {
@Query("page") page: Int,
@Query("size") size: Int
): EducationDatas

}
}
3 changes: 0 additions & 3 deletions data/src/main/java/co/dasa/data/network/api/TokenApi.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package co.dasa.data.network.api

import co.dasa.data.network.response.LoginData
import co.dasa.data.network.url.DasaUrl
import co.dasa.domain.request.auth.LoginRequest
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.POST

interface TokenApi {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import co.dasa.data.datasource.AccountDataSource
import co.dasa.data.utils.AppDispatchers
import co.dasa.domain.exception.TokenException
import co.dasa.domain.model.token.Token
import co.dasa.domain.usecases.auth.AuthUseCases
import co.dasa.domain.usecases.auth.Login
import co.dasa.domain.usecases.token.TokenUseCases
import co.dasa.domain.util.Resource
Expand Down Expand Up @@ -142,4 +141,4 @@ class TokenInterceptor @Inject constructor(
.addHeader(TOKEN_HEADER, "Bearer ${token.token}")
.build()
.let(::proceed)
}
}
12 changes: 4 additions & 8 deletions data/src/main/java/co/dasa/data/network/remote/AuthRemote.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,21 @@ import co.dasa.data.network.response.LoginData
import co.dasa.domain.request.auth.JoinOwnerRequest
import co.dasa.domain.request.auth.JoinUserRequest
import co.dasa.domain.request.auth.LoginRequest
import com.stac.data.base.remote.BaseRemote
import com.stac.data.base.remote.RetrofitRemote
import javax.inject.Inject

class AuthRemote : RetrofitRemote<AuthApi>() {
override val api: AuthApi
get() = createApi(AuthApi::class.java)

suspend fun login(loginRequest: LoginRequest) : LoginData {
suspend fun login(loginRequest: LoginRequest): LoginData {
return api.login(loginRequest)
}

suspend fun joinUser(joinUserRequest: JoinUserRequest){
suspend fun joinUser(joinUserRequest: JoinUserRequest) {
return api.joinUser(joinUserRequest)
}

suspend fun joinOwner(joinOwnerRequest: JoinOwnerRequest){
suspend fun joinOwner(joinOwnerRequest: JoinOwnerRequest) {
return api.joinOwner(joinOwnerRequest)
}


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ class EducationRemote : RetrofitRemote<EducationApi>() {
override val api: EducationApi
get() = createApi(EducationApi::class.java)

suspend fun getEducationAll(page: Int) : EducationDatas {
suspend fun getEducationAll(page: Int): EducationDatas {
return api.getEducationAll(page, 10)
}

}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
package co.dasa.data.network.remote

import co.dasa.data.network.api.TokenApi
import com.stac.data.base.remote.BaseRemote
import com.stac.data.base.remote.RetrofitRemote
import javax.inject.Inject

class TokenRemote : RetrofitRemote<TokenApi>() {
override val api: TokenApi
get() = createApi(TokenApi::class.java)

suspend fun getNewToken(token: String): String = api.getNewToken(token)

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ data class LoginData(
val name: String,
val refreshToken: String,
val type: String
)
)
2 changes: 1 addition & 1 deletion data/src/main/java/co/dasa/data/network/url/DasaUrl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ object DasaUrl {
const val REFRESH_TOKEN = ""

const val EDUCATION_ALL = "education/list"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,18 @@ class AuthRepositoryImpl @Inject constructor(
private val tokenDataSource: TokenDataSource
) : AuthRepository {


override suspend fun login(loginRequest: LoginRequest) {
authDataSource.login(loginRequest).also {
accountDataSource.insertAccount(AccountEntity(loginRequest.userId!!, loginRequest.password!!))
tokenDataSource.insertToken(Token(it.accessToken, it.refreshToken))
}
}

override suspend fun joinUser(joinUserRequest: JoinUserRequest){
override suspend fun joinUser(joinUserRequest: JoinUserRequest) {
authDataSource.joinUser(joinUserRequest)
}

override suspend fun joinOwner(joinOwnerRequest: JoinOwnerRequest){
override suspend fun joinOwner(joinOwnerRequest: JoinOwnerRequest) {
authDataSource.joinOwner(joinOwnerRequest)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,25 +1,15 @@
package co.dasa.data.repository

import co.dasa.data.database.entity.AccountEntity
import co.dasa.data.datasource.AccountDataSource
import co.dasa.data.datasource.AuthDataSource
import co.dasa.data.datasource.EducationDataSource
import co.dasa.data.datasource.TokenDataSource
import co.dasa.domain.model.education.EducationDatas
import co.dasa.domain.model.token.Token
import co.dasa.domain.repository.AuthRepository
import co.dasa.domain.repository.EducationRepository
import co.dasa.domain.request.auth.JoinOwnerRequest
import co.dasa.domain.request.auth.JoinUserRequest
import co.dasa.domain.request.auth.LoginRequest
import javax.inject.Inject

class EducationRepositoryImpl @Inject constructor(
private val educationDataSource: EducationDataSource
) : EducationRepository {


override suspend fun getEducationAll(page: Int): EducationDatas {
return educationDataSource.getEducationAll(page)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ class TokenRepositoryImpl @Inject constructor(

override suspend fun deleteToken() =
tokenDataSource.deleteToken()
}
}
2 changes: 1 addition & 1 deletion data/src/main/java/co/dasa/data/utils/AppDispatchers.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ class AppDispatchersImpl @Inject constructor() : AppDispatchers {
override val io: CoroutineDispatcher = IO
override val main: CoroutineDispatcher = Main
override val default: CoroutineDispatcher = Default
}
}
3 changes: 1 addition & 2 deletions domain/src/main/java/co/dasa/domain/base/UseCase.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package co.dasa.domain.base

import android.util.Log
import co.dasa.domain.exception.TokenException
import co.dasa.domain.util.Resource
import co.dasa.domain.util.Utils
Expand Down Expand Up @@ -30,4 +29,4 @@ abstract class UseCase<PR, R> {
emit(Resource.Error<R>(Utils.EXCEPTION))
}
}
}
}
Loading

0 comments on commit 226a1ed

Please sign in to comment.