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