Skip to content

Commit

Permalink
Code improvements
Browse files Browse the repository at this point in the history
Removed - partial - stupid code.
  • Loading branch information
litetex committed Feb 17, 2022
1 parent cd8c7ec commit 91c67b0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,6 @@ public void onAttach(@NonNull final Context context) {
}
}

@Override
public void onDetach() {
super.onDetach();
}

@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,21 +183,17 @@ public void onCreateOptionsMenu(@NonNull final Menu menu,
}
}

private void openRssFeed() {
final ChannelInfo info = currentInfo;
if (info != null) {
ShareUtils.openUrlInBrowser(requireContext(), info.getFeedUrl(), false);
}
}

@Override
public boolean onOptionsItemSelected(final MenuItem item) {
switch (item.getItemId()) {
case R.id.action_settings:
NavigationHelper.openSettings(requireContext());
break;
case R.id.menu_item_rss:
openRssFeed();
if (currentInfo != null) {
ShareUtils.openUrlInBrowser(
requireContext(), currentInfo.getFeedUrl(), false);
}
break;
case R.id.menu_item_openInBrowser:
if (currentInfo != null) {
Expand Down Expand Up @@ -516,12 +512,11 @@ private PlayQueue getPlayQueue() {
}

private PlayQueue getPlayQueue(final int index) {
final List<StreamInfoItem> streamItems = new ArrayList<>();
for (final InfoItem i : infoListAdapter.getItemsList()) {
if (i instanceof StreamInfoItem) {
streamItems.add((StreamInfoItem) i);
}
}
final List<StreamInfoItem> streamItems = infoListAdapter.getItemsList().stream()
.filter(StreamInfoItem.class::isInstance)
.map(StreamInfoItem.class::cast)
.collect(Collectors.toList());

return new ChannelPlayQueue(currentInfo.getServiceId(), currentInfo.getUrl(),
currentInfo.getNextPage(), streamItems, index);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ private Flowable<Integer> getUpdateProcessor(
}

private Subscriber<List<PlaylistRemoteEntity>> getPlaylistBookmarkSubscriber() {
return new Subscriber<List<PlaylistRemoteEntity>>() {
return new Subscriber<>() {
@Override
public void onSubscribe(final Subscription s) {
if (bookmarkReactor != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@
import java.io.Serializable;

import io.reactivex.rxjava3.core.Single;
import io.reactivex.rxjava3.disposables.CompositeDisposable;

public class RelatedItemsFragment extends BaseListInfoFragment<RelatedItemInfo>
implements SharedPreferences.OnSharedPreferenceChangeListener {
private static final String INFO_KEY = "related_info_key";
private final CompositeDisposable disposables = new CompositeDisposable();

private RelatedItemInfo relatedItemInfo;

/*//////////////////////////////////////////////////////////////////////////
Expand All @@ -54,11 +53,6 @@ public RelatedItemsFragment() {
// LifeCycle
//////////////////////////////////////////////////////////////////////////*/

@Override
public void onAttach(@NonNull final Context context) {
super.onAttach(context);
}

@Override
public View onCreateView(@NonNull final LayoutInflater inflater,
@Nullable final ViewGroup container,
Expand All @@ -67,9 +61,6 @@ public View onCreateView(@NonNull final LayoutInflater inflater,
}

@Override
public void onDestroy() {
super.onDestroy();
disposables.clear();
}

@Override
Expand Down Expand Up @@ -128,7 +119,6 @@ public void handleResult(@NonNull final RelatedItemInfo result) {
}
ViewUtils.slideUp(requireView(), 120, 96, 0.06f);

disposables.clear();
}

/*//////////////////////////////////////////////////////////////////////////
Expand All @@ -137,11 +127,13 @@ public void handleResult(@NonNull final RelatedItemInfo result) {

@Override
public void setTitle(final String title) {
// Nothing to do - override parent
}

@Override
public void onCreateOptionsMenu(@NonNull final Menu menu,
@NonNull final MenuInflater inflater) {
// Nothing to do - override parent
}

private void setInitialData(final StreamInfo info) {
Expand Down

0 comments on commit 91c67b0

Please sign in to comment.