Skip to content

Commit 7ba4c54

Browse files
committed
Fixed intermittent deadlock issue in Android text editing when textfield is just above the fold. Issue described in this SO thread. https://stackoverflow.com/questions/49102943/textarea-malfunctions-and-the-app-hangs-cn1
Problem was that Container.isScrollableY() is context sensitive so it doesn't actually say whether the component is capable of scrolling. It only returns true if the container is capable o scrolling AND some of it is below the fold - so needs to scroll. Also made some fixes to iOS port where it used this method with the assumption that it returned whether the container was capable of scrolling.
1 parent 662c8aa commit 7ba4c54

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

Ports/Android/src/com/codename1/impl/android/InPlaceEditView.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
import android.widget.ArrayAdapter;
6464
import android.widget.AutoCompleteTextView;
6565
import android.widget.FrameLayout;
66+
import com.codename1.ui.Accessor;
6667

6768
import com.codename1.ui.Component;
6869
import com.codename1.ui.Container;
@@ -1739,7 +1740,7 @@ private static boolean isScrollableParent(Component c){
17391740
float pixelSize = f == null ? Display.getInstance().convertToPixels(4) : f.getPixelSize();
17401741
while( p != null){
17411742

1742-
if(p.isScrollableY() && p.getAbsoluteY() + p.getScrollY() < Display.getInstance().getDisplayHeight() / 2 - pixelSize * 2){
1743+
if(Accessor.scrollableYFlag(p) && p.getAbsoluteY() + p.getScrollY() < Display.getInstance().getDisplayHeight() / 2 - pixelSize * 2){
17431744
return true;
17441745
}
17451746
p = p.getParent();

Ports/Android/src/com/codename1/ui/Accessor.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,7 @@ public class Accessor {
3232
public static Object getNativeGraphics(Graphics g) {
3333
return g.getGraphics();
3434
}
35+
public static boolean scrollableYFlag(Container c) {
36+
return c.scrollableYFlag();
37+
}
3538
}

Ports/iOSPort/src/com/codename1/impl/ios/IOSImplementation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ public void run() {
670670
// async editing viable. We start with half-way down the screen.
671671
int keyboardClippingThresholdY = Display.getInstance().getDisplayWidth() / 2;
672672
while(p != null) {
673-
if(p.isScrollableY() && p.getAbsoluteY() < keyboardClippingThresholdY) {
673+
if(Accessor.scrollableYFlag(p) && p.getAbsoluteY() < keyboardClippingThresholdY) {
674674
break;
675675
}
676676
p = p.getParent();

Ports/iOSPort/src/com/codename1/ui/Accessor.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,8 @@ public static Object getNativeGraphics(Graphics g) {
3636
public static boolean isPaintPeersBehindEnabled(Graphics g) {
3737
return g.paintPeersBehind;
3838
}
39+
40+
public static boolean scrollableYFlag(Container cnt) {
41+
return cnt.scrollableYFlag();
42+
}
3943
}

0 commit comments

Comments
 (0)