Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SubscriptionsImportFragment: Inline setup stuff #10782

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this was originally set based on the function that was removed, but, if I recall correctly, a declared String in Java is already null, so this assignment is not needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably, but this just inlines the existing code, which I don’t want to change here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah there's no problem in making it explicit that it's initialized to 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
Loading