Moved the 'Remove Watched' button to the three dot menu button.
This commit is contained in:
parent
66c95f901d
commit
954399b255
3 changed files with 47 additions and 45 deletions
|
@ -8,6 +8,9 @@ import android.os.Parcelable;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuInflater;
|
||||||
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
@ -76,7 +79,6 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
|
||||||
private View headerPlayAllButton;
|
private View headerPlayAllButton;
|
||||||
private View headerPopupButton;
|
private View headerPopupButton;
|
||||||
private View headerBackgroundButton;
|
private View headerBackgroundButton;
|
||||||
private View headerRemoveWatchedButton;
|
|
||||||
|
|
||||||
private ItemTouchHelper itemTouchHelper;
|
private ItemTouchHelper itemTouchHelper;
|
||||||
|
|
||||||
|
@ -153,7 +155,6 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
|
||||||
headerPlayAllButton = headerRootLayout.findViewById(R.id.playlist_ctrl_play_all_button);
|
headerPlayAllButton = headerRootLayout.findViewById(R.id.playlist_ctrl_play_all_button);
|
||||||
headerPopupButton = headerRootLayout.findViewById(R.id.playlist_ctrl_play_popup_button);
|
headerPopupButton = headerRootLayout.findViewById(R.id.playlist_ctrl_play_popup_button);
|
||||||
headerBackgroundButton = headerRootLayout.findViewById(R.id.playlist_ctrl_play_bg_button);
|
headerBackgroundButton = headerRootLayout.findViewById(R.id.playlist_ctrl_play_bg_button);
|
||||||
headerRemoveWatchedButton = headerRootLayout.findViewById(R.id.playlist_ctrl_remove_watched_button);
|
|
||||||
|
|
||||||
return headerRootLayout;
|
return headerRootLayout;
|
||||||
}
|
}
|
||||||
|
@ -252,6 +253,14 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
|
||||||
saveImmediate();
|
saveImmediate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreateOptionsMenu(Menu menu, 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);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroyView() {
|
public void onDestroyView() {
|
||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
|
@ -268,9 +277,6 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
|
||||||
if (headerPopupButton != null) {
|
if (headerPopupButton != null) {
|
||||||
headerPopupButton.setOnClickListener(null);
|
headerPopupButton.setOnClickListener(null);
|
||||||
}
|
}
|
||||||
if (headerRemoveWatchedButton != null) {
|
|
||||||
headerRemoveWatchedButton.setOnClickListener(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (databaseSubscription != null) {
|
if (databaseSubscription != null) {
|
||||||
databaseSubscription.cancel();
|
databaseSubscription.cancel();
|
||||||
|
@ -342,6 +348,20 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
switch (item.getItemId()) {
|
||||||
|
case R.id.menu_item_removeWatched:
|
||||||
|
//Solution, Scorched Earth, Copy non duplicates, clear playlist, then copy back over
|
||||||
|
//Other options didn't work as intended, or crashed. Like deleteItem(playlist_item) crashes when called in this function.
|
||||||
|
new RemoveWatchedStreams().execute();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleResult(@NonNull final List<PlaylistStreamEntry> result) {
|
public void handleResult(@NonNull final List<PlaylistStreamEntry> result) {
|
||||||
super.handleResult(result);
|
super.handleResult(result);
|
||||||
|
@ -369,13 +389,6 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
|
||||||
NavigationHelper.playOnPopupPlayer(activity, getPlayQueue(), false));
|
NavigationHelper.playOnPopupPlayer(activity, getPlayQueue(), false));
|
||||||
headerBackgroundButton.setOnClickListener(view ->
|
headerBackgroundButton.setOnClickListener(view ->
|
||||||
NavigationHelper.playOnBackgroundPlayer(activity, getPlayQueue(), false));
|
NavigationHelper.playOnBackgroundPlayer(activity, getPlayQueue(), false));
|
||||||
headerRemoveWatchedButton.setOnClickListener(
|
|
||||||
view -> {
|
|
||||||
//Solution, Scorched Earth, Copy non duplicates, clear playlist, then copy back over
|
|
||||||
//Other options didn't work as intended, or crashed. Like deleteItem(playlist_item) crashes when called in this function.
|
|
||||||
new RemoveWatchedStreams().execute();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
headerPopupButton.setOnLongClickListener(view -> {
|
headerPopupButton.setOnLongClickListener(view -> {
|
||||||
NavigationHelper.enqueueOnPopupPlayer(activity, getPlayQueue(), true);
|
NavigationHelper.enqueueOnPopupPlayer(activity, getPlayQueue(), true);
|
||||||
|
@ -706,7 +719,7 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
|
||||||
private class RemoveWatchedStreams extends AsyncTask<String, Long, Long> {
|
private class RemoveWatchedStreams extends AsyncTask<String, Long, Long> {
|
||||||
List<PlaylistStreamEntry> localItems = new ArrayList<>();
|
List<PlaylistStreamEntry> localItems = new ArrayList<>();
|
||||||
Long RemovedItemCount = 0l;
|
Long RemovedItemCount = 0l;
|
||||||
boolean thumbNailVideoRemoved = false;
|
boolean thumbnailVideoRemoved = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPreExecute() {
|
protected void onPreExecute() {
|
||||||
|
@ -749,7 +762,7 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
|
||||||
RemovedItemCount++;
|
RemovedItemCount++;
|
||||||
if(playlistManager.getPlaylistThumbnail(playlistId).equals(playlist_item.thumbnailUrl))
|
if(playlistManager.getPlaylistThumbnail(playlistId).equals(playlist_item.thumbnailUrl))
|
||||||
{
|
{
|
||||||
thumbNailVideoRemoved = true;
|
thumbnailVideoRemoved = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -762,13 +775,17 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
|
||||||
itemListAdapter.addItems(localItems);
|
itemListAdapter.addItems(localItems);
|
||||||
localItems.clear();
|
localItems.clear();
|
||||||
|
|
||||||
if (thumbNailVideoRemoved)
|
if (thumbnailVideoRemoved)
|
||||||
updateThumbnailUrl();
|
updateThumbnailUrl();
|
||||||
|
|
||||||
setVideoCount(itemListAdapter.getItemsList().size());
|
int amountOfVideos = itemListAdapter.getItemsList().size();
|
||||||
|
setVideoCount(amountOfVideos);
|
||||||
|
|
||||||
saveChanges();
|
saveChanges();
|
||||||
hideLoading();
|
hideLoading();
|
||||||
|
|
||||||
|
if(amountOfVideos == 0)
|
||||||
|
showEmptyState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -30,6 +32,7 @@
|
||||||
android:drawableStart="?attr/audio"/>
|
android:drawableStart="?attr/audio"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
<View android:id="@+id/anchorLeft"
|
<View android:id="@+id/anchorLeft"
|
||||||
android:layout_width="1dp"
|
android:layout_width="1dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
@ -56,7 +59,7 @@
|
||||||
android:textColor="?attr/colorAccent"/>
|
android:textColor="?attr/colorAccent"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<View android:id="@+id/anchorMiddle"
|
<View android:id="@+id/anchorRight"
|
||||||
android:layout_width="1dp"
|
android:layout_width="1dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:clickable="false"
|
android:clickable="false"
|
||||||
|
@ -84,32 +87,4 @@
|
||||||
android:drawableLeft="?attr/popup"
|
android:drawableLeft="?attr/popup"
|
||||||
android:drawableStart="?attr/popup"/>
|
android:drawableStart="?attr/popup"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<View android:id="@+id/anchorRight"
|
|
||||||
android:layout_width="1dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:clickable="false"
|
|
||||||
android:layout_marginBottom="@dimen/playlist_ctrl_seperator_margin"
|
|
||||||
android:layout_marginTop="@dimen/playlist_ctrl_seperator_margin"
|
|
||||||
android:background="?attr/colorAccent"/>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="1.2"
|
|
||||||
android:gravity="center"
|
|
||||||
android:clickable="true"
|
|
||||||
android:focusable="true"
|
|
||||||
android:background="?attr/selectableItemBackground"
|
|
||||||
android:id="@+id/playlist_ctrl_remove_watched_button">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:paddingLeft="15px"
|
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:text="@string/remove_watched"
|
|
||||||
android:textColor="?attr/colorAccent"
|
|
||||||
android:textSize="@dimen/channel_rss_title_size" />
|
|
||||||
</LinearLayout>
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
10
app/src/main/res/menu/menu_local_playlist.xml
Normal file
10
app/src/main/res/menu/menu_local_playlist.xml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/menu_item_removeWatched"
|
||||||
|
android:title="@string/remove_watched"
|
||||||
|
app:showAsAction="never"/>
|
||||||
|
</menu>
|
Loading…
Reference in a new issue