Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
76 changes: 76 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

apply plugin: 'kotlin-kapt'

android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.sunday"
minSdkVersion 28
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

dataBinding{
enabled = true
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

// material
implementation "com.google.android.material:material:1.0.0"

// ViewModel and LiveData
implementation "androidx.lifecycle:lifecycle-extensions:2.2.0-rc01"
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0-rc01'


//Retrofit2
implementation 'com.squareup.retrofit2:retrofit:2.6.0'
implementation 'com.squareup.retrofit2:converter-gson:2.6.0'
implementation "com.squareup.retrofit2:adapter-rxjava2:2.6.0"

//Glide
implementation 'com.github.bumptech.glide:glide:4.10.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.10.0'

//Browser Helper
implementation 'com.google.androidbrowserhelper:androidbrowserhelper:0.1.0-alpha1'

// RxJava2
implementation "io.reactivex.rxjava2:rxandroid:2.1.1"
implementation "io.reactivex.rxjava2:rxjava:2.2.15"

//Koin lib
implementation 'org.koin:koin-androidx-scope:2.0.1'
implementation 'org.koin:koin-androidx-viewmodel:2.0.1'
implementation 'org.koin:koin-androidx-ext:2.0.1'

// Coroutines
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.0'


}
21 changes: 21 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.example.sunday

import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith

