Use new item holder
This commit is contained in:
parent
3c48825699
commit
0aa08a5e40
6 changed files with 163 additions and 49 deletions
|
@ -13,6 +13,7 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||||
import org.schabi.newpipe.database.LocalItem;
|
import org.schabi.newpipe.database.LocalItem;
|
||||||
import org.schabi.newpipe.database.stream.model.StreamStateEntity;
|
import org.schabi.newpipe.database.stream.model.StreamStateEntity;
|
||||||
import org.schabi.newpipe.local.history.HistoryRecordManager;
|
import org.schabi.newpipe.local.history.HistoryRecordManager;
|
||||||
|
import org.schabi.newpipe.local.holder.LocalBookmarkPlaylistItemHolder;
|
||||||
import org.schabi.newpipe.local.holder.LocalItemHolder;
|
import org.schabi.newpipe.local.holder.LocalItemHolder;
|
||||||
import org.schabi.newpipe.local.holder.LocalPlaylistGridItemHolder;
|
import org.schabi.newpipe.local.holder.LocalPlaylistGridItemHolder;
|
||||||
import org.schabi.newpipe.local.holder.LocalPlaylistItemHolder;
|
import org.schabi.newpipe.local.holder.LocalPlaylistItemHolder;
|
||||||
|
@ -20,6 +21,7 @@ import org.schabi.newpipe.local.holder.LocalPlaylistStreamGridItemHolder;
|
||||||
import org.schabi.newpipe.local.holder.LocalPlaylistStreamItemHolder;
|
import org.schabi.newpipe.local.holder.LocalPlaylistStreamItemHolder;
|
||||||
import org.schabi.newpipe.local.holder.LocalStatisticStreamGridItemHolder;
|
import org.schabi.newpipe.local.holder.LocalStatisticStreamGridItemHolder;
|
||||||
import org.schabi.newpipe.local.holder.LocalStatisticStreamItemHolder;
|
import org.schabi.newpipe.local.holder.LocalStatisticStreamItemHolder;
|
||||||
|
import org.schabi.newpipe.local.holder.RemoteBookmarkPlaylistItemHolder;
|
||||||
import org.schabi.newpipe.local.holder.RemotePlaylistGridItemHolder;
|
import org.schabi.newpipe.local.holder.RemotePlaylistGridItemHolder;
|
||||||
import org.schabi.newpipe.local.holder.RemotePlaylistItemHolder;
|
import org.schabi.newpipe.local.holder.RemotePlaylistItemHolder;
|
||||||
import org.schabi.newpipe.util.FallbackViewHolder;
|
import org.schabi.newpipe.util.FallbackViewHolder;
|
||||||
|
@ -66,6 +68,8 @@ public class LocalItemListAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||||
private static final int REMOTE_PLAYLIST_HOLDER_TYPE = 0x2001;
|
private static final int REMOTE_PLAYLIST_HOLDER_TYPE = 0x2001;
|
||||||
private static final int LOCAL_PLAYLIST_GRID_HOLDER_TYPE = 0x2002;
|
private static final int LOCAL_PLAYLIST_GRID_HOLDER_TYPE = 0x2002;
|
||||||
private static final int REMOTE_PLAYLIST_GRID_HOLDER_TYPE = 0x2004;
|
private static final int REMOTE_PLAYLIST_GRID_HOLDER_TYPE = 0x2004;
|
||||||
|
private static final int LOCAL_BOOKMARK_PLAYLIST_HOLDER_TYPE = 0x2008;
|
||||||
|
private static final int REMOTE_BOOKMARK_PLAYLIST_HOLDER_TYPE = 0x2010;
|
||||||
|
|
||||||
private final LocalItemBuilder localItemBuilder;
|
private final LocalItemBuilder localItemBuilder;
|
||||||
private final ArrayList<LocalItem> localItems;
|
private final ArrayList<LocalItem> localItems;
|
||||||
|
@ -74,6 +78,7 @@ public class LocalItemListAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||||
|
|
||||||
private boolean showFooter = false;
|
private boolean showFooter = false;
|
||||||
private boolean useGridVariant = false;
|
private boolean useGridVariant = false;
|
||||||
|
private boolean useItemHandle = false;
|
||||||
private View header = null;
|
private View header = null;
|
||||||
private View footer = null;
|
private View footer = null;
|
||||||
|
|
||||||
|
@ -169,6 +174,10 @@ public class LocalItemListAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||||
this.useGridVariant = useGridVariant;
|
this.useGridVariant = useGridVariant;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setUseItemHandle(final boolean useItemHandle) {
|
||||||
|
this.useItemHandle = useItemHandle;
|
||||||
|
}
|
||||||
|
|
||||||
public void setHeader(final View header) {
|
public void setHeader(final View header) {
|
||||||
final boolean changed = header != this.header;
|
final boolean changed = header != this.header;
|
||||||
this.header = header;
|
this.header = header;
|
||||||
|
@ -247,11 +256,11 @@ public class LocalItemListAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||||
|
|
||||||
switch (item.getLocalItemType()) {
|
switch (item.getLocalItemType()) {
|
||||||
case PLAYLIST_LOCAL_ITEM:
|
case PLAYLIST_LOCAL_ITEM:
|
||||||
return useGridVariant
|
return useItemHandle ? LOCAL_BOOKMARK_PLAYLIST_HOLDER_TYPE : (useGridVariant
|
||||||
? LOCAL_PLAYLIST_GRID_HOLDER_TYPE : LOCAL_PLAYLIST_HOLDER_TYPE;
|
? LOCAL_PLAYLIST_GRID_HOLDER_TYPE : LOCAL_PLAYLIST_HOLDER_TYPE);
|
||||||
case PLAYLIST_REMOTE_ITEM:
|
case PLAYLIST_REMOTE_ITEM:
|
||||||
return useGridVariant
|
return useItemHandle ? REMOTE_BOOKMARK_PLAYLIST_HOLDER_TYPE : (useGridVariant
|
||||||
? REMOTE_PLAYLIST_GRID_HOLDER_TYPE : REMOTE_PLAYLIST_HOLDER_TYPE;
|
? REMOTE_PLAYLIST_GRID_HOLDER_TYPE : REMOTE_PLAYLIST_HOLDER_TYPE);
|
||||||
|
|
||||||
case PLAYLIST_STREAM_ITEM:
|
case PLAYLIST_STREAM_ITEM:
|
||||||
return useGridVariant
|
return useGridVariant
|
||||||
|
@ -283,10 +292,14 @@ public class LocalItemListAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||||
return new LocalPlaylistItemHolder(localItemBuilder, parent);
|
return new LocalPlaylistItemHolder(localItemBuilder, parent);
|
||||||
case LOCAL_PLAYLIST_GRID_HOLDER_TYPE:
|
case LOCAL_PLAYLIST_GRID_HOLDER_TYPE:
|
||||||
return new LocalPlaylistGridItemHolder(localItemBuilder, parent);
|
return new LocalPlaylistGridItemHolder(localItemBuilder, parent);
|
||||||
|
case LOCAL_BOOKMARK_PLAYLIST_HOLDER_TYPE:
|
||||||
|
return new LocalBookmarkPlaylistItemHolder(localItemBuilder, parent);
|
||||||
case REMOTE_PLAYLIST_HOLDER_TYPE:
|
case REMOTE_PLAYLIST_HOLDER_TYPE:
|
||||||
return new RemotePlaylistItemHolder(localItemBuilder, parent);
|
return new RemotePlaylistItemHolder(localItemBuilder, parent);
|
||||||
case REMOTE_PLAYLIST_GRID_HOLDER_TYPE:
|
case REMOTE_PLAYLIST_GRID_HOLDER_TYPE:
|
||||||
return new RemotePlaylistGridItemHolder(localItemBuilder, parent);
|
return new RemotePlaylistGridItemHolder(localItemBuilder, parent);
|
||||||
|
case REMOTE_BOOKMARK_PLAYLIST_HOLDER_TYPE:
|
||||||
|
return new RemoteBookmarkPlaylistItemHolder(localItemBuilder, parent);
|
||||||
case STREAM_PLAYLIST_HOLDER_TYPE:
|
case STREAM_PLAYLIST_HOLDER_TYPE:
|
||||||
return new LocalPlaylistStreamItemHolder(localItemBuilder, parent);
|
return new LocalPlaylistStreamItemHolder(localItemBuilder, parent);
|
||||||
case STREAM_PLAYLIST_GRID_HOLDER_TYPE:
|
case STREAM_PLAYLIST_GRID_HOLDER_TYPE:
|
||||||
|
|
|
@ -31,8 +31,8 @@ import org.schabi.newpipe.databinding.DialogEditTextBinding;
|
||||||
import org.schabi.newpipe.error.ErrorInfo;
|
import org.schabi.newpipe.error.ErrorInfo;
|
||||||
import org.schabi.newpipe.error.UserAction;
|
import org.schabi.newpipe.error.UserAction;
|
||||||
import org.schabi.newpipe.local.BaseLocalListFragment;
|
import org.schabi.newpipe.local.BaseLocalListFragment;
|
||||||
import org.schabi.newpipe.local.holder.LocalPlaylistItemHolder;
|
import org.schabi.newpipe.local.holder.LocalBookmarkPlaylistItemHolder;
|
||||||
import org.schabi.newpipe.local.holder.RemotePlaylistItemHolder;
|
import org.schabi.newpipe.local.holder.RemoteBookmarkPlaylistItemHolder;
|
||||||
import org.schabi.newpipe.local.playlist.LocalPlaylistManager;
|
import org.schabi.newpipe.local.playlist.LocalPlaylistManager;
|
||||||
import org.schabi.newpipe.local.playlist.RemotePlaylistManager;
|
import org.schabi.newpipe.local.playlist.RemotePlaylistManager;
|
||||||
import org.schabi.newpipe.util.NavigationHelper;
|
import org.schabi.newpipe.util.NavigationHelper;
|
||||||
|
@ -53,7 +53,6 @@ import io.reactivex.rxjava3.disposables.Disposable;
|
||||||
import io.reactivex.rxjava3.subjects.PublishSubject;
|
import io.reactivex.rxjava3.subjects.PublishSubject;
|
||||||
|
|
||||||
public final class BookmarkFragment extends BaseLocalListFragment<List<PlaylistLocalItem>, Void> {
|
public final class BookmarkFragment extends BaseLocalListFragment<List<PlaylistLocalItem>, Void> {
|
||||||
// todo: add to playlists, item handle should be invisible
|
|
||||||
|
|
||||||
// Save the list 10s after the last change occurred
|
// Save the list 10s after the last change occurred
|
||||||
private static final long SAVE_DEBOUNCE_MILLIS = 10000;
|
private static final long SAVE_DEBOUNCE_MILLIS = 10000;
|
||||||
|
@ -126,6 +125,8 @@ public final class BookmarkFragment extends BaseLocalListFragment<List<PlaylistL
|
||||||
@Override
|
@Override
|
||||||
protected void initViews(final View rootView, final Bundle savedInstanceState) {
|
protected void initViews(final View rootView, final Bundle savedInstanceState) {
|
||||||
super.initViews(rootView, savedInstanceState);
|
super.initViews(rootView, savedInstanceState);
|
||||||
|
|
||||||
|
itemListAdapter.setUseItemHandle(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -530,15 +531,16 @@ public final class BookmarkFragment extends BaseLocalListFragment<List<PlaylistL
|
||||||
@NonNull final RecyclerView.ViewHolder target) {
|
@NonNull final RecyclerView.ViewHolder target) {
|
||||||
if (source.getItemViewType() != target.getItemViewType()
|
if (source.getItemViewType() != target.getItemViewType()
|
||||||
|| itemListAdapter == null) {
|
|| itemListAdapter == null) {
|
||||||
// Allow swap LocalPlaylistItemHolder and RemotePlaylistItemHolder.
|
// Allow swap LocalBookmarkPlaylistItemHolder and
|
||||||
|
// RemoteBookmarkPlaylistItemHolder.
|
||||||
if (!(
|
if (!(
|
||||||
(
|
(
|
||||||
(source instanceof LocalPlaylistItemHolder)
|
(source instanceof LocalBookmarkPlaylistItemHolder)
|
||||||
|| (source instanceof RemotePlaylistItemHolder)
|
|| (source instanceof RemoteBookmarkPlaylistItemHolder)
|
||||||
)
|
)
|
||||||
&& (
|
&& (
|
||||||
(target instanceof LocalPlaylistItemHolder)
|
(target instanceof LocalBookmarkPlaylistItemHolder)
|
||||||
|| (target instanceof RemotePlaylistItemHolder)
|
|| (target instanceof RemoteBookmarkPlaylistItemHolder)
|
||||||
)
|
)
|
||||||
)) {
|
)) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -0,0 +1,63 @@
|
||||||
|
package org.schabi.newpipe.local.holder;
|
||||||
|
|
||||||
|
import android.view.MotionEvent;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import org.schabi.newpipe.R;
|
||||||
|
import org.schabi.newpipe.database.LocalItem;
|
||||||
|
import org.schabi.newpipe.database.playlist.PlaylistMetadataEntry;
|
||||||
|
import org.schabi.newpipe.local.LocalItemBuilder;
|
||||||
|
import org.schabi.newpipe.local.history.HistoryRecordManager;
|
||||||
|
import org.schabi.newpipe.util.Localization;
|
||||||
|
import org.schabi.newpipe.util.PicassoHelper;
|
||||||
|
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
|
public class LocalBookmarkPlaylistItemHolder extends PlaylistItemHolder {
|
||||||
|
private final View itemHandleView;
|
||||||
|
|
||||||
|
public LocalBookmarkPlaylistItemHolder(final LocalItemBuilder infoItemBuilder,
|
||||||
|
final ViewGroup parent) {
|
||||||
|
this(infoItemBuilder, R.layout.list_playlist_bookmark_item, parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
LocalBookmarkPlaylistItemHolder(final LocalItemBuilder infoItemBuilder, final int layoutId,
|
||||||
|
final ViewGroup parent) {
|
||||||
|
super(infoItemBuilder, layoutId, parent);
|
||||||
|
itemHandleView = itemView.findViewById(R.id.itemHandle);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateFromItem(final LocalItem localItem,
|
||||||
|
final HistoryRecordManager historyRecordManager,
|
||||||
|
final DateTimeFormatter dateTimeFormatter) {
|
||||||
|
if (!(localItem instanceof PlaylistMetadataEntry)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final PlaylistMetadataEntry item = (PlaylistMetadataEntry) localItem;
|
||||||
|
|
||||||
|
itemTitleView.setText(item.name);
|
||||||
|
itemStreamCountView.setText(Localization.localizeStreamCountMini(
|
||||||
|
itemStreamCountView.getContext(), item.streamCount));
|
||||||
|
itemUploaderView.setVisibility(View.INVISIBLE);
|
||||||
|
|
||||||
|
PicassoHelper.loadPlaylistThumbnail(item.thumbnailUrl).into(itemThumbnailView);
|
||||||
|
|
||||||
|
itemHandleView.setOnTouchListener(getOnTouchListener(item));
|
||||||
|
|
||||||
|
super.updateFromItem(localItem, historyRecordManager, dateTimeFormatter);
|
||||||
|
}
|
||||||
|
|
||||||
|
private View.OnTouchListener getOnTouchListener(final PlaylistMetadataEntry item) {
|
||||||
|
return (view, motionEvent) -> {
|
||||||
|
view.performClick();
|
||||||
|
if (itemBuilder != null && itemBuilder.getOnItemSelectedListener() != null
|
||||||
|
&& motionEvent.getActionMasked() == MotionEvent.ACTION_DOWN) {
|
||||||
|
itemBuilder.getOnItemSelectedListener().drag(item,
|
||||||
|
LocalBookmarkPlaylistItemHolder.this);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,5 @@
|
||||||
package org.schabi.newpipe.local.holder;
|
package org.schabi.newpipe.local.holder;
|
||||||
|
|
||||||
import android.view.MotionEvent;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
@ -15,16 +14,14 @@ import org.schabi.newpipe.util.Localization;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
public class LocalPlaylistItemHolder extends PlaylistItemHolder {
|
public class LocalPlaylistItemHolder extends PlaylistItemHolder {
|
||||||
private final View itemHandleView;
|
|
||||||
|
|
||||||
public LocalPlaylistItemHolder(final LocalItemBuilder infoItemBuilder, final ViewGroup parent) {
|
public LocalPlaylistItemHolder(final LocalItemBuilder infoItemBuilder, final ViewGroup parent) {
|
||||||
this(infoItemBuilder, R.layout.list_playlist_bookmark_item, parent);
|
this(infoItemBuilder, R.layout.list_playlist_mini_item, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalPlaylistItemHolder(final LocalItemBuilder infoItemBuilder, final int layoutId,
|
LocalPlaylistItemHolder(final LocalItemBuilder infoItemBuilder, final int layoutId,
|
||||||
final ViewGroup parent) {
|
final ViewGroup parent) {
|
||||||
super(infoItemBuilder, layoutId, parent);
|
super(infoItemBuilder, layoutId, parent);
|
||||||
itemHandleView = itemView.findViewById(R.id.itemHandle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -43,20 +40,6 @@ public class LocalPlaylistItemHolder extends PlaylistItemHolder {
|
||||||
|
|
||||||
PicassoHelper.loadPlaylistThumbnail(item.thumbnailUrl).into(itemThumbnailView);
|
PicassoHelper.loadPlaylistThumbnail(item.thumbnailUrl).into(itemThumbnailView);
|
||||||
|
|
||||||
itemHandleView.setOnTouchListener(getOnTouchListener(item));
|
|
||||||
|
|
||||||
super.updateFromItem(localItem, historyRecordManager, dateTimeFormatter);
|
super.updateFromItem(localItem, historyRecordManager, dateTimeFormatter);
|
||||||
}
|
}
|
||||||
|
|
||||||
private View.OnTouchListener getOnTouchListener(final PlaylistMetadataEntry item) {
|
|
||||||
return (view, motionEvent) -> {
|
|
||||||
view.performClick();
|
|
||||||
if (itemBuilder != null && itemBuilder.getOnItemSelectedListener() != null
|
|
||||||
&& motionEvent.getActionMasked() == MotionEvent.ACTION_DOWN) {
|
|
||||||
itemBuilder.getOnItemSelectedListener().drag(item,
|
|
||||||
LocalPlaylistItemHolder.this);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,71 @@
|
||||||
|
package org.schabi.newpipe.local.holder;
|
||||||
|
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import android.view.MotionEvent;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import org.schabi.newpipe.R;
|
||||||
|
import org.schabi.newpipe.database.LocalItem;
|
||||||
|
import org.schabi.newpipe.database.playlist.model.PlaylistRemoteEntity;
|
||||||
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
|
import org.schabi.newpipe.local.LocalItemBuilder;
|
||||||
|
import org.schabi.newpipe.local.history.HistoryRecordManager;
|
||||||
|
import org.schabi.newpipe.util.Localization;
|
||||||
|
import org.schabi.newpipe.util.PicassoHelper;
|
||||||
|
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
|
public class RemoteBookmarkPlaylistItemHolder extends PlaylistItemHolder {
|
||||||
|
private final View itemHandleView;
|
||||||
|
|
||||||
|
public RemoteBookmarkPlaylistItemHolder(final LocalItemBuilder infoItemBuilder,
|
||||||
|
final ViewGroup parent) {
|
||||||
|
this(infoItemBuilder, R.layout.list_playlist_bookmark_item, parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
RemoteBookmarkPlaylistItemHolder(final LocalItemBuilder infoItemBuilder, final int layoutId,
|
||||||
|
final ViewGroup parent) {
|
||||||
|
super(infoItemBuilder, layoutId, parent);
|
||||||
|
itemHandleView = itemView.findViewById(R.id.itemHandle);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateFromItem(final LocalItem localItem,
|
||||||
|
final HistoryRecordManager historyRecordManager,
|
||||||
|
final DateTimeFormatter dateTimeFormatter) {
|
||||||
|
if (!(localItem instanceof PlaylistRemoteEntity)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final PlaylistRemoteEntity item = (PlaylistRemoteEntity) localItem;
|
||||||
|
|
||||||
|
itemTitleView.setText(item.getName());
|
||||||
|
itemStreamCountView.setText(Localization.localizeStreamCountMini(
|
||||||
|
itemStreamCountView.getContext(), item.getStreamCount()));
|
||||||
|
// Here is where the uploader name is set in the bookmarked playlists library
|
||||||
|
if (!TextUtils.isEmpty(item.getUploader())) {
|
||||||
|
itemUploaderView.setText(Localization.concatenateStrings(item.getUploader(),
|
||||||
|
NewPipe.getNameOfService(item.getServiceId())));
|
||||||
|
} else {
|
||||||
|
itemUploaderView.setText(NewPipe.getNameOfService(item.getServiceId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
PicassoHelper.loadPlaylistThumbnail(item.getThumbnailUrl()).into(itemThumbnailView);
|
||||||
|
|
||||||
|
itemHandleView.setOnTouchListener(getOnTouchListener(item));
|
||||||
|
|
||||||
|
super.updateFromItem(localItem, historyRecordManager, dateTimeFormatter);
|
||||||
|
}
|
||||||
|
|
||||||
|
private View.OnTouchListener getOnTouchListener(final PlaylistRemoteEntity item) {
|
||||||
|
return (view, motionEvent) -> {
|
||||||
|
view.performClick();
|
||||||
|
if (itemBuilder != null && itemBuilder.getOnItemSelectedListener() != null
|
||||||
|
&& motionEvent.getActionMasked() == MotionEvent.ACTION_DOWN) {
|
||||||
|
itemBuilder.getOnItemSelectedListener().drag(item,
|
||||||
|
RemoteBookmarkPlaylistItemHolder.this);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,8 +1,6 @@
|
||||||
package org.schabi.newpipe.local.holder;
|
package org.schabi.newpipe.local.holder;
|
||||||
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.view.MotionEvent;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
|
@ -17,17 +15,15 @@ import org.schabi.newpipe.util.Localization;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
public class RemotePlaylistItemHolder extends PlaylistItemHolder {
|
public class RemotePlaylistItemHolder extends PlaylistItemHolder {
|
||||||
private final View itemHandleView;
|
|
||||||
|
|
||||||
public RemotePlaylistItemHolder(final LocalItemBuilder infoItemBuilder,
|
public RemotePlaylistItemHolder(final LocalItemBuilder infoItemBuilder,
|
||||||
final ViewGroup parent) {
|
final ViewGroup parent) {
|
||||||
this(infoItemBuilder, R.layout.list_playlist_bookmark_item, parent);
|
this(infoItemBuilder, R.layout.list_playlist_mini_item, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
RemotePlaylistItemHolder(final LocalItemBuilder infoItemBuilder, final int layoutId,
|
RemotePlaylistItemHolder(final LocalItemBuilder infoItemBuilder, final int layoutId,
|
||||||
final ViewGroup parent) {
|
final ViewGroup parent) {
|
||||||
super(infoItemBuilder, layoutId, parent);
|
super(infoItemBuilder, layoutId, parent);
|
||||||
itemHandleView = itemView.findViewById(R.id.itemHandle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -52,20 +48,6 @@ public class RemotePlaylistItemHolder extends PlaylistItemHolder {
|
||||||
|
|
||||||
PicassoHelper.loadPlaylistThumbnail(item.getThumbnailUrl()).into(itemThumbnailView);
|
PicassoHelper.loadPlaylistThumbnail(item.getThumbnailUrl()).into(itemThumbnailView);
|
||||||
|
|
||||||
itemHandleView.setOnTouchListener(getOnTouchListener(item));
|
|
||||||
|
|
||||||
super.updateFromItem(localItem, historyRecordManager, dateTimeFormatter);
|
super.updateFromItem(localItem, historyRecordManager, dateTimeFormatter);
|
||||||
}
|
}
|
||||||
|
|
||||||
private View.OnTouchListener getOnTouchListener(final PlaylistRemoteEntity item) {
|
|
||||||
return (view, motionEvent) -> {
|
|
||||||
view.performClick();
|
|
||||||
if (itemBuilder != null && itemBuilder.getOnItemSelectedListener() != null
|
|
||||||
&& motionEvent.getActionMasked() == MotionEvent.ACTION_DOWN) {
|
|
||||||
itemBuilder.getOnItemSelectedListener().drag(item,
|
|
||||||
RemotePlaylistItemHolder.this);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue