Skip to content
Snippets Groups Projects
Commit b62e17ad authored by cyberta's avatar cyberta
Browse files

#8789 fix IllegalStateException for failed provider configuring

parent 590f95df
Branches
Tags
No related merge requests found
...@@ -89,7 +89,9 @@ public abstract class BaseConfigurationWizard extends Activity ...@@ -89,7 +89,9 @@ public abstract class BaseConfigurationWizard extends Activity
final protected static String PROVIDER_NOT_SET = "PROVIDER NOT SET"; final protected static String PROVIDER_NOT_SET = "PROVIDER NOT SET";
final protected static String SETTING_UP_PROVIDER = "PROVIDER GETS SET"; final protected static String SETTING_UP_PROVIDER = "PROVIDER GETS SET";
private static final String SETTING_UP_PROVIDER_SHOW_PROVIDER_DETILS = "PROVIDER DETAILS SHOWN"; final private static String PENDING_SHOW_PROVIDER_DETAILS = "PROVIDER DETAILS SHOWN";
final private static String PENDING_SHOW_FAILED_DIALOG = "SHOW FAILED DIALOG";
final private static String REASON_TO_FAIL = "REASON TO FAIL";
final protected static String PROVIDER_SET = "PROVIDER SET"; final protected static String PROVIDER_SET = "PROVIDER SET";
final protected static String SERVICES_RETRIEVED = "SERVICES RETRIEVED"; final protected static String SERVICES_RETRIEVED = "SERVICES RETRIEVED";
...@@ -149,7 +151,11 @@ public abstract class BaseConfigurationWizard extends Activity ...@@ -149,7 +151,11 @@ public abstract class BaseConfigurationWizard extends Activity
progressbar_text = savedInstanceState.getString(PROGRESSBAR_TEXT, ""); progressbar_text = savedInstanceState.getString(PROGRESSBAR_TEXT, "");
selected_provider = savedInstanceState.getParcelable(Provider.KEY); selected_provider = savedInstanceState.getParcelable(Provider.KEY);
if (fragment_manager.findFragmentByTag(ProviderDetailFragment.TAG) == null && SETTING_UP_PROVIDER.equals(mConfigState.getAction())) { if (fragment_manager.findFragmentByTag(ProviderDetailFragment.TAG) == null &&
(SETTING_UP_PROVIDER.equals(mConfigState.getAction()) ||
PENDING_SHOW_PROVIDER_DETAILS.equals(mConfigState.getAction()) ||
PENDING_SHOW_FAILED_DIALOG.equals(mConfigState.getAction())
)) {
onItemSelectedUi(); onItemSelectedUi();
} }
} }
...@@ -160,8 +166,10 @@ public abstract class BaseConfigurationWizard extends Activity ...@@ -160,8 +166,10 @@ public abstract class BaseConfigurationWizard extends Activity
if (SETTING_UP_PROVIDER.equals(mConfigState.getAction())) { if (SETTING_UP_PROVIDER.equals(mConfigState.getAction())) {
showProgressBar(); showProgressBar();
adapter.hideAllBut(adapter.indexOf(selected_provider)); adapter.hideAllBut(adapter.indexOf(selected_provider));
} else if (SETTING_UP_PROVIDER_SHOW_PROVIDER_DETILS.equals(mConfigState.getAction())) { } else if (PENDING_SHOW_PROVIDER_DETAILS.equals(mConfigState.getAction())) {
showProviderDetails(); showProviderDetails();
} else if (PENDING_SHOW_FAILED_DIALOG.equals(mConfigState.getAction())) {
showDownloadFailedDialog(mConfigState.getStringExtra(REASON_TO_FAIL));
} }
} }
...@@ -248,7 +256,8 @@ public abstract class BaseConfigurationWizard extends Activity ...@@ -248,7 +256,8 @@ public abstract class BaseConfigurationWizard extends Activity
@OnItemClick(R.id.provider_list) @OnItemClick(R.id.provider_list)
void onItemSelected(int position) { void onItemSelected(int position) {
if (SETTING_UP_PROVIDER.equals(mConfigState.getAction()) || if (SETTING_UP_PROVIDER.equals(mConfigState.getAction()) ||
SETTING_UP_PROVIDER_SHOW_PROVIDER_DETILS.equals(mConfigState.getAction())) { PENDING_SHOW_PROVIDER_DETAILS.equals(mConfigState.getAction()) ||
PENDING_SHOW_FAILED_DIALOG.equals(mConfigState.getAction())) {
return; return;
} }
...@@ -266,7 +275,9 @@ public abstract class BaseConfigurationWizard extends Activity ...@@ -266,7 +275,9 @@ public abstract class BaseConfigurationWizard extends Activity
@Override @Override
public void onBackPressed() { public void onBackPressed() {
if (SETTING_UP_PROVIDER.equals(mConfigState.getAction())) { if (SETTING_UP_PROVIDER.equals(mConfigState.getAction()) ||
PENDING_SHOW_PROVIDER_DETAILS.equals(mConfigState.getAction()) ||
PENDING_SHOW_FAILED_DIALOG.equals(mConfigState.getAction())) {
stopSettingUpProvider(); stopSettingUpProvider();
} else { } else {
askDashboardToQuitApp(); askDashboardToQuitApp();
...@@ -364,10 +375,17 @@ public abstract class BaseConfigurationWizard extends Activity ...@@ -364,10 +375,17 @@ public abstract class BaseConfigurationWizard extends Activity
* @param reason_to_fail * @param reason_to_fail
*/ */
public void showDownloadFailedDialog(String reason_to_fail) { public void showDownloadFailedDialog(String reason_to_fail) {
try {
FragmentTransaction fragment_transaction = fragment_manager.removePreviousFragment(DownloadFailedDialog.TAG); FragmentTransaction fragment_transaction = fragment_manager.removePreviousFragment(DownloadFailedDialog.TAG);
DialogFragment newFragment = DownloadFailedDialog.newInstance(reason_to_fail); DialogFragment newFragment = DownloadFailedDialog.newInstance(reason_to_fail);
newFragment.show(fragment_transaction, DownloadFailedDialog.TAG); newFragment.show(fragment_transaction, DownloadFailedDialog.TAG);
} catch (IllegalStateException e) {
e.printStackTrace();
mConfigState.setAction(PENDING_SHOW_FAILED_DIALOG);
mConfigState.putExtra(REASON_TO_FAIL, reason_to_fail);
}
} }
...@@ -380,7 +398,6 @@ public abstract class BaseConfigurationWizard extends Activity ...@@ -380,7 +398,6 @@ public abstract class BaseConfigurationWizard extends Activity
* *
*/ */
public void showProviderDetails() { public void showProviderDetails() {
mConfigState.setAction(SETTING_UP_PROVIDER_SHOW_PROVIDER_DETILS);
try { try {
FragmentTransaction fragment_transaction = fragment_manager.removePreviousFragment(ProviderDetailFragment.TAG); FragmentTransaction fragment_transaction = fragment_manager.removePreviousFragment(ProviderDetailFragment.TAG);
...@@ -388,6 +405,7 @@ public abstract class BaseConfigurationWizard extends Activity ...@@ -388,6 +405,7 @@ public abstract class BaseConfigurationWizard extends Activity
newFragment.show(fragment_transaction, ProviderDetailFragment.TAG); newFragment.show(fragment_transaction, ProviderDetailFragment.TAG);
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
e.printStackTrace(); e.printStackTrace();
mConfigState.setAction(PENDING_SHOW_PROVIDER_DETAILS);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment