Class ActivityTimeline

All Implemented Interfaces:
Animation, Editable, StyleListener, Iterable<Component>

public class ActivityTimeline extends Container

A list of events joined by a line: order tracking ("Placed", "Packed", "Out for delivery"), an activity feed or a history. Vertical by default; new ActivityTimeline(true) lays the steps out in a row instead, the step indicator of a checkout or a sign-up wizard.

An order timeline with done, current and pending steps

Form form = new Form("Order", BoxLayout.y());
ActivityTimeline order = new ActivityTimeline();
order.addStep("Order placed", "We received your order", "9:02", ActivityTimeline.DONE);
order.addStep("Preparing", "The kitchen is on it", "9:05", ActivityTimeline.DONE);
order.addStep("On the way", "Dana is 6 minutes away", "9:21", ActivityTimeline.CURRENT);
order.addStep("Delivered", null, null, ActivityTimeline.PENDING);
form.add(order);
form.show();

A step is #DONE, #CURRENT or #PENDING. Done steps and the line up to the current one take the accent colour; the current step is a ring; pending steps and the line after the current one are faded. Change a step later with #setState(int, int).

In the horizontal mode the steps share the width equally, the line runs through the markers along the top and each step's texts are centred under its marker. Keep titles short there; a step's detail text wraps within its column.

It is unrelated to com.codename1.ui.animations.Timeline, which sequences animation frames.

UIIDs: ActivityTimeline for the container, ActivityTimelineTitle, ActivityTimelineText and ActivityTimelineTime for a step's texts, falling back to Label. The marker colours follow the theme's Slider colours unless ActivityTimelineMarker is styled.

  • Field Details

  • Constructor Details

    • ActivityTimeline

      public ActivityTimeline()
      An empty vertical timeline.
    • ActivityTimeline

      public ActivityTimeline(boolean horizontal)

      An empty timeline.

      Parameters
      • horizontal: true to lay the steps out in a row, false for a column
  • Method Details

    • isHorizontal

      public boolean isHorizontal()

      Whether the steps are laid out in a row.

      Returns

      true for a horizontal timeline

    • initUnselectedStyle

      protected void initUnselectedStyle(Style unselectedStyle)
      Description copied from class: Component

      Can be overridden by subclasses to perform initialization when the unselected style is set to a new value.

      Parameters
      • unselectedStyle: The unselected style.
      Overrides:
      initUnselectedStyle in class Component
    • addStep

      public ActivityTimeline addStep(String title, String text, String time, int state)

      Adds a step at the end.

      Parameters
      • title: the step's title

      • text: a line of detail, or null

      • time: when it happened or is due, or null

      • state: #DONE, #CURRENT or #PENDING

      Returns

      this, for chaining

    • clearSteps

      public void clearSteps()
      Removes every step.
    • getStepCount

      public int getStepCount()

      The number of steps.

      Returns

      the step count

    • getState

      public int getState(int index)

      The state of a step.

      Parameters
      • index: the step's index
      Returns

      #DONE, #CURRENT or #PENDING

    • setState

      public void setState(int index, int state)

      Changes the state of a step, such as moving an order on.

      Parameters
      • index: the step's index

      • state: #DONE, #CURRENT or #PENDING