From 9d3e22200c0c2b8c11061ddbf70ff73c9f046aac Mon Sep 17 00:00:00 2001 From: Poussinou Date: Tue, 3 Apr 2018 21:59:42 +0200 Subject: [PATCH 1/7] Update gradle-wrapper.properties --- gradle/wrapper/gradle-wrapper.properties | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 445e90296..9c71e270e 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -4,3 +4,5 @@ distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip +distributionSha256Sum=7a2c66d1a78f811d5f37d14630ad21cec5e77a2a4dc61e787e2257a6341016ce +#distributionSha256Sum must be updated along with the version of gradle in distributionUrl From 0bd040a85180afd8770dd069ab0924a5762f4b21 Mon Sep 17 00:00:00 2001 From: Poussinou Date: Wed, 4 Apr 2018 13:33:21 +0200 Subject: [PATCH 2/7] Update gradle to 4.6 (and add corresponding distributionSha256Sum) --- gradle/wrapper/gradle-wrapper.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 9c71e270e..5084c008b 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,6 +3,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip -distributionSha256Sum=7a2c66d1a78f811d5f37d14630ad21cec5e77a2a4dc61e787e2257a6341016ce +distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip +distributionSha256Sum=9af7345c199f1731c187c96d3fe3d31f5405192a42046bafa71d846c3d9adacb #distributionSha256Sum must be updated along with the version of gradle in distributionUrl From f3a280dcb6fd95f4f720a5ce1959010ad83d5e99 Mon Sep 17 00:00:00 2001 From: Aris Poloway Date: Wed, 4 Apr 2018 20:11:13 -0400 Subject: [PATCH 3/7] Don't preemptively clean url and save StreamInfo with PlayQueueItem --- .../main/java/org/schabi/newpipe/RouterActivity.java | 5 +++-- .../org/schabi/newpipe/playlist/PlayQueueItem.java | 10 +++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/RouterActivity.java b/app/src/main/java/org/schabi/newpipe/RouterActivity.java index ad79c40b4..ab560111e 100644 --- a/app/src/main/java/org/schabi/newpipe/RouterActivity.java +++ b/app/src/main/java/org/schabi/newpipe/RouterActivity.java @@ -122,7 +122,7 @@ public class RouterActivity extends AppCompatActivity { currentService = NewPipe.getServiceByUrl(url); currentServiceId = currentService.getServiceId(); currentLinkType = currentService.getLinkTypeByUrl(url); - currentUrl = NavigationHelper.getCleanUrl(currentService, url, currentLinkType); + currentUrl = url; } else { currentService = NewPipe.getService(currentServiceId); } @@ -307,7 +307,8 @@ public class RouterActivity extends AppCompatActivity { // StreamDetailFragment can fetch data itself if(playerChoiceKey.equals(getString(R.string.show_info_key))) { disposables.add(Observable - .fromCallable(() -> NavigationHelper.getIntentByLink(this, currentUrl)) + .fromCallable(() -> NavigationHelper.getIntentByLink(this, + NavigationHelper.getCleanUrl(currentService, currentUrl, currentLinkType))) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(intent -> { diff --git a/app/src/main/java/org/schabi/newpipe/playlist/PlayQueueItem.java b/app/src/main/java/org/schabi/newpipe/playlist/PlayQueueItem.java index df4d19720..4b7f96ce9 100644 --- a/app/src/main/java/org/schabi/newpipe/playlist/PlayQueueItem.java +++ b/app/src/main/java/org/schabi/newpipe/playlist/PlayQueueItem.java @@ -29,11 +29,13 @@ public class PlayQueueItem implements Serializable { private Throwable error; private transient Single stream; + private StreamInfo info; PlayQueueItem(@NonNull final StreamInfo info) { this(info.getName(), info.getUrl(), info.getServiceId(), info.getDuration(), info.getThumbnailUrl(), info.getUploaderName(), info.getStreamType()); this.stream = Single.just(info); + this.info = info; } PlayQueueItem(@NonNull final StreamInfoItem item) { @@ -105,7 +107,13 @@ public class PlayQueueItem implements Serializable { @NonNull private Single getInfo() { - return ExtractorHelper.getStreamInfo(this.serviceId, this.url, false) + Single single; + if (this.info != null){ + single = Single.just(info); + } else { + single = ExtractorHelper.getStreamInfo(this.serviceId, this.url, false); + } + return single .subscribeOn(Schedulers.io()) .doOnError(throwable -> error = throwable); } From b3c49ac86ba089993735b05ed37b8bc2017af8d5 Mon Sep 17 00:00:00 2001 From: Aris Poloway Date: Thu, 5 Apr 2018 16:45:00 -0400 Subject: [PATCH 4/7] Revert unnecessary url clean --- app/src/main/java/org/schabi/newpipe/RouterActivity.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/RouterActivity.java b/app/src/main/java/org/schabi/newpipe/RouterActivity.java index ab560111e..e0221fc22 100644 --- a/app/src/main/java/org/schabi/newpipe/RouterActivity.java +++ b/app/src/main/java/org/schabi/newpipe/RouterActivity.java @@ -307,8 +307,7 @@ public class RouterActivity extends AppCompatActivity { // StreamDetailFragment can fetch data itself if(playerChoiceKey.equals(getString(R.string.show_info_key))) { disposables.add(Observable - .fromCallable(() -> NavigationHelper.getIntentByLink(this, - NavigationHelper.getCleanUrl(currentService, currentUrl, currentLinkType))) + .fromCallable(() -> NavigationHelper.getIntentByLink(this, currentUrl)) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(intent -> { From 2b281c43575b7cdb1943bf2150509954388b7bc4 Mon Sep 17 00:00:00 2001 From: Aris Poloway Date: Thu, 5 Apr 2018 23:47:20 -0400 Subject: [PATCH 5/7] Don't save stream and store recovery position from StreamInfo --- .../newpipe/playlist/PlayQueueItem.java | 21 ++++--------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/playlist/PlayQueueItem.java b/app/src/main/java/org/schabi/newpipe/playlist/PlayQueueItem.java index 4b7f96ce9..2d543fb4e 100644 --- a/app/src/main/java/org/schabi/newpipe/playlist/PlayQueueItem.java +++ b/app/src/main/java/org/schabi/newpipe/playlist/PlayQueueItem.java @@ -28,14 +28,12 @@ public class PlayQueueItem implements Serializable { private long recoveryPosition; private Throwable error; - private transient Single stream; - private StreamInfo info; - PlayQueueItem(@NonNull final StreamInfo info) { this(info.getName(), info.getUrl(), info.getServiceId(), info.getDuration(), info.getThumbnailUrl(), info.getUploaderName(), info.getStreamType()); - this.stream = Single.just(info); - this.info = info; + + if (info.getStartPosition() > 0) + setRecoveryPosition(info.getStartPosition() * 1000); } PlayQueueItem(@NonNull final StreamInfoItem item) { @@ -102,18 +100,7 @@ public class PlayQueueItem implements Serializable { @NonNull public Single getStream() { - return stream == null ? stream = getInfo() : stream; - } - - @NonNull - private Single getInfo() { - Single single; - if (this.info != null){ - single = Single.just(info); - } else { - single = ExtractorHelper.getStreamInfo(this.serviceId, this.url, false); - } - return single + return ExtractorHelper.getStreamInfo(this.serviceId, this.url, false) .subscribeOn(Schedulers.io()) .doOnError(throwable -> error = throwable); } From 140fb864011680abf6e4c81dd4bce6ce4b8acc90 Mon Sep 17 00:00:00 2001 From: Mauricio Colli Date: Fri, 6 Apr 2018 04:35:44 -0300 Subject: [PATCH 6/7] Fix Info's start time when using VideoDetailFragment - Update extractor dependency --- app/build.gradle | 2 +- .../fragments/detail/VideoDetailFragment.java | 19 ++++++++++--------- .../schabi/newpipe/util/NavigationHelper.java | 15 --------------- 3 files changed, 11 insertions(+), 25 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index b6ce0ffd4..e20535ee4 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -54,7 +54,7 @@ dependencies { exclude module: 'support-annotations' } - implementation 'com.github.TeamNewPipe:NewPipeExtractor:a6b6235644474' + implementation 'com.github.TeamNewPipe:NewPipeExtractor:77a74b8' testImplementation 'junit:junit:4.12' diff --git a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java index 74e561f99..611cd8bfb 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java @@ -70,7 +70,6 @@ import org.schabi.newpipe.player.helper.PlayerHelper; import org.schabi.newpipe.player.old.PlayVideoActivity; import org.schabi.newpipe.playlist.PlayQueue; import org.schabi.newpipe.playlist.SinglePlayQueue; -import org.schabi.newpipe.report.ErrorActivity; import org.schabi.newpipe.report.UserAction; import org.schabi.newpipe.util.Constants; import org.schabi.newpipe.util.ExtractorHelper; @@ -205,7 +204,7 @@ public class VideoDetailFragment } @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return inflater.inflate(R.layout.fragment_video_detail, container, false); } @@ -681,15 +680,15 @@ public class VideoDetailFragment int id = item.getItemId(); switch (id) { case R.id.menu_item_share: { - if(currentInfo != null) { - shareUrl(currentInfo.getName(), url); - } else { - shareUrl(url, url); + if (currentInfo != null) { + shareUrl(currentInfo.getName(), currentInfo.getUrl()); } return true; } case R.id.menu_item_openInBrowser: { - openUrlInBrowser(url); + if (currentInfo != null) { + openUrlInBrowser(currentInfo.getUrl()); + } return true; } case R.id.action_play_with_kodi: @@ -818,7 +817,7 @@ public class VideoDetailFragment public void prepareAndHandleInfo(final StreamInfo info, boolean scrollToTop) { if (DEBUG) Log.d(TAG, "prepareAndHandleInfo() called with: info = [" + info + "], scrollToTop = [" + scrollToTop + "]"); - setInitialData(info.getServiceId(), info.getUrl(), info.getName()); + setInitialData(info.getServiceId(), info.getOriginalUrl(), info.getName()); pushToStack(serviceId, url, name); showLoading(); @@ -1112,7 +1111,7 @@ public class VideoDetailFragment public void handleResult(@NonNull StreamInfo info) { super.handleResult(info); - setInitialData(info.getServiceId(), info.getUrl(), info.getName()); + setInitialData(info.getServiceId(), info.getOriginalUrl(), info.getName()); pushToStack(serviceId, url, name); animateView(thumbnailPlayButton, true, 200); @@ -1192,7 +1191,9 @@ public class VideoDetailFragment toggleExpandRelatedVideos(currentInfo); wasRelatedStreamsExpanded = false; } + setTitleToUrl(info.getServiceId(), info.getUrl(), info.getName()); + setTitleToUrl(info.getServiceId(), info.getOriginalUrl(), info.getName()); if (!info.getErrors().isEmpty()) { showSnackBarError(info.getErrors(), diff --git a/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java b/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java index 26088a64c..3d9a3e0de 100644 --- a/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java @@ -475,7 +475,6 @@ public class NavigationHelper { throw new ExtractionException("Url not known to service. service=" + service + " url=" + url); } - url = getCleanUrl(service, url, linkType); Intent rIntent = getOpenIntent(context, url, service.getServiceId(), linkType); switch (linkType) { @@ -488,20 +487,6 @@ public class NavigationHelper { return rIntent; } - public static String getCleanUrl(StreamingService service, String dirtyUrl, StreamingService.LinkType linkType) throws ExtractionException { - switch (linkType) { - case STREAM: - return service.getStreamUrlIdHandler().cleanUrl(dirtyUrl); - case CHANNEL: - return service.getChannelUrlIdHandler().cleanUrl(dirtyUrl); - case PLAYLIST: - return service.getPlaylistUrlIdHandler().cleanUrl(dirtyUrl); - case NONE: - break; - } - return null; - } - private static Uri openMarketUrl(String packageName) { return Uri.parse("market://details") .buildUpon() From 669d2c44c94e31d0e92ea88e80153a7ce64bcfc4 Mon Sep 17 00:00:00 2001 From: Mauricio Colli Date: Fri, 6 Apr 2018 06:02:51 -0300 Subject: [PATCH 7/7] Dynamically create the opening choices - Fixes TODO --- .../org/schabi/newpipe/RouterActivity.java | 106 ++++++++++-------- 1 file changed, 61 insertions(+), 45 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/RouterActivity.java b/app/src/main/java/org/schabi/newpipe/RouterActivity.java index e0221fc22..4a1d9be57 100644 --- a/app/src/main/java/org/schabi/newpipe/RouterActivity.java +++ b/app/src/main/java/org/schabi/newpipe/RouterActivity.java @@ -1,6 +1,7 @@ package org.schabi.newpipe; import android.app.IntentService; +import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; @@ -24,7 +25,6 @@ import android.widget.Toast; import org.schabi.newpipe.extractor.Info; import org.schabi.newpipe.extractor.NewPipe; -import org.schabi.newpipe.extractor.ServiceList; import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.StreamingService.LinkType; import org.schabi.newpipe.extractor.channel.ChannelInfo; @@ -43,9 +43,11 @@ import org.schabi.newpipe.util.PermissionHelper; import org.schabi.newpipe.util.ThemeHelper; import java.io.Serializable; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.HashSet; +import java.util.List; import icepick.Icepick; import icepick.State; @@ -57,6 +59,7 @@ import io.reactivex.disposables.Disposable; import io.reactivex.functions.Consumer; import io.reactivex.schedulers.Schedulers; +import static org.schabi.newpipe.extractor.StreamingService.ServiceInfo.MediaCapability.*; import static org.schabi.newpipe.util.ThemeHelper.resolveResourceIdFromAttr; /** @@ -168,18 +171,23 @@ public class RouterActivity extends AppCompatActivity { return; } - // TODO: Add some sort of "capabilities" field to services (audio only, video and audio, etc.) - if (currentService == ServiceList.SoundCloud) { - handleChoice(getString(R.string.background_player_key)); - return; - } + final String playerChoiceKey = preferences.getString(getString(R.string.preferred_open_action_key), getString(R.string.preferred_open_action_default)); - final String playerChoiceKey = preferences.getString( - getString(R.string.preferred_open_action_key), - getString(R.string.preferred_open_action_default)); + final String videoPlayerKey = getString(R.string.video_player_key); + final String backgroundPlayerKey = getString(R.string.background_player_key); + final String popupPlayerKey = getString(R.string.popup_player_key); final String alwaysAskKey = getString(R.string.always_ask_open_action_key); - if (playerChoiceKey.equals(alwaysAskKey)) { + final List capabilities = currentService.getServiceInfo().getMediaCapabilities(); + + boolean serviceSupportsPlayer = false; + if (playerChoiceKey.equals(videoPlayerKey) || playerChoiceKey.equals(popupPlayerKey)) { + serviceSupportsPlayer = capabilities.contains(VIDEO); + } else if (playerChoiceKey.equals(backgroundPlayerKey)) { + serviceSupportsPlayer = capabilities.contains(AUDIO); + } + + if (playerChoiceKey.equals(alwaysAskKey) || !serviceSupportsPlayer) { showDialog(); } else { handleChoice(playerChoiceKey); @@ -187,29 +195,20 @@ public class RouterActivity extends AppCompatActivity { } private void showDialog() { - SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); - final ContextThemeWrapper themeWrapper = new ContextThemeWrapper(this, + final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); + final ContextThemeWrapper themeWrapperContext = new ContextThemeWrapper(this, ThemeHelper.isLightThemeSelected(this) ? R.style.LightTheme : R.style.DarkTheme); - LayoutInflater inflater = LayoutInflater.from(themeWrapper); + final LayoutInflater inflater = LayoutInflater.from(themeWrapperContext); final LinearLayout rootLayout = (LinearLayout) inflater.inflate(R.layout.preferred_player_dialog_view, null, false); final RadioGroup radioGroup = rootLayout.findViewById(android.R.id.list); - final AdapterChoiceItem[] choices = { - new AdapterChoiceItem(getString(R.string.show_info_key), getString(R.string.show_info), - resolveResourceIdFromAttr(themeWrapper, R.attr.info)), - new AdapterChoiceItem(getString(R.string.video_player_key), getString(R.string.video_player), - resolveResourceIdFromAttr(themeWrapper, R.attr.play)), - new AdapterChoiceItem(getString(R.string.background_player_key), getString(R.string.background_player), - resolveResourceIdFromAttr(themeWrapper, R.attr.audio)), - new AdapterChoiceItem(getString(R.string.popup_player_key), getString(R.string.popup_player), - resolveResourceIdFromAttr(themeWrapper, R.attr.popup)) - }; + final List choices = getChoicesForService(themeWrapperContext, currentService); final DialogInterface.OnClickListener dialogButtonsClickListener = (dialog, which) -> { final int indexOfChild = radioGroup.indexOfChild( radioGroup.findViewById(radioGroup.getCheckedRadioButtonId())); - final AdapterChoiceItem choice = choices[indexOfChild]; + final AdapterChoiceItem choice = choices.get(indexOfChild); handleChoice(choice.key); @@ -218,7 +217,7 @@ public class RouterActivity extends AppCompatActivity { } }; - final AlertDialog alertDialog = new AlertDialog.Builder(themeWrapper) + final AlertDialog alertDialog = new AlertDialog.Builder(themeWrapperContext) .setTitle(R.string.preferred_player_share_menu_title) .setView(radioGroup) .setCancelable(true) @@ -227,6 +226,7 @@ public class RouterActivity extends AppCompatActivity { .setOnDismissListener((dialog) -> finish()) .create(); + //noinspection CodeBlock2Expr alertDialog.setOnShowListener(dialog -> { setDialogButtonsState(alertDialog, radioGroup.getCheckedRadioButtonId() != -1); }); @@ -240,7 +240,7 @@ public class RouterActivity extends AppCompatActivity { selectedRadioPosition = indexOfChild; if (selectedPreviously == selectedRadioPosition) { - handleChoice(choices[selectedRadioPosition].key); + handleChoice(choices.get(selectedRadioPosition).key); } }; @@ -259,8 +259,8 @@ public class RouterActivity extends AppCompatActivity { if (selectedRadioPosition == -1) { final String lastSelectedPlayer = preferences.getString(getString(R.string.preferred_open_action_last_selected_key), null); if (!TextUtils.isEmpty(lastSelectedPlayer)) { - for (int i = 0; i < choices.length; i++) { - AdapterChoiceItem c = choices[i]; + for (int i = 0; i < choices.size(); i++) { + AdapterChoiceItem c = choices.get(i); if (lastSelectedPlayer.equals(c.key)) { selectedRadioPosition = i; break; @@ -269,7 +269,7 @@ public class RouterActivity extends AppCompatActivity { } } - selectedRadioPosition = Math.min(Math.max(-1, selectedRadioPosition), choices.length - 1); + selectedRadioPosition = Math.min(Math.max(-1, selectedRadioPosition), choices.size() - 1); if (selectedRadioPosition != -1) { ((RadioButton) radioGroup.getChildAt(selectedRadioPosition)).setChecked(true); } @@ -278,6 +278,28 @@ public class RouterActivity extends AppCompatActivity { alertDialog.show(); } + private List getChoicesForService(Context context, StreamingService service) { + final List returnList = new ArrayList<>(); + final List capabilities = service.getServiceInfo().getMediaCapabilities(); + + returnList.add(new AdapterChoiceItem(getString(R.string.show_info_key), getString(R.string.show_info), + resolveResourceIdFromAttr(context, R.attr.info))); + + if (capabilities.contains(VIDEO)) { + returnList.add(new AdapterChoiceItem(getString(R.string.video_player_key), getString(R.string.video_player), + resolveResourceIdFromAttr(context, R.attr.play))); + returnList.add(new AdapterChoiceItem(getString(R.string.popup_player_key), getString(R.string.popup_player), + resolveResourceIdFromAttr(context, R.attr.popup))); + } + + if (capabilities.contains(AUDIO)) { + returnList.add(new AdapterChoiceItem(getString(R.string.background_player_key), getString(R.string.background_player), + resolveResourceIdFromAttr(context, R.attr.audio))); + } + + return returnList; + } + private void setDialogButtonsState(AlertDialog dialog, boolean state) { final Button negativeButton = dialog.getButton(DialogInterface.BUTTON_NEGATIVE); final Button positiveButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE); @@ -288,16 +310,14 @@ public class RouterActivity extends AppCompatActivity { } private void handleChoice(final String playerChoiceKey) { - if (Arrays.asList(getResources() - .getStringArray(R.array.preferred_open_action_values_list)) - .contains(playerChoiceKey)) { + final List validChoicesList = Arrays.asList(getResources().getStringArray(R.array.preferred_open_action_values_list)); + if (validChoicesList.contains(playerChoiceKey)) { PreferenceManager.getDefaultSharedPreferences(this).edit() - .putString(getString(R.string.preferred_open_action_last_selected_key), - playerChoiceKey).apply(); + .putString(getString(R.string.preferred_open_action_last_selected_key), playerChoiceKey) + .apply(); } - if (playerChoiceKey.equals(getString(R.string.popup_player_key)) - && !PermissionHelper.isPopupEnabled(this)) { + if (playerChoiceKey.equals(getString(R.string.popup_player_key)) && !PermissionHelper.isPopupEnabled(this)) { PermissionHelper.showPopupEnablementToast(this); finish(); return; @@ -305,7 +325,7 @@ public class RouterActivity extends AppCompatActivity { // stop and bypass FetcherService if InfoScreen was selected since // StreamDetailFragment can fetch data itself - if(playerChoiceKey.equals(getString(R.string.show_info_key))) { + if (playerChoiceKey.equals(getString(R.string.show_info_key))) { disposables.add(Observable .fromCallable(() -> NavigationHelper.getIntentByLink(this, currentUrl)) .subscribeOn(Schedulers.io()) @@ -322,11 +342,8 @@ public class RouterActivity extends AppCompatActivity { } final Intent intent = new Intent(this, FetcherService.class); - intent.putExtra(FetcherService.KEY_CHOICE, - new Choice(currentService.getServiceId(), - currentLinkType, - currentUrl, - playerChoiceKey)); + final Choice choice = new Choice(currentService.getServiceId(), currentLinkType, currentUrl, playerChoiceKey); + intent.putExtra(FetcherService.KEY_CHOICE, choice); startService(intent); finish(); @@ -334,8 +351,7 @@ public class RouterActivity extends AppCompatActivity { private static class AdapterChoiceItem { final String description, key; - @DrawableRes - final int icon; + @DrawableRes final int icon; AdapterChoiceItem(String key, String description, int icon) { this.description = description; @@ -554,7 +570,7 @@ public class RouterActivity extends AppCompatActivity { * @param sharedText text to scan for URLs. * @return potential URLs */ - protected String[] getUris(final String sharedText) { + protected String[] getUris(final String sharedText) { final Collection result = new HashSet<>(); if (sharedText != null) { final String[] array = sharedText.split("\\p{Space}");