-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
746 additions
and
633 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
120 changes: 60 additions & 60 deletions
120
app/src/main/java/com/example/mempal/cache/DashboardCache.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 |
---|---|---|
@@ -1,61 +1,61 @@ | ||
package com.example.mempal.cache | ||
|
||
import com.example.mempal.api.FeeRates | ||
import com.example.mempal.api.MempoolInfo | ||
|
||
// Singleton object to store dashboard data in memory | ||
object DashboardCache { | ||
private var blockHeight: Int? = null | ||
private var blockTimestamp: Long? = null | ||
private var mempoolInfo: MempoolInfo? = null | ||
private var feeRates: FeeRates? = null | ||
private var lastUpdateTime: Long? = null | ||
|
||
// Save all dashboard data at once | ||
fun saveState( | ||
blockHeight: Int?, | ||
blockTimestamp: Long?, | ||
mempoolInfo: MempoolInfo?, | ||
feeRates: FeeRates? | ||
) { | ||
this.blockHeight = blockHeight | ||
this.blockTimestamp = blockTimestamp | ||
this.mempoolInfo = mempoolInfo | ||
this.feeRates = feeRates | ||
this.lastUpdateTime = System.currentTimeMillis() | ||
} | ||
|
||
// Get cached state | ||
fun getCachedState(): DashboardState { | ||
return DashboardState( | ||
blockHeight = blockHeight, | ||
blockTimestamp = blockTimestamp, | ||
mempoolInfo = mempoolInfo, | ||
feeRates = feeRates, | ||
lastUpdateTime = lastUpdateTime | ||
) | ||
} | ||
|
||
// Check if we have any cached data | ||
fun hasCachedData(): Boolean { | ||
return blockHeight != null || mempoolInfo != null || feeRates != null | ||
} | ||
|
||
// Clear cache (useful when app is closing) | ||
fun clearCache() { | ||
blockHeight = null | ||
blockTimestamp = null | ||
mempoolInfo = null | ||
feeRates = null | ||
lastUpdateTime = null | ||
} | ||
} | ||
|
||
// Data class to hold all dashboard state | ||
data class DashboardState( | ||
val blockHeight: Int?, | ||
val blockTimestamp: Long?, | ||
val mempoolInfo: MempoolInfo?, | ||
val feeRates: FeeRates?, | ||
val lastUpdateTime: Long? | ||
package com.example.mempal.cache | ||
|
||
import com.example.mempal.api.FeeRates | ||
import com.example.mempal.api.MempoolInfo | ||
|
||
// Singleton object to store dashboard data in memory | ||
object DashboardCache { | ||
private var blockHeight: Int? = null | ||
private var blockTimestamp: Long? = null | ||
private var mempoolInfo: MempoolInfo? = null | ||
private var feeRates: FeeRates? = null | ||
private var lastUpdateTime: Long? = null | ||
|
||
// Save all dashboard data at once | ||
fun saveState( | ||
blockHeight: Int?, | ||
blockTimestamp: Long?, | ||
mempoolInfo: MempoolInfo?, | ||
feeRates: FeeRates? | ||
) { | ||
this.blockHeight = blockHeight | ||
this.blockTimestamp = blockTimestamp | ||
this.mempoolInfo = mempoolInfo | ||
this.feeRates = feeRates | ||
this.lastUpdateTime = System.currentTimeMillis() | ||
} | ||
|
||
// Get cached state | ||
fun getCachedState(): DashboardState { | ||
return DashboardState( | ||
blockHeight = blockHeight, | ||
blockTimestamp = blockTimestamp, | ||
mempoolInfo = mempoolInfo, | ||
feeRates = feeRates, | ||
lastUpdateTime = lastUpdateTime | ||
) | ||
} | ||
|
||
// Check if we have any cached data | ||
fun hasCachedData(): Boolean { | ||
return blockHeight != null || mempoolInfo != null || feeRates != null | ||
} | ||
|
||
// Clear cache (useful when app is closing) | ||
fun clearCache() { | ||
blockHeight = null | ||
blockTimestamp = null | ||
mempoolInfo = null | ||
feeRates = null | ||
lastUpdateTime = null | ||
} | ||
} | ||
|
||
// Data class to hold all dashboard state | ||
data class DashboardState( | ||
val blockHeight: Int?, | ||
val blockTimestamp: Long?, | ||
val mempoolInfo: MempoolInfo?, | ||
val feeRates: FeeRates?, | ||
val lastUpdateTime: Long? | ||
) |
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
Oops, something went wrong.