Class ActivityTimeline

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

public class ActivityTimeline extends Container

A vertical list of events joined by a line: order tracking ("Placed", "Packed", "Out for delivery"), an activity feed or a history.

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).

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 timeline.
  • Method Details

    • 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