File tree Expand file tree Collapse file tree 4 files changed +12
-53
lines changed 
etherscan-sample/src/main/java/jfyg/etherscan/helloetherescan Expand file tree Collapse file tree 4 files changed +12
-53
lines changed Original file line number Diff line number Diff line change @@ -32,10 +32,10 @@ class SampleActivity : AppCompatActivity() {
3232        fab.setOnClickListener {
3333
3434            // stat test
35-             stat.getLastPriceInBtc ()
35+             stat.getEtherStatistics ()
3636                    .observeOn(AndroidSchedulers .mainThread())
3737                    .subscribeBy(
38-                             onSuccess =  { Log .d(TAG , " The current price of Ether in Btc: $it  " 
38+                             onSuccess =  { Log .d(TAG , " The current price of Ether in Btc: ${it.ethUsd}  " 
3939                            onError =  { Log .d(TAG , " error receiving stat" 
4040
4141
Original file line number Diff line number Diff line change 11package  jfyg.data.stat 
22
33import  io.reactivex.Single 
4+ import  jfyg.data.StatPrice 
45import  jfyg.network.queries.ApiQuery 
56import  jfyg.utils.ETH_PRICE 
67import  jfyg.utils.ETH_SUPPLY 
@@ -28,24 +29,9 @@ class Stats : StatsContract {
2829    override  fun  getTotalSupplyInWei (): Single <Double > =  supplyQuery.map { it.result?.toDouble()?.div(wei) }
2930
3031    /* *
31-      * Get ETHER LastPrice Price in btc  
32+      * Get Ether Statistics  
3233     */  
33-     override  fun  getLastPriceInUsd (): Single <Float > =  priceQuery.map { it.result?.ethUsd?.toFloat() }
34- 
35-     /* *
36-      * Return timestamp 
37-      */  
38-     override  fun  getEthTimestamp (): Single <Long > =  priceQuery.map { it.result?.ethUsdTimestamp?.toLong() }
39- 
40-     /* *
41-      * Get ETHER LastPrice Price in usd 
42-      */  
43-     override  fun  getLastPriceInBtc (): Single <Float > =  priceQuery.map { it.result?.ethBtcTimestamp?.toFloat() }
44- 
45-     /* *
46-      * Return timestamp 
47-      */  
48-     override  fun  getBtcTimestamp (): Single <Long > =  priceQuery.map { it.result?.ethBtcTimestamp?.toLong() }
34+     override  fun  getEtherStatistics (): Single <StatPrice > =  priceQuery.map { it.result }
4935
5036    /* *
5137     * Return network status 
Original file line number Diff line number Diff line change 11package  jfyg.data.stat 
22
33import  io.reactivex.Single 
4+ import  jfyg.data.StatPrice 
45
56/* *
67 * https://etherscan.io/apis#stats 
@@ -18,24 +19,9 @@ internal interface StatsContract {
1819    fun  getTotalSupplyInWei (): Single <Double >
1920
2021    /* *
21-      * Get ETHER LastPrice Price in btc  
22+      * Get ETHER statistics  
2223     */  
23-     fun  getLastPriceInBtc (): Single <Float >
24- 
25-     /* *
26-      * Return timestamp 
27-      */  
28-     fun  getBtcTimestamp (): Single <Long >
29- 
30-     /* *
31-      * Get ETHER LastPrice Price in usd 
32-      */  
33-     fun  getLastPriceInUsd (): Single <Float >
34- 
35-     /* *
36-      * Return timestamp 
37-      */  
38-     fun  getEthTimestamp (): Single <Long >
24+     fun  getEtherStatistics (): Single <StatPrice >
3925
4026    /* *
4127     * Return network status 
Original file line number Diff line number Diff line change @@ -61,33 +61,20 @@ internal class StatsTest {
6161    }
6262
6363    @Test
64-     fun  getLastPriceInUsd () {
64+     fun  getEtherStatistics () {
6565        val  response =  gson.fromJson(inputPrice, StatPriceResponse ::class .java)
6666        assertEquals(" 377.67" 
67-     }
68- 
69-     @Test
70-     fun  getEthTimestamp () {
71-         val  response =  gson.fromJson(inputPrice, StatPriceResponse ::class .java)
72-         assertEquals(" 1523064526" 
73-     }
74- 
75-     @Test
76-     fun  getLastPriceInBtc () {
77-         val  response =  gson.fromJson(inputPrice, StatPriceResponse ::class .java)
7867        assertEquals(" 0.0557" 
79-     }
80- 
81-     @Test
82-     fun  getBtcTimestamp () {
83-         val  response =  gson.fromJson(inputPrice, StatPriceResponse ::class .java)
68+         assertEquals(" 1523064526" 
8469        assertEquals(" 1523064523" 
70+ 
8571    }
8672
8773    @Test
8874    fun  networkStatusIsDown () {
8975        val  response =  gson.fromJson(inputBadResponse, BaseResponse ::class .java)
9076        assertEquals(" 0" 
77+ 
9178    }
9279
9380    @Test
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments