Refactoring + deduplicated code

This commit is contained in:
litetex 2021-11-28 14:07:45 +01:00
parent 68e7fcf8ee
commit b2323859e5
8 changed files with 134 additions and 112 deletions

View file

@ -1,7 +1,6 @@
package us.shandian.giga.ui.fragment;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@ -11,7 +10,6 @@ import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.os.IBinder;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
@ -34,7 +32,7 @@ import com.nononsenseapps.filepicker.Utils;
import org.schabi.newpipe.R;
import org.schabi.newpipe.settings.NewPipeSettings;
import org.schabi.newpipe.streams.io.NoFileManagerHelper;
import org.schabi.newpipe.streams.io.NoFileManagerSafeGuard;
import org.schabi.newpipe.streams.io.StoredFileHelper;
import org.schabi.newpipe.util.FilePickerActivityHelper;
@ -261,14 +259,13 @@ public class MissionsFragment extends Fragment {
initialPath = Uri.parse(initialSavePath.getAbsolutePath());
}
try {
requestDownloadSaveAsLauncher.launch(
StoredFileHelper.getNewPicker(mContext, mission.storage.getName(),
mission.storage.getType(), initialPath));
} catch (final ActivityNotFoundException aex) {
Log.w(TAG, "Unable to launch file picker", aex);
NoFileManagerHelper.showActivityNotFoundAlert(getContext());
}
NoFileManagerSafeGuard.launchSafe(
requestDownloadSaveAsLauncher,
StoredFileHelper.getNewPicker(mContext, mission.storage.getName(),
mission.storage.getType(), initialPath),
TAG,
mContext
);
}
@Override