Skip to main content

Loading Indicator

SecureLoadingIndicator (Jetpack Compose) and SecureLoadingView (XML/View) are optional library components that display an animated loading indicator during payment processing. Once bound to ComgateSecureSession, the component shows and hides automatically based on payment state.

Tip

The component is optional - payment works correctly even without it. It serves only as visual feedback for users.

Structure

Loading indicator consists of two visual elements:

  • Animated spinner - circular spinner with smoothly rotating arc over static track
  • Text label - optional text shown below spinner; default text is automatically derived from session language

By default, component is hidden (visibility GONE) and appears only when payment processing starts.

Jetpack Compose usage

import cz.comgate.sdk.compose.*

val loadingState = rememberLoadingIndicatorState(session)

SecureLoadingIndicator(
state = loadingState,
modifier = Modifier
.fillMaxWidth()
.padding(top = 12.dp)
)

rememberLoadingIndicatorState(session) creates LoadingIndicatorState, automatically binds component to session, and remembers it across recompositions. No additional initialization call is needed.

XML (View) usage

Add SecureLoadingView to layout:

<cz.comgate.sdk.SecureLoadingView
android:id="@+id/loadingView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
app:loadingSpinnerColor="#1E88E5"
app:loadingTrackColor="#BBDEFB"
app:loadingStrokeWidth="5dp"
app:loadingSpinnerSize="52dp"
app:loadingBackgroundColor="#F5F9FF"
app:loadingCornerRadius="12dp"
app:loadingPaddingHorizontal="16dp"
app:loadingPaddingVertical="20dp" />

Then bind component to session in activity/fragment code:

binding.loadingView.setup(session)

Automatic session integration

After binding (setup(session) or rememberLoadingIndicatorState(session)), component behaves automatically:

  • Shows when payment processing starts (user presses payment button)
  • Hides when terminal payment result arrives (Paid, Cancelled, Failed, or Pending)

Automatic behavior can be disabled anytime, for example if you control loading visibility yourself:

// Compose (via state)
loadingState.isLoadingEnabled = false

// View
binding.loadingView.isLoadingEnabled = false
Information

With isLoadingEnabled = false, show() / hide() methods remain fully functional. Only automatic state-driven visibility is disabled.

Manual control

Component can be controlled independently from session, for custom loading scenarios unrelated to payment:

// Compose
loadingState.show()
loadingState.hide()

// View
binding.loadingView.show()
binding.loadingView.hide()

Text label translation

Default text under spinner is automatically derived from selected payment session language - no manual setup required.

Custom label text can be set like this:

// Compose (via LoadingIndicatorState)
loadingState.setLoadingText("Processing payment...")

// View
binding.loadingView.setLoadingText("Processing payment...")

After custom text is set, automatic session-based translation is no longer applied to this label, even if payment language changes.

Hide label by passing null or empty string:

loadingState.setLoadingText(null)

Styling

Methods

All methods below are available in composable SecureLoadingIndicator update block (direct access to SecureLoadingView instance) and via direct calls on View.

Subset marked as View only is not exposed through LoadingIndicatorState or Compose update block.

MethodParameterDescription
setSpinnerColor(color)IntRotating arc color.
setTrackColor(color)IntStatic spinner track color.
setStrokeWidthDp(dp)FloatArc/track thickness in dp.
setSpinnerSizeDp(dp)FloatSpinner diameter in dp.
setLoadingText(text)String?Label text below spinner. null or "" hides label.
setLoadingTextColor(color)IntLabel text color.
setLoadingTextSizeSp(sp)FloatLabel text size in sp.
setLoadingBackgroundColor(color)IntBackground color of whole component.
setLoadingCornerRadiusDp(dp)FloatBackground corner radius in dp.
setLoadingPaddingDp(horizontalDp, verticalDp)Float, FloatComponent inner padding in dp.
setLoadingTextGapDp(dp)FloatGap between spinner and label in dp. (View only)
setLoadingFontFamily(family)StringLabel font family (for example "sans-serif-medium"). (View only)
setLoadingTypeface(typeface)TypefaceLabel font using Typeface instance. (View only)
Information

In Compose, LoadingIndicatorState exposes a reduced method set: setSpinnerColor, setTrackColor, setStrokeWidthDp, setSpinnerSizeDp, setLoadingText, setLoadingTextColor, and setLoadingTextSizeSp. Other methods (background, corner radius, padding, etc.) are available only through update block, see example below.

Compose example (update block)

SecureLoadingIndicator(
state = loadingState,
modifier = Modifier.fillMaxWidth(),
update = {
setSpinnerColor(Color.parseColor("#FF0000"))
setTrackColor(Color.parseColor("#FFEBEE"))
setStrokeWidthDp(4f)
setSpinnerSizeDp(48f)
setLoadingBackgroundColor(Color.WHITE)
setLoadingCornerRadiusDp(12f)
setLoadingPaddingDp(16f, 20f)
}
)

XML attributes

XML attributeFormatDefaultDescription
app:loadingSpinnerColorcolor#4287f5Rotating arc color.
app:loadingTrackColorcolor#E0E0E0Static spinner track color.
app:loadingStrokeWidthdimension4dpArc and track thickness.
app:loadingSpinnerSizedimension48dpSpinner diameter.
app:loadingTextstring(session translation)Custom label text. If not provided, translated session text is used.
app:loadingTextColorcolor#666666Label text color.
app:loadingTextSizedimension14spLabel text size.
app:loadingTextGapdimension8dpGap between spinner and label.
app:loadingBackgroundColorcolorTransparentBackground color of whole component.
app:loadingCornerRadiusdimension0dpBackground corner radius.
app:loadingPaddingHorizontaldimension16dpHorizontal inner padding.
app:loadingPaddingVerticaldimension16dpVertical inner padding.
app:loadingEnabledbooleantrueEnables/disables automatic visibility during payment processing.