Skip to content

Commit

Permalink
Fixed intermittent deadlock issue in Android text editing when textfi…
Browse files Browse the repository at this point in the history
…eld 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.
  • Loading branch information
shannah committed Mar 5, 2018
1 parent 662c8aa commit 7ba4c54
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.FrameLayout;
import com.codename1.ui.Accessor;

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

if(p.isScrollableY() && p.getAbsoluteY() + p.getScrollY() < Display.getInstance().getDisplayHeight() / 2 - pixelSize * 2){
if(Accessor.scrollableYFlag(p) && p.getAbsoluteY() + p.getScrollY() < Display.getInstance().getDisplayHeight() / 2 - pixelSize * 2){
return true;
}
p = p.getParent();
Expand Down
3 changes: 3 additions & 0 deletions Ports/Android/src/com/codename1/ui/Accessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,7 @@ public class Accessor {
public static Object getNativeGraphics(Graphics g) {
return g.getGraphics();
}
public static boolean scrollableYFlag(Container c) {
return c.scrollableYFlag();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ public void run() {
// async editing viable. We start with half-way down the screen.
int keyboardClippingThresholdY = Display.getInstance().getDisplayWidth() / 2;
while(p != null) {
if(p.isScrollableY() && p.getAbsoluteY() < keyboardClippingThresholdY) {
if(Accessor.scrollableYFlag(p) && p.getAbsoluteY() < keyboardClippingThresholdY) {
break;
}
p = p.getParent();
Expand Down
4 changes: 4 additions & 0 deletions Ports/iOSPort/src/com/codename1/ui/Accessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,8 @@ public static Object getNativeGraphics(Graphics g) {
public static boolean isPaintPeersBehindEnabled(Graphics g) {
return g.paintPeersBehind;
}

public static boolean scrollableYFlag(Container cnt) {
return cnt.scrollableYFlag();
}
}

0 comments on commit 7ba4c54

Please sign in to comment.