From 9caf149aaa6047f2316989e21dabeb16f893f554 Mon Sep 17 00:00:00 2001 From: Ephraim Kigamba Date: Thu, 23 Mar 2023 16:20:43 +0300 Subject: [PATCH] Fix moving to next form page on AndroidX Fragments - 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 https://github.com/opensrp/opensrp-client-giz-malawi/issues/510 --- .../jsonwizard/fragments/JsonFormFragment.java | 15 +++++++++++++++ .../jsonwizard/task/NextProgressDialogTask.java | 7 ++++++- gradle.properties | 2 +- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/fragments/JsonFormFragment.java b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/fragments/JsonFormFragment.java index 895fe3330..eae402c0e 100644 --- a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/fragments/JsonFormFragment.java +++ b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/fragments/JsonFormFragment.java @@ -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; } diff --git a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/task/NextProgressDialogTask.java b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/task/NextProgressDialogTask.java index 76b4e18e7..935c05296 100644 --- a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/task/NextProgressDialogTask.java +++ b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/task/NextProgressDialogTask.java @@ -10,6 +10,7 @@ public class NextProgressDialogTask extends AsyncTask { private JsonWizardFormFragment formFragment; private Context context; private ProgressDialog progressDialog; + private Runnable runnableOnUiThread; private void showDialog() { setProgressDialog(new ProgressDialog(getContext())); @@ -34,7 +35,7 @@ public NextProgressDialogTask(JsonWizardFormFragment jsonFormFragment) { @Override protected Void doInBackground(Void... voids) { - getFormFragment().next(); + runnableOnUiThread = getFormFragment().nextAsRunnable(); return null; } @@ -48,6 +49,10 @@ protected void onPreExecute() { protected void onPostExecute(Void aVoid) { super.onPostExecute(aVoid); hideDialog(); + + if (runnableOnUiThread != null) { + runnableOnUiThread.run(); + } } public JsonWizardFormFragment getFormFragment() { diff --git a/gradle.properties b/gradle.properties index fec4378b0..10b03564b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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