/**
* 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.sunday", appContext.packageName)
}
}
28 changes: 28 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:dist="http://schemas.android.com/apk/distribution"
package="com.example.sunday">

<uses-permission android:name="android.permission.INTERNET" />
<dist:module dist:instant="true" />

<application
android:name=".CoinApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".ui.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ui.ExchangeActivity"
android:screenOrientation="portrait" />
</application>
</manifest>
21 changes: 21 additions & 0 deletions app/src/main/java/com/example/sunday/CoinApplication.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.example.sunday


import android.app.Application
import com.example.sunday.di.networkModuelUpbit
import com.example.sunday.di.viewModelModule
import org.koin.android.ext.koin.androidContext
import org.koin.core.context.startKoin


class CoinApplication : Application() {
private val moduleList = listOf(viewModelModule, networkModuelUpbit)

override fun onCreate() {
super.onCreate()
startKoin {
androidContext(this@CoinApplication)
modules(moduleList)
}
}
}
34 changes: 34 additions & 0 deletions app/src/main/java/com/example/sunday/base/BaseActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.example.sunday.base

import android.content.pm.ActivityInfo
import android.os.Bundle
import android.widget.Toast
import androidx.annotation.LayoutRes
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding

abstract class BaseActivity<B : ViewDataBinding>(@LayoutRes private val layoutId: Int) :
AppCompatActivity() {

protected lateinit var binding: B

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

binding = DataBindingUtil.setContentView(this, layoutId)
binding.lifecycleOwner = this

setOrientationToPortrait()
}

protected fun showToastMessage(msg: String?) {
if (!msg.isNullOrEmpty()) {
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show()
}
}

private fun setOrientationToPortrait() {
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
}
}
16 changes: 16 additions & 0 deletions app/src/main/java/com/example/sunday/base/BaseViewHolder.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.example.sunday.base

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.annotation.LayoutRes
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.recyclerview.widget.RecyclerView

abstract class BaseViewHolder<B : ViewDataBinding>(@LayoutRes private val layoutId: Int, parent: ViewGroup) :
RecyclerView.ViewHolder(
LayoutInflater.from(parent.context).inflate(layoutId, parent, false)
) {

protected val binding: B = DataBindingUtil.bind(itemView)!!
}
28 changes: 28 additions & 0 deletions app/src/main/java/com/example/sunday/data/enums/BaseCurrency.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.example.sunday.data.enums

enum class BaseCurrency {
KRW,
BTC,
ETH,
USDT,
BNB,
USD,
EUR,
GBP,
JPY,
EOS,
HT,
BCH,
EURS,
DAI,
TUSD,
QC,
ZB,
PAX,
LBCN,
QTUM,
ELA,
DAX,
BIX,
GUSD
}
7 changes: 7 additions & 0 deletions app/src/main/java/com/example/sunday/data/enums/Exchange.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.example.sunday.data.enums

enum class Exchange(val exchangeName: String) {
UPBIT("Upbit"),
BITHUMB("Bithumb"),
COINONE("Coinone")
}
12 changes: 12 additions & 0 deletions app/src/main/java/com/example/sunday/data/model/ExchangeTicker.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.example.sunday.data.model

class ExchangeTicker (
val exchangeName: String,
ticker: Ticker)
: Ticker(currency = ticker.currency,
baseCurrency = ticker.baseCurrency,
last = ticker.last,
high = ticker.high,
low = ticker.low,
volume = ticker.volume,
diff = ticker.diff)
14 changes: 14 additions & 0 deletions app/src/main/java/com/example/sunday/data/model/Ticker.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.example.sunday.data.model

open class Ticker(
var currency: String? = "",
var baseCurrency: String? = "",
var last: Double?,
var high: Double?,
var low: Double?,
var volume: Double?,
var diff: Double? = null) : TickerProvider{

override fun toTicker(): Ticker = this
override fun toExchangeTicker(exchangeName: String): ExchangeTicker = ExchangeTicker(exchangeName, this)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.example.sunday.data.model

interface TickerProvider {
fun toTicker(): Ticker
fun toExchangeTicker(exchangeName: String = "empty") : ExchangeTicker
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.example.sunday.data.repository.ticker

import com.example.sunday.data.soruce.remote.RemoteTickerDataSource

class BithumbRepository(private val remoteTickerDataSource: RemoteTickerDataSource) : TickerRepository {
override suspend fun getAllTicker():Any = remoteTickerDataSource.getAllTicker()
override suspend fun getTicker(currency: String) = remoteTickerDataSource.getTicker(currency)
override suspend fun getExchangeTicker(currency: String) = remoteTickerDataSource.getExchangeTicker(currency)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.example.sunday.data.repository.ticker

import com.example.sunday.data.soruce.remote.RemoteTickerDataSource

class CoinoneRepository(private val remoteTickerDataSource: RemoteTickerDataSource) : TickerRepository {
override suspend fun getAllTicker() = remoteTickerDataSource.getAllTicker()
override suspend fun getTicker(currency: String) = remoteTickerDataSource.getTicker(currency)
override suspend fun getExchangeTicker(currency: String) = remoteTickerDataSource.getExchangeTicker(currency)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.example.sunday.data.repository.ticker

interface TickerRepository {
suspend fun getAllTicker():Any
suspend fun getTicker(currency: String):Any
suspend fun getExchangeTicker(currency: String):Any
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.example.sunday.data.repository.ticker

import com.example.sunday.data.soruce.remote.RemoteTickerDataSource

class UpbitRepository(private val remoteTickerDataSource: RemoteTickerDataSource) : TickerRepository {
override suspend fun getAllTicker(): Any = remoteTickerDataSource.getAllTicker()
override suspend fun getTicker(currency: String): Any = remoteTickerDataSource.getTicker(currency)
override suspend fun getExchangeTicker(currency: String): Any = remoteTickerDataSource.getExchangeTicker(currency)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.example.sunday.data.soruce.remote

import com.example.sunday.network.api.BithumbApi

class RemoteBitumbDataSoruceImpl(private val networkApi: BithumbApi) : RemoteTickerDataSource {
override suspend fun getAllTicker(): Any = networkApi.getTickerList()
override suspend fun getTicker(currency: String): Any = this
override suspend fun getExchangeTicker(currency: String):Any = networkApi.getExchangeTicker(currency)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.example.sunday.data.soruce.remote

import com.example.sunday.network.api.CoinoneApi

class RemoteCoinoneDataSourceImpl(private val networkApi: CoinoneApi) : RemoteTickerDataSource {
override suspend fun getAllTicker(): Any = networkApi.getAllTicker()
override suspend fun getTicker(currency: String): Any = networkApi.getTicker(currency)
override suspend fun getExchangeTicker(currency: String): Any = networkApi.getExchangeTicker(currency)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.example.sunday.data.soruce.remote

interface RemoteTickerDataSource {
suspend fun getAllTicker():Any
suspend fun getTicker(currency: String):Any
suspend fun getExchangeTicker(currency: String):Any
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.example.sunday.data.soruce.remote

import com.example.sunday.network.api.UpbitApi

class RemoteUpbitDataSourceImpl(private val networkApi: UpbitApi) : RemoteTickerDataSource {
override suspend fun getAllTicker(): Any = networkApi.getMarket()
override suspend fun getTicker(currency: String): Any = networkApi.getTicker(currency)
override suspend fun getExchangeTicker(currency: String): Any = networkApi.getExchangeTicker(currency)
}
Loading