Skip to content

Commit

Permalink
SubscriptionsImportFragment: Inline setup stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Profpatsch committed Jan 23, 2024
1 parent 1d8850d commit eaa68b7
Showing 1 changed file with 14 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ public class SubscriptionsImportFragment extends BaseFragment {
@State
int currentServiceId = Constants.NO_SERVICE_ID;

private List<SubscriptionExtractor.ContentSource> supportedSources;
private String relatedUrl;
private List<SubscriptionExtractor.ContentSource> supportedSources = Collections.emptyList();
private String relatedUrl = null;

@StringRes
private int instructionsString;
private int instructionsString = 0;

/*//////////////////////////////////////////////////////////////////////////
// Views
Expand Down Expand Up @@ -85,7 +85,17 @@ private void setInitialData(final int serviceId) {
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setupServiceVariables();
if (currentServiceId != Constants.NO_SERVICE_ID) {
try {
final SubscriptionExtractor extractor = NewPipe.getService(currentServiceId)
.getSubscriptionExtractor();
supportedSources = extractor.getSupportedSources();
relatedUrl = extractor.getRelatedUrl();
instructionsString = ServiceHelper.getImportInstructions(currentServiceId);
} catch (final ExtractionException ignored) {
}
}

if (supportedSources.isEmpty() && currentServiceId != Constants.NO_SERVICE_ID) {
ErrorUtil.showSnackbar(activity,
new ErrorInfo(new String[]{}, UserAction.SUBSCRIPTION_IMPORT_EXPORT,
Expand Down Expand Up @@ -203,23 +213,6 @@ private void requestImportFileResult(final ActivityResult result) {
// Subscriptions
///////////////////////////////////////////////////////////////////////////

private void setupServiceVariables() {
if (currentServiceId != Constants.NO_SERVICE_ID) {
try {
final SubscriptionExtractor extractor = NewPipe.getService(currentServiceId)
.getSubscriptionExtractor();
supportedSources = extractor.getSupportedSources();
relatedUrl = extractor.getRelatedUrl();
instructionsString = ServiceHelper.getImportInstructions(currentServiceId);
return;
} catch (final ExtractionException ignored) {
}
}

supportedSources = Collections.emptyList();
relatedUrl = null;
instructionsString = 0;
}

private void setInfoText(final String infoString) {
infoTextView.setText(infoString);
Expand Down

0 comments on commit eaa68b7

Please sign in to comment.