Skip to content

Commit

Permalink
Merge pull request #22 from OpenSRP/266-app-crash-on-multiple-button-…
Browse files Browse the repository at this point in the history
…clicks

Check for null dialogs to prevent NullPointerExceptions
  • Loading branch information
vincent-karuri authored Mar 22, 2018
2 parents d22bc24 + 0ecd881 commit 58636b0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION_NAME=1.0.5-SNAPSHOT
VERSION_NAME=1.0.6-SNAPSHOT
VERSION_CODE=1
GROUP=org.smartregister
POM_SETTING_DESCRIPTION=OpenSRP Client Growth Monitoring Application
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,15 @@ public void onStart() {
new Handler().post(new Runnable() {
@Override
public void run() {
Window window = getDialog().getWindow();
Window window = null;
if (getDialog() != null) {
window = getDialog().getWindow();
}

if (window == null) {
return;
}

Point size = new Point();

Display display = window.getWindowManager().getDefaultDisplay();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.DatePicker;
Expand Down Expand Up @@ -244,14 +245,23 @@ private void formatEditWeightView(EditText editWeight, String userInput) {
@Override
public void onStart() {
super.onStart();
// without a handler, the window sizes itself correctly
// without a handler, the window size itself correctly
// but the keyboard does not show up
new Handler().post(new Runnable() {
@Override
public void run() {
getDialog().getWindow().setLayout(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT);
Window window = null;
if (getDialog() != null) {
window = getDialog().getWindow();
}

if (window == null) {
return;
}
window.setLayout(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT);

}

});

}
Expand Down

0 comments on commit 58636b0

Please sign in to comment.