Skip to content

Commit

Permalink
Rename Context to ProgressContext
Browse files Browse the repository at this point in the history
- Relates #995
  • Loading branch information
jvalkeal committed Feb 17, 2024
1 parent 192eb5e commit cdb2eb8
Showing 1 changed file with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,16 @@ public class ProgressView extends BoxView {
private GridView grid;
private long startTime;
private long updateTime;
private List<TextCell<Context>> cells = new ArrayList<>();
private List<TextCell<ProgressContext>> cells = new ArrayList<>();

private final static Function<Context, TextCell<Context>> DEFAULT_DESCRIPTION_FACTORY =
private final static Function<ProgressContext, TextCell<ProgressContext>> DEFAULT_DESCRIPTION_FACTORY =
(item) -> TextCell.of(item, ctx -> {
return ctx.getDescription();
});

private final static Function<Context, TextCell<Context>> DEFAULT_PERCENT_FACTORY =
private final static Function<ProgressContext, TextCell<ProgressContext>> DEFAULT_PERCENT_FACTORY =
(item) -> {
TextCell<Context> cell = TextCell.of(item, ctx -> {
TextCell<ProgressContext> cell = TextCell.of(item, ctx -> {
ProgressState state = ctx.getState();
int percentAbs = state.tickEnd() - state.tickStart();
int relativeValue = state.tickValue() - state.tickStart();
Expand All @@ -82,9 +82,9 @@ public class ProgressView extends BoxView {
return cell;
};

private final static Function<Context, TextCell<Context>> DEFAULT_SPINNER_FACTORY =
private final static Function<ProgressContext, TextCell<ProgressContext>> DEFAULT_SPINNER_FACTORY =
item -> {
TextCell<Context> cell = TextCell.of(item, ctx -> {
TextCell<ProgressContext> cell = TextCell.of(item, ctx -> {
int frame = 0;

// via view setting, then via theming, then fallback default
Expand Down Expand Up @@ -166,11 +166,11 @@ public ProgressView(int tickStart, int tickEnd, ProgressViewItem... items) {
*/
public static class ProgressViewItem {

private final Function<Context, TextCell<Context>> factory;
private final Function<ProgressContext, TextCell<ProgressContext>> factory;
private final int size;
private final HorizontalAlign align;

public ProgressViewItem(Function<Context, TextCell<Context>> factory, int size, HorizontalAlign align) {
public ProgressViewItem(Function<ProgressContext, TextCell<ProgressContext>> factory, int size, HorizontalAlign align) {
this.factory = factory;
this.size = size;
this.align = align;
Expand Down Expand Up @@ -300,8 +300,8 @@ public void stop() {
}

private static class BoxWrapper extends BoxView {
TextCell<Context> delegate;
BoxWrapper(TextCell<Context> delegate) {
TextCell<ProgressContext> delegate;
BoxWrapper(TextCell<ProgressContext> delegate) {
this.delegate = delegate;
}
@Override
Expand All @@ -319,7 +319,7 @@ private void initLayout() {
int index = 0;
for (ProgressViewItem item : items) {
columnSizes[index] = item.size;
TextCell<Context> cell = item.factory.apply(buildContext());
TextCell<ProgressContext> cell = item.factory.apply(buildContext());
cells.add(cell);
cell.setHorizontalAlign(item.align);
grid.addItem(new BoxWrapper(cell), 0, index, 1, 1, 0, 0);
Expand All @@ -335,8 +335,8 @@ protected void drawInternal(Screen screen) {
long current = System.currentTimeMillis();

updateTime = current;
Context context = buildContext();
for (TextCell<Context> cell : cells) {
ProgressContext context = buildContext();
for (TextCell<ProgressContext> cell : cells) {
cell.setItem(context);
}

Expand Down Expand Up @@ -394,8 +394,8 @@ public ProgressState getState() {
return ProgressState.of(tickStart, tickEnd, tickValue, running, startTime, updateTime);
}

private Context buildContext() {
return new Context() {
private ProgressContext buildContext() {
return new ProgressContext() {

@Override
public String getDescription() {
Expand Down Expand Up @@ -432,7 +432,7 @@ public Spinner getSpinner() {
/**
* Context for {@code ProgressView} cell components.
*/
public interface Context {
public interface ProgressContext {

/**
* Get a {@link ProgressView} description.
Expand Down

0 comments on commit cdb2eb8

Please sign in to comment.