Skip to content

Commit

Permalink
Fix checkstyle errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Stypox committed Apr 3, 2020
1 parent 9c3f138 commit 6571fdb
Showing 1 changed file with 21 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
private View headerPlayAllButton;
private View headerPopupButton;
private View headerBackgroundButton;

private ItemTouchHelper itemTouchHelper;

private LocalPlaylistManager playlistManager;
Expand Down Expand Up @@ -255,9 +255,11 @@ public void onPause() {
}

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
if (DEBUG) Log.d(TAG, "onCreateOptionsMenu() called with: menu = [" + menu +
"], inflater = [" + inflater + "]");
public void onCreateOptionsMenu(final Menu menu, final MenuInflater inflater) {
if (DEBUG) {
Log.d(TAG, "onCreateOptionsMenu() called with: menu = [" + menu
+ "], inflater = [" + inflater + "]");
}
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.menu_local_playlist, menu);
}
Expand Down Expand Up @@ -300,7 +302,9 @@ public void onDestroy() {
disposables.dispose();
}

if (removeWatchedDisposable != null) removeWatchedDisposable.dispose();
if (removeWatchedDisposable != null) {
removeWatchedDisposable.dispose();
}

debouncedSaveSignal = null;
playlistManager = null;
Expand Down Expand Up @@ -353,7 +357,7 @@ public void onComplete() { }
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
public boolean onOptionsItemSelected(final MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_item_removeWatched:
removeWatchedStreams();
Expand All @@ -372,7 +376,8 @@ public void removeWatchedStreams() {
removeWatchedDisposable.dispose();
}

removeWatchedDisposable = Flowable.just(playlistManager.getPlaylistStreams(playlistId).blockingFirst())
removeWatchedDisposable = Flowable.just(
playlistManager.getPlaylistStreams(playlistId).blockingFirst())
.subscribeOn(Schedulers.newThread())
.map((@NonNull List<PlaylistStreamEntry> playlist) -> {
HistoryRecordManager recordManager = new HistoryRecordManager(getContext());
Expand All @@ -382,19 +387,22 @@ public void removeWatchedStreams() {

// already sorted by ^ getStreamHistorySortedById(), binary search can be used
ArrayList<Long> historyStreamIds = new ArrayList<>();
while(historyIter.hasNext()) {
while (historyIter.hasNext()) {
historyStreamIds.add(historyIter.next().getStreamId());
}

List<PlaylistStreamEntry> notWatchedItems = new ArrayList<>();
boolean thumbnailVideoRemoved = false;
while(playlistIter.hasNext()) {
while (playlistIter.hasNext()) {
PlaylistStreamEntry playlistItem = playlistIter.next();
int indexInHistory = Collections.binarySearch(historyStreamIds, playlistItem.getStreamId());
int indexInHistory = Collections.binarySearch(historyStreamIds,
playlistItem.getStreamId());

if (indexInHistory < 0) {
notWatchedItems.add(playlistItem);
} else if (!thumbnailVideoRemoved && playlistManager.getPlaylistThumbnail(playlistId).equals(playlistItem.getStreamEntity().getThumbnailUrl())) {
} else if (!thumbnailVideoRemoved
&& playlistManager.getPlaylistThumbnail(playlistId)
.equals(playlistItem.getStreamEntity().getThumbnailUrl())) {
thumbnailVideoRemoved = true;
}
}
Expand All @@ -403,7 +411,8 @@ public void removeWatchedStreams() {
})
.observeOn(AndroidSchedulers.mainThread())
.subscribe(flow -> {
List<PlaylistStreamEntry> notWatchedItems = (List<PlaylistStreamEntry>) flow.blockingFirst();
List<PlaylistStreamEntry> notWatchedItems =
(List<PlaylistStreamEntry>) flow.blockingFirst();
boolean thumbnailVideoRemoved = (Boolean) flow.blockingLast();

itemListAdapter.clearStreamItemList();
Expand Down

0 comments on commit 6571fdb

Please sign in to comment.