Skip to content

Commit

Permalink
LMH1-182: Ensure hideProgressDialog hides 'saving' dialog
Browse files Browse the repository at this point in the history
Seems ProgressDialog behaves weirdly depending on ways of instantiation.
Assuming duplicate progressdialogs were being created, where dismissal was dismissing one but the other still showing...may depend on the android api level
https://stackoverflow.com/a/9444565
  • Loading branch information
LZRS committed Mar 24, 2022
1 parent 3cc7afe commit cd0e495
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 22 deletions.
2 changes: 2 additions & 0 deletions opensrp-chw/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,8 @@ android {
dependencies {
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'

implementation('com.google.android.gms:play-services-vision:17.0.2')

implementation('org.smartregister:opensrp-client-chw-core:2.1.4-LMH-Beta-04-SNAPSHOT@aar') {
transitive = true
exclude group: 'com.android.support', module: 'appcompat-v7'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

import androidx.annotation.StringRes;

import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.vijay.jsonwizard.domain.Form;

Expand Down Expand Up @@ -81,31 +82,24 @@ protected BaseRegisterFragment getRegisterFragment() {
return new FamilyRegisterFragment();
}

private void initializeProgressDialog() {
progressDialog = new ProgressDialog(this);
progressDialog.setCancelable(true);
progressDialog.setTitle(getString(R.string.syncing_records));
}

public void showProgressDialog() {
try {
if (progressDialog == null) {
initializeProgressDialog();
}
if (progressDialog != null && progressDialog.isShowing()) progressDialog.dismiss();
progressDialog = ProgressDialog.show(this, getString(R.string.syncing_records), getString(R.string.please_wait_message), true, true);
}

progressDialog.show();
} catch (Exception e) {
Timber.e(Log.getStackTraceString(e));
@Override
public void showProgressDialog(@StringRes int titleIdentifier) {
if (progressDialog != null && progressDialog.isShowing()) progressDialog.dismiss();
if (!isFinishing()) {
progressDialog = ProgressDialog.show(this, getString(titleIdentifier), getString(R.string.please_wait_message), true, false);
}
}


@Override
public void hideProgressDialog() {
try {
if (progressDialog != null) {
progressDialog.dismiss();
}
} catch (Exception e) {
Timber.e(Log.getStackTraceString(e));
if (progressDialog != null) {
progressDialog.dismiss();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void onRegistrationSaved(boolean isEditMode, boolean isSaved, List<Family
BaseRegisterContract.View view = viewReference == null? null : viewReference.get();
if (view != null && view.getContext() != null) {
// view.refreshList(FetchStatus.fetched);

view.hideProgressDialog();
FamilyEventClient familyEventClient = familyEventClientList.get(0);
// FamilyEventClient headEventClient = familyEventClientList.get(1);
Intent intent = new Intent(view.getContext(), Utils.metadata().profileActivity);
Expand All @@ -33,8 +33,8 @@ public void onRegistrationSaved(boolean isEditMode, boolean isSaved, List<Family
// intent.putExtra("village_town", Utils.getValue(patient.getColumnmaps(), "village_town", false));
// intent.putExtra("family_name", Utils.getValue(patient.getColumnmaps(), "first_name", false));
// intent.putExtra("go_to_due_page", goToDuePage);

view.getContext().startActivity(intent);
view.hideProgressDialog();
}
}else{
super.onRegistrationSaved(isEditMode, isSaved, familyEventClientList);
Expand Down

0 comments on commit cd0e495

Please sign in to comment.