add delete options for StatisticPlaylistFragment

This commit is contained in:
Christian Schabesberger 2018-04-23 22:02:36 +02:00
parent 5e59cfcf9d
commit c470909f19
20 changed files with 50 additions and 66 deletions

View file

@ -29,7 +29,7 @@ import org.schabi.newpipe.extractor.kiosk.KioskList;
import org.schabi.newpipe.fragments.list.channel.ChannelFragment;
import org.schabi.newpipe.local.feed.FeedFragment;
import org.schabi.newpipe.fragments.list.kiosk.KioskFragment;
import org.schabi.newpipe.fragments.local.bookmark.BookmarkFragment;
import org.schabi.newpipe.local.bookmark.BookmarkFragment;
import org.schabi.newpipe.local.subscription.SubscriptionFragment;
import org.schabi.newpipe.report.ErrorActivity;
import org.schabi.newpipe.report.UserAction;

View file

@ -64,7 +64,7 @@ import org.schabi.newpipe.fragments.BackPressable;
import org.schabi.newpipe.fragments.BaseStateFragment;
import org.schabi.newpipe.util.StreamItemAdapter;
import org.schabi.newpipe.util.StreamItemAdapter.StreamSizeWrapper;
import org.schabi.newpipe.fragments.local.dialog.PlaylistAppendDialog;
import org.schabi.newpipe.local.dialog.PlaylistAppendDialog;
import org.schabi.newpipe.info_list.InfoItemBuilder;
import org.schabi.newpipe.info_list.InfoItemDialog;
import org.schabi.newpipe.player.MainVideoPlayer;

View file

@ -20,8 +20,7 @@ import org.schabi.newpipe.extractor.playlist.PlaylistInfoItem;
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import org.schabi.newpipe.fragments.BaseStateFragment;
import org.schabi.newpipe.fragments.OnScrollBelowItemsListener;
import org.schabi.newpipe.fragments.local.dialog.PlaylistAppendDialog;
import org.schabi.newpipe.local.history.HistoryInfoItem;
import org.schabi.newpipe.local.dialog.PlaylistAppendDialog;
import org.schabi.newpipe.info_list.InfoItemDialog;
import org.schabi.newpipe.info_list.InfoListAdapter;
import org.schabi.newpipe.player.playqueue.SinglePlayQueue;
@ -222,41 +221,6 @@ public abstract class BaseListFragment<I, N> extends BaseStateFragment<I> implem
new InfoItemDialog(getActivity(), item, commands, actions).show();
}
protected void showHistoryItemDialog(final HistoryInfoItem item) {
final Context context = getContext();
final Activity activity = getActivity();
if (context == null || context.getResources() == null || getActivity() == null) return;
final String[] commands = new String[]{
context.getResources().getString(R.string.enqueue_on_background),
context.getResources().getString(R.string.enqueue_on_popup),
context.getResources().getString(R.string.append_playlist),
context.getResources().getString(R.string.delete)
};
final DialogInterface.OnClickListener actions = (dialogInterface, i) -> {
switch (i) {
case 0:
NavigationHelper.enqueueOnBackgroundPlayer(context, new SinglePlayQueue(item));
break;
case 1:
NavigationHelper.enqueueOnPopupPlayer(activity, new SinglePlayQueue(item));
break;
case 2:
if (getFragmentManager() != null) {
PlaylistAppendDialog.fromStreamInfoItems(Collections.singletonList(item))
.show(getFragmentManager(), TAG);
}
break;
case 3:
default:
break;
}
};
new InfoItemDialog(getActivity(), item, commands, actions).show();
}
/*//////////////////////////////////////////////////////////////////////////
// Menu
//////////////////////////////////////////////////////////////////////////*/

View file

@ -13,7 +13,6 @@ import android.view.View;
import org.schabi.newpipe.R;
import org.schabi.newpipe.fragments.BaseStateFragment;
import org.schabi.newpipe.fragments.list.ListViewContract;
import org.schabi.newpipe.fragments.local.LocalItemListAdapter;
import static org.schabi.newpipe.util.AnimationUtils.animateView;

View file

@ -1,4 +1,4 @@
package org.schabi.newpipe.fragments.local;
package org.schabi.newpipe.local;
import android.support.v7.widget.RecyclerView;
import android.view.View;

View file

@ -1,4 +1,4 @@
package org.schabi.newpipe.fragments.local;
package org.schabi.newpipe.local;
import android.content.Context;
import android.widget.ImageView;

