-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Migration to Kotlin (1 of 2): Code converted and refactored * Migration to Kotlin (2 of 2): Renamed extensions .java to .kt * Rebranding modules and namespaces * Fix code after kotlin migration * More fixes after kotlin migration * Fixed lint warnings
- Loading branch information
Alexander Biryukov
authored
Sep 5, 2020
1 parent
924c6c0
commit 1aac1e1
Showing
319 changed files
with
8,597 additions
and
10,000 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,6 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.mobnetic.coinguardiandatamodule" | ||
package="com.aneonex.bitcoinchecker.datamodule" | ||
android:versionCode="1" | ||
android:versionName="1.1" > | ||
|
||
<!--uses-sdk | ||
android:minSdkVersion="9" | ||
android:targetSdkVersion="18" /--> | ||
android:versionName="2.0" > | ||
|
||
</manifest> |
140 changes: 140 additions & 0 deletions
140
dataModule/src/main/java/com/aneonex/bitcoinchecker/datamodule/config/MarketsConfig.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
package com.aneonex.bitcoinchecker.datamodule.config | ||
|
||
import com.aneonex.bitcoinchecker.datamodule.model.Market | ||
import com.aneonex.bitcoinchecker.datamodule.model.market.* | ||
import java.util.* | ||
|
||
object MarketsConfig { | ||
@kotlin.jvm.JvmField | ||
val MARKETS = LinkedHashMap<String, Market>() | ||
private fun addMarket(market: Market) { | ||
MARKETS[market.key] = market | ||
} | ||
|
||
init { | ||
addMarket(Bitstamp()) | ||
addMarket(Mercado()) | ||
addMarket(Kraken()) | ||
addMarket(Bitfinex()) | ||
addMarket(Okcoin()) | ||
addMarket(Cryptsy()) | ||
addMarket(Coinbase()) | ||
addMarket(Vircurex()) | ||
addMarket(Fxbtc()) | ||
addMarket(Bter()) | ||
addMarket(Justcoin()) | ||
addMarket(Btcturk()) | ||
addMarket(Coinse()) | ||
addMarket(Campbx()) | ||
addMarket(TheRock()) | ||
addMarket(CexIO()) | ||
addMarket(Virtex()) | ||
addMarket(Huobi()) | ||
addMarket(VaultOfSatoshi()) | ||
addMarket(CoinMarketIO()) | ||
addMarket(McxNOW()) | ||
addMarket(CryptoTrade()) | ||
addMarket(MintPal()) | ||
addMarket(CoinJar()) | ||
addMarket(Poloniex()) | ||
addMarket(Winkdex()) | ||
addMarket(BitX()) | ||
addMarket(CCex()) | ||
addMarket(Bitorado()) | ||
addMarket(CryptoRush()) | ||
addMarket(CoinDesk()) | ||
addMarket(Koinim()) | ||
addMarket(FybSE()) | ||
addMarket(FybSG()) | ||
addMarket(Prelude()) | ||
addMarket(BitKonan()) | ||
addMarket(BitTrex()) | ||
addMarket(Comkort()) | ||
addMarket(Bit2c()) | ||
addMarket(CryptoAltex()) | ||
addMarket(BtcMarkets()) | ||
addMarket(Bleutrade()) | ||
addMarket(ShareXcoin()) | ||
addMarket(Unisend()) | ||
addMarket(BitcoinVenezuela()) | ||
addMarket(Korbit()) | ||
addMarket(CoinTree()) | ||
addMarket(Cryptonit()) | ||
addMarket(LakeBTC()) | ||
addMarket(BitMaszyna()) | ||
addMarket(Zaydo()) | ||
addMarket(AllCoin()) | ||
addMarket(Ripio()) | ||
addMarket(DolarBlueNet()) | ||
addMarket(CoinSwap()) | ||
addMarket(Paymium()) | ||
addMarket(Bitso()) | ||
addMarket(Cryptoine()) | ||
addMarket(BitcoinToYou()) | ||
addMarket(BitexLa()) | ||
addMarket(ItBit()) | ||
addMarket(BitcoinCoId()) | ||
addMarket(HitBtc()) | ||
addMarket(CleverCoin()) | ||
addMarket(BitBay()) | ||
addMarket(QuadrigaCX()) | ||
addMarket(CoinMateIO()) | ||
addMarket(Buttercoin()) | ||
addMarket(CoinTraderNet()) | ||
addMarket(LocalBitcoins()) | ||
addMarket(Cryptopia()) | ||
addMarket(Igot()) | ||
addMarket(Mexbt()) | ||
addMarket(Vaultoro()) | ||
addMarket(BitxCom()) | ||
addMarket(BtcBox()) | ||
addMarket(BtcXIndia()) | ||
addMarket(Uphold()) | ||
addMarket(YoBit()) | ||
addMarket(ShapeShift()) | ||
addMarket(BitoEX()) | ||
addMarket(OKCoinFutures()) | ||
// addMarket(new FoscEx()); | ||
addMarket(CoinSecure()) | ||
addMarket(Dashcurex()) | ||
addMarket(Quoine()) | ||
addMarket(Livecoin()) | ||
addMarket(Gemini()) | ||
addMarket(Coinapult()) | ||
addMarket(Btc38()) | ||
addMarket(ETHEXIndia()) | ||
addMarket(GateCoin()) | ||
addMarket(Liqui()) | ||
addMarket(ChileBit()) | ||
addMarket(SurBitcoin()) | ||
addMarket(VBtc()) | ||
addMarket(Urdubit()) | ||
addMarket(NegocieCoins()) | ||
addMarket(BitMEX()) | ||
addMarket(BitFlyer()) | ||
addMarket(BitFlyerFX()) | ||
addMarket(Coinone()) | ||
addMarket(Bithumb()) | ||
addMarket(Coinsph()) | ||
addMarket(Bl3p()) | ||
addMarket(SurBtc()) | ||
addMarket(CoinFloor()) | ||
addMarket(Lykke()) | ||
addMarket(Coinnest()) | ||
addMarket(Braziliex()) | ||
addMarket(Abucoins()) | ||
addMarket(Zebpay()) | ||
addMarket(Paribu()) | ||
addMarket(SatoshiTango()) | ||
addMarket(Koinex()) | ||
// addMarket(new Unocoin()); | ||
addMarket(BlinkTrade()) | ||
addMarket(Exmo()) | ||
addMarket(Binance()) | ||
addMarket(Kucoin()) | ||
addMarket(BitcoinTrade()) | ||
addMarket(OmniTrade()) | ||
addMarket(Coinome()) | ||
addMarket(Nocks()) | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
dataModule/src/main/java/com/aneonex/bitcoinchecker/datamodule/config/Settings.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.aneonex.bitcoinchecker.datamodule.config | ||
|
||
object Settings { | ||
var userCountry: String? = null | ||
} |
11 changes: 11 additions & 0 deletions
11
dataModule/src/main/java/com/aneonex/bitcoinchecker/datamodule/model/CheckerInfo.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.aneonex.bitcoinchecker.datamodule.model | ||
|
||
import java.util.* | ||
|
||
class CheckerInfo(currencyBase: String, currencyCounter: String, currencyPairId: String?, val contractType: Int) | ||
: CurrencyPairInfo(currencyBase, currencyCounter, currencyPairId) { | ||
val currencyBaseLowerCase: String | ||
get() = currencyBase.toLowerCase(Locale.US) | ||
val currencyCounterLowerCase: String | ||
get() = currencyCounter.toLowerCase(Locale.US) | ||
} |
9 changes: 9 additions & 0 deletions
9
dataModule/src/main/java/com/aneonex/bitcoinchecker/datamodule/model/CurrencyPairInfo.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.aneonex.bitcoinchecker.datamodule.model | ||
|
||
open class CurrencyPairInfo(val currencyBase: String, val currencyCounter: String, val currencyPairId: String?) : Comparable<CurrencyPairInfo> { | ||
@Throws(NullPointerException::class) | ||
override fun compareTo(other: CurrencyPairInfo): Int { | ||
val compBase = currencyBase.compareTo(other.currencyBase, ignoreCase = true) | ||
return if (compBase != 0) compBase else currencyCounter.compareTo(other.currencyCounter, ignoreCase = true) | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...le/src/main/java/com/aneonex/bitcoinchecker/datamodule/model/CurrencyPairsListWithDate.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.aneonex.bitcoinchecker.datamodule.model | ||
|
||
class CurrencyPairsListWithDate { | ||
@kotlin.jvm.JvmField | ||
var date: Long = 0 | ||
@kotlin.jvm.JvmField | ||
var pairs: List<CurrencyPairInfo>? = null | ||
} |
3 changes: 3 additions & 0 deletions
3
dataModule/src/main/java/com/aneonex/bitcoinchecker/datamodule/model/CurrencySubunit.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package com.aneonex.bitcoinchecker.datamodule.model | ||
|
||
class CurrencySubunit @JvmOverloads constructor(val name: String, val subunitToUnit: Long, val allowDecimal: Boolean = true) |
13 changes: 13 additions & 0 deletions
13
dataModule/src/main/java/com/aneonex/bitcoinchecker/datamodule/model/CurrencySubunitsMap.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.aneonex.bitcoinchecker.datamodule.model | ||
|
||
import java.util.* | ||
|
||
class CurrencySubunitsMap(vararg currencySubunits: CurrencySubunit) : LinkedHashMap<Long, CurrencySubunit>() { | ||
companion object { | ||
// private const val serialVersionUID = -7219011491064245859L | ||
} | ||
|
||
init { | ||
for (currencySubunit in currencySubunits) put(currencySubunit.subunitToUnit, currencySubunit) | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
dataModule/src/main/java/com/aneonex/bitcoinchecker/datamodule/model/Futures.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.aneonex.bitcoinchecker.datamodule.model | ||
|
||
object Futures { | ||
const val CONTRACT_TYPE_WEEKLY = 0 | ||
const val CONTRACT_TYPE_BIWEEKLY = 1 | ||
// const val CONTRACT_TYPE_MONTHLY = 2 | ||
// const val CONTRACT_TYPE_BIMONTHLY = 3 | ||
const val CONTRACT_TYPE_QUARTERLY = 4 | ||
private val CONTRACT_TYPE_SHORT_NAMES = arrayOf( | ||
"1W", | ||
"2W", | ||
"1M", | ||
"2M", | ||
"3M" | ||
) | ||
|
||
@kotlin.jvm.JvmStatic | ||
fun getContractTypeShortName(contractType: Int): String? { | ||
return if (contractType >= 0 && contractType < CONTRACT_TYPE_SHORT_NAMES.size) { | ||
CONTRACT_TYPE_SHORT_NAMES[contractType] | ||
} else null | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
dataModule/src/main/java/com/aneonex/bitcoinchecker/datamodule/model/FuturesMarket.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.aneonex.bitcoinchecker.datamodule.model | ||
|
||
import com.aneonex.bitcoinchecker.datamodule.model.currency.CurrencyPairsMap | ||
|
||
abstract class FuturesMarket(name: String, ttsName: String, currencyPairs: CurrencyPairsMap?, val contractTypes: IntArray) | ||
: Market(name, ttsName, currencyPairs) { | ||
|
||
override fun getUrl(requestId: Int, checkerInfo: CheckerInfo): String { | ||
return getUrl(requestId, checkerInfo, checkerInfo.contractType) | ||
} | ||
|
||
protected abstract fun getUrl(requestId: Int, checkerInfo: CheckerInfo, contractType: Int): String | ||
} |
98 changes: 98 additions & 0 deletions
98
dataModule/src/main/java/com/aneonex/bitcoinchecker/datamodule/model/Market.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
package com.aneonex.bitcoinchecker.datamodule.model | ||
|
||
import android.text.TextUtils | ||
import com.aneonex.bitcoinchecker.datamodule.model.currency.CurrencyPairsMap | ||
import com.aneonex.bitcoinchecker.datamodule.util.TimeUtils | ||
import org.json.JSONObject | ||
|
||
abstract class Market(name: String, ttsName: String, currencyPairs: CurrencyPairsMap?) { | ||
@kotlin.jvm.JvmField | ||
val key: String = this.javaClass.simpleName | ||
|
||
@kotlin.jvm.JvmField | ||
val name: String = name | ||
|
||
val ttsName: String = ttsName | ||
|
||
@kotlin.jvm.JvmField | ||
val currencyPairs: CurrencyPairsMap? | ||
|
||
open val cautionResId: Int | ||
get() = 0 | ||
|
||
// ==================== | ||
// Parse Ticker | ||
// ==================== | ||
open fun getNumOfRequests(checkerInfo: CheckerInfo?): Int { | ||
return 1 | ||
} | ||
|
||
abstract fun getUrl(requestId: Int, checkerInfo: CheckerInfo): String | ||
@Throws(Exception::class) | ||
fun parseTickerMain(requestId: Int, responseString: String, ticker: Ticker, checkerInfo: CheckerInfo): Ticker { | ||
parseTicker(requestId, responseString, ticker, checkerInfo) | ||
if (ticker.timestamp <= 0) ticker.timestamp = System.currentTimeMillis() else ticker.timestamp = TimeUtils.parseTimeToMillis(ticker.timestamp) | ||
return ticker | ||
} | ||
|
||
@Throws(Exception::class) | ||
protected open fun parseTicker(requestId: Int, responseString: String, ticker: Ticker, checkerInfo: CheckerInfo) { | ||
parseTickerFromJsonObject(requestId, JSONObject(responseString), ticker, checkerInfo) | ||
} | ||
|
||
@Throws(Exception::class) | ||
protected open fun parseTickerFromJsonObject(requestId: Int, jsonObject: JSONObject, ticker: Ticker, checkerInfo: CheckerInfo) { | ||
// do parsing | ||
} | ||
|
||
// ==================== | ||
// Parse Ticker Error | ||
// ==================== | ||
@Throws(Exception::class) | ||
fun parseErrorMain(requestId: Int, responseString: String, checkerInfo: CheckerInfo): String? { | ||
return parseError(requestId, responseString, checkerInfo) | ||
} | ||
|
||
@Throws(Exception::class) | ||
protected open fun parseError(requestId: Int, responseString: String, checkerInfo: CheckerInfo): String? { | ||
return parseErrorFromJsonObject(requestId, JSONObject(responseString), checkerInfo) | ||
} | ||
|
||
@Throws(Exception::class) | ||
protected open fun parseErrorFromJsonObject(requestId: Int, jsonObject: JSONObject, checkerInfo: CheckerInfo?): String? { | ||
throw Exception() | ||
} | ||
|
||
// ==================== | ||
// Parse currency pairs | ||
// ==================== | ||
open val currencyPairsNumOfRequests: Int | ||
get() = 1 | ||
|
||
open fun getCurrencyPairsUrl(requestId: Int): String? { | ||
return null | ||
} | ||
|
||
@Throws(Exception::class) | ||
fun parseCurrencyPairsMain(requestId: Int, responseString: String, pairs: MutableList<CurrencyPairInfo>) { | ||
parseCurrencyPairs(requestId, responseString, pairs) | ||
for (i in pairs.indices.reversed()) { | ||
val currencyPairInfo = pairs[i] | ||
if (TextUtils.isEmpty(currencyPairInfo.currencyBase) || TextUtils.isEmpty(currencyPairInfo.currencyCounter)) pairs.removeAt(i) | ||
} | ||
} | ||
|
||
@Throws(Exception::class) | ||
protected open fun parseCurrencyPairs(requestId: Int, responseString: String, pairs: MutableList<CurrencyPairInfo>) { | ||
parseCurrencyPairsFromJsonObject(requestId, JSONObject(responseString), pairs) | ||
} | ||
|
||
@Throws(Exception::class) | ||
protected open fun parseCurrencyPairsFromJsonObject(requestId: Int, jsonObject: JSONObject, pairs: MutableList<CurrencyPairInfo>) { | ||
// do parsing | ||
} | ||
|
||
init { | ||
this.currencyPairs = currencyPairs | ||
} | ||
} |
Oops, something went wrong.