Skip to content

Commit

Permalink
fix #1009: New instance of home created only if language is changed
Browse files Browse the repository at this point in the history
  • Loading branch information
rahul-jha98 committed Feb 8, 2019
1 parent 052fdf7 commit a641656
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,37 @@

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;

import org.mifos.mobilebanking.R;
import org.mifos.mobilebanking.ui.activities.base.BaseActivity;
import org.mifos.mobilebanking.ui.fragments.SettingsFragment;
import org.mifos.mobilebanking.utils.Constants;

public class SettingsActivity extends BaseActivity {

private boolean hasSettingsChanged;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_settings);
setToolbarTitle(getString(R.string.settings));
showBackButton();
replaceFragment(SettingsFragment.newInstance(), false, R.id.container);
if (getIntent().hasExtra(Constants.HAS_SETTINGS_CHANGED)) {
hasSettingsChanged = getIntent().getBooleanExtra(Constants.HAS_SETTINGS_CHANGED,
false);
}
}

@Override
public void onBackPressed() {
super.onBackPressed();
Intent i = new Intent(this, HomeActivity.class);
startActivity(i);
if (hasSettingsChanged) {
ActivityCompat.finishAffinity(this);
Intent i = new Intent(this, HomeActivity.class);
startActivity(i);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.mifos.mobilebanking.R;
import org.mifos.mobilebanking.utils.ConfigurationPreference;
import org.mifos.mobilebanking.utils.ConfigurationDialogFragmentCompat;
import org.mifos.mobilebanking.utils.Constants;
import org.mifos.mobilebanking.utils.LanguageHelper;

/**
Expand Down Expand Up @@ -68,7 +69,9 @@ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Strin
if (preference instanceof ListPreference) {
ListPreference listPreference = (ListPreference) preference;
LanguageHelper.setLocale(getContext(), listPreference.getValue());
startActivity(new Intent(getActivity(), getActivity().getClass()));
Intent intent = new Intent(getActivity(), getActivity().getClass());
intent.putExtra(Constants.HAS_SETTINGS_CHANGED, true);
startActivity(intent);
getActivity().finish();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,6 @@ public class Constants {
public static final String INDEX = "index";

public static final String DATE_PICKER_TYPE = "datePickerType";

public static final String HAS_SETTINGS_CHANGED = "hasSettingsChanged";
}

0 comments on commit a641656

Please sign in to comment.