Skip to content

Commit

Permalink
fix issue when action view crashed app on cold start
Browse files Browse the repository at this point in the history
increment version
  • Loading branch information
Aefyr committed Aug 17, 2019
1 parent 9eafda5 commit d8f6a4c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
applicationId "com.aefyr.sai"
minSdkVersion 21
targetSdkVersion 28
versionCode 30
versionName "2.0"
versionCode 31
versionName "2.1"
}
buildTypes {
release {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ private void deliverActionViewUri(Uri uri) {
}
mBottomNavigationView.getMenu().getItem(0).setChecked(true);
mFragmentNavigator.switchTo("installer");
getInstallerFragment().onActionView(uri);
getInstallerFragment().handleActionView(uri);
}

private void showMiuiWarning() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public class InstallerFragment extends SaiBaseFragment implements FilePickerDial

private PreferencesHelper mHelper;

private Uri mPendingActionViewUri;

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
Expand Down Expand Up @@ -84,9 +86,19 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat

mButton.setOnClickListener((v) -> checkPermissionsAndPickFiles());
findViewById(R.id.button_help).setOnClickListener((v) -> AlertsUtils.showAlert(this, R.string.help, R.string.installer_help));

if (mPendingActionViewUri != null) {
handleActionView(mPendingActionViewUri);
mPendingActionViewUri = null;
}
}

public void onActionView(Uri uri) {
public void handleActionView(Uri uri) {
if (!isAdded()) {
mPendingActionViewUri = uri;
return;
}

DialogFragment existingDialog = (DialogFragment) getChildFragmentManager().findFragmentByTag("installation_confirmation_dialog");
if (existingDialog != null)
existingDialog.dismiss();
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/com/aefyr/sai/utils/FragmentNavigator.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ public FragmentNavigator(@Nullable Bundle savedInstanceState, FragmentManager fr
}

public void switchTo(String tag) {
if (mCurrentFragment != null && tag.equals(mCurrentFragment.getTag()))
return;

ensureStateWasRestored();

FragmentTransaction transaction = mFragmentManager.beginTransaction();
Expand Down

0 comments on commit d8f6a4c

Please sign in to comment.