Skip to content

Commit

Permalink
Attempted fix for #3164 a random NPE in Android
Browse files Browse the repository at this point in the history
  • Loading branch information
shai-almog authored Oct 3, 2023
1 parent 72199a4 commit 1a7c149
Showing 1 changed file with 18 additions and 57 deletions.
75 changes: 18 additions & 57 deletions Ports/Android/src/com/codename1/impl/android/AndroidAsyncView.java
Original file line number Diff line number Diff line change
Expand Up @@ -332,22 +332,24 @@ public void resizeViews() {
if(children > 0) {
for (int iter = 0; iter < children; iter++) {
final View v = getChildAt(iter);
final AndroidAsyncView.LayoutParams lp = (AndroidAsyncView.LayoutParams) v.getLayoutParams();
if (lp.dirty) {
lp.dirty = false;
v.post(new Runnable() {
@Override
public void run() {
v.requestLayout();

Display.getInstance().getInstance().callSerially(new Runnable() {
@Override
public void run() {
Display.getInstance().getCurrent().repaint();
}
});
}
});
if(v != null) {
final AndroidAsyncView.LayoutParams lp = (AndroidAsyncView.LayoutParams) v.getLayoutParams();
if (lp.dirty) {
lp.dirty = false;
v.post(new Runnable() {
@Override
public void run() {
v.requestLayout();

Display.getInstance().getInstance().callSerially(new Runnable() {
@Override
public void run() {
Display.getInstance().getCurrent().repaint();
}
});
}
});
}
}
}
}
Expand Down Expand Up @@ -426,47 +428,6 @@ public void run() {
}

int children = getChildCount();
if(children > 0) {
com.codename1.ui.Form c = Display.getInstance().getCurrent();
for (int iter = 0; iter < children; iter++) {
final View v = getChildAt(iter);
final AndroidAsyncView.LayoutParams lp = (AndroidAsyncView.LayoutParams) v.getLayoutParams();
//if (lp != null && c == lp.pc.getComponentForm()) {
//v.postInvalidate();

/*if(lp.dirty) {
lp.dirty = false;
v.post(new Runnable() {
@Override
public void run() {
if (v.getVisibility() == View.INVISIBLE) {
v.setVisibility(View.VISIBLE);
}
v.requestLayout();
}
});
} else {
if (v.getVisibility() == View.INVISIBLE) {
v.post(new Runnable() {
@Override
public void run() {
v.setVisibility(View.VISIBLE);
}
});
}
}*/
//} else {
/*if(v.getVisibility() == View.VISIBLE) {
v.post(new Runnable() {
@Override
public void run() {
v.setVisibility(View.INVISIBLE);
}
});
}*/
//}
}
}
if (rect == null) {
postInvalidate();
} else {
Expand Down

0 comments on commit 1a7c149

Please sign in to comment.