Skip to content

Commit 9c637a2

Browse files
author
Ebenezer Ackon
committed
add Logs and more logic in mainactivity just for testing
1 parent b54bf2c commit 9c637a2

File tree

1 file changed

+25
-14
lines changed

1 file changed

+25
-14
lines changed

app/src/main/java/jfyg/etherscan/helloetherescan/MainActivity.kt

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,40 +7,50 @@ import android.view.Menu
77
import android.view.MenuItem
88
import io.reactivex.android.schedulers.AndroidSchedulers
99
import io.reactivex.schedulers.Schedulers
10-
import jfyg.etherscan.helloetherescan.network.responses.BaseResponse
10+
import jfyg.etherscan.helloetherescan.ethereum.EthereumStat
11+
import jfyg.etherscan.helloetherescan.model.EtherPriceModel
12+
import jfyg.etherscan.helloetherescan.network.responses.MainResponse
1113
import jfyg.etherscan.helloetherescan.network.RestClient
1214

1315
import kotlinx.android.synthetic.main.activity_main.*
14-
16+
//TODO: clean up and write tests
1517
class MainActivity : AppCompatActivity() {
1618
private val TAG = javaClass.name!!
19+
20+
var etherPrice = EtherPriceModel()
21+
1722
override fun onCreate(savedInstanceState: Bundle?) {
1823
super.onCreate(savedInstanceState)
1924
setContentView(R.layout.activity_main)
2025
setSupportActionBar(toolbar)
2126

27+
var testing = EthereumStat()
2228

2329
fab.setOnClickListener {
24-
queryPrice("1I7CRNU2QIU253UBPFVB5UV2C2PBDURAIY")
30+
//testing.getTotalSupply()
31+
//testing.getTotalSupplyInWei()
32+
testing.getLastPriceInUsd()
33+
testing.getLastPriceInBtc()
34+
//queryStats("stats", "ethPrice")
2535
}
2636
}
2737

28-
private fun queryPrice(apiKey: String) {
38+
fun queryStats(module: String, action: String) {
39+
//pass apikey that will save in preferences or singleton or something.. or application class
2940
RestClient().getQuery()
30-
.getEtherStats("stats", "ethprice", apiKey)
41+
.getEtherStats(module, action, "1I7CRNU2QIU253UBPFVB5UV2C2PBDURAIYZ")
3142
.observeOn(AndroidSchedulers.mainThread())
3243
.subscribeOn(Schedulers.io())
3344
.subscribe(this::handleResponse, this::handleError)
3445
}
3546

36-
private fun handleResponse(retrieveQuery: BaseResponse) {
37-
Log.d(TAG, "status: " + retrieveQuery.status)
38-
Log.d(TAG, "message: " + retrieveQuery.message)
39-
Log.d(TAG, "Eth in Btc: " + retrieveQuery.etherPriceresult?.ethBtc)
40-
Log.d(TAG, "Eth in Btc Timestamp: " + retrieveQuery.etherPriceresult?.ethBtcTimestamp)
41-
Log.d(TAG, "Eth in Usd: " + retrieveQuery.etherPriceresult?.ethUsd)
42-
Log.d(TAG, "Eth in Usd Timestamp: " + retrieveQuery.etherPriceresult?.ethUsdTimestamp)
43-
//Log.d(TAG, "Eth supply: " + retrieveQuery.etherSupplyResult)
47+
private fun handleResponse(retrieveQuery: MainResponse) {
48+
etherPrice.status = retrieveQuery.status
49+
etherPrice.message = retrieveQuery.message
50+
etherPrice.ethBtc = retrieveQuery.etherPriceresult?.ethBtc
51+
etherPrice.ethBtcTimestamp = retrieveQuery.etherPriceresult?.ethBtcTimestamp
52+
etherPrice.ethUsd = retrieveQuery.etherPriceresult?.ethUsd
53+
etherPrice.ethUsdTimestamp = retrieveQuery.etherPriceresult?.ethUsdTimestamp
4454
}
4555

4656
private fun handleError(error: Throwable) {
@@ -62,4 +72,5 @@ class MainActivity : AppCompatActivity() {
6272
else -> super.onOptionsItemSelected(item)
6373
}
6474
}
65-
}
75+
76+
}

0 commit comments

Comments
 (0)