Skip to content

Commit c9ac07a

Browse files
committed
Further fixes
1 parent bf4c042 commit c9ac07a

File tree

4 files changed

+52
-31
lines changed

4 files changed

+52
-31
lines changed

CodenameOne/src/com/codename1/ui/Container.java

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040

4141
import java.util.ArrayList;
4242
import java.util.Collections;
43-
import java.util.Comparator;
4443
import java.util.HashSet;
4544
import java.util.Iterator;
4645
import java.util.Vector;
@@ -304,24 +303,12 @@ public void run() {
304303
};
305304
AnimationManager a = getAnimationManager();
306305
if (a != null && a.isAnimating()) {
307-
308-
a.addAnimation(new ComponentAnimation() {
309-
@Override
310-
public boolean isInProgress() {
311-
return false;
312-
}
313-
314-
@Override
315-
protected void updateState() {
316-
r.run();
317-
}
318-
});
306+
a.addAnimation(new RefreshThemeCallback(r));
319307
return newParent;
320308
} else {
321309
r.run();
322310
return newParent;
323311
}
324-
325312
}
326313

327314
/**
@@ -961,11 +948,7 @@ void insertComponentAtImpl(int index, final Component cmp) {
961948
boolean refreshLaf = manager != cmp.getUIManager();
962949
cmp.setParent(this);
963950
if (refreshLaf) {
964-
Display.getInstance().callSerially(new Runnable() {
965-
public void run() {
966-
cmp.refreshTheme(false);
967-
}
968-
});
951+
Display.getInstance().callSerially(new RefreshThemeRunnable(cmp));
969952
}
970953
components.add(index, cmp);
971954
if (layout instanceof BorderLayout && !BorderLayout.OVERLAY.equals(layout.getComponentConstraint(cmp))) {
@@ -1904,18 +1887,7 @@ void paintElevatedPane(Graphics g, final boolean useIntersection, int intersecti
19041887
_tmpRenderingElevatedComponents.clear();
19051888
_tmpRenderingElevatedComponents.addAll(elevatedComponents);
19061889
}
1907-
Collections.sort(_tmpRenderingElevatedComponents, new Comparator<Component>() {
1908-
1909-
public int compare(Component o1, Component o2) {
1910-
int e1 = o1.getStyle().getElevation();
1911-
int e2 = o2.getStyle().getElevation();
1912-
if (e1 < e2) return -1;
1913-
else if (e1 > e2) return 1;
1914-
else {
1915-
return o1.renderedElevationComponentIndex - o2.renderedElevationComponentIndex;
1916-
}
1917-
}
1918-
});
1890+
Collections.sort(_tmpRenderingElevatedComponents, new ElevationComparator());
19191891
for (Component child : _tmpRenderingElevatedComponents) {
19201892
int relativeX = child.getRelativeX(this) + child.getScrollX();
19211893
int relativeY = child.getRelativeY(this) + child.getScrollY();
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.codename1.ui;
2+
3+
import java.util.Comparator;
4+
5+
class ElevationComparator implements Comparator<Component> {
6+
public int compare(Component o1, Component o2) {
7+
int e1 = o1.getStyle().getElevation();
8+
int e2 = o2.getStyle().getElevation();
9+
if (e1 < e2) return -1;
10+
else if (e1 > e2) return 1;
11+
else {
12+
return o1.renderedElevationComponentIndex - o2.renderedElevationComponentIndex;
13+
}
14+
}
15+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.codename1.ui;
2+
3+
import com.codename1.ui.animations.ComponentAnimation;
4+
5+
class RefreshThemeCallback extends ComponentAnimation {
6+
private final Runnable r;
7+
8+
public RefreshThemeCallback(Runnable r) {
9+
this.r = r;
10+
}
11+
12+
@Override
13+
public boolean isInProgress() {
14+
return false;
15+
}
16+
17+
@Override
18+
protected void updateState() {
19+
r.run();
20+
}
21+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.codename1.ui;
2+
3+
class RefreshThemeRunnable implements Runnable {
4+
private final Component cmp;
5+
6+
public RefreshThemeRunnable(Component cmp) {
7+
this.cmp = cmp;
8+
}
9+
10+
public void run() {
11+
cmp.refreshTheme(false);
12+
}
13+
}

0 commit comments

Comments
 (0)