Skip to content

Commit 6b6aa2b

Browse files
committed
Temporary fix for unresponsive UI
1 parent 6c3cde4 commit 6b6aa2b

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

AndroidUIDemo/src/com/oreilly/demo/android/pa/uidemo/TouchMe.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import android.view.View.OnKeyListener;
2020
import android.widget.Button;
2121
import android.widget.EditText;
22+
2223
import com.oreilly.demo.android.pa.uidemo.model.Dot;
2324
import com.oreilly.demo.android.pa.uidemo.model.Dots;
2425
import com.oreilly.demo.android.pa.uidemo.view.DotView;
@@ -96,7 +97,7 @@ private void addDot(Dots dots, float x, float y, float p, float s) {
9697
x,
9798
y,
9899
Color.CYAN,
99-
(int) ((p * s * DOT_DIAMETER) + 1));
100+
(int) ((p + 0.5) * (s + 0.5) * DOT_DIAMETER));
100101
}
101102
}
102103

@@ -211,8 +212,10 @@ else if (hasFocus && (null == dotGenerator)) {
211212
dotModel.setDotsChangeListener(new Dots.DotsChangeListener() {
212213
@Override public void onDotsChange(Dots dots) {
213214
Dot d = dots.getLastDot();
214-
tb1.setText((null == d) ? "" : String.valueOf(d.getX()));
215-
tb2.setText((null == d) ? "" : String.valueOf(d.getY()));
215+
// This code makes the UI unacceptably unresponsive.
216+
// ... investigating
217+
//tb1.setText((null == d) ? "" : String.valueOf(d.getX()));
218+
//tb2.setText((null == d) ? "" : String.valueOf(d.getY()));
216219
dotView.invalidate();
217220
} });
218221
}

AndroidUIDemo/src/com/oreilly/demo/android/pa/uidemo/model/Dots.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ public interface DotsChangeListener {
1212
/** @param dots the dots that changed. */
1313
void onDotsChange(Dots dots);
1414
}
15-
15+
1616
private final LinkedList<Dot> dots = new LinkedList<Dot>();
1717
private final List<Dot> safeDots = Collections.unmodifiableList(dots);
18-
18+
1919
private DotsChangeListener dotsChangeListener;
20-
20+
2121
/** @param l set the change listener. */
2222
public void setDotsChangeListener(DotsChangeListener l) {
2323
dotsChangeListener = l;
@@ -27,7 +27,7 @@ public void setDotsChangeListener(DotsChangeListener l) {
2727
public Dot getLastDot() {
2828
return (dots.size() <= 0) ? null : dots.getLast();
2929
}
30-
30+
3131
/** @return immutable list of dots. */
3232
public List<Dot> getDots() { return safeDots; }
3333

@@ -50,7 +50,7 @@ public void clearDots() {
5050

5151
private void notifyListener() {
5252
if (null != dotsChangeListener) {
53-
dotsChangeListener.onDotsChange(this);
53+
dotsChangeListener.onDotsChange(this);
5454
}
5555
}
5656
}

0 commit comments

Comments
 (0)