/** * Changes quotes' instrument symbol * * @param symbol instrument symbol */ fun changeSymbol(symbol: String) } `}
= endpoint.feed.createSubscription(Quote::class.java) private val _dataFlow = MutableStateFlow(null) override val dataFlow: StateFlow get() = _dataFlow private val _errorFlow = MutableStateFlow (null) override val errorFlow: StateFlow get() = _errorFlow private val eventListener = DXFeedEventListener { try { val quote = it.last() _dataFlow.tryEmit(quote?.toDataObject()) } catch (e: Exception) { _errorFlow.tryEmit(QuoteProviderError.DataProcessingError("Error during processing quotes: $e.message", e)) } } private var currentSymbol: String? = null private var executorService: ExecutorService? = null /** * Connects to the dxFeed API [endpoint] at the [endpointAddress], * subscribes [sub] to receive quotes, connects [eventListener], * and starts the process of obtaining quotes in a separate thread [executorService]. * Handles connection errors and updates [_errorFlow]. */ fun connect() { try { _errorFlow.tryEmit(null) endpoint.connect(endpointAddress) sub.addEventListener(eventListener) if (executorService == null || executorService?.isShutdown == true) { executorService = Executors.newFixedThreadPool(1) executorService?.execute { try { endpoint.awaitNotConnected() } catch (e: Exception) { _errorFlow.tryEmit(QuoteProviderError.NetworkError("Connection to quote provider was interrupted: $e.message}", e)) } } } else { Log.w(TAG, "ExecutorService is already running.") } } catch (e: Exception) { _errorFlow.tryEmit( QuoteProviderError.ConnectionError("Unknown error during connection to quote provider: $e.message", e) ) } } /** * Removes [eventListener] from [sub], clears [sub] from [endpoint], * disconnects [endpoint] from the dxFeed API, and shuts down [executorService]. * Handles disconnection errors and updates [_errorFlow]. */ fun disconnect() { try { sub.removeEventListener(eventListener) endpoint.feed.detachSubscriptionAndClear(sub) endpoint.disconnectAndClear() executorService?.shutdown() executorService = null } catch (e: Exception) { _errorFlow.tryEmit( QuoteProviderError.ConnectionError("Unknown error during disconnection of quote provider $e.message", e) ) } } /** * Extension function for transforming [Quote] into [com.devexperts.dxcharts.provider.domain.Quote]. */ private fun Quote.toDataObject() = com.devexperts.dxcharts.provider.domain.Quote( bidPrice = bidPrice, askPrice = askPrice, ) /** * Method to change the instrument symbol [currentSymbol] in the subscription [sub]. * * When the symbol changes [currentSymbol], the subscription [sub] is disconnected from the old symbol, * connected to the new one, and [dataFlow] is cleared. */ override fun changeSymbol(symbol: String) { if (currentSymbol == symbol) { return } currentSymbol?.let { try { sub.removeSymbols(currentSymbol) _dataFlow.tryEmit(null) } catch (e: Exception) { _errorFlow.tryEmit( QuoteProviderError.DataProcessingError( "Error during processing quotes: $e.message", e ) ) } } currentSymbol = symbol try { sub.addSymbols(symbol) } catch (e: Exception) { _errorFlow.tryEmit( QuoteProviderError.DataProcessingError("Error adding symbol: $e.message", e) ) } } companion object { private const val TAG = "DxFeedQuoteProvider" } } /** * Sealed class representing different types of errors that can occur in the provider. */ sealed class QuoteProviderError(override val message: String, override val error: Throwable?) : ProviderError { data class NetworkError( override val message: String, override val error: Throwable? = null ) : QuoteProviderError(message, error) data class ConnectionError( override val message: String, override val error: Throwable? = null ) : QuoteProviderError(message, error) data class DataProcessingError( override val message: String, override val error: Throwable? = null ) : QuoteProviderError(message, error) } `}
Here is the default implementation of **`DxChartsStudiesDataProvider`**:
Here is the default implementation of **`DxChartsStudiesPreviewDataProvider`**:
/** * Changes quotes' instrument symbol * * @param symbol instrument symbol */ fun changeSymbol(symbol: String) } `}
|
| Bin |
|
| Tick |
|
| Back |
|
| Close |
|
| Search |
|
| RightArrow |
|
| RemoveText |
|
| Ok |
|
| Add |
|
| Delete |
|
| Plus |
|
- Studies Icons:
These icons are used in the studies section of the library.
| Value name | Default value |
|--------------------|-----------------------------------------------------------------------------|
| LineType |
|
| ListItem |
|
| ListItemSelected |
|
| FavStudies |
|
| FavStudiesSelected |
|
- Toolbar Icons:
These icons are used in the toolbar of the library.
| Value name | Default value |
|-------------|-----------------------------------------------------------------------------------|
| Search |
|
| Drawings |
|
| Settings |
|
| Magnet |
|
| Brush |
|
| LineWidth |
|
| ColorPicker |
|
| Plus |
|
| TextSize |
|
- Top Bar Icons:
These icons are used in the top bar which is shown when drawing mode is active of the library.
| Value name | Default Value |
|--------------|---------------------------------------------------------------------------------------|
| ArrowBack |
|
| ArrowForward |
|
---
## Chart for Android/Configuration/Theme configuration/Components/Shapes.md
# Shapes
Class `com.devexperts.dxcharts.lib.ui.theme.Shape` contains parameters for rounding UI elements in the form of `androidx.compose.foundation.shape.RoundedCornerShape`.
The class is passed as a parameter in `DxChartsTheme`.
How to override shapes used in library can be found [here](https://devexperts.com/dxcharts/documentation-for-developers/Chart-for-Android/Configuration/Theme-configuration/Using-a-theme/Shapes)
Table of elements in the `com.devexperts.dxcharts.lib.ui.theme.Shapes` class:
| topStart parameter | topEnd parameter | bottomStart parameter | bottomEnd parameter | Illustration | Values |
|--------------------|------------------|-----------------------|---------------------|-----------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 4.dp | 4.dp | 4.dp | 4.dp |
| lastCandleInfoWidgetShape
| colorPaletteShape
| searchRowTextFieldShape
| roundButtonStudiesColorShapes |
| Circle | Circle | Circle | Circle |
| roundButtonStudiesColorShape
| bottomSheetShape |
| 8.dp | 8.dp | - | - |
| drawingsListFirstItemShape |
| - | - | 8.dp | 8.dp |
| drawingsListLastItemShape |
| 0.dp | 0.dp | 0.dp | 0.dp |
| drawingsListItemShape
| limitOrderButtonShape |
| 0.dp | 16.dp | 0.dp | 16.dp |
| stopOrderButtonShape |
---
## Chart for Android/Configuration/Theme configuration/Components/Text styles.md
# Text Styles
The list of text styles used by the library is passed to `DxChartsTheme` within the `DxChartsTypography` object. It also contains default values for each style.
The object used to store information about text style is `androidx.compose.ui.text.TextStyle`.
The font within the chart itself is currently immutable.
By default, library uses Open Sans SemiBold (https://fonts.google.com/specimen/Open+Sans).
Text styles do not include the color parameter; it is set individually for each element based on the color palette parameters.
The table of text styles in the library:
| Font size (sp) | Values |
|----------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 130 | aggregationSelectorValue |
| 90 | selectorValue |
| 36 | aggregationSelectorTimeUnit{ get } /// Changes the instrument symbol for which quotes are being provided. /// /// - Parameter symbol: The instrument symbol (e.g., "AAPL", "TSLA") for which the quotes data should be fetched. func changeSymbol(_ symbol: String) } `}
{ get } /// Changes the instrument symbol for which quotes are being provided. /// /// - Parameter symbol: The instrument symbol (e.g., "AAPL", "TSLA") for which the quotes data should be fetched. func changeSymbol(_ symbol: String) } `}
A {props.order.type} order to {props.order.side}
Expiration: {props.order.expiration}
Total price: {totalPrice}
Custom Toolbar
{MainInstrumentComponent &&