View file

@ -1,4 +1,4 @@
package org.schabi.newpipe.fragments.local;
package org.schabi.newpipe.local;
import android.app.Activity;
import android.support.v7.widget.RecyclerView;
@ -7,11 +7,13 @@ import android.view.View;
import android.view.ViewGroup;
import org.schabi.newpipe.database.LocalItem;
import org.schabi.newpipe.fragments.local.holder.LocalItemHolder;
import org.schabi.newpipe.fragments.local.holder.LocalPlaylistItemHolder;
import org.schabi.newpipe.fragments.local.holder.LocalPlaylistStreamItemHolder;
import org.schabi.newpipe.fragments.local.holder.LocalStatisticStreamItemHolder;
import org.schabi.newpipe.fragments.local.holder.RemotePlaylistItemHolder;
import org.schabi.newpipe.local.HeaderFooterHolder;
import org.schabi.newpipe.local.LocalItemBuilder;
import org.schabi.newpipe.local.holder.LocalItemHolder;
import org.schabi.newpipe.local.holder.LocalPlaylistItemHolder;
import org.schabi.newpipe.local.holder.LocalPlaylistStreamItemHolder;
import org.schabi.newpipe.local.holder.LocalStatisticStreamItemHolder;
import org.schabi.newpipe.local.holder.RemotePlaylistItemHolder;
import org.schabi.newpipe.util.Localization;
import org.schabi.newpipe.util.OnClickGesture;

View file

@ -1,4 +1,4 @@
package org.schabi.newpipe.fragments.local.bookmark;
package org.schabi.newpipe.local.bookmark;
import android.app.AlertDialog;
import android.os.Bundle;

View file

@ -1,4 +1,4 @@
package org.schabi.newpipe.fragments.local.dialog;
package org.schabi.newpipe.local.dialog;
import android.annotation.SuppressLint;
import android.os.Bundle;
@ -18,7 +18,7 @@ import org.schabi.newpipe.database.playlist.PlaylistMetadataEntry;
import org.schabi.newpipe.database.stream.model.StreamEntity;
import org.schabi.newpipe.extractor.stream.StreamInfo;
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import org.schabi.newpipe.fragments.local.LocalItemListAdapter;
import org.schabi.newpipe.local.LocalItemListAdapter;
import org.schabi.newpipe.local.playlist.LocalPlaylistManager;
import org.schabi.newpipe.player.playqueue.PlayQueueItem;
import org.schabi.newpipe.util.OnClickGesture;

View file

@ -1,4 +1,4 @@
package org.schabi.newpipe.fragments.local.dialog;
package org.schabi.newpipe.local.dialog;
import android.app.AlertDialog;
import android.app.Dialog;

View file

@ -1,4 +1,4 @@
package org.schabi.newpipe.fragments.local.dialog;
package org.schabi.newpipe.local.dialog;
import android.os.Bundle;
import android.support.annotation.NonNull;

View file

@ -7,6 +7,7 @@ import android.os.Bundle;
import android.os.Parcelable;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.Snackbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -250,6 +251,7 @@ public abstract class StatisticsPlaylistFragment
context.getResources().getString(R.string.start_here_on_main),
context.getResources().getString(R.string.start_here_on_background),
context.getResources().getString(R.string.start_here_on_popup),
context.getResources().getString(R.string.delete),
};
final DialogInterface.OnClickListener actions = (dialogInterface, i) -> {
@ -270,6 +272,9 @@ public abstract class StatisticsPlaylistFragment
case 4:
NavigationHelper.playOnPopupPlayer(activity, getPlayQueue(index));
break;
case 5:
deleteEntry(index);
break;
default:
break;
}
@ -278,6 +283,19 @@ public abstract class StatisticsPlaylistFragment
new InfoItemDialog(getActivity(), infoItem, commands, actions).show();
}
private void deleteEntry(final int index) {
final LocalItem infoItem = itemListAdapter.getItemsList()
.get(index);
if(infoItem instanceof StreamStatisticsEntry) {
final StreamStatisticsEntry entry = (StreamStatisticsEntry) infoItem;
recordManager.deleteStreamHistory(entry.streamId);
Snackbar.make(getView(), R.string.one_item_deleted, Snackbar.LENGTH_SHORT)
.show();
startLoading(true);
}
}
private PlayQueue getPlayQueue() {
return getPlayQueue(0);
}

