-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add offerbook and marketprice domain (#78)
* Add dependency to bisq-easy library * Add markets images * Add payment images * Remove outdated payment images * Apply offerbook and market price domain * Add default markets * Remove unused onCreate method * Use field for coroutineScope Add cancelJob method with exception handling * Refactor: Move serviceFacade packages into new service package * Refactor: Move view model classes into data/model * Let view models extend BaseModel * Add overload methods for passing a string or no argument (Default logger) * Use logger instead of println * Rename all image to use `_` instead of `-` * Rename image path to use `_` instead of `-` * Rename private method * Refactor: Rename to match domain terms * - fix android lint compilation errors on android node --------- Co-authored-by: Rodrigo Varela <[email protected]>
- Loading branch information
1 parent
b73abf6
commit b548046
Showing
259 changed files
with
2,081 additions
and
536 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
41 changes: 28 additions & 13 deletions
41
...otlin/network/bisq/mobile/android/node/domain/bootstrap/NodeApplicationBootstrapFacade.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,46 +1,61 @@ | ||
package network.bisq.mobile.android.node.domain.bootstrap | ||
|
||
import bisq.application.State | ||
import bisq.common.observable.Observable | ||
import bisq.common.observable.Pin | ||
import network.bisq.mobile.android.node.AndroidApplicationService | ||
import network.bisq.mobile.domain.data.repository.main.bootstrap.ApplicationBootstrapFacade | ||
|
||
class NodeApplicationBootstrapFacade( | ||
private val supplier: AndroidApplicationService.Supplier | ||
private val applicationService: AndroidApplicationService.Provider | ||
) : | ||
ApplicationBootstrapFacade() { | ||
|
||
override fun initialize() { | ||
supplier.stateSupplier.get().addObserver { state: State -> | ||
// Dependencies | ||
private val applicationServiceState: Observable<State> by lazy { | ||
applicationService.state.get() | ||
} | ||
|
||
// Misc | ||
private var applicationServiceStatePin: Pin? = null | ||
|
||
override fun activate() { | ||
applicationServiceStatePin = applicationServiceState.addObserver { state: State -> | ||
when (state) { | ||
State.INITIALIZE_APP -> { | ||
setState("Starting Bisq") | ||
setProgress(0f) | ||
setState("Starting Bisq") | ||
setProgress(0f) | ||
} | ||
|
||
State.INITIALIZE_NETWORK -> { | ||
setState("Initialize P2P network") | ||
setProgress(0.5f) | ||
setState("Initialize P2P network") | ||
setProgress(0.5f) | ||
} | ||
|
||
// not used | ||
State.INITIALIZE_WALLET -> { | ||
} | ||
|
||
State.INITIALIZE_SERVICES -> { | ||
setState("Initialize services") | ||
setProgress(0.75f) | ||
setState("Initialize services") | ||
setProgress(0.75f) | ||
} | ||
|
||
State.APP_INITIALIZED -> { | ||
setState("Bisq started") | ||
setProgress(1f) | ||
setState("Bisq started") | ||
setProgress(1f) | ||
} | ||
|
||
State.FAILED -> { | ||
setState("Startup failed") | ||
setProgress(0f) | ||
setState("Startup failed") | ||
setProgress(0f) | ||
} | ||
} | ||
} | ||
} | ||
|
||
override fun deactivate() { | ||
applicationServiceStatePin?.unbind() | ||
applicationServiceStatePin = null | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
...tlin/network/bisq/mobile/android/node/domain/market_price/NodeMarketPriceServiceFacade.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,71 @@ | ||
package network.bisq.mobile.android.node.domain.market_price | ||
|
||
import bisq.bonded_roles.market_price.MarketPriceService | ||
import bisq.common.observable.Pin | ||
import bisq.presentation.formatters.PriceFormatter | ||
import kotlinx.coroutines.flow.MutableStateFlow | ||
import kotlinx.coroutines.flow.StateFlow | ||
import network.bisq.mobile.android.node.AndroidApplicationService | ||
import network.bisq.mobile.android.node.domain.offerbook.NodeOfferbookServiceFacade.Companion.toLibraryMarket | ||
import network.bisq.mobile.android.node.domain.offerbook.NodeOfferbookServiceFacade.Companion.toReplicatedMarket | ||
import network.bisq.mobile.domain.data.model.market_price.MarketPriceItem | ||
import network.bisq.mobile.domain.service.market_price.MarketPriceServiceFacade | ||
import network.bisq.mobile.domain.data.model.offerbook.market.MarketListItem | ||
import network.bisq.mobile.utils.Logging | ||
|
||
class NodeMarketPriceServiceFacade(private val applicationService: AndroidApplicationService.Provider) : | ||
MarketPriceServiceFacade, Logging { | ||
|
||
// Dependencies | ||
private val marketPriceService: MarketPriceService by lazy { | ||
applicationService.bondedRolesService.get().marketPriceService | ||
} | ||
|
||
// Properties | ||
private val _marketPriceItem = MutableStateFlow(MarketPriceItem.EMPTY) | ||
override val marketPriceItem: StateFlow<MarketPriceItem> get() = _marketPriceItem | ||
|
||
// Misc | ||
private var selectedMarketPin: Pin? = null | ||
private var marketPricePin: Pin? = null | ||
|
||
// Life cycle | ||
override fun activate() { | ||
observeSelectedMarket() | ||
observeMarketPrice() | ||
} | ||
|
||
override fun deactivate() { | ||
selectedMarketPin?.unbind() | ||
selectedMarketPin = null | ||
marketPricePin?.unbind() | ||
marketPricePin = null | ||
} | ||
|
||
// API | ||
override fun selectMarket(marketListItem: MarketListItem) { | ||
marketPriceService.setSelectedMarket(toLibraryMarket(marketListItem)) | ||
} | ||
|
||
// Private | ||
private fun observeMarketPrice() { | ||
marketPricePin = marketPriceService.marketPriceByCurrencyMap.addObserver { updatePrice() } | ||
} | ||
|
||
private fun observeSelectedMarket() { | ||
selectedMarketPin?.unbind() | ||
selectedMarketPin = marketPriceService.selectedMarket.addObserver { market -> | ||
_marketPriceItem.value = MarketPriceItem(toReplicatedMarket(market)) | ||
updatePrice() | ||
} | ||
} | ||
|
||
private fun updatePrice() { | ||
marketPriceService.findMarketPriceQuote(marketPriceService.selectedMarket.get()) | ||
.ifPresent { priceQuote -> | ||
_marketPriceItem.value.setQuote(priceQuote.value) | ||
val formattedPrice = PriceFormatter.format(priceQuote) | ||
_marketPriceItem.value.setFormattedPrice(formattedPrice) | ||
} | ||
} | ||
} |
Oops, something went wrong.