Skip to content

Commit

Permalink
Fix moving to next form page on AndroidX Fragments
Browse files Browse the repository at this point in the history
- Fixes an issue where observers on androidx fragments are registered during creation. The next step login is done inside an async
task causing an exception when this is run on a project that uses androidx instead of android-support

- Update version to 2.1.14.1-GIZ-SNAPSHOT

Fixes opensrp/opensrp-client-giz-malawi#510
  • Loading branch information
ekigamba committed Mar 23, 2023
1 parent 8829729 commit 9caf149
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,21 @@ public boolean next() {
return false;
}


public Runnable nextAsRunnable() {
return new Runnable() {
@Override
public void run() {
try {
presenter.onNextClick(mMainView);
} catch (Exception e) {
Timber.e(e, " --> next");
}
}
};

}

public void setShouldSkipStep(boolean shouldSkipStep) {
this.shouldSkipStep = shouldSkipStep;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class NextProgressDialogTask extends AsyncTask<Void, Void, Void> {
private JsonWizardFormFragment formFragment;
private Context context;
private ProgressDialog progressDialog;
private Runnable runnableOnUiThread;

private void showDialog() {
setProgressDialog(new ProgressDialog(getContext()));
Expand All @@ -34,7 +35,7 @@ public NextProgressDialogTask(JsonWizardFormFragment jsonFormFragment) {

@Override
protected Void doInBackground(Void... voids) {
getFormFragment().next();
runnableOnUiThread = getFormFragment().nextAsRunnable();
return null;
}

Expand All @@ -48,6 +49,10 @@ protected void onPreExecute() {
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
hideDialog();

if (runnableOnUiThread != null) {
runnableOnUiThread.run();
}
}

public JsonWizardFormFragment getFormFragment() {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION_NAME=2.1.14-SNAPSHOT
VERSION_NAME=2.1.14.1-GIZ-SNAPSHOT
VERSION_CODE=1
GROUP=org.smartregister
POM_SETTING_DESCRIPTION=OpenSRP Client Native Form Json Wizard
Expand Down

0 comments on commit 9caf149

Please sign in to comment.