Fix whitespace

This commit is contained in:
Anderson Mesquita 2019-05-26 07:41:47 -04:00
parent 486ceed0ef
commit aabe370db3
3 changed files with 48 additions and 44 deletions

View File

@ -21,11 +21,14 @@ import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import com.yqritc.recyclerviewflexibledivider.HorizontalDividerItemDecoration; import com.yqritc.recyclerviewflexibledivider.HorizontalDividerItemDecoration;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.util.List; import java.util.List;
import de.danoeh.antennapod.R; import de.danoeh.antennapod.R;
@ -50,15 +53,11 @@ import de.danoeh.antennapod.core.util.FeedItemUtil;
import de.danoeh.antennapod.core.util.LongList; import de.danoeh.antennapod.core.util.LongList;
import de.danoeh.antennapod.menuhandler.FeedItemMenuHandler; import de.danoeh.antennapod.menuhandler.FeedItemMenuHandler;
import de.danoeh.antennapod.menuhandler.MenuItemUtils; import de.danoeh.antennapod.menuhandler.MenuItemUtils;
import de.danoeh.antennapod.view.EmptyViewHandler; import de.danoeh.antennapod.view.EmptyViewHandler;
import io.reactivex.Observable; import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable; import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers; import io.reactivex.schedulers.Schedulers;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
/** /**
* Shows unread or recently published episodes * Shows unread or recently published episodes
@ -93,8 +92,13 @@ public class AllEpisodesFragment extends Fragment {
Disposable disposable; Disposable disposable;
private LinearLayoutManager layoutManager; private LinearLayoutManager layoutManager;
boolean showOnlyNewEpisodes() { return false; } boolean showOnlyNewEpisodes() {
String getPrefName() { return DEFAULT_PREF_NAME; } return false;
}
String getPrefName() {
return DEFAULT_PREF_NAME;
}
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
@ -146,7 +150,7 @@ public class AllEpisodesFragment extends Fragment {
int firstItem = layoutManager.findFirstVisibleItemPosition(); int firstItem = layoutManager.findFirstVisibleItemPosition();
View firstItemView = layoutManager.findViewByPosition(firstItem); View firstItemView = layoutManager.findViewByPosition(firstItem);
float topOffset; float topOffset;
if(firstItemView == null) { if (firstItemView == null) {
topOffset = 0; topOffset = 0;
} else { } else {
topOffset = firstItemView.getTop(); topOffset = firstItemView.getTop();
@ -184,7 +188,7 @@ public class AllEpisodesFragment extends Fragment {
@Override @Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
if(!isAdded()) { if (!isAdded()) {
return; return;
} }
super.onCreateOptionsMenu(menu, inflater); super.onCreateOptionsMenu(menu, inflater);
@ -220,7 +224,7 @@ public class AllEpisodesFragment extends Fragment {
markAllRead.setVisible(!showOnlyNewEpisodes() && episodes != null && !episodes.isEmpty()); markAllRead.setVisible(!showOnlyNewEpisodes() && episodes != null && !episodes.isEmpty());
} }
MenuItem markAllSeen = menu.findItem(R.id.mark_all_seen_item); MenuItem markAllSeen = menu.findItem(R.id.mark_all_seen_item);
if(markAllSeen != null) { if (markAllSeen != null) {
markAllSeen.setVisible(showOnlyNewEpisodes() && episodes != null && !episodes.isEmpty()); markAllSeen.setVisible(showOnlyNewEpisodes() && episodes != null && !episodes.isEmpty());
} }
} }
@ -275,10 +279,10 @@ public class AllEpisodesFragment extends Fragment {
@Override @Override
public boolean onContextItemSelected(MenuItem item) { public boolean onContextItemSelected(MenuItem item) {
Log.d(TAG, "onContextItemSelected() called with: " + "item = [" + item + "]"); Log.d(TAG, "onContextItemSelected() called with: " + "item = [" + item + "]");
if(!isVisible()) { if (!isVisible()) {
return false; return false;
} }
if(item.getItemId() == R.id.share_item) { if (item.getItemId() == R.id.share_item) {
return true; // avoids that the position is reset when we need it in the submenu return true; // avoids that the position is reset when we need it in the submenu
} }
@ -387,11 +391,11 @@ public class AllEpisodesFragment extends Fragment {
@Override @Override
public LongList getItemsIds() { public LongList getItemsIds() {
if(episodes == null) { if (episodes == null) {
return new LongList(0); return new LongList(0);
} }
LongList ids = new LongList(episodes.size()); LongList ids = new LongList(episodes.size());
for(FeedItem episode : episodes) { for (FeedItem episode : episodes) {
ids.add(episode.getId()); ids.add(episode.getId());
} }
return ids; return ids;
@ -418,11 +422,11 @@ public class AllEpisodesFragment extends Fragment {
@Override @Override
public LongList getQueueIds() { public LongList getQueueIds() {
LongList queueIds = new LongList(); LongList queueIds = new LongList();
if(episodes == null) { if (episodes == null) {
return queueIds; return queueIds;
} }
for(FeedItem item : episodes) { for (FeedItem item : episodes) {
if(item.isTagged(FeedItem.TAG_QUEUE)) { if (item.isTagged(FeedItem.TAG_QUEUE)) {
queueIds.add(item.getId()); queueIds.add(item.getId());
} }
} }
@ -464,16 +468,16 @@ public class AllEpisodesFragment extends Fragment {
DownloaderUpdate update = event.update; DownloaderUpdate update = event.update;
downloaderList = update.downloaders; downloaderList = update.downloaders;
if (isMenuInvalidationAllowed && isUpdatingFeeds != update.feedIds.length > 0) { if (isMenuInvalidationAllowed && isUpdatingFeeds != update.feedIds.length > 0) {
getActivity().supportInvalidateOptionsMenu(); getActivity().supportInvalidateOptionsMenu();
} }
if (listAdapter == null) { if (listAdapter == null) {
loadItems(); loadItems();
return; return;
} }
if (update.mediaIds.length > 0) { if (update.mediaIds.length > 0) {
for(long mediaId : update.mediaIds) { for (long mediaId : update.mediaIds) {
int pos = FeedItemUtil.indexOfItemWithMediaId(episodes, mediaId); int pos = FeedItemUtil.indexOfItemWithMediaId(episodes, mediaId);
if(pos >= 0) { if (pos >= 0) {
listAdapter.notifyItemChanged(pos); listAdapter.notifyItemChanged(pos);
} }
} }
@ -537,7 +541,7 @@ public class AllEpisodesFragment extends Fragment {
DBWriter.markItemPlayed(FeedItem.UNPLAYED, item.getId()); DBWriter.markItemPlayed(FeedItem.UNPLAYED, item.getId());
final Handler h = new Handler(getActivity().getMainLooper()); final Handler h = new Handler(getActivity().getMainLooper());
final Runnable r = () -> { final Runnable r = () -> {
FeedMedia media = item.getMedia(); FeedMedia media = item.getMedia();
if (media != null && media.hasAlmostEnded() && UserPreferences.isAutoDelete()) { if (media != null && media.hasAlmostEnded() && UserPreferences.isAutoDelete()) {
DBWriter.deleteFeedMediaOfItem(getActivity(), media.getId()); DBWriter.deleteFeedMediaOfItem(getActivity(), media.getId());
@ -552,7 +556,6 @@ public class AllEpisodesFragment extends Fragment {
h.removeCallbacks(r); h.removeCallbacks(r);
}); });
snackbar.show(); snackbar.show();
h.postDelayed(r, (int)Math.ceil(snackbar.getDuration() * 1.05f)); h.postDelayed(r, (int) Math.ceil(snackbar.getDuration() * 1.05f));
} }
} }

View File

@ -8,7 +8,8 @@ import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.TextView;
import org.greenrobot.eventbus.Subscribe;
import java.util.List; import java.util.List;
@ -18,15 +19,11 @@ import de.danoeh.antennapod.core.event.FavoritesEvent;
import de.danoeh.antennapod.core.feed.FeedItem; import de.danoeh.antennapod.core.feed.FeedItem;
import de.danoeh.antennapod.core.storage.DBReader; import de.danoeh.antennapod.core.storage.DBReader;
import de.danoeh.antennapod.core.storage.DBWriter; import de.danoeh.antennapod.core.storage.DBWriter;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
/** /**
* Like 'EpisodesFragment' except that it only shows favorite episodes and * Like 'EpisodesFragment' except that it only shows favorite episodes and
* supports swiping to remove from favorites. * supports swiping to remove from favorites.
*/ */
public class FavoriteEpisodesFragment extends AllEpisodesFragment { public class FavoriteEpisodesFragment extends AllEpisodesFragment {
private static final String TAG = "FavoriteEpisodesFrag"; private static final String TAG = "FavoriteEpisodesFrag";
@ -34,10 +31,14 @@ public class FavoriteEpisodesFragment extends AllEpisodesFragment {
private static final String PREF_NAME = "PrefFavoriteEpisodesFragment"; private static final String PREF_NAME = "PrefFavoriteEpisodesFragment";
@Override @Override
protected boolean showOnlyNewEpisodes() { return true; } protected boolean showOnlyNewEpisodes() {
return true;
}
@Override @Override
protected String getPrefName() { return PREF_NAME; } protected String getPrefName() {
return PREF_NAME;
}
@Subscribe @Subscribe
public void onEvent(FavoritesEvent event) { public void onEvent(FavoritesEvent event) {
@ -65,7 +66,7 @@ public class FavoriteEpisodesFragment extends AllEpisodesFragment {
@Override @Override
public void onSwiped(RecyclerView.ViewHolder viewHolder, int swipeDir) { public void onSwiped(RecyclerView.ViewHolder viewHolder, int swipeDir) {
AllEpisodesRecycleAdapter.Holder holder = (AllEpisodesRecycleAdapter.Holder)viewHolder; AllEpisodesRecycleAdapter.Holder holder = (AllEpisodesRecycleAdapter.Holder) viewHolder;
Log.d(TAG, "remove(" + holder.getItemId() + ")"); Log.d(TAG, "remove(" + holder.getItemId() + ")");
if (disposable != null) { if (disposable != null) {
@ -75,8 +76,7 @@ public class FavoriteEpisodesFragment extends AllEpisodesFragment {
if (item != null) { if (item != null) {
DBWriter.removeFavoriteItem(item); DBWriter.removeFavoriteItem(item);
Snackbar snackbar = Snackbar.make(root, getString(R.string.removed_item), Snackbar snackbar = Snackbar.make(root, getString(R.string.removed_item), Snackbar.LENGTH_LONG);
Snackbar.LENGTH_LONG);
snackbar.setAction(getString(R.string.undo), v -> DBWriter.addFavoriteItem(item)); snackbar.setAction(getString(R.string.undo), v -> DBWriter.addFavoriteItem(item));
snackbar.show(); snackbar.show();
} }

View File

@ -3,34 +3,35 @@ package de.danoeh.antennapod.fragment;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.helper.ItemTouchHelper; import android.support.v7.widget.helper.ItemTouchHelper;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.TextView;
import java.util.List; import java.util.List;
import de.danoeh.antennapod.R; import de.danoeh.antennapod.R;
import de.danoeh.antennapod.adapter.AllEpisodesRecycleAdapter; import de.danoeh.antennapod.adapter.AllEpisodesRecycleAdapter;
import de.danoeh.antennapod.core.event.FeedItemEvent;
import de.danoeh.antennapod.core.feed.FeedItem; import de.danoeh.antennapod.core.feed.FeedItem;
import de.danoeh.antennapod.core.storage.DBReader; import de.danoeh.antennapod.core.storage.DBReader;
import de.danoeh.antennapod.core.util.FeedItemUtil;
/** /**
* Like 'EpisodesFragment' except that it only shows new episodes and * Like 'EpisodesFragment' except that it only shows new episodes and
* supports swiping to mark as read. * supports swiping to mark as read.
*/ */
public class NewEpisodesFragment extends AllEpisodesFragment { public class NewEpisodesFragment extends AllEpisodesFragment {
public static final String TAG = "NewEpisodesFragment"; public static final String TAG = "NewEpisodesFragment";
private static final String PREF_NAME = "PrefNewEpisodesFragment"; private static final String PREF_NAME = "PrefNewEpisodesFragment";
@Override
protected boolean showOnlyNewEpisodes() { return true; }
@Override @Override
protected String getPrefName() { return PREF_NAME; } protected boolean showOnlyNewEpisodes() {
return true;
}
@Override
protected String getPrefName() {
return PREF_NAME;
}
@Override @Override
protected void resetViewState() { protected void resetViewState() {
@ -57,7 +58,7 @@ public class NewEpisodesFragment extends AllEpisodesFragment {
@Override @Override
public void onSwiped(RecyclerView.ViewHolder viewHolder, int swipeDir) { public void onSwiped(RecyclerView.ViewHolder viewHolder, int swipeDir) {
AllEpisodesRecycleAdapter.Holder holder = (AllEpisodesRecycleAdapter.Holder)viewHolder; AllEpisodesRecycleAdapter.Holder holder = (AllEpisodesRecycleAdapter.Holder) viewHolder;
markItemAsSeenWithUndo(holder.getFeedItem()); markItemAsSeenWithUndo(holder.getFeedItem());
} }
@ -75,6 +76,7 @@ public class NewEpisodesFragment extends AllEpisodesFragment {
super.onSelectedChanged(viewHolder, actionState); super.onSelectedChanged(viewHolder, actionState);
} }
@Override @Override
public void clearView(RecyclerView recyclerView, public void clearView(RecyclerView recyclerView,
RecyclerView.ViewHolder viewHolder) { RecyclerView.ViewHolder viewHolder) {
@ -98,5 +100,4 @@ public class NewEpisodesFragment extends AllEpisodesFragment {
protected List<FeedItem> loadData() { protected List<FeedItem> loadData() {
return DBReader.getNewItemsList(); return DBReader.getNewItemsList();
} }
} }