diff --git a/app/build.gradle b/app/build.gradle index 1904bbc..85d631b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -28,13 +28,13 @@ android { } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 } kotlinOptions { freeCompilerArgs += [ "-Xjvm-default=all"] - jvmTarget = '1.8' + jvmTarget = '17' } buildFeatures { viewBinding = true } @@ -46,16 +46,17 @@ kapt { correctErrorTypes = true } dependencies { //Android X, constraintLayout, navigation - implementation 'androidx.core:core-ktx:1.10.0' + implementation 'androidx.core:core-ktx:1.10.1' implementation 'androidx.appcompat:appcompat:1.6.1' - implementation 'com.google.android.material:material:1.8.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' - implementation "androidx.navigation:navigation-fragment-ktx:2.5.3" - implementation "androidx.navigation:navigation-ui-ktx:2.5.3" + implementation "androidx.navigation:navigation-fragment-ktx:2.6.0" + implementation "androidx.navigation:navigation-ui-ktx:2.6.0" // Android material - implementation 'com.google.android.material:material:1.8.0' + implementation 'com.google.android.material:material:1.9.0' + implementation project(path: ':data') + implementation project(path: ':domain') // Android Test Tool testImplementation 'junit:junit:4.13.2' @@ -73,8 +74,7 @@ dependencies { //Android Jetpack ViewModel implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1" - //Android Jetpack LiveData` - + //Android Jetpack LiveData implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.6.1" // Kotlin Coroutine diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 212eab0..32f4fd1 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -3,7 +3,7 @@ @@ -25,11 +25,11 @@ - if (ticker != null) { - lifecycleScope.launch(mainDispatcher) { - delay(Constants.DELAY_TIME_MILLIS) - startActivity(Intent(this@LogoActivity, MainActivity::class.java)) - finish() - } - } else { - lifecycleScope.launch(mainDispatcher) { - delay(Constants.DELAY_TIME_MILLIS) - startActivity(Intent(this@LogoActivity, SelectKoinActivity::class.java)) - finish() - } - } - } - } - -} \ No newline at end of file diff --git a/app/src/main/java/com/example/koin_apps/MainActivity.kt b/app/src/main/java/com/example/koin_apps/MainActivity.kt deleted file mode 100644 index d14b68f..0000000 --- a/app/src/main/java/com/example/koin_apps/MainActivity.kt +++ /dev/null @@ -1,62 +0,0 @@ -package com.example.koin_apps - -import android.content.Intent -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import android.util.Log -import androidx.activity.viewModels -import androidx.appcompat.app.AlertDialog -import androidx.lifecycle.lifecycleScope -import androidx.recyclerview.widget.LinearLayoutManager -import com.example.koin_apps.data.di.coroutineDispatcher.MainDispatcher -import com.example.koin_apps.data.recyclerViewAdapter.MainRecyclerAdapter -import com.example.koin_apps.viewModel.activity.MainViewModel -import com.example.koin_apps.databinding.ActivityMainBinding -import dagger.hilt.android.AndroidEntryPoint -import kotlinx.coroutines.CoroutineDispatcher -import kotlinx.coroutines.Job -import kotlinx.coroutines.launch -import javax.inject.Inject - -@AndroidEntryPoint -class MainActivity : AppCompatActivity() { - @MainDispatcher @Inject lateinit var mainDispatcher: CoroutineDispatcher - @Inject lateinit var alertDialog: AlertDialog.Builder - private val mainActivityBinding by lazy { ActivityMainBinding.inflate(layoutInflater) } - private val mainViewModel: MainViewModel by viewModels() - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - - mainActivityBinding.mainRecyclerView.layoutManager = LinearLayoutManager(this) - - fetchTickerDB() - updateUI() - - mainActivityBinding.addCoinBtn.setOnClickListener { - startActivity(Intent(this, SelectKoinActivity::class.java)) - } - - setContentView(mainActivityBinding.root) - } - - private fun updateUI() = mainViewModel.readAllTicker.observe(this) { ticker -> - if(ticker != null) { - lifecycleScope.launch(mainDispatcher) { - mainActivityBinding.mainRecyclerView.adapter = - MainRecyclerAdapter(this@MainActivity, ticker) - } - } else { lifecycleScope.launch(mainDispatcher) { showDataNullDialog() } } - } - - private fun showDataNullDialog(): AlertDialog = - alertDialog - .setIcon(R.drawable.ic_dangerous) - .setTitle(R.string.NullDialog_Title) - .setMessage(R.string.NullDialog_Content) - .setPositiveButton(R.string.NullDialog_okBtn, null) - .show() - - private fun fetchTickerDB(): Job = mainViewModel.fetchDBData() - -} \ No newline at end of file diff --git a/app/src/main/java/com/example/koin_apps/OrderBookFragment.kt b/app/src/main/java/com/example/koin_apps/OrderBookFragment.kt deleted file mode 100644 index 8ab0677..0000000 --- a/app/src/main/java/com/example/koin_apps/OrderBookFragment.kt +++ /dev/null @@ -1,86 +0,0 @@ -package com.example.koin_apps - -import android.os.Bundle -import androidx.fragment.app.Fragment -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import androidx.fragment.app.viewModels -import androidx.lifecycle.lifecycleScope -import com.example.koin_apps.data.di.coroutineDispatcher.MainDispatcher -import com.example.koin_apps.data.listViewAdapter.OrderBookAskListAdapter -import com.example.koin_apps.data.listViewAdapter.OrderBookBidListAdapter -import com.example.koin_apps.data.listViewAdapter.TransactionListAdapter -import com.example.koin_apps.databinding.FragmentOrderBookBinding -import com.example.koin_apps.viewModel.fragment.OrderBookViewModel -import dagger.hilt.android.AndroidEntryPoint -import kotlinx.coroutines.CoroutineDispatcher -import kotlinx.coroutines.launch -import javax.inject.Inject - -@AndroidEntryPoint -class OrderBookFragment : Fragment() { - @MainDispatcher @Inject lateinit var mainDispatcher: CoroutineDispatcher - private var _orderBookBinding: FragmentOrderBookBinding? = null - private val orderBookBinding get() = _orderBookBinding!! - private val orderBookViewModel: OrderBookViewModel by viewModels() - private val ticker: String by lazy { setTicker() } - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - orderBookViewModel.fetchTickerData(ticker) - } - - override fun onCreateView( - inflater: LayoutInflater, - container: ViewGroup?, - savedInstanceState: Bundle? - ): View { - _orderBookBinding = FragmentOrderBookBinding.inflate(inflater, container, false) - return orderBookBinding.root - } - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - updateTickerTextView() - updateTransactionList() - updateOrderBookList() - } - - override fun onDestroyView() { - super.onDestroyView() - _orderBookBinding = null - } - - private fun setTicker(): String = arguments?.getString("coinTitle").toString() - - private fun updateTickerTextView() = orderBookViewModel.tickerData - .observe(viewLifecycleOwner) { result -> - lifecycleScope.launch(mainDispatcher) { - orderBookBinding.orderBookTickerInfo.text = - getString( - R.string.orderBook_Ticker_Info, - result.closingPrice, - result.prevClosingPrice, - result.maxPrice, - result.minPrice, - result.unitsTraded - ) - } - } - - private fun updateTransactionList() = orderBookViewModel.transactionData - .observe(viewLifecycleOwner) { result -> - lifecycleScope.launch(mainDispatcher) { - orderBookBinding.transactionList.adapter = TransactionListAdapter(result) - } - } - - private fun updateOrderBookList() = orderBookViewModel.orderBookData - .observe(viewLifecycleOwner) { result -> - lifecycleScope.launch(mainDispatcher) { - orderBookBinding.orderBookAskList.adapter = OrderBookAskListAdapter(result.asks!!) - orderBookBinding.orderBookBidList.adapter = OrderBookBidListAdapter(result.bids!!) - } - } - -} \ No newline at end of file diff --git a/app/src/main/java/com/example/koin_apps/common/Constants.kt b/app/src/main/java/com/example/koin_apps/common/Constants.kt index 2b3ee9b..de99496 100644 --- a/app/src/main/java/com/example/koin_apps/common/Constants.kt +++ b/app/src/main/java/com/example/koin_apps/common/Constants.kt @@ -3,7 +3,7 @@ package com.example.koin_apps.common object Constants { const val BITHUMB_PUBLIC_API_URL: String = "https://api.bithumb.com/public/" const val DELAY_TIME_MILLIS: Long = 1000L - const val RETRY_MAX_ATTEMPT: Int = 3 const val LOG_TAG: String = "로그" const val LOG_ERROR_TAG: String = "에러" + const val RETRY_MAX_ATTEMPT = 3 } \ No newline at end of file diff --git a/app/src/main/java/com/example/koin_apps/data/database/TickerDataBase.kt b/app/src/main/java/com/example/koin_apps/data/database/TickerDataBase.kt deleted file mode 100644 index 81377fd..0000000 --- a/app/src/main/java/com/example/koin_apps/data/database/TickerDataBase.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.example.koin_apps.data.database - -import androidx.room.Database -import androidx.room.RoomDatabase -import com.example.koin_apps.data.database.tables.TickerEntity -import com.example.koin_apps.data.database.dao.TickerDao - -@Database(entities = [TickerEntity::class], version = 1, exportSchema = false) -abstract class TickerDataBase: RoomDatabase() { - abstract fun tickerDao(): TickerDao -} \ No newline at end of file diff --git a/app/src/main/java/com/example/koin_apps/data/di/dataSource/TickerDBDataSource.kt b/app/src/main/java/com/example/koin_apps/data/di/dataSource/TickerDBDataSource.kt deleted file mode 100644 index 16eea78..0000000 --- a/app/src/main/java/com/example/koin_apps/data/di/dataSource/TickerDBDataSource.kt +++ /dev/null @@ -1,82 +0,0 @@ -package com.example.koin_apps.data.di.dataSource - -import android.database.SQLException -import androidx.lifecycle.LiveData -import com.example.koin_apps.common.Constants -import com.example.koin_apps.data.database.dao.TickerDao -import com.example.koin_apps.data.database.tables.TickerEntity -import kotlinx.coroutines.delay -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.catch -import kotlinx.coroutines.flow.flow -import kotlinx.coroutines.flow.retryWhen -import java.io.IOException -import java.sql.SQLDataException -import javax.inject.Inject - -/** - * Ticker DataBase Select, Insert, Delete Method (Coroutine Flow Producer) - * 1. readAllTicker() : SELECT : Get All CryptoCurrency Ticker from TickerDataBase - * 2. insertTicker() : INSERT : Insert CryptoCurrency Ticker into TickerDataBase - * 3. deleteTicker() : DELETE : Delete CryptoCurrency Ticker from TickerDataBase - * */ -class TickerDBDataSource @Inject constructor( - private val tickerDAO: TickerDao -) { - fun readAllTicker(): Flow> = flow { - emit(tickerDAO.readAllTicker()) - }.catch { exception -> - when (exception) { - is IOException -> emit(listOf()) - is ClassNotFoundException -> emit(listOf()) - is SQLDataException -> emit(listOf()) - else -> throw exception - } - }.retryWhen { cause, attempt -> - if (cause is SQLException && attempt < Constants.RETRY_MAX_ATTEMPT) { - delay(Constants.DELAY_TIME_MILLIS) - true - } else { - false - } - } - - fun insertTicker(ticker: TickerEntity): Flow> = flow { - tickerDAO.insertTicker(ticker) - emit(Result.success(Unit)) - }.catch { exception -> - when (exception) { - is IOException -> emit(Result.failure(exception)) - is ClassNotFoundException -> emit(Result.failure(exception)) - is SQLDataException -> emit(Result.failure(exception)) - else -> throw exception - } - }.retryWhen {cause, attempt -> - if (cause is SQLException && attempt < Constants.RETRY_MAX_ATTEMPT) { - delay(Constants.DELAY_TIME_MILLIS) - true - } else { - false - } - } - - fun deleteTicker(ticker: TickerEntity): Flow> = flow { - tickerDAO.deleteTicker(ticker) - emit(Result.success(Unit)) - }.catch { exception -> - when (exception) { - is IOException -> emit(Result.failure(exception)) - is ClassNotFoundException -> emit(Result.failure(exception)) - is SQLDataException -> emit(Result.failure(exception)) - else -> throw exception - } - }.retryWhen {cause, attempt -> - if (cause is SQLException && attempt < Constants.RETRY_MAX_ATTEMPT) { - delay(Constants.DELAY_TIME_MILLIS) - true - } else { - false - } - } - -} \ No newline at end of file diff --git a/app/src/main/java/com/example/koin_apps/data/di/dataSource/TickerRemoteDataSource.kt b/app/src/main/java/com/example/koin_apps/data/di/dataSource/TickerRemoteDataSource.kt deleted file mode 100644 index 4b2597d..0000000 --- a/app/src/main/java/com/example/koin_apps/data/di/dataSource/TickerRemoteDataSource.kt +++ /dev/null @@ -1,150 +0,0 @@ -package com.example.koin_apps.data.di.dataSource - -import com.example.koin_apps.common.Constants -import com.example.koin_apps.data.remote.IKoinApiService -import com.example.koin_apps.data.remote.model.orderBook.OrderData -import com.example.koin_apps.data.remote.model.orderBook.OrderRoot -import com.example.koin_apps.data.remote.model.ticker.TickerRoot -import com.example.koin_apps.data.remote.model.transaction.TransactionData -import com.example.koin_apps.data.remote.model.transaction.TransactionRoot -import kotlinx.coroutines.delay -import kotlinx.coroutines.flow.flow -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.catch -import kotlinx.coroutines.flow.retryWhen -import retrofit2.HttpException -import retrofit2.Response -import java.io.IOException -import javax.inject.Inject - -/** - * Bithumb Public API Service (Coroutine Flow Producer) - * 1. getTickerInfoAll() : Get All CryptoCurrency Ticker Code - * 2. getTickerInfo() : Get Ticker's information (ex. openingPrice, closingPrice...) - * 3. getTransactionInfo() : Get CryptoCurrency Transactions - * 4. getOrderBookInfo() : Get CryptoCurrency Order information - * */ -class TickerRemoteDataSource @Inject constructor( - private val koinApiService: IKoinApiService -) { - fun getTickerInfoAll(): Flow> = flow { - val response: Response = koinApiService.getTickerALL() - - if (response.isSuccessful && response.body()?.data != null) { - val result: MutableList = response.body()?.data?.keys!!.toMutableList() - emit(result) - } else { - if (response.body()?.data == null) { - throw (NullPointerException("response body data is Null")) - } - if (!response.isSuccessful) { - throw (HttpException(response)) - } - } - }.catch { exception -> - if (exception is IOException) { - emit(mutableListOf()) - } else { throw exception } - }.retryWhen { cause, attempt -> - when { - (cause is HttpException && attempt < Constants.RETRY_MAX_ATTEMPT) -> { - delay(Constants.DELAY_TIME_MILLIS) - true - } - else -> false - } - } - - fun getTickerInfo(ticker: String): Flow?> = flow { - val response: Response = koinApiService.getTicker(ticker) - - if (response.isSuccessful && response.body()?.data != null) { - val result: Map? = response.body()?.data - emit(result) - } else { - if (response.body()?.data == null) { - throw (NullPointerException("response body data is Null")) - } - if (!response.isSuccessful) { - throw (HttpException(response)) - } - } - }.catch { exception -> - if (exception is IOException) { - TODO("emit() what?") - } else { throw exception } - }.retryWhen { cause, attempt -> - when { - (cause is HttpException && attempt < Constants.RETRY_MAX_ATTEMPT) -> { - delay(Constants.DELAY_TIME_MILLIS) - true - } - else -> false - } - } - - fun getTransactionInfo(path: String, count: Int): Flow?> = flow { - val response: Response = koinApiService.getTransactionHistory(path, count) - - if (response.isSuccessful && response.body()?.data != null) { - val result: ArrayList? = response.body()?.data - emit(result) - } else { - if (response.body()?.data == null) { - throw (NullPointerException("response body data is Null")) - } - if (!response.isSuccessful) { - throw (HttpException(response)) - } - } - }.catch { exception -> - if (exception is IOException) { - emit(ArrayList()) - } else { throw exception } - }.retryWhen { cause, attempt -> - when { - (cause is HttpException && attempt < Constants.RETRY_MAX_ATTEMPT) -> { - delay(Constants.DELAY_TIME_MILLIS) - true - } - else -> false - } - } - - fun getOrderBookInfo(path: String, count: Int): Flow = flow { - val response: Response = koinApiService.getOrderBook(path, count) - - if (response.isSuccessful && response.body()?.data != null) { - val result: OrderData = response.body()?.data!! - emit(result) - } else { - if (response.body()?.data == null) { - throw (NullPointerException("response body data is Null")) - } - if (!response.isSuccessful) { - throw (HttpException(response)) - } - } - }.catch { exception -> - if (exception is IOException) { - emit( - OrderData( - null, - null, - null, - null, - null, - null - ) - ) - } else { throw exception } - }.retryWhen { cause, attempt -> - when { - (cause is HttpException && attempt < Constants.RETRY_MAX_ATTEMPT) -> { - delay(Constants.DELAY_TIME_MILLIS) - true - } - else -> false - } - } -} \ No newline at end of file diff --git a/app/src/main/java/com/example/koin_apps/data/di/repository/TickerDBRepository.kt b/app/src/main/java/com/example/koin_apps/data/di/repository/TickerDBRepository.kt deleted file mode 100644 index e3e7bb2..0000000 --- a/app/src/main/java/com/example/koin_apps/data/di/repository/TickerDBRepository.kt +++ /dev/null @@ -1,25 +0,0 @@ -package com.example.koin_apps.data.di.repository - -import com.example.koin_apps.data.database.tables.TickerEntity -import com.example.koin_apps.data.di.dataSource.TickerDBDataSource -import kotlinx.coroutines.flow.Flow -import javax.inject.Inject - -/** - * TickerDataBase Insert, Select, Delete Method Repository (Coroutine Flow Intermediary) - * 1. readAllTicker() : SELECT : Get All CryptoCurrency Ticker from TickerDataBase - * 2. insertTicker() : INSERT : Insert CryptoCurrency Ticker into TickerDataBase - * 3. deleteTicker() : DELETE : Delete CryptoCurrency Ticker from TickerDataBase - * */ - -class TickerDBRepository @Inject constructor( - private val tickerDBDataSource: TickerDBDataSource -) { - fun readAllTicker(): Flow> = tickerDBDataSource.readAllTicker() - - fun insertTicker(ticker: TickerEntity): Flow> = - tickerDBDataSource.insertTicker(ticker) - - fun deleteTicker(ticker: TickerEntity): Flow> = - tickerDBDataSource.deleteTicker(ticker) -} \ No newline at end of file diff --git a/app/src/main/java/com/example/koin_apps/data/di/repository/TickerRepository.kt b/app/src/main/java/com/example/koin_apps/data/di/repository/TickerRepository.kt deleted file mode 100644 index b63b2c9..0000000 --- a/app/src/main/java/com/example/koin_apps/data/di/repository/TickerRepository.kt +++ /dev/null @@ -1,65 +0,0 @@ -package com.example.koin_apps.data.di.repository - -import android.icu.text.DecimalFormat -import com.example.koin_apps.data.di.dataSource.TickerRemoteDataSource -import com.example.koin_apps.data.remote.model.orderBook.OrderData -import com.example.koin_apps.data.remote.model.ticker.LiveTickerData -import com.example.koin_apps.data.remote.model.ticker.OrderTickerData -import com.example.koin_apps.data.remote.model.transaction.TransactionData -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.filter -import kotlinx.coroutines.flow.map -import javax.inject.Inject - -/** - * Convert Bithumb Public API Result (Coroutine Flow Intermediary) - * 1. getTickerInfoAll() - * - Get All CryptoCurrency Ticker Code - * 2. getTickerInfoLive() : - * - parameter : ticker(String) - * - Get Ticker closingPrice, Fluctate_24H, Fluctate_Rate_24H - * 3. getTickerInfoDetail() : - * - parameter : ticker(String) - * - Get Ticker closingPrice, PrevClosingPrice, MaxPrice, MinPrice, UnitsTraded24H - * 4. getTransactionInfo() : - * - parameter : ticker(String), count(Int) - * - Get Transaction Data - * 5. getOrderBookInfo() : - * - parameter : ticker(String), count(Int) - * - Get Transaction Data - * */ -class TickerRepository @Inject constructor( - private val tickerRemoteDataSource: TickerRemoteDataSource -) { - private val wonFormat = DecimalFormat("###,###") - private val unitsFormat = DecimalFormat("##.##") - - fun getTickerInfoALL(): Flow> = - tickerRemoteDataSource.getTickerInfoAll().filter { it.remove("date") } - - fun getTickerInfoLive(ticker: String): Flow = - tickerRemoteDataSource.getTickerInfo(ticker).map { result -> - LiveTickerData( - wonFormat.format(result?.get("closing_price").toString().toInt()), - wonFormat.format(result?.get("fluctate_24H").toString().toInt()), - unitsFormat.format(result?.get("fluctate_rate_24H").toString().toDouble()) - ) - } - - fun getTickerInfoDetail(ticker: String): Flow = - tickerRemoteDataSource.getTickerInfo(ticker).map { result -> - OrderTickerData( - wonFormat.format(result?.get("closing_price").toString().toInt()), - wonFormat.format(result?.get("prev_closing_price").toString().toInt()), - wonFormat.format(result?.get("max_price").toString().toInt()), - wonFormat.format(result?.get("min_price").toString().toInt()), - unitsFormat.format(result?.get("units_traded_24H").toString().toDouble()) - ) - } - - fun getTransactionInfo(ticker: String, count: Int): Flow?> = - tickerRemoteDataSource.getTransactionInfo(ticker, count) - - fun getOrderBookInfo(ticker: String, count: Int): Flow = - tickerRemoteDataSource.getOrderBookInfo(ticker, count) -} \ No newline at end of file diff --git a/app/src/main/java/com/example/koin_apps/data/remote/model/ticker/LiveTickerData.kt b/app/src/main/java/com/example/koin_apps/data/remote/model/ticker/LiveTickerData.kt deleted file mode 100644 index 6efacdd..0000000 --- a/app/src/main/java/com/example/koin_apps/data/remote/model/ticker/LiveTickerData.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.example.koin_apps.data.remote.model.ticker - -data class LiveTickerData ( - val closing_price: String, - val fluctate_24H: String, - val fluctate_rate_24H: String -) \ No newline at end of file diff --git a/app/src/main/java/com/example/koin_apps/data/remote/model/ticker/OrderTickerData.kt b/app/src/main/java/com/example/koin_apps/data/remote/model/ticker/OrderTickerData.kt deleted file mode 100644 index 61c3f93..0000000 --- a/app/src/main/java/com/example/koin_apps/data/remote/model/ticker/OrderTickerData.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.example.koin_apps.data.remote.model.ticker - -data class OrderTickerData ( - val closingPrice: String, - val prevClosingPrice: String, - val maxPrice: String, - val minPrice: String, - val unitsTraded: String -) \ No newline at end of file diff --git a/app/src/main/java/com/example/koin_apps/data/di/module/AlertDialogModule.kt b/app/src/main/java/com/example/koin_apps/module/AlertDialogModule.kt similarity index 87% rename from app/src/main/java/com/example/koin_apps/data/di/module/AlertDialogModule.kt rename to app/src/main/java/com/example/koin_apps/module/AlertDialogModule.kt index e8043c9..e0f8fe4 100644 --- a/app/src/main/java/com/example/koin_apps/data/di/module/AlertDialogModule.kt +++ b/app/src/main/java/com/example/koin_apps/module/AlertDialogModule.kt @@ -1,4 +1,4 @@ -package com.example.koin_apps.data.di.module +package com.example.koin_apps.module import android.content.Context import androidx.appcompat.app.AlertDialog @@ -9,7 +9,7 @@ import dagger.hilt.android.qualifiers.ApplicationContext import dagger.hilt.components.SingletonComponent import javax.inject.Singleton -/** AlertDialog Module **/ +/** AlertDialogBuilder Module **/ @Module @InstallIn(SingletonComponent::class) object AlertDialogModule { diff --git a/app/src/main/java/com/example/koin_apps/data/di/module/TickerRemoteModule.kt b/app/src/main/java/com/example/koin_apps/module/BithumbApiModule.kt similarity index 68% rename from app/src/main/java/com/example/koin_apps/data/di/module/TickerRemoteModule.kt rename to app/src/main/java/com/example/koin_apps/module/BithumbApiModule.kt index f0d20bf..32ea570 100644 --- a/app/src/main/java/com/example/koin_apps/data/di/module/TickerRemoteModule.kt +++ b/app/src/main/java/com/example/koin_apps/module/BithumbApiModule.kt @@ -1,8 +1,9 @@ -package com.example.koin_apps.data.di.module +package com.example.koin_apps.module +import com.example.data.remote.BithumbApiService +import com.example.data.repositoryImpl.BithumbApiRepositoryImpl +import com.example.domain.repository.BithumbApiRepository import com.example.koin_apps.common.Constants -import com.example.koin_apps.data.di.dataSource.TickerRemoteDataSource -import com.example.koin_apps.data.remote.IKoinApiService import dagger.Module import dagger.Provides import dagger.hilt.InstallIn @@ -16,7 +17,7 @@ import javax.inject.Singleton /** Bithumb Public Api Module **/ @Module @InstallIn(SingletonComponent::class) -object TickerRemoteModule { +object BithumbApiModule { @Provides fun providesBaseUrl(): String = Constants.BITHUMB_PUBLIC_API_URL @@ -38,11 +39,11 @@ object TickerRemoteModule { @Provides @Singleton - fun providesApiService(retrofit: Retrofit): IKoinApiService = - retrofit.create(IKoinApiService::class.java) + fun providesApiService(retrofit: Retrofit): BithumbApiService = + retrofit.create(BithumbApiService::class.java) @Provides @Singleton - fun providesDataSource(koinApiService: IKoinApiService): TickerRemoteDataSource = - TickerRemoteDataSource(koinApiService) + fun provideApiRepository(bithumbApiService: BithumbApiService): BithumbApiRepository = + BithumbApiRepositoryImpl(bithumbApiService) } \ No newline at end of file diff --git a/app/src/main/java/com/example/koin_apps/data/di/module/DispatcherModule.kt b/app/src/main/java/com/example/koin_apps/module/DispatcherModule.kt similarity index 66% rename from app/src/main/java/com/example/koin_apps/data/di/module/DispatcherModule.kt rename to app/src/main/java/com/example/koin_apps/module/DispatcherModule.kt index cecfe6e..8bde424 100644 --- a/app/src/main/java/com/example/koin_apps/data/di/module/DispatcherModule.kt +++ b/app/src/main/java/com/example/koin_apps/module/DispatcherModule.kt @@ -1,8 +1,8 @@ -package com.example.koin_apps.data.di.module +package com.example.koin_apps.module -import com.example.koin_apps.data.di.coroutineDispatcher.DefaultDispatcher -import com.example.koin_apps.data.di.coroutineDispatcher.IoDispatcher -import com.example.koin_apps.data.di.coroutineDispatcher.MainDispatcher +import com.example.koin_apps.module.coroutineDispatcher.DefaultDispatcher +import com.example.koin_apps.module.coroutineDispatcher.IoDispatcher +import com.example.koin_apps.module.coroutineDispatcher.MainDispatcher import dagger.Module import dagger.Provides import dagger.hilt.InstallIn @@ -10,7 +10,7 @@ import dagger.hilt.components.SingletonComponent import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.Dispatchers -/** Coroutine Dispatcher Module **/ +/** Coroutine Dispatcher Module (IO, Main, Default) **/ @Module @InstallIn(SingletonComponent::class) object DispatcherModule { diff --git a/app/src/main/java/com/example/koin_apps/data/di/module/TickerDBModule.kt b/app/src/main/java/com/example/koin_apps/module/TickerDBModule.kt similarity index 63% rename from app/src/main/java/com/example/koin_apps/data/di/module/TickerDBModule.kt rename to app/src/main/java/com/example/koin_apps/module/TickerDBModule.kt index b42b724..f5e3bfd 100644 --- a/app/src/main/java/com/example/koin_apps/data/di/module/TickerDBModule.kt +++ b/app/src/main/java/com/example/koin_apps/module/TickerDBModule.kt @@ -1,11 +1,11 @@ -package com.example.koin_apps.data.di.module +package com.example.koin_apps.module import android.content.Context import androidx.room.Room -import com.example.koin_apps.data.database.TickerDataBase -import com.example.koin_apps.data.database.dao.TickerDao -import com.example.koin_apps.data.di.dataSource.TickerDBDataSource -import com.example.koin_apps.data.di.repository.TickerDBRepository +import com.example.data.database.TickerDataBase +import com.example.data.database.dao.TickerDao +import com.example.data.repositoryImpl.DataBaseRepositoryImpl +import com.example.domain.repository.DataBaseRepository import dagger.Module import dagger.Provides import dagger.hilt.InstallIn @@ -13,7 +13,7 @@ import dagger.hilt.android.qualifiers.ApplicationContext import dagger.hilt.components.SingletonComponent import javax.inject.Singleton -/** Room Database Module **/ +/** Room ORM (Local Database) Module **/ @Module @InstallIn(SingletonComponent::class) object TickerDBModule { @@ -29,5 +29,6 @@ object TickerDBModule { @Provides @Singleton - fun providesCoinDBRepository(tickerDAO: TickerDao) = TickerDBDataSource(tickerDAO) + fun provideDaoService(tickerDao: TickerDao): DataBaseRepository = + DataBaseRepositoryImpl(tickerDao) } \ No newline at end of file diff --git a/app/src/main/java/com/example/koin_apps/data/di/module/ToastModule.kt b/app/src/main/java/com/example/koin_apps/module/ToastModule.kt similarity index 92% rename from app/src/main/java/com/example/koin_apps/data/di/module/ToastModule.kt rename to app/src/main/java/com/example/koin_apps/module/ToastModule.kt index c5d0653..f6321fc 100644 --- a/app/src/main/java/com/example/koin_apps/data/di/module/ToastModule.kt +++ b/app/src/main/java/com/example/koin_apps/module/ToastModule.kt @@ -1,4 +1,4 @@ -package com.example.koin_apps.data.di.module +package com.example.koin_apps.module import android.content.Context import android.widget.Toast diff --git a/app/src/main/java/com/example/koin_apps/data/di/coroutineDispatcher/DispatcherQualifier.kt b/app/src/main/java/com/example/koin_apps/module/coroutineDispatcher/DispatcherQualifier.kt similarity index 60% rename from app/src/main/java/com/example/koin_apps/data/di/coroutineDispatcher/DispatcherQualifier.kt rename to app/src/main/java/com/example/koin_apps/module/coroutineDispatcher/DispatcherQualifier.kt index 75a161f..247ad93 100644 --- a/app/src/main/java/com/example/koin_apps/data/di/coroutineDispatcher/DispatcherQualifier.kt +++ b/app/src/main/java/com/example/koin_apps/module/coroutineDispatcher/DispatcherQualifier.kt @@ -1,16 +1,18 @@ -package com.example.koin_apps.data.di.coroutineDispatcher +package com.example.koin_apps.module.coroutineDispatcher import javax.inject.Qualifier -/** Coroutine Dispatcher Qualifier **/ +/** Coroutine IoDispatcher Qualifier **/ @Retention(AnnotationRetention.RUNTIME) @Qualifier annotation class IoDispatcher +/** Coroutine DefaultDispatcher Qualifier **/ @Retention(AnnotationRetention.RUNTIME) @Qualifier annotation class DefaultDispatcher +/** Coroutine MainDispatcher Qualifier **/ @Retention(AnnotationRetention.RUNTIME) @Qualifier annotation class MainDispatcher diff --git a/app/src/main/java/com/example/koin_apps/AndroidApp.kt b/app/src/main/java/com/example/koin_apps/presenter/AndroidApp.kt similarity index 75% rename from app/src/main/java/com/example/koin_apps/AndroidApp.kt rename to app/src/main/java/com/example/koin_apps/presenter/AndroidApp.kt index 1069b29..d19757d 100644 --- a/app/src/main/java/com/example/koin_apps/AndroidApp.kt +++ b/app/src/main/java/com/example/koin_apps/presenter/AndroidApp.kt @@ -1,4 +1,4 @@ -package com.example.koin_apps +package com.example.koin_apps.presenter import android.app.Application import dagger.hilt.android.HiltAndroidApp diff --git a/app/src/main/java/com/example/koin_apps/LiveTimeActivity.kt b/app/src/main/java/com/example/koin_apps/presenter/LiveTimeActivity.kt similarity index 56% rename from app/src/main/java/com/example/koin_apps/LiveTimeActivity.kt rename to app/src/main/java/com/example/koin_apps/presenter/LiveTimeActivity.kt index 73cb2fa..3102d35 100644 --- a/app/src/main/java/com/example/koin_apps/LiveTimeActivity.kt +++ b/app/src/main/java/com/example/koin_apps/presenter/LiveTimeActivity.kt @@ -1,24 +1,20 @@ -package com.example.koin_apps +package com.example.koin_apps.presenter import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import androidx.activity.viewModels -import androidx.lifecycle.lifecycleScope -import com.example.koin_apps.data.di.coroutineDispatcher.MainDispatcher +import com.example.koin_apps.R import com.example.koin_apps.databinding.ActivityLiveTimeBinding -import com.example.koin_apps.viewModel.activity.LiveTimeViewModel +import com.example.koin_apps.presenter.viewModel.LiveTimeViewModel import dagger.hilt.android.AndroidEntryPoint -import kotlinx.coroutines.CoroutineDispatcher -import kotlinx.coroutines.launch -import javax.inject.Inject @AndroidEntryPoint class LiveTimeActivity : AppCompatActivity() { - @MainDispatcher @Inject lateinit var mainDispatcher: CoroutineDispatcher private val liveTimeBinding by lazy { ActivityLiveTimeBinding.inflate(layoutInflater) } private val liveTimeViewModel: LiveTimeViewModel by viewModels() - private val orderBookFragment = OrderBookFragment() - private val fragmentBundle = Bundle() + + private val orderBookFragment: OrderBookFragment = OrderBookFragment() + private val fragmentBundle: Bundle = Bundle() private val ticker: String by lazy { setTicker() } override fun onCreate(savedInstanceState: Bundle?) { @@ -29,8 +25,7 @@ class LiveTimeActivity : AppCompatActivity() { updateTickerTitle() updateTickerInfo() - supportFragmentManager - .beginTransaction() + supportFragmentManager.beginTransaction() .replace(R.id.FragmentLayout, orderBookFragment) .commit() @@ -47,14 +42,9 @@ class LiveTimeActivity : AppCompatActivity() { private fun updateTickerTitle() { liveTimeBinding.coinTitle.text = ticker } private fun updateTickerInfo() = liveTimeViewModel.tickerLiveViewData.observe(this) { - lifecycleScope.launch(mainDispatcher) { - liveTimeBinding.tickerWon.text = - getString(R.string.tickerWon, it.closing_price) - liveTimeBinding.Flucatate24H.text = - getString(R.string.ticker_Flucatate_won24H, it.fluctate_24H) - liveTimeBinding.FlucatateRate24H.text = - getString(R.string.ticker_Flucatate_rate24H, it.fluctate_rate_24H) - } + liveTimeBinding.tickerWon.text = getString(R.string.tickerWon, it.closingPrice.toString()) + liveTimeBinding.Flucatate24H.text = getString(R.string.ticker_Flucatate_won24H, it.fluctate_24H.toString()) + liveTimeBinding.FlucatateRate24H.text = getString(R.string.ticker_Flucatate_rate24H, it.fluctate_Rate.toString()) } } diff --git a/app/src/main/java/com/example/koin_apps/presenter/LogoActivity.kt b/app/src/main/java/com/example/koin_apps/presenter/LogoActivity.kt new file mode 100644 index 0000000..5b01dbe --- /dev/null +++ b/app/src/main/java/com/example/koin_apps/presenter/LogoActivity.kt @@ -0,0 +1,32 @@ +package com.example.koin_apps.presenter + +import android.content.Intent +import androidx.appcompat.app.AppCompatActivity +import android.os.Bundle +import androidx.activity.viewModels +import com.example.koin_apps.databinding.ActivityLogoBinding +import com.example.koin_apps.presenter.viewModel.LogoViewModel +import dagger.hilt.android.AndroidEntryPoint + +@AndroidEntryPoint +class LogoActivity : AppCompatActivity() { + private val logoBinding by lazy { ActivityLogoBinding.inflate(layoutInflater) } + private val logoViewModel: LogoViewModel by viewModels() + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + logoViewModel.readAllTicker.observe(this) { tickerList -> + if (tickerList != null) { + startActivity(Intent(this, MainActivity::class.java)) + finish() + } else { + startActivity(Intent(this, SelectKoinActivity::class.java)) + finish() + } + } + + setContentView(logoBinding.root) + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/example/koin_apps/presenter/MainActivity.kt b/app/src/main/java/com/example/koin_apps/presenter/MainActivity.kt new file mode 100644 index 0000000..5bb85f2 --- /dev/null +++ b/app/src/main/java/com/example/koin_apps/presenter/MainActivity.kt @@ -0,0 +1,60 @@ +package com.example.koin_apps.presenter + +import android.content.Intent +import androidx.appcompat.app.AppCompatActivity +import android.os.Bundle +import androidx.activity.viewModels +import androidx.appcompat.app.AlertDialog +import androidx.recyclerview.widget.LinearLayoutManager +import androidx.recyclerview.widget.RecyclerView +import com.example.koin_apps.R +import com.example.koin_apps.presenter.adapter.recyclerViewAdapter.MainRecyclerAdapter +import com.example.koin_apps.presenter.viewModel.MainViewModel +import com.example.koin_apps.databinding.ActivityMainBinding +import dagger.hilt.android.AndroidEntryPoint +import kotlinx.coroutines.Job +import javax.inject.Inject + +@AndroidEntryPoint +class MainActivity : AppCompatActivity() { + @Inject lateinit var alertDialog: AlertDialog.Builder + + private val mainActivityBinding by lazy { ActivityMainBinding.inflate(layoutInflater) } + private val mainRecyclerView by lazy { mainActivityBinding.mainRecyclerView } + private val mainViewModel: MainViewModel by viewModels() + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + fetchTickerDB() + initRecyclerView() + + mainViewModel.tickerAllData.observe(this) { tickerList -> + if (tickerList != null) { + mainRecyclerView.adapter = MainRecyclerAdapter(this, tickerList) + } else { + showDataNullDialog() + } + } + + mainActivityBinding.addCoinBtn.setOnClickListener { + startActivity(Intent(this, SelectKoinActivity::class.java)) + } + + setContentView(mainActivityBinding.root) + } + + private fun fetchTickerDB(): Job = mainViewModel.fetchAllTickerData() + + private fun initRecyclerView(): RecyclerView = mainActivityBinding.mainRecyclerView.apply { + layoutManager = LinearLayoutManager(this@MainActivity) + setHasFixedSize(true) + } + + private fun showDataNullDialog(): AlertDialog = alertDialog + .setIcon(R.drawable.ic_dangerous) + .setTitle(R.string.NullDialog_Title) + .setMessage(R.string.NullDialog_Content) + .setPositiveButton(R.string.NullDialog_okBtn, null) + .show() + +} \ No newline at end of file diff --git a/app/src/main/java/com/example/koin_apps/presenter/OrderBookFragment.kt b/app/src/main/java/com/example/koin_apps/presenter/OrderBookFragment.kt new file mode 100644 index 0000000..caafc10 --- /dev/null +++ b/app/src/main/java/com/example/koin_apps/presenter/OrderBookFragment.kt @@ -0,0 +1,69 @@ +package com.example.koin_apps.presenter + +import android.os.Bundle +import androidx.fragment.app.Fragment +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.viewModels +import com.example.koin_apps.R +import com.example.koin_apps.presenter.adapter.listViewAdapter.OrderBookAskListAdapter +import com.example.koin_apps.presenter.adapter.listViewAdapter.OrderBookBidListAdapter +import com.example.koin_apps.presenter.adapter.listViewAdapter.TransactionListAdapter +import com.example.koin_apps.databinding.FragmentOrderBookBinding +import com.example.koin_apps.presenter.viewModel.OrderBookViewModel +import dagger.hilt.android.AndroidEntryPoint + +@AndroidEntryPoint +class OrderBookFragment : Fragment() { + private var _orderBookBinding: FragmentOrderBookBinding? = null + private val orderBookBinding get() = _orderBookBinding!! + private val orderBookViewModel: OrderBookViewModel by viewModels() + + private val ticker: String by lazy { setTicker() } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + orderBookViewModel.fetchTickerData(ticker) + } + + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View { + _orderBookBinding = FragmentOrderBookBinding.inflate(inflater, container, false) + return orderBookBinding.root + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + orderBookViewModel.tickerData.observe(viewLifecycleOwner) { result -> + orderBookBinding.orderBookTickerInfo.text = getString( + R.string.orderBook_Ticker_Info, + result.closingPrice.toString(), + result.prevClosingPrice.toString(), + result.maxPrice.toString(), + result.minPrice.toString(), + result.unitsTraded_24H.toString() + ) + } + + orderBookViewModel.transactionData.observe(viewLifecycleOwner) { result -> + orderBookBinding.transactionList.adapter = TransactionListAdapter(result) + } + + orderBookViewModel.orderBookData.observe(viewLifecycleOwner) { result -> + orderBookBinding.orderBookAskList.adapter = OrderBookAskListAdapter(result.asks!!) + orderBookBinding.orderBookBidList.adapter = OrderBookBidListAdapter(result.bids!!) + } + + } + + override fun onDestroyView() { + super.onDestroyView() + _orderBookBinding = null + } + + private fun setTicker(): String = arguments?.getString("coinTitle").toString() + +} \ No newline at end of file diff --git a/app/src/main/java/com/example/koin_apps/SelectKoinActivity.kt b/app/src/main/java/com/example/koin_apps/presenter/SelectKoinActivity.kt similarity index 54% rename from app/src/main/java/com/example/koin_apps/SelectKoinActivity.kt rename to app/src/main/java/com/example/koin_apps/presenter/SelectKoinActivity.kt index aca5303..2f7be9c 100644 --- a/app/src/main/java/com/example/koin_apps/SelectKoinActivity.kt +++ b/app/src/main/java/com/example/koin_apps/presenter/SelectKoinActivity.kt @@ -1,50 +1,48 @@ -package com.example.koin_apps +package com.example.koin_apps.presenter import android.content.Intent import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import androidx.activity.viewModels -import androidx.lifecycle.lifecycleScope import androidx.recyclerview.widget.LinearLayoutManager -import com.example.koin_apps.data.di.coroutineDispatcher.MainDispatcher -import com.example.koin_apps.data.recyclerViewAdapter.SelectRecyclerAdapter +import com.example.koin_apps.presenter.adapter.recyclerViewAdapter.SelectRecyclerAdapter import com.example.koin_apps.databinding.ActivitySelectKoinBinding -import com.example.koin_apps.viewModel.activity.SelectViewModel +import com.example.koin_apps.presenter.viewModel.SelectViewModel import dagger.hilt.android.AndroidEntryPoint -import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.Job -import kotlinx.coroutines.launch -import javax.inject.Inject @AndroidEntryPoint class SelectKoinActivity : AppCompatActivity() { - @MainDispatcher @Inject lateinit var mainDispatcher: CoroutineDispatcher - private lateinit var selectRecyclerAdapter: SelectRecyclerAdapter private val selectKoinBinding by lazy { ActivitySelectKoinBinding.inflate(layoutInflater) } private val selectViewModel: SelectViewModel by viewModels() + private lateinit var selectRecyclerAdapter: SelectRecyclerAdapter + private val selectedTickerList: List by lazy { selectRecyclerAdapter.getSelectedItems() } + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - selectKoinBinding.CoinRecyclerView.layoutManager = LinearLayoutManager(this) - + initRecyclerView() updateTickerList() + selectKoinBinding.compSelectBtn.setOnClickListener { - storeTicker() + storeTicker(selectedTickerList) startActivity(Intent(this, MainActivity::class.java)) } setContentView(selectKoinBinding.root) } - private fun updateTickerList() = selectViewModel.tickerList.observe(this) { result -> - lifecycleScope.launch(mainDispatcher) { - selectRecyclerAdapter = SelectRecyclerAdapter(result) - selectKoinBinding.CoinRecyclerView.adapter = selectRecyclerAdapter - } + private fun initRecyclerView() = selectKoinBinding.CoinRecyclerView.apply { + layoutManager = LinearLayoutManager(this@SelectKoinActivity) + setHasFixedSize(true) } - private fun storeTicker(): Job = - selectViewModel.storeTickerTitle(selectRecyclerAdapter.getSelectedItems()) + private fun updateTickerList() = selectViewModel.tickerList.observe(this) { result -> + selectRecyclerAdapter = SelectRecyclerAdapter(result) + selectKoinBinding.CoinRecyclerView.adapter = selectRecyclerAdapter + } + private fun storeTicker(selectedTickers: List): Job = + selectViewModel.storeTickerTitle(selectedTickers) } \ No newline at end of file diff --git a/app/src/main/java/com/example/koin_apps/data/listViewAdapter/OrderBookAskListAdapter.kt b/app/src/main/java/com/example/koin_apps/presenter/adapter/listViewAdapter/OrderBookAskListAdapter.kt similarity index 86% rename from app/src/main/java/com/example/koin_apps/data/listViewAdapter/OrderBookAskListAdapter.kt rename to app/src/main/java/com/example/koin_apps/presenter/adapter/listViewAdapter/OrderBookAskListAdapter.kt index 141373d..2c7b4eb 100644 --- a/app/src/main/java/com/example/koin_apps/data/listViewAdapter/OrderBookAskListAdapter.kt +++ b/app/src/main/java/com/example/koin_apps/presenter/adapter/listViewAdapter/OrderBookAskListAdapter.kt @@ -1,16 +1,16 @@ -package com.example.koin_apps.data.listViewAdapter +package com.example.koin_apps.presenter.adapter.listViewAdapter import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.BaseAdapter import android.widget.TextView +import com.example.domain.entity.OrderAskBidEntity import com.example.koin_apps.R -import com.example.koin_apps.data.remote.model.orderBook.OrderAskBidData import javax.inject.Inject class OrderBookAskListAdapter @Inject constructor( - private val orderAskList: ArrayList + private val orderAskList: List ): BaseAdapter() { override fun getView(position: Int, view: View?, parent: ViewGroup?): View { var convertView = view diff --git a/app/src/main/java/com/example/koin_apps/data/listViewAdapter/OrderBookBidListAdapter.kt b/app/src/main/java/com/example/koin_apps/presenter/adapter/listViewAdapter/OrderBookBidListAdapter.kt similarity index 86% rename from app/src/main/java/com/example/koin_apps/data/listViewAdapter/OrderBookBidListAdapter.kt rename to app/src/main/java/com/example/koin_apps/presenter/adapter/listViewAdapter/OrderBookBidListAdapter.kt index c5c7cef..02419a9 100644 --- a/app/src/main/java/com/example/koin_apps/data/listViewAdapter/OrderBookBidListAdapter.kt +++ b/app/src/main/java/com/example/koin_apps/presenter/adapter/listViewAdapter/OrderBookBidListAdapter.kt @@ -1,16 +1,16 @@ -package com.example.koin_apps.data.listViewAdapter +package com.example.koin_apps.presenter.adapter.listViewAdapter import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.BaseAdapter import android.widget.TextView +import com.example.domain.entity.OrderAskBidEntity import com.example.koin_apps.R -import com.example.koin_apps.data.remote.model.orderBook.OrderAskBidData import javax.inject.Inject class OrderBookBidListAdapter @Inject constructor( - private val orderBidList: ArrayList + private val orderBidList: List ): BaseAdapter() { override fun getView(position: Int, view: View?, parent: ViewGroup?): View { var convertView = view diff --git a/app/src/main/java/com/example/koin_apps/data/listViewAdapter/TransactionListAdapter.kt b/app/src/main/java/com/example/koin_apps/presenter/adapter/listViewAdapter/TransactionListAdapter.kt similarity index 87% rename from app/src/main/java/com/example/koin_apps/data/listViewAdapter/TransactionListAdapter.kt rename to app/src/main/java/com/example/koin_apps/presenter/adapter/listViewAdapter/TransactionListAdapter.kt index a705626..f441f21 100644 --- a/app/src/main/java/com/example/koin_apps/data/listViewAdapter/TransactionListAdapter.kt +++ b/app/src/main/java/com/example/koin_apps/presenter/adapter/listViewAdapter/TransactionListAdapter.kt @@ -1,16 +1,16 @@ -package com.example.koin_apps.data.listViewAdapter +package com.example.koin_apps.presenter.adapter.listViewAdapter import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.BaseAdapter import android.widget.TextView +import com.example.domain.entity.TransactionEntity import com.example.koin_apps.R -import com.example.koin_apps.data.remote.model.transaction.TransactionData import javax.inject.Inject class TransactionListAdapter @Inject constructor( - private val transactionList: ArrayList + private val transactionList: List ): BaseAdapter() { override fun getView(position: Int, view: View?, parent: ViewGroup?): View { var convertView = view diff --git a/app/src/main/java/com/example/koin_apps/data/recyclerViewAdapter/MainRecyclerAdapter.kt b/app/src/main/java/com/example/koin_apps/presenter/adapter/recyclerViewAdapter/MainRecyclerAdapter.kt similarity index 82% rename from app/src/main/java/com/example/koin_apps/data/recyclerViewAdapter/MainRecyclerAdapter.kt rename to app/src/main/java/com/example/koin_apps/presenter/adapter/recyclerViewAdapter/MainRecyclerAdapter.kt index 247d9c8..c72a250 100644 --- a/app/src/main/java/com/example/koin_apps/data/recyclerViewAdapter/MainRecyclerAdapter.kt +++ b/app/src/main/java/com/example/koin_apps/presenter/adapter/recyclerViewAdapter/MainRecyclerAdapter.kt @@ -1,12 +1,12 @@ -package com.example.koin_apps.data.recyclerViewAdapter +package com.example.koin_apps.presenter.adapter.recyclerViewAdapter import android.content.Context import android.content.Intent import android.view.LayoutInflater import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView -import com.example.koin_apps.LiveTimeActivity -import com.example.koin_apps.data.database.tables.TickerEntity +import com.example.domain.entity.TickerEntity +import com.example.koin_apps.presenter.LiveTimeActivity import com.example.koin_apps.databinding.MainCoinviewItemBinding import javax.inject.Inject @@ -19,10 +19,10 @@ class MainRecyclerAdapter @Inject constructor( :RecyclerView.ViewHolder(binding.root) { fun bind(tickerEntity: TickerEntity) { - binding.titleCoin.text = tickerEntity.Ticker + binding.titleCoin.text = tickerEntity.ticker binding.NavigateCoinDesc.setOnClickListener { Intent(context, LiveTimeActivity::class.java) - .putExtra("coinTitle", tickerEntity.Ticker) + .putExtra("coinTitle", tickerEntity.ticker) .run { context.startActivity(this) } } } diff --git a/app/src/main/java/com/example/koin_apps/data/recyclerViewAdapter/SelectRecyclerAdapter.kt b/app/src/main/java/com/example/koin_apps/presenter/adapter/recyclerViewAdapter/SelectRecyclerAdapter.kt similarity index 77% rename from app/src/main/java/com/example/koin_apps/data/recyclerViewAdapter/SelectRecyclerAdapter.kt rename to app/src/main/java/com/example/koin_apps/presenter/adapter/recyclerViewAdapter/SelectRecyclerAdapter.kt index 0f666fc..ef603e6 100644 --- a/app/src/main/java/com/example/koin_apps/data/recyclerViewAdapter/SelectRecyclerAdapter.kt +++ b/app/src/main/java/com/example/koin_apps/presenter/adapter/recyclerViewAdapter/SelectRecyclerAdapter.kt @@ -1,4 +1,4 @@ -package com.example.koin_apps.data.recyclerViewAdapter +package com.example.koin_apps.presenter.adapter.recyclerViewAdapter import android.view.LayoutInflater import android.view.ViewGroup @@ -7,7 +7,7 @@ import com.example.koin_apps.databinding.SelectCoinviewItemBinding import javax.inject.Inject class SelectRecyclerAdapter @Inject constructor( - private var tickerList: List?, + private val tickerList: List?, ): RecyclerView.Adapter() { private val selectedTickerList: MutableList = mutableListOf() @@ -17,13 +17,16 @@ class SelectRecyclerAdapter @Inject constructor( fun bind(ticker: String) { binding.titleCoin.text = ticker binding.checkCoin.setOnCheckedChangeListener { _, isChecked -> - if (isChecked) { selectedTickerList.add(ticker) } - else { selectedTickerList.remove(ticker) } + if (isChecked) { + selectedTickerList.add(ticker) + } else { + selectedTickerList.remove(ticker) + } } } } - fun getSelectedItems(): List = selectedTickerList + fun getSelectedItems(): List = selectedTickerList.toList() override fun onCreateViewHolder( parent: ViewGroup, diff --git a/app/src/main/java/com/example/koin_apps/presenter/viewModel/LiveTimeViewModel.kt b/app/src/main/java/com/example/koin_apps/presenter/viewModel/LiveTimeViewModel.kt new file mode 100644 index 0000000..2a8e5ef --- /dev/null +++ b/app/src/main/java/com/example/koin_apps/presenter/viewModel/LiveTimeViewModel.kt @@ -0,0 +1,36 @@ +package com.example.koin_apps.presenter.viewModel + +import androidx.lifecycle.LiveData +import androidx.lifecycle.MutableLiveData +import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope +import com.example.domain.entity.TickerLiveDataEntity +import com.example.domain.usecase.apiUseCase.GetTickerLiveInfoUseCase +import com.example.koin_apps.common.Constants +import com.example.koin_apps.module.coroutineDispatcher.IoDispatcher +import kotlinx.coroutines.* +import dagger.hilt.android.lifecycle.HiltViewModel +import javax.inject.Inject + +@HiltViewModel +class LiveTimeViewModel @Inject constructor( + private val getTickerInfoUseCase: GetTickerLiveInfoUseCase, + @IoDispatcher private val ioDispatcher: CoroutineDispatcher +): ViewModel() { + private val _tickerLiveViewData = MutableLiveData() + val tickerLiveViewData: LiveData get() = _tickerLiveViewData + + fun loadTickerInfo( + ticker: String + ): Job = viewModelScope.launch(ioDispatcher) { + while (true) { + getTickerInfoUseCase(ticker).collect { _tickerLiveViewData.postValue(it) } + delay(Constants.DELAY_TIME_MILLIS) + } + } + + override fun onCleared() { + super.onCleared() + viewModelScope.cancel() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/koin_apps/viewModel/activity/LogoViewModel.kt b/app/src/main/java/com/example/koin_apps/presenter/viewModel/LogoViewModel.kt similarity index 55% rename from app/src/main/java/com/example/koin_apps/viewModel/activity/LogoViewModel.kt rename to app/src/main/java/com/example/koin_apps/presenter/viewModel/LogoViewModel.kt index 157342e..bf63a89 100644 --- a/app/src/main/java/com/example/koin_apps/viewModel/activity/LogoViewModel.kt +++ b/app/src/main/java/com/example/koin_apps/presenter/viewModel/LogoViewModel.kt @@ -1,12 +1,12 @@ -package com.example.koin_apps.viewModel.activity +package com.example.koin_apps.presenter.viewModel -import com.example.koin_apps.data.database.tables.TickerEntity import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import com.example.koin_apps.data.di.coroutineDispatcher.IoDispatcher -import com.example.koin_apps.data.di.repository.TickerDBRepository +import com.example.domain.entity.TickerEntity +import com.example.domain.usecase.databaseUseCase.ReadAllTickerUseCase +import com.example.koin_apps.module.coroutineDispatcher.IoDispatcher import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.Job @@ -16,16 +16,16 @@ import javax.inject.Inject @HiltViewModel class LogoViewModel @Inject constructor( - @IoDispatcher private val ioDispatcher: CoroutineDispatcher, - private val tickerDBRepo: TickerDBRepository + private val readAllTickerUseCase: ReadAllTickerUseCase, + @IoDispatcher private val ioDispatcher: CoroutineDispatcher ): ViewModel() { private val _readAllTicker = MutableLiveData>() val readAllTicker: LiveData> get() = _readAllTicker - init { fetchDBData() } + init { fetchTickerAllData() } - private fun fetchDBData(): Job = viewModelScope.launch(ioDispatcher) { - tickerDBRepo.readAllTicker().collect { result -> _readAllTicker.postValue(result) } + private fun fetchTickerAllData(): Job = viewModelScope.launch(ioDispatcher) { + readAllTickerUseCase().collect { result -> _readAllTicker.postValue(result)} } override fun onCleared() { diff --git a/app/src/main/java/com/example/koin_apps/presenter/viewModel/MainViewModel.kt b/app/src/main/java/com/example/koin_apps/presenter/viewModel/MainViewModel.kt new file mode 100644 index 0000000..0575c7d --- /dev/null +++ b/app/src/main/java/com/example/koin_apps/presenter/viewModel/MainViewModel.kt @@ -0,0 +1,30 @@ +package com.example.koin_apps.presenter.viewModel + +import androidx.lifecycle.* +import com.example.domain.entity.TickerEntity +import com.example.domain.usecase.databaseUseCase.ReadAllTickerUseCase +import com.example.koin_apps.module.coroutineDispatcher.IoDispatcher +import dagger.hilt.android.lifecycle.HiltViewModel +import kotlinx.coroutines.CoroutineDispatcher +import kotlinx.coroutines.Job +import kotlinx.coroutines.cancel +import kotlinx.coroutines.launch +import javax.inject.Inject + +@HiltViewModel +class MainViewModel @Inject constructor( + private val readAllTickerUseCase: ReadAllTickerUseCase, + @IoDispatcher private val ioDispatcher: CoroutineDispatcher +): ViewModel() { + private val _tickerAllData = MutableLiveData>() + val tickerAllData: LiveData> get() = _tickerAllData + + fun fetchAllTickerData(): Job = viewModelScope.launch(ioDispatcher) { + readAllTickerUseCase().collect { result -> _tickerAllData.postValue(result) } + } + + override fun onCleared() { + super.onCleared() + viewModelScope.cancel() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/koin_apps/presenter/viewModel/OrderBookViewModel.kt b/app/src/main/java/com/example/koin_apps/presenter/viewModel/OrderBookViewModel.kt new file mode 100644 index 0000000..7f9eb37 --- /dev/null +++ b/app/src/main/java/com/example/koin_apps/presenter/viewModel/OrderBookViewModel.kt @@ -0,0 +1,58 @@ +package com.example.koin_apps.presenter.viewModel + +import androidx.lifecycle.LiveData +import androidx.lifecycle.MutableLiveData +import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope +import com.example.domain.entity.OrderBookEntity +import com.example.domain.entity.TickerOrderDataEntity +import com.example.domain.entity.TransactionEntity +import com.example.domain.usecase.apiUseCase.GetOrderBookUseCase +import com.example.domain.usecase.apiUseCase.GetTickerDetailInfoUseCase +import com.example.domain.usecase.apiUseCase.GetTransactionHistoryUseCase +import com.example.koin_apps.common.Constants +import com.example.koin_apps.module.coroutineDispatcher.IoDispatcher +import dagger.hilt.android.lifecycle.HiltViewModel +import kotlinx.coroutines.* +import javax.inject.Inject + +@HiltViewModel +class OrderBookViewModel @Inject constructor( + private val getOrderBookUseCase: GetOrderBookUseCase, + private val getTickerDetailInfoUseCase: GetTickerDetailInfoUseCase, + private val getTransactionHistoryUseCase: GetTransactionHistoryUseCase, + @IoDispatcher private val ioDispatcher: CoroutineDispatcher +): ViewModel() { + private val _tickerData = MutableLiveData() + private val _transactionData = MutableLiveData>() + private val _orderBookData = MutableLiveData() + val tickerData: LiveData get() = _tickerData + val transactionData: LiveData> get() = _transactionData + val orderBookData: LiveData get() = _orderBookData + + fun fetchTickerData(ticker: String): Job = viewModelScope.launch(ioDispatcher) { + while (true) { + launch { + getTickerDetailInfoUseCase(ticker).collect { _tickerData.postValue(it) } + delay(Constants.DELAY_TIME_MILLIS) + }.join() + + launch { + getTransactionHistoryUseCase(ticker, 10).collect { + _transactionData.postValue(it) + } + delay(Constants.DELAY_TIME_MILLIS) + }.join() + + launch { + getOrderBookUseCase(ticker, 10).collect { _orderBookData.postValue(it) } + delay(Constants.DELAY_TIME_MILLIS) + } + } + } + + override fun onCleared() { + super.onCleared() + viewModelScope.cancel() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/koin_apps/viewModel/activity/SelectViewModel.kt b/app/src/main/java/com/example/koin_apps/presenter/viewModel/SelectViewModel.kt similarity index 61% rename from app/src/main/java/com/example/koin_apps/viewModel/activity/SelectViewModel.kt rename to app/src/main/java/com/example/koin_apps/presenter/viewModel/SelectViewModel.kt index 06462c2..88ea433 100644 --- a/app/src/main/java/com/example/koin_apps/viewModel/activity/SelectViewModel.kt +++ b/app/src/main/java/com/example/koin_apps/presenter/viewModel/SelectViewModel.kt @@ -1,13 +1,13 @@ -package com.example.koin_apps.viewModel.activity +package com.example.koin_apps.presenter.viewModel import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import com.example.koin_apps.data.database.tables.TickerEntity -import com.example.koin_apps.data.di.coroutineDispatcher.IoDispatcher -import com.example.koin_apps.data.di.repository.TickerRepository -import com.example.koin_apps.data.di.repository.TickerDBRepository +import com.example.domain.entity.TickerEntity +import com.example.domain.usecase.apiUseCase.GetTickerAllUseCase +import com.example.domain.usecase.databaseUseCase.InsertTickerUseCase +import com.example.koin_apps.module.coroutineDispatcher.IoDispatcher import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.Job @@ -17,8 +17,8 @@ import javax.inject.Inject @HiltViewModel class SelectViewModel @Inject constructor( - private val tickerApiRepos: TickerRepository, - private val tickerDBRepo: TickerDBRepository, + private val getTickerAllUseCase: GetTickerAllUseCase, + private val insertTickerUseCase: InsertTickerUseCase, @IoDispatcher private val ioDispatcher: CoroutineDispatcher ): ViewModel() { private val _tickerList = MutableLiveData?>() @@ -27,13 +27,11 @@ class SelectViewModel @Inject constructor( init { loadTickerTitle() } private fun loadTickerTitle(): Job = viewModelScope.launch(ioDispatcher) { - tickerApiRepos.getTickerInfoALL().collect { _tickerList.postValue(it) } + getTickerAllUseCase().collect { _tickerList.postValue(it.toList()) } } fun storeTickerTitle(tickerList: List): Job = viewModelScope.launch(ioDispatcher) { - for (ticker in tickerList) { - tickerDBRepo.insertTicker(TickerEntity(ticker)).collect{ } - } + tickerList.forEach { insertTickerUseCase(TickerEntity(it)).collect { } } } override fun onCleared() { diff --git a/app/src/main/java/com/example/koin_apps/viewModel/activity/LiveTimeViewModel.kt b/app/src/main/java/com/example/koin_apps/viewModel/activity/LiveTimeViewModel.kt deleted file mode 100644 index d0ea8dc..0000000 --- a/app/src/main/java/com/example/koin_apps/viewModel/activity/LiveTimeViewModel.kt +++ /dev/null @@ -1,37 +0,0 @@ -package com.example.koin_apps.viewModel.activity - -import androidx.lifecycle.LiveData -import androidx.lifecycle.MutableLiveData -import androidx.lifecycle.ViewModel -import androidx.lifecycle.viewModelScope -import com.example.koin_apps.common.Constants -import com.example.koin_apps.data.di.coroutineDispatcher.IoDispatcher -import com.example.koin_apps.data.di.repository.TickerRepository -import kotlinx.coroutines.* -import com.example.koin_apps.data.remote.model.ticker.LiveTickerData -import dagger.hilt.android.lifecycle.HiltViewModel -import javax.inject.Inject - -@HiltViewModel -class LiveTimeViewModel @Inject constructor( - private val tickerApiRepos: TickerRepository, - @IoDispatcher private val ioDispatcher: CoroutineDispatcher -): ViewModel() { - private val _tickerLiveViewData = MutableLiveData() - val tickerLiveViewData: LiveData get() = _tickerLiveViewData - - fun loadTickerInfo(ticker: String): Job = viewModelScope.launch(ioDispatcher) { - while (true) { - tickerApiRepos.getTickerInfoLive(ticker).collect { result -> - _tickerLiveViewData.postValue(result) - } - - delay(Constants.DELAY_TIME_MILLIS) - } - } - - override fun onCleared() { - super.onCleared() - viewModelScope.cancel() - } -} \ No newline at end of file diff --git a/app/src/main/java/com/example/koin_apps/viewModel/activity/MainViewModel.kt b/app/src/main/java/com/example/koin_apps/viewModel/activity/MainViewModel.kt deleted file mode 100644 index 5f92757..0000000 --- a/app/src/main/java/com/example/koin_apps/viewModel/activity/MainViewModel.kt +++ /dev/null @@ -1,30 +0,0 @@ -package com.example.koin_apps.viewModel.activity - -import androidx.lifecycle.* -import com.example.koin_apps.data.database.tables.TickerEntity -import com.example.koin_apps.data.di.coroutineDispatcher.IoDispatcher -import com.example.koin_apps.data.di.repository.TickerDBRepository -import dagger.hilt.android.lifecycle.HiltViewModel -import kotlinx.coroutines.CoroutineDispatcher -import kotlinx.coroutines.Job -import kotlinx.coroutines.cancel -import kotlinx.coroutines.launch -import javax.inject.Inject - -@HiltViewModel -class MainViewModel @Inject constructor( - @IoDispatcher private val ioDispatcher: CoroutineDispatcher, - private val tickerDBRepo: TickerDBRepository -): ViewModel() { - private val _readAllTicker = MutableLiveData>() - val readAllTicker: LiveData> get() = _readAllTicker - - fun fetchDBData(): Job = viewModelScope.launch(ioDispatcher) { - tickerDBRepo.readAllTicker().collect { result -> _readAllTicker.postValue(result) } - } - - override fun onCleared() { - super.onCleared() - viewModelScope.cancel() - } -} \ No newline at end of file diff --git a/app/src/main/java/com/example/koin_apps/viewModel/fragment/OrderBookViewModel.kt b/app/src/main/java/com/example/koin_apps/viewModel/fragment/OrderBookViewModel.kt deleted file mode 100644 index 66a2b47..0000000 --- a/app/src/main/java/com/example/koin_apps/viewModel/fragment/OrderBookViewModel.kt +++ /dev/null @@ -1,58 +0,0 @@ -package com.example.koin_apps.viewModel.fragment - -import androidx.lifecycle.LiveData -import androidx.lifecycle.MutableLiveData -import androidx.lifecycle.ViewModel -import androidx.lifecycle.viewModelScope -import com.example.koin_apps.common.Constants -import com.example.koin_apps.data.di.coroutineDispatcher.IoDispatcher -import com.example.koin_apps.data.di.repository.TickerRepository -import com.example.koin_apps.data.remote.model.orderBook.OrderData -import com.example.koin_apps.data.remote.model.ticker.OrderTickerData -import com.example.koin_apps.data.remote.model.transaction.TransactionData -import dagger.hilt.android.lifecycle.HiltViewModel -import kotlinx.coroutines.* -import javax.inject.Inject - -@HiltViewModel -class OrderBookViewModel @Inject constructor( - private val tickerApiRepos: TickerRepository, - @IoDispatcher private val ioDispatcher: CoroutineDispatcher -): ViewModel() { - private val _tickerData = MutableLiveData() - private val _transactionData = MutableLiveData>() - private val _orderBookData = MutableLiveData() - val tickerData: LiveData get() = _tickerData - val transactionData: LiveData> get() = _transactionData - val orderBookData: LiveData get() = _orderBookData - - fun fetchTickerData(ticker: String): Job = viewModelScope.launch (ioDispatcher) { - while (true) { - launch { - tickerApiRepos.getTickerInfoDetail(ticker).collect { - _tickerData.postValue(it) - } - delay(Constants.DELAY_TIME_MILLIS) - }.join() - - launch { - tickerApiRepos.getTransactionInfo(ticker, 10).collect { - _transactionData.postValue(it) - } - delay(Constants.DELAY_TIME_MILLIS) - }.join() - - launch { - tickerApiRepos.getOrderBookInfo(ticker, 10).collect { - _orderBookData.postValue(it) - } - delay(Constants.DELAY_TIME_MILLIS) - } - } - } - - override fun onCleared() { - super.onCleared() - viewModelScope.cancel() - } -} \ No newline at end of file diff --git a/app/src/main/res/layout/activity_live_time.xml b/app/src/main/res/layout/activity_live_time.xml index f2b2b8c..5a866d1 100644 --- a/app/src/main/res/layout/activity_live_time.xml +++ b/app/src/main/res/layout/activity_live_time.xml @@ -8,7 +8,7 @@ android:orientation="vertical" android:background="@color/Mint_100" android:padding="20dp" - tools:context=".LiveTimeActivity" > + tools:context=".presenter.LiveTimeActivity" > + tools:context=".presenter.LogoActivity"> + tools:context=".presenter.SelectKoinActivity"> + tools:context=".presenter.OrderBookFragment"> + + + \ No newline at end of file diff --git a/data/src/main/java/com/example/data/database/TickerDataBase.kt b/data/src/main/java/com/example/data/database/TickerDataBase.kt new file mode 100644 index 0000000..ec0aa05 --- /dev/null +++ b/data/src/main/java/com/example/data/database/TickerDataBase.kt @@ -0,0 +1,11 @@ +package com.example.data.database + +import androidx.room.Database +import androidx.room.RoomDatabase +import com.example.data.database.tables.TickerTables +import com.example.data.database.dao.TickerDao + +@Database(entities = [TickerTables::class], version = 1, exportSchema = false) +abstract class TickerDataBase: RoomDatabase() { + abstract fun tickerDao(): TickerDao +} \ No newline at end of file diff --git a/app/src/main/java/com/example/koin_apps/data/database/dao/TickerDao.kt b/data/src/main/java/com/example/data/database/dao/TickerDao.kt similarity index 51% rename from app/src/main/java/com/example/koin_apps/data/database/dao/TickerDao.kt rename to data/src/main/java/com/example/data/database/dao/TickerDao.kt index 65ba204..75323af 100644 --- a/app/src/main/java/com/example/koin_apps/data/database/dao/TickerDao.kt +++ b/data/src/main/java/com/example/data/database/dao/TickerDao.kt @@ -1,21 +1,20 @@ -package com.example.koin_apps.data.database.dao +package com.example.data.database.dao -import androidx.lifecycle.LiveData import androidx.room.Dao import androidx.room.Delete import androidx.room.Insert import androidx.room.OnConflictStrategy import androidx.room.Query -import com.example.koin_apps.data.database.tables.TickerEntity +import com.example.data.database.tables.TickerTables @Dao interface TickerDao { @Query("SELECT * FROM Ticker_Table ORDER BY Ticker ASC") - fun readAllTicker(): List + fun readAllTicker(): List @Insert(onConflict = OnConflictStrategy.REPLACE) - suspend fun insertTicker(ticker: TickerEntity) + suspend fun insertTicker(ticker: TickerTables) @Delete - suspend fun deleteTicker(ticker: TickerEntity) + suspend fun deleteTicker(ticker: TickerTables) } \ No newline at end of file diff --git a/app/src/main/java/com/example/koin_apps/data/database/tables/TickerEntity.kt b/data/src/main/java/com/example/data/database/tables/TickerTables.kt similarity index 72% rename from app/src/main/java/com/example/koin_apps/data/database/tables/TickerEntity.kt rename to data/src/main/java/com/example/data/database/tables/TickerTables.kt index c3b1d15..a42eca6 100644 --- a/app/src/main/java/com/example/koin_apps/data/database/tables/TickerEntity.kt +++ b/data/src/main/java/com/example/data/database/tables/TickerTables.kt @@ -1,11 +1,11 @@ -package com.example.koin_apps.data.database.tables +package com.example.data.database.tables import androidx.room.ColumnInfo import androidx.room.Entity import androidx.room.PrimaryKey @Entity(tableName= "Ticker_Table") -data class TickerEntity( +data class TickerTables( @PrimaryKey @ColumnInfo(name= "Ticker") var Ticker: String diff --git a/app/src/main/java/com/example/koin_apps/data/remote/IKoinApiService.kt b/data/src/main/java/com/example/data/remote/BithumbApiService.kt similarity index 68% rename from app/src/main/java/com/example/koin_apps/data/remote/IKoinApiService.kt rename to data/src/main/java/com/example/data/remote/BithumbApiService.kt index b401e25..aca2da4 100644 --- a/app/src/main/java/com/example/koin_apps/data/remote/IKoinApiService.kt +++ b/data/src/main/java/com/example/data/remote/BithumbApiService.kt @@ -1,19 +1,19 @@ -package com.example.koin_apps.data.remote +package com.example.data.remote -import com.example.koin_apps.data.remote.model.orderBook.OrderRoot -import com.example.koin_apps.data.remote.model.ticker.TickerRoot -import com.example.koin_apps.data.remote.model.transaction.TransactionRoot +import com.example.data.remote.model.orderbook.OrderRoot +import com.example.data.remote.model.ticker.TickerRoot +import com.example.data.remote.model.transaction.TransactionRoot import retrofit2.Response import retrofit2.http.GET import retrofit2.http.Path import retrofit2.http.Query -interface IKoinApiService { +interface BithumbApiService { @GET("ticker/ALL_KRW") suspend fun getTickerALL(): Response @GET("ticker/{path}_KRW") - suspend fun getTicker( + suspend fun getTickerInfo( @Path("path") path: String ): Response diff --git a/app/src/main/java/com/example/koin_apps/data/remote/model/orderBook/OrderAskBidData.kt b/data/src/main/java/com/example/data/remote/model/orderbook/OrderAskBidData.kt similarity index 57% rename from app/src/main/java/com/example/koin_apps/data/remote/model/orderBook/OrderAskBidData.kt rename to data/src/main/java/com/example/data/remote/model/orderbook/OrderAskBidData.kt index 895748e..8235b15 100644 --- a/app/src/main/java/com/example/koin_apps/data/remote/model/orderBook/OrderAskBidData.kt +++ b/data/src/main/java/com/example/data/remote/model/orderbook/OrderAskBidData.kt @@ -1,4 +1,4 @@ -package com.example.koin_apps.data.remote.model.orderBook +package com.example.data.remote.model.orderbook data class OrderAskBidData ( val quantity: String, diff --git a/app/src/main/java/com/example/koin_apps/data/remote/model/orderBook/OrderData.kt b/data/src/main/java/com/example/data/remote/model/orderbook/OrderData.kt similarity index 79% rename from app/src/main/java/com/example/koin_apps/data/remote/model/orderBook/OrderData.kt rename to data/src/main/java/com/example/data/remote/model/orderbook/OrderData.kt index e7cd343..5b9e24e 100644 --- a/app/src/main/java/com/example/koin_apps/data/remote/model/orderBook/OrderData.kt +++ b/data/src/main/java/com/example/data/remote/model/orderbook/OrderData.kt @@ -1,4 +1,4 @@ -package com.example.koin_apps.data.remote.model.orderBook +package com.example.data.remote.model.orderbook data class OrderData( val status: String?, diff --git a/app/src/main/java/com/example/koin_apps/data/remote/model/orderBook/OrderRoot.kt b/data/src/main/java/com/example/data/remote/model/orderbook/OrderRoot.kt similarity index 63% rename from app/src/main/java/com/example/koin_apps/data/remote/model/orderBook/OrderRoot.kt rename to data/src/main/java/com/example/data/remote/model/orderbook/OrderRoot.kt index 1cd8da5..bc01efa 100644 --- a/app/src/main/java/com/example/koin_apps/data/remote/model/orderBook/OrderRoot.kt +++ b/data/src/main/java/com/example/data/remote/model/orderbook/OrderRoot.kt @@ -1,4 +1,4 @@ -package com.example.koin_apps.data.remote.model.orderBook +package com.example.data.remote.model.orderbook data class OrderRoot( val status: String, diff --git a/app/src/main/java/com/example/koin_apps/data/remote/model/ticker/TickerRoot.kt b/data/src/main/java/com/example/data/remote/model/ticker/TickerRoot.kt similarity index 65% rename from app/src/main/java/com/example/koin_apps/data/remote/model/ticker/TickerRoot.kt rename to data/src/main/java/com/example/data/remote/model/ticker/TickerRoot.kt index b64b41f..7c37290 100644 --- a/app/src/main/java/com/example/koin_apps/data/remote/model/ticker/TickerRoot.kt +++ b/data/src/main/java/com/example/data/remote/model/ticker/TickerRoot.kt @@ -1,7 +1,7 @@ -package com.example.koin_apps.data.remote.model.ticker +package com.example.data.remote.model.ticker data class TickerRoot( val status: String, val message: String?, val data: Map -) \ No newline at end of file +) diff --git a/app/src/main/java/com/example/koin_apps/data/remote/model/transaction/TransactionData.kt b/data/src/main/java/com/example/data/remote/model/transaction/TransactionData.kt similarity index 72% rename from app/src/main/java/com/example/koin_apps/data/remote/model/transaction/TransactionData.kt rename to data/src/main/java/com/example/data/remote/model/transaction/TransactionData.kt index 44451b7..23963c1 100644 --- a/app/src/main/java/com/example/koin_apps/data/remote/model/transaction/TransactionData.kt +++ b/data/src/main/java/com/example/data/remote/model/transaction/TransactionData.kt @@ -1,4 +1,4 @@ -package com.example.koin_apps.data.remote.model.transaction +package com.example.data.remote.model.transaction data class TransactionData( val transaction_date: String, diff --git a/app/src/main/java/com/example/koin_apps/data/remote/model/transaction/TransactionRoot.kt b/data/src/main/java/com/example/data/remote/model/transaction/TransactionRoot.kt similarity index 67% rename from app/src/main/java/com/example/koin_apps/data/remote/model/transaction/TransactionRoot.kt rename to data/src/main/java/com/example/data/remote/model/transaction/TransactionRoot.kt index 8ff224a..d4fbaff 100644 --- a/app/src/main/java/com/example/koin_apps/data/remote/model/transaction/TransactionRoot.kt +++ b/data/src/main/java/com/example/data/remote/model/transaction/TransactionRoot.kt @@ -1,4 +1,4 @@ -package com.example.koin_apps.data.remote.model.transaction +package com.example.data.remote.model.transaction data class TransactionRoot( val status: String, diff --git a/data/src/main/java/com/example/data/repositoryImpl/BithumbApiRepositoryImpl.kt b/data/src/main/java/com/example/data/repositoryImpl/BithumbApiRepositoryImpl.kt new file mode 100644 index 0000000..35d037d --- /dev/null +++ b/data/src/main/java/com/example/data/repositoryImpl/BithumbApiRepositoryImpl.kt @@ -0,0 +1,164 @@ +package com.example.data.repositoryImpl + +import com.example.data.remote.BithumbApiService +import com.example.data.remote.model.orderbook.OrderData +import com.example.data.remote.model.orderbook.OrderRoot +import com.example.data.remote.model.ticker.TickerRoot +import com.example.data.remote.model.transaction.TransactionData +import com.example.data.remote.model.transaction.TransactionRoot +import com.example.data.util.apiMapper.mapperToOrderBookEntity +import com.example.data.util.apiMapper.mapperToTransactionEntity +import com.example.domain.entity.OrderBookEntity +import com.example.domain.entity.TransactionEntity +import com.example.domain.repository.BithumbApiRepository +import kotlinx.coroutines.delay +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.catch +import kotlinx.coroutines.flow.flow +import kotlinx.coroutines.flow.retryWhen +import retrofit2.HttpException +import retrofit2.Response +import java.io.IOException +import javax.inject.Inject + +class BithumbApiRepositoryImpl @Inject constructor( + private val bithumbApiService: BithumbApiService +): BithumbApiRepository { + + override fun getTickerInfoAll(): Flow> = flow { + val response: Response = bithumbApiService.getTickerALL() + + if (response.isSuccessful && response.body()?.data != null) { + val responseResult: MutableList = response.body()?.data!!.keys.toMutableList() + emit(responseResult) + } else { + if (response.body()?.data == null) { + throw (NullPointerException("response body data is Null")) + } + if (!response.isSuccessful) { + throw (HttpException(response)) + } + } + }.catch { exception -> + if (exception is IOException) { + emit(mutableListOf()) + } else { + throw exception + } + }.retryWhen { cause, attempt -> + when { + (cause is HttpException && attempt < 3) -> { + delay(2000L) + true + } + else -> false + } + } + + override fun getTickerInfo(ticker: String): Flow> = flow { + val response: Response = bithumbApiService.getTickerInfo(ticker) + + if (response.isSuccessful && response.body()?.data != null) { + val responseResult: Map = response.body()!!.data + emit(responseResult) + } else { + if (response.body()?.data == null) { + throw (NullPointerException("response body data is Null")) + } + if (!response.isSuccessful) { + throw (HttpException(response)) + } + } + }.catch { exception -> + if (exception is IOException) { + emit(mapOf()) + } else { + throw exception + } + }.retryWhen { cause, attempt -> + when { + (cause is HttpException && attempt < 3) -> { + delay(2000L) + true + } + else -> false + } + } + + override fun getTransactionHistory( + ticker: String, + count: Int + ): Flow> = flow { + val response: Response = + bithumbApiService.getTransactionHistory(ticker, count) + + if (response.isSuccessful && response.body()?.data != null) { + val responseResult: ArrayList = response.body()?.data!! + emit(mapperToTransactionEntity(responseResult)) + } else { + if (response.body()?.data == null) { + throw (NullPointerException("response body data is Null")) + } + if (!response.isSuccessful) { + throw (HttpException(response)) + } + } + }.catch { exception -> + if (exception is IOException) { + emit(listOf()) + } else { + throw exception + } + }.retryWhen { cause, attempt -> + when { + (cause is HttpException && attempt < 3) -> { + delay(2000L) + true + } + else -> false + } + } + + override fun getOrderBookInfo( + ticker: String, + count: Int + ): Flow = flow { + val response: Response = bithumbApiService.getOrderBook(ticker, count) + + if (response.isSuccessful && response.body()?.data != null) { + val responseResult: OrderData = response.body()?.data!! + emit(mapperToOrderBookEntity(responseResult)) + } else { + if (response.body()?.data == null) { + throw (NullPointerException("response body data is Null")) + } + if (!response.isSuccessful) { + throw (HttpException(response)) + } + } + }.catch { exception -> + if (exception is IOException) { + emit( + OrderBookEntity( + null, + null, + null, + null, + null, + null + ) + ) + } else { + throw exception + } + }.retryWhen { cause, attempt -> + when { + (cause is HttpException && attempt < 3) -> { + delay(2000L) + true + } + else -> false + } + } + +} \ No newline at end of file diff --git a/data/src/main/java/com/example/data/repositoryImpl/DataBaseRepositoryImpl.kt b/data/src/main/java/com/example/data/repositoryImpl/DataBaseRepositoryImpl.kt new file mode 100644 index 0000000..37c5a3b --- /dev/null +++ b/data/src/main/java/com/example/data/repositoryImpl/DataBaseRepositoryImpl.kt @@ -0,0 +1,76 @@ +package com.example.data.repositoryImpl + +import android.database.SQLException +import com.example.data.database.dao.TickerDao +import com.example.data.util.databaseMapper.mapperToTickerEntity +import com.example.data.util.databaseMapper.mapperToTickerTable +import com.example.domain.entity.TickerEntity +import com.example.domain.repository.DataBaseRepository +import kotlinx.coroutines.delay +import kotlinx.coroutines.flow.* +import java.io.IOException +import java.sql.SQLDataException +import javax.inject.Inject + +class DataBaseRepositoryImpl @Inject constructor( + private val tickerDao: TickerDao +): DataBaseRepository { + override fun readAllTicker(): Flow> = flow { + val tickerResults = mapperToTickerEntity(tickerDao.readAllTicker()) + emit(tickerResults) + }.catch { exception -> + when (exception) { + is IOException -> emit(listOf()) + is SQLDataException -> emit(listOf()) + is ClassNotFoundException -> emit(listOf()) + else -> throw exception + } + }.retryWhen { cause, attempt -> + if (cause is SQLException && attempt < 3) { + delay(1000L) + true + } else { + false + } + } + + override fun insertTicker(ticker: TickerEntity): Flow> = flow { + val tickerInput = mapperToTickerTable(ticker) + tickerDao.insertTicker(tickerInput) + emit(Result.success(Unit)) + }.catch { exception -> + when (exception) { + is IOException -> emit(Result.failure(exception)) + is SQLDataException -> emit(Result.failure(exception)) + is ClassNotFoundException -> emit(Result.failure(exception)) + else -> throw exception + } + }.retryWhen { cause, attempt -> + if (cause is SQLException && attempt < 3) { + delay(1000L) + true + } else { + false + } + } + + override fun deleteTicker(ticker: TickerEntity): Flow> = flow { + val tickerInput = mapperToTickerTable(ticker) + tickerDao.deleteTicker(tickerInput) + emit(Result.success(Unit)) + }.catch { exception -> + when (exception) { + is IOException -> emit(Result.failure(exception)) + is SQLDataException -> emit(Result.failure(exception)) + is ClassNotFoundException -> emit(Result.failure(exception)) + else -> throw exception + } + }.retryWhen { cause, attempt -> + if (cause is SQLException && attempt < 3) { + delay(1000L) + true + } else { + false + } + } +} \ No newline at end of file diff --git a/data/src/main/java/com/example/data/util/apiMapper/OrderBookEntityMapper.kt b/data/src/main/java/com/example/data/util/apiMapper/OrderBookEntityMapper.kt new file mode 100644 index 0000000..bd48671 --- /dev/null +++ b/data/src/main/java/com/example/data/util/apiMapper/OrderBookEntityMapper.kt @@ -0,0 +1,17 @@ +package com.example.data.util.apiMapper + + +import com.example.data.remote.model.orderbook.OrderData +import com.example.domain.entity.OrderAskBidEntity +import com.example.domain.entity.OrderBookEntity + +fun mapperToOrderBookEntity( + orderBookData: OrderData +): OrderBookEntity = OrderBookEntity( + status = orderBookData.status, + timestamp = orderBookData.timestamp, + order_currency = orderBookData.order_currency, + payment_currency = orderBookData.payment_currency, + bids = orderBookData.bids?.map { OrderAskBidEntity(quantity = it.quantity, price = it.price) }, + asks = orderBookData.asks?.map { OrderAskBidEntity(quantity = it.quantity, price = it.price) } +) \ No newline at end of file diff --git a/data/src/main/java/com/example/data/util/apiMapper/TransactionEntityMapper.kt b/data/src/main/java/com/example/data/util/apiMapper/TransactionEntityMapper.kt new file mode 100644 index 0000000..8c3ccc1 --- /dev/null +++ b/data/src/main/java/com/example/data/util/apiMapper/TransactionEntityMapper.kt @@ -0,0 +1,17 @@ +package com.example.data.util.apiMapper + +import com.example.data.remote.model.transaction.TransactionData +import com.example.domain.entity.TransactionEntity + +fun mapperToTransactionEntity( + transactionArrayList: ArrayList +): List = transactionArrayList.map { + TransactionEntity( + transaction_date = it.transaction_date, + type = it.type, + units_traded = it.units_traded, + price = it.price, + total = it.total + ) +} + diff --git a/data/src/main/java/com/example/data/util/databaseMapper/TickerEntityMapper.kt b/data/src/main/java/com/example/data/util/databaseMapper/TickerEntityMapper.kt new file mode 100644 index 0000000..95efb79 --- /dev/null +++ b/data/src/main/java/com/example/data/util/databaseMapper/TickerEntityMapper.kt @@ -0,0 +1,7 @@ +package com.example.data.util.databaseMapper + +import com.example.data.database.tables.TickerTables +import com.example.domain.entity.TickerEntity + +fun mapperToTickerEntity(tickers: List): List = + tickers.toList().map { TickerEntity(ticker = it.Ticker) } \ No newline at end of file diff --git a/data/src/main/java/com/example/data/util/databaseMapper/TickerTableMapper.kt b/data/src/main/java/com/example/data/util/databaseMapper/TickerTableMapper.kt new file mode 100644 index 0000000..09ff18a --- /dev/null +++ b/data/src/main/java/com/example/data/util/databaseMapper/TickerTableMapper.kt @@ -0,0 +1,7 @@ +package com.example.data.util.databaseMapper + +import com.example.data.database.tables.TickerTables +import com.example.domain.entity.TickerEntity + +fun mapperToTickerTable(tickerEntity: TickerEntity): TickerTables = + TickerTables(Ticker = tickerEntity.ticker) \ No newline at end of file diff --git a/data/src/main/res/drawable-v24/ic_launcher_foreground.xml b/data/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/data/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/data/src/main/res/drawable/ic_launcher_background.xml b/data/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/data/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/data/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/data/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/data/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/data/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/data/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/data/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/data/src/main/res/mipmap-anydpi-v33/ic_launcher.xml b/data/src/main/res/mipmap-anydpi-v33/ic_launcher.xml new file mode 100644 index 0000000..6f3b755 --- /dev/null +++ b/data/src/main/res/mipmap-anydpi-v33/ic_launcher.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/data/src/main/res/mipmap-hdpi/ic_launcher.webp b/data/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 0000000..c209e78 Binary files /dev/null and b/data/src/main/res/mipmap-hdpi/ic_launcher.webp differ diff --git a/data/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/data/src/main/res/mipmap-hdpi/ic_launcher_round.webp new file mode 100644 index 0000000..b2dfe3d Binary files /dev/null and b/data/src/main/res/mipmap-hdpi/ic_launcher_round.webp differ diff --git a/data/src/main/res/mipmap-mdpi/ic_launcher.webp b/data/src/main/res/mipmap-mdpi/ic_launcher.webp new file mode 100644 index 0000000..4f0f1d6 Binary files /dev/null and b/data/src/main/res/mipmap-mdpi/ic_launcher.webp differ diff --git a/data/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/data/src/main/res/mipmap-mdpi/ic_launcher_round.webp new file mode 100644 index 0000000..62b611d Binary files /dev/null and b/data/src/main/res/mipmap-mdpi/ic_launcher_round.webp differ diff --git a/data/src/main/res/mipmap-xhdpi/ic_launcher.webp b/data/src/main/res/mipmap-xhdpi/ic_launcher.webp new file mode 100644 index 0000000..948a307 Binary files /dev/null and b/data/src/main/res/mipmap-xhdpi/ic_launcher.webp differ diff --git a/data/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/data/src/main/res/mipmap-xhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..1b9a695 Binary files /dev/null and b/data/src/main/res/mipmap-xhdpi/ic_launcher_round.webp differ diff --git a/data/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/data/src/main/res/mipmap-xxhdpi/ic_launcher.webp new file mode 100644 index 0000000..28d4b77 Binary files /dev/null and b/data/src/main/res/mipmap-xxhdpi/ic_launcher.webp differ diff --git a/data/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/data/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9287f50 Binary files /dev/null and b/data/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp differ diff --git a/data/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/data/src/main/res/mipmap-xxxhdpi/ic_launcher.webp new file mode 100644 index 0000000..aa7d642 Binary files /dev/null and b/data/src/main/res/mipmap-xxxhdpi/ic_launcher.webp differ diff --git a/data/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/data/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9126ae3 Binary files /dev/null and b/data/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp differ diff --git a/data/src/main/res/values-night/themes.xml b/data/src/main/res/values-night/themes.xml new file mode 100644 index 0000000..2647319 --- /dev/null +++ b/data/src/main/res/values-night/themes.xml @@ -0,0 +1,16 @@ + + + + \ No newline at end of file diff --git a/data/src/main/res/values/colors.xml b/data/src/main/res/values/colors.xml new file mode 100644 index 0000000..f8c6127 --- /dev/null +++ b/data/src/main/res/values/colors.xml @@ -0,0 +1,10 @@ + + + #FFBB86FC + #FF6200EE + #FF3700B3 + #FF03DAC5 + #FF018786 + #FF000000 + #FFFFFFFF + \ No newline at end of file diff --git a/data/src/main/res/values/strings.xml b/data/src/main/res/values/strings.xml new file mode 100644 index 0000000..ce5d8a4 --- /dev/null +++ b/data/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + data + \ No newline at end of file diff --git a/data/src/main/res/values/themes.xml b/data/src/main/res/values/themes.xml new file mode 100644 index 0000000..f5bf07d --- /dev/null +++ b/data/src/main/res/values/themes.xml @@ -0,0 +1,16 @@ + + + + \ No newline at end of file diff --git a/data/src/test/java/com/example/data/ExampleUnitTest.kt b/data/src/test/java/com/example/data/ExampleUnitTest.kt new file mode 100644 index 0000000..8943744 --- /dev/null +++ b/data/src/test/java/com/example/data/ExampleUnitTest.kt @@ -0,0 +1,17 @@ +package com.example.data + +import org.junit.Test + +import org.junit.Assert.* + +/** + * Example local unit test, which will execute on the development machine (host). + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +class ExampleUnitTest { + @Test + fun addition_isCorrect() { + assertEquals(4, 2 + 2) + } +} \ No newline at end of file diff --git a/domain/.gitignore b/domain/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/domain/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/domain/build.gradle b/domain/build.gradle new file mode 100644 index 0000000..e0a7dda --- /dev/null +++ b/domain/build.gradle @@ -0,0 +1,49 @@ +plugins { + id 'com.android.library' + id 'org.jetbrains.kotlin.android' +} + +apply plugin: 'kotlin-kapt' +apply plugin: 'com.google.dagger.hilt.android' + +android { + namespace 'com.example.domain' + compileSdk 33 + + defaultConfig { + minSdk 26 + targetSdk 33 + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 + } + kotlinOptions { + jvmTarget = '17' + } +} + +dependencies { + implementation 'androidx.core:core-ktx:1.10.1' + + // Kotlin Coroutine + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4" + + // DI(Dependency Injection) Tool - Dagger-hilt + implementation "com.google.dagger:hilt-android:2.44.2" + kapt "com.google.dagger:hilt-android-compiler:2.44.2" + + // Android Test Tool - Junit, espresso + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.5' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' +} \ No newline at end of file diff --git a/domain/proguard-rules.pro b/domain/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/domain/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/domain/src/androidTest/java/com/example/domain/ExampleInstrumentedTest.kt b/domain/src/androidTest/java/com/example/domain/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..4d43b5b --- /dev/null +++ b/domain/src/androidTest/java/com/example/domain/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.example.domain + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.example.domain", appContext.packageName) + } +} \ No newline at end of file diff --git a/domain/src/main/AndroidManifest.xml b/domain/src/main/AndroidManifest.xml new file mode 100644 index 0000000..ecebd57 --- /dev/null +++ b/domain/src/main/AndroidManifest.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/domain/src/main/java/com/example/domain/entity/OrderAskBidEntity.kt b/domain/src/main/java/com/example/domain/entity/OrderAskBidEntity.kt new file mode 100644 index 0000000..c868d62 --- /dev/null +++ b/domain/src/main/java/com/example/domain/entity/OrderAskBidEntity.kt @@ -0,0 +1,6 @@ +package com.example.domain.entity + +data class OrderAskBidEntity( + val quantity: String, + val price: String +) \ No newline at end of file diff --git a/domain/src/main/java/com/example/domain/entity/OrderBookEntity.kt b/domain/src/main/java/com/example/domain/entity/OrderBookEntity.kt new file mode 100644 index 0000000..4ea753f --- /dev/null +++ b/domain/src/main/java/com/example/domain/entity/OrderBookEntity.kt @@ -0,0 +1,10 @@ +package com.example.domain.entity + +data class OrderBookEntity( + val status: String?, + val timestamp: String?, + val order_currency: String?, + val payment_currency: String?, + val bids: List?, + val asks: List? +) \ No newline at end of file diff --git a/domain/src/main/java/com/example/domain/entity/TickerEntity.kt b/domain/src/main/java/com/example/domain/entity/TickerEntity.kt new file mode 100644 index 0000000..21c61ba --- /dev/null +++ b/domain/src/main/java/com/example/domain/entity/TickerEntity.kt @@ -0,0 +1,3 @@ +package com.example.domain.entity + +data class TickerEntity( var ticker: String ) \ No newline at end of file diff --git a/domain/src/main/java/com/example/domain/entity/TickerLiveDataEntity.kt b/domain/src/main/java/com/example/domain/entity/TickerLiveDataEntity.kt new file mode 100644 index 0000000..412e68a --- /dev/null +++ b/domain/src/main/java/com/example/domain/entity/TickerLiveDataEntity.kt @@ -0,0 +1,7 @@ +package com.example.domain.entity + +data class TickerLiveDataEntity( + var closingPrice: Int, + var fluctate_24H: Int, + var fluctate_Rate: Double +) diff --git a/domain/src/main/java/com/example/domain/entity/TickerOrderDataEntity.kt b/domain/src/main/java/com/example/domain/entity/TickerOrderDataEntity.kt new file mode 100644 index 0000000..4dbbf3f --- /dev/null +++ b/domain/src/main/java/com/example/domain/entity/TickerOrderDataEntity.kt @@ -0,0 +1,9 @@ +package com.example.domain.entity + +data class TickerOrderDataEntity( + var closingPrice: Int, + var prevClosingPrice: Int, + var maxPrice: Int, + var minPrice: Int, + var unitsTraded_24H: Double +) \ No newline at end of file diff --git a/domain/src/main/java/com/example/domain/entity/TransactionEntity.kt b/domain/src/main/java/com/example/domain/entity/TransactionEntity.kt new file mode 100644 index 0000000..570d377 --- /dev/null +++ b/domain/src/main/java/com/example/domain/entity/TransactionEntity.kt @@ -0,0 +1,9 @@ +package com.example.domain.entity + +data class TransactionEntity( + val transaction_date: String, + val type: String, + val units_traded: String, + val price: String, + val total: String +) \ No newline at end of file diff --git a/domain/src/main/java/com/example/domain/repository/BithumbApiRepository.kt b/domain/src/main/java/com/example/domain/repository/BithumbApiRepository.kt new file mode 100644 index 0000000..7f61f3a --- /dev/null +++ b/domain/src/main/java/com/example/domain/repository/BithumbApiRepository.kt @@ -0,0 +1,15 @@ +package com.example.domain.repository + +import com.example.domain.entity.OrderBookEntity +import com.example.domain.entity.TransactionEntity +import kotlinx.coroutines.flow.Flow + +interface BithumbApiRepository { + fun getTickerInfoAll(): Flow> + + fun getTickerInfo(ticker: String): Flow> + + fun getTransactionHistory(ticker: String, count: Int): Flow> + + fun getOrderBookInfo(ticker: String, count: Int): Flow +} \ No newline at end of file diff --git a/domain/src/main/java/com/example/domain/repository/DataBaseRepository.kt b/domain/src/main/java/com/example/domain/repository/DataBaseRepository.kt new file mode 100644 index 0000000..68e1f66 --- /dev/null +++ b/domain/src/main/java/com/example/domain/repository/DataBaseRepository.kt @@ -0,0 +1,12 @@ +package com.example.domain.repository + +import com.example.domain.entity.TickerEntity +import kotlinx.coroutines.flow.Flow + +interface DataBaseRepository { + fun readAllTicker(): Flow> + + fun insertTicker(ticker: TickerEntity): Flow> + + fun deleteTicker(ticker: TickerEntity): Flow> +} \ No newline at end of file diff --git a/domain/src/main/java/com/example/domain/usecase/apiUseCase/GetOrderBookUseCase.kt b/domain/src/main/java/com/example/domain/usecase/apiUseCase/GetOrderBookUseCase.kt new file mode 100644 index 0000000..8fee882 --- /dev/null +++ b/domain/src/main/java/com/example/domain/usecase/apiUseCase/GetOrderBookUseCase.kt @@ -0,0 +1,13 @@ +package com.example.domain.usecase.apiUseCase + +import com.example.domain.entity.OrderBookEntity +import com.example.domain.repository.BithumbApiRepository +import kotlinx.coroutines.flow.Flow +import javax.inject.Inject + +class GetOrderBookUseCase @Inject constructor( + private val bithumbApiRepo: BithumbApiRepository +) { + operator fun invoke(ticker: String, count: Int): Flow = + bithumbApiRepo.getOrderBookInfo(ticker, count) +} \ No newline at end of file diff --git a/domain/src/main/java/com/example/domain/usecase/apiUseCase/GetTickerAllUseCase.kt b/domain/src/main/java/com/example/domain/usecase/apiUseCase/GetTickerAllUseCase.kt new file mode 100644 index 0000000..e5ab89c --- /dev/null +++ b/domain/src/main/java/com/example/domain/usecase/apiUseCase/GetTickerAllUseCase.kt @@ -0,0 +1,13 @@ +package com.example.domain.usecase.apiUseCase + +import com.example.domain.repository.BithumbApiRepository +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.filter +import javax.inject.Inject + +class GetTickerAllUseCase @Inject constructor( + private val bithumbApiRepo: BithumbApiRepository +) { + operator fun invoke(): Flow> = + bithumbApiRepo.getTickerInfoAll().filter { it.remove("date") } +} \ No newline at end of file diff --git a/domain/src/main/java/com/example/domain/usecase/apiUseCase/GetTickerDetailInfoUseCase.kt b/domain/src/main/java/com/example/domain/usecase/apiUseCase/GetTickerDetailInfoUseCase.kt new file mode 100644 index 0000000..4cad149 --- /dev/null +++ b/domain/src/main/java/com/example/domain/usecase/apiUseCase/GetTickerDetailInfoUseCase.kt @@ -0,0 +1,23 @@ +package com.example.domain.usecase.apiUseCase + +import com.example.domain.entity.TickerOrderDataEntity +import com.example.domain.repository.BithumbApiRepository +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.map +import javax.inject.Inject + +class GetTickerDetailInfoUseCase @Inject constructor( + private val bithumbApiRepo: BithumbApiRepository +) { + operator fun invoke( + ticker: String + ): Flow = bithumbApiRepo.getTickerInfo(ticker).map { + TickerOrderDataEntity( + closingPrice = it["closing_price"].toString().toInt(), + prevClosingPrice = it["prev_closing_price"].toString().toInt(), + maxPrice = it["max_price"].toString().toInt(), + minPrice = it["min_price"].toString().toInt(), + unitsTraded_24H = it["units_traded_24H"].toString().toDouble() + ) + } +} \ No newline at end of file diff --git a/domain/src/main/java/com/example/domain/usecase/apiUseCase/GetTickerLiveInfoUseCase.kt b/domain/src/main/java/com/example/domain/usecase/apiUseCase/GetTickerLiveInfoUseCase.kt new file mode 100644 index 0000000..ea2f62c --- /dev/null +++ b/domain/src/main/java/com/example/domain/usecase/apiUseCase/GetTickerLiveInfoUseCase.kt @@ -0,0 +1,21 @@ +package com.example.domain.usecase.apiUseCase + +import com.example.domain.entity.TickerLiveDataEntity +import com.example.domain.repository.BithumbApiRepository +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.map +import javax.inject.Inject + +class GetTickerLiveInfoUseCase @Inject constructor( + private val bithumbApiRepo: BithumbApiRepository +) { + operator fun invoke( + ticker: String + ): Flow = bithumbApiRepo.getTickerInfo(ticker).map { + TickerLiveDataEntity( + closingPrice = it["closing_price"].toString().toInt(), + fluctate_24H = it["fluctate_24H"].toString().toInt(), + fluctate_Rate = it["fluctate_rate_24H"].toString().toDouble() + ) + } +} \ No newline at end of file diff --git a/domain/src/main/java/com/example/domain/usecase/apiUseCase/GetTransactionHistoryUseCase.kt b/domain/src/main/java/com/example/domain/usecase/apiUseCase/GetTransactionHistoryUseCase.kt new file mode 100644 index 0000000..7294596 --- /dev/null +++ b/domain/src/main/java/com/example/domain/usecase/apiUseCase/GetTransactionHistoryUseCase.kt @@ -0,0 +1,13 @@ +package com.example.domain.usecase.apiUseCase + +import com.example.domain.entity.TransactionEntity +import com.example.domain.repository.BithumbApiRepository +import kotlinx.coroutines.flow.Flow +import javax.inject.Inject + +class GetTransactionHistoryUseCase @Inject constructor( + private val bithumbApiRepo: BithumbApiRepository +) { + operator fun invoke(ticker: String, count: Int): Flow> = + bithumbApiRepo.getTransactionHistory(ticker, count) +} \ No newline at end of file diff --git a/domain/src/main/java/com/example/domain/usecase/databaseUseCase/DeleteTickerUseCase.kt b/domain/src/main/java/com/example/domain/usecase/databaseUseCase/DeleteTickerUseCase.kt new file mode 100644 index 0000000..e52f84a --- /dev/null +++ b/domain/src/main/java/com/example/domain/usecase/databaseUseCase/DeleteTickerUseCase.kt @@ -0,0 +1,13 @@ +package com.example.domain.usecase.databaseUseCase + +import com.example.domain.entity.TickerEntity +import com.example.domain.repository.DataBaseRepository +import kotlinx.coroutines.flow.Flow +import javax.inject.Inject + +class DeleteTickerUseCase @Inject constructor( + private val DBRepos: DataBaseRepository +) { + operator fun invoke(ticker: TickerEntity): Flow> = + DBRepos.deleteTicker(ticker) +} \ No newline at end of file diff --git a/domain/src/main/java/com/example/domain/usecase/databaseUseCase/InsertTickerUseCase.kt b/domain/src/main/java/com/example/domain/usecase/databaseUseCase/InsertTickerUseCase.kt new file mode 100644 index 0000000..fa97cbe --- /dev/null +++ b/domain/src/main/java/com/example/domain/usecase/databaseUseCase/InsertTickerUseCase.kt @@ -0,0 +1,13 @@ +package com.example.domain.usecase.databaseUseCase + +import com.example.domain.entity.TickerEntity +import com.example.domain.repository.DataBaseRepository +import kotlinx.coroutines.flow.Flow +import javax.inject.Inject + +class InsertTickerUseCase @Inject constructor( + private val DBRepos: DataBaseRepository +) { + operator fun invoke(ticker: TickerEntity): Flow> = + DBRepos.insertTicker(ticker) +} \ No newline at end of file diff --git a/domain/src/main/java/com/example/domain/usecase/databaseUseCase/ReadAllTickerUseCase.kt b/domain/src/main/java/com/example/domain/usecase/databaseUseCase/ReadAllTickerUseCase.kt new file mode 100644 index 0000000..bcceb1b --- /dev/null +++ b/domain/src/main/java/com/example/domain/usecase/databaseUseCase/ReadAllTickerUseCase.kt @@ -0,0 +1,12 @@ +package com.example.domain.usecase.databaseUseCase + +import com.example.domain.entity.TickerEntity +import com.example.domain.repository.DataBaseRepository +import kotlinx.coroutines.flow.Flow +import javax.inject.Inject + +class ReadAllTickerUseCase @Inject constructor( + private val DBRepos: DataBaseRepository +) { + operator fun invoke(): Flow> = DBRepos.readAllTicker() +} \ No newline at end of file diff --git a/domain/src/main/res/drawable-v24/ic_launcher_foreground.xml b/domain/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/domain/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/domain/src/main/res/drawable/ic_launcher_background.xml b/domain/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/domain/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/domain/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/domain/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/domain/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/domain/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/domain/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/domain/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/domain/src/main/res/mipmap-anydpi-v33/ic_launcher.xml b/domain/src/main/res/mipmap-anydpi-v33/ic_launcher.xml new file mode 100644 index 0000000..6f3b755 --- /dev/null +++ b/domain/src/main/res/mipmap-anydpi-v33/ic_launcher.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/domain/src/main/res/mipmap-hdpi/ic_launcher.webp b/domain/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 0000000..c209e78 Binary files /dev/null and b/domain/src/main/res/mipmap-hdpi/ic_launcher.webp differ diff --git a/domain/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/domain/src/main/res/mipmap-hdpi/ic_launcher_round.webp new file mode 100644 index 0000000..b2dfe3d Binary files /dev/null and b/domain/src/main/res/mipmap-hdpi/ic_launcher_round.webp differ diff --git a/domain/src/main/res/mipmap-mdpi/ic_launcher.webp b/domain/src/main/res/mipmap-mdpi/ic_launcher.webp new file mode 100644 index 0000000..4f0f1d6 Binary files /dev/null and b/domain/src/main/res/mipmap-mdpi/ic_launcher.webp differ diff --git a/domain/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/domain/src/main/res/mipmap-mdpi/ic_launcher_round.webp new file mode 100644 index 0000000..62b611d Binary files /dev/null and b/domain/src/main/res/mipmap-mdpi/ic_launcher_round.webp differ diff --git a/domain/src/main/res/mipmap-xhdpi/ic_launcher.webp b/domain/src/main/res/mipmap-xhdpi/ic_launcher.webp new file mode 100644 index 0000000..948a307 Binary files /dev/null and b/domain/src/main/res/mipmap-xhdpi/ic_launcher.webp differ diff --git a/domain/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/domain/src/main/res/mipmap-xhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..1b9a695 Binary files /dev/null and b/domain/src/main/res/mipmap-xhdpi/ic_launcher_round.webp differ diff --git a/domain/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/domain/src/main/res/mipmap-xxhdpi/ic_launcher.webp new file mode 100644 index 0000000..28d4b77 Binary files /dev/null and b/domain/src/main/res/mipmap-xxhdpi/ic_launcher.webp differ diff --git a/domain/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/domain/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9287f50 Binary files /dev/null and b/domain/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp differ diff --git a/domain/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/domain/src/main/res/mipmap-xxxhdpi/ic_launcher.webp new file mode 100644 index 0000000..aa7d642 Binary files /dev/null and b/domain/src/main/res/mipmap-xxxhdpi/ic_launcher.webp differ diff --git a/domain/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/domain/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9126ae3 Binary files /dev/null and b/domain/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp differ diff --git a/domain/src/main/res/values-night/themes.xml b/domain/src/main/res/values-night/themes.xml new file mode 100644 index 0000000..2647319 --- /dev/null +++ b/domain/src/main/res/values-night/themes.xml @@ -0,0 +1,16 @@ + + + + \ No newline at end of file diff --git a/domain/src/main/res/values/colors.xml b/domain/src/main/res/values/colors.xml new file mode 100644 index 0000000..f8c6127 --- /dev/null +++ b/domain/src/main/res/values/colors.xml @@ -0,0 +1,10 @@ + + + #FFBB86FC + #FF6200EE + #FF3700B3 + #FF03DAC5 + #FF018786 + #FF000000 + #FFFFFFFF + \ No newline at end of file diff --git a/domain/src/main/res/values/strings.xml b/domain/src/main/res/values/strings.xml new file mode 100644 index 0000000..e9a792b --- /dev/null +++ b/domain/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + domain + \ No newline at end of file diff --git a/domain/src/main/res/values/themes.xml b/domain/src/main/res/values/themes.xml new file mode 100644 index 0000000..f5bf07d --- /dev/null +++ b/domain/src/main/res/values/themes.xml @@ -0,0 +1,16 @@ + + + + \ No newline at end of file diff --git a/domain/src/test/java/com/example/domain/ExampleUnitTest.kt b/domain/src/test/java/com/example/domain/ExampleUnitTest.kt new file mode 100644 index 0000000..cd437eb --- /dev/null +++ b/domain/src/test/java/com/example/domain/ExampleUnitTest.kt @@ -0,0 +1,17 @@ +package com.example.domain + +import org.junit.Test + +import org.junit.Assert.* + +/** + * Example local unit test, which will execute on the development machine (host). + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +class ExampleUnitTest { + @Test + fun addition_isCorrect() { + assertEquals(4, 2 + 2) + } +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index ca36a32..8eabed2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,22 +1,8 @@ -# Project-wide Gradle settings. -# IDE (e.g. Android Studio) users: -# Gradle settings configured through the IDE *will override* -# any settings specified in this file. -# For more details on how to configure your build environment visit -# http://www.gradle.org/docs/current/userguide/build_environment.html -# Specifies the JVM arguments used for the daemon process. -# The setting is particularly useful for tweaking memory settings. org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 -# When configured, Gradle will run in incubating parallel mode. -# This option should only be used with decoupled projects. More details, visit -# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects -# org.gradle.parallel=true -# AndroidX package structure to make it clearer which packages are bundled with the -# Android operating system, and which are packaged with your app"s APK -# https://developer.android.com/topic/libraries/support-library/androidx-rn android.useAndroidX=true -# Automatically convert third-party libraries to use AndroidX android.enableJetifier=true -# Kotlin code style for this project: "official" or "obsolete": kotlin.code.style=official -org.gradle.unsafe.configuration-cache=true \ No newline at end of file +org.gradle.unsafe.configuration-cache=true +android.defaults.buildfeatures.buildconfig=true +android.nonTransitiveRClass=false +android.nonFinalResIds=false \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 2c45cea..3ffebc8 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Fri Sep 16 21:52:29 KST 2022 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/settings.gradle b/settings.gradle index 01514a1..8550a49 100644 --- a/settings.gradle +++ b/settings.gradle @@ -9,3 +9,5 @@ dependencyResolutionManagement { } rootProject.name = "Koin_Apps" include ':app' +include ':data' +include ':domain'