View file

@ -1,11 +1,11 @@
package org.schabi.newpipe.fragments.local.holder;
package org.schabi.newpipe.local.holder;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import org.schabi.newpipe.database.LocalItem;
import org.schabi.newpipe.fragments.local.LocalItemBuilder;
import org.schabi.newpipe.local.LocalItemBuilder;
import java.text.DateFormat;

View file

@ -1,11 +1,11 @@
package org.schabi.newpipe.fragments.local.holder;
package org.schabi.newpipe.local.holder;
import android.view.View;
import android.view.ViewGroup;
import org.schabi.newpipe.database.LocalItem;
import org.schabi.newpipe.database.playlist.PlaylistMetadataEntry;
import org.schabi.newpipe.fragments.local.LocalItemBuilder;
import org.schabi.newpipe.local.LocalItemBuilder;
import org.schabi.newpipe.util.ImageDisplayConstants;
import java.text.DateFormat;

View file

@ -1,4 +1,4 @@
package org.schabi.newpipe.fragments.local.holder;
package org.schabi.newpipe.local.holder;
import android.support.v4.content.ContextCompat;
import android.view.MotionEvent;
@ -11,7 +11,7 @@ import org.schabi.newpipe.R;
import org.schabi.newpipe.database.LocalItem;
import org.schabi.newpipe.database.playlist.PlaylistStreamEntry;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.fragments.local.LocalItemBuilder;
import org.schabi.newpipe.local.LocalItemBuilder;
import org.schabi.newpipe.util.ImageDisplayConstants;
import org.schabi.newpipe.util.Localization;

View file

@ -1,4 +1,4 @@
package org.schabi.newpipe.fragments.local.holder;
package org.schabi.newpipe.local.holder;
import android.support.v4.content.ContextCompat;
import android.view.View;
@ -10,7 +10,7 @@ import org.schabi.newpipe.R;
import org.schabi.newpipe.database.LocalItem;
import org.schabi.newpipe.database.stream.StreamStatisticsEntry;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.fragments.local.LocalItemBuilder;
import org.schabi.newpipe.local.LocalItemBuilder;
import org.schabi.newpipe.util.ImageDisplayConstants;
import org.schabi.newpipe.util.Localization;

View file

@ -1,4 +1,4 @@
package org.schabi.newpipe.fragments.local.holder;
package org.schabi.newpipe.local.holder;
import android.view.ViewGroup;
import android.widget.ImageView;
@ -6,7 +6,7 @@ import android.widget.TextView;
import org.schabi.newpipe.R;
import org.schabi.newpipe.database.LocalItem;
import org.schabi.newpipe.fragments.local.LocalItemBuilder;
import org.schabi.newpipe.local.LocalItemBuilder;
import java.text.DateFormat;

View file

@ -1,11 +1,11 @@
package org.schabi.newpipe.fragments.local.holder;
package org.schabi.newpipe.local.holder;
import android.view.ViewGroup;
import org.schabi.newpipe.database.LocalItem;
import org.schabi.newpipe.database.playlist.model.PlaylistRemoteEntity;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.fragments.local.LocalItemBuilder;
import org.schabi.newpipe.local.LocalItemBuilder;
import org.schabi.newpipe.util.ImageDisplayConstants;
import org.schabi.newpipe.util.Localization;

View file

@ -29,7 +29,7 @@ import com.google.android.exoplayer2.Player;
import org.schabi.newpipe.R;
import org.schabi.newpipe.extractor.stream.StreamInfo;
import org.schabi.newpipe.fragments.OnScrollBelowItemsListener;
import org.schabi.newpipe.fragments.local.dialog.PlaylistAppendDialog;
import org.schabi.newpipe.local.dialog.PlaylistAppendDialog;
import org.schabi.newpipe.player.event.PlayerEventListener;
import org.schabi.newpipe.player.helper.PlaybackParameterDialog;
import org.schabi.newpipe.player.playqueue.PlayQueueAdapter;

View file

@ -273,6 +273,7 @@
<string name="msg_copied">Copied to clipboard</string>
<string name="no_available_dir">Please select an available download folder</string>
<string name="msg_popup_permission">This permission is needed to\nopen in popup mode</string>
<string name="one_item_deleted">1 item deleted.</string>
<!-- Checksum types -->
<string name="md5" translatable="false">MD5</string>