diff --git a/app/src/main/java/org/schabi/newpipe/info_list/InfoItemBuilder.java b/app/src/main/java/org/schabi/newpipe/info_list/InfoItemBuilder.java deleted file mode 100644 index d959c6327..000000000 --- a/app/src/main/java/org/schabi/newpipe/info_list/InfoItemBuilder.java +++ /dev/null @@ -1,131 +0,0 @@ -package org.schabi.newpipe.info_list; - -import android.content.Context; -import android.view.View; -import android.view.ViewGroup; - -import androidx.annotation.NonNull; - -import org.schabi.newpipe.extractor.InfoItem; -import org.schabi.newpipe.extractor.channel.ChannelInfoItem; -import org.schabi.newpipe.extractor.comments.CommentsInfoItem; -import org.schabi.newpipe.extractor.playlist.PlaylistInfoItem; -import org.schabi.newpipe.extractor.stream.StreamInfoItem; -import org.schabi.newpipe.info_list.holder.ChannelInfoItemHolder; -import org.schabi.newpipe.info_list.holder.ChannelMiniInfoItemHolder; -import org.schabi.newpipe.info_list.holder.CommentInfoItemHolder; -import org.schabi.newpipe.info_list.holder.InfoItemHolder; -import org.schabi.newpipe.info_list.holder.PlaylistInfoItemHolder; -import org.schabi.newpipe.info_list.holder.PlaylistMiniInfoItemHolder; -import org.schabi.newpipe.info_list.holder.StreamInfoItemHolder; -import org.schabi.newpipe.info_list.holder.StreamMiniInfoItemHolder; -import org.schabi.newpipe.local.history.HistoryRecordManager; -import org.schabi.newpipe.util.OnClickGesture; - -/* - * Created by Christian Schabesberger on 26.09.16. - *

- * Copyright (C) Christian Schabesberger 2016 - * InfoItemBuilder.java is part of NewPipe. - *

- *

- * NewPipe is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - *

- *

- * NewPipe is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - *

- *

- * You should have received a copy of the GNU General Public License - * along with NewPipe. If not, see . - *

- */ - -public class InfoItemBuilder { - private final Context context; - - private OnClickGesture onStreamSelectedListener; - private OnClickGesture onChannelSelectedListener; - private OnClickGesture onPlaylistSelectedListener; - private OnClickGesture onCommentsSelectedListener; - - public InfoItemBuilder(final Context context) { - this.context = context; - } - - public View buildView(@NonNull final ViewGroup parent, @NonNull final InfoItem infoItem, - final HistoryRecordManager historyRecordManager) { - return buildView(parent, infoItem, historyRecordManager, false); - } - - public View buildView(@NonNull final ViewGroup parent, @NonNull final InfoItem infoItem, - final HistoryRecordManager historyRecordManager, - final boolean useMiniVariant) { - final InfoItemHolder holder = - holderFromInfoType(parent, infoItem.getInfoType(), useMiniVariant); - holder.updateFromItem(infoItem, historyRecordManager); - return holder.itemView; - } - - private InfoItemHolder holderFromInfoType(@NonNull final ViewGroup parent, - @NonNull final InfoItem.InfoType infoType, - final boolean useMiniVariant) { - switch (infoType) { - case STREAM: - return useMiniVariant ? new StreamMiniInfoItemHolder(this, parent) - : new StreamInfoItemHolder(this, parent); - case CHANNEL: - return useMiniVariant ? new ChannelMiniInfoItemHolder(this, parent) - : new ChannelInfoItemHolder(this, parent); - case PLAYLIST: - return useMiniVariant ? new PlaylistMiniInfoItemHolder(this, parent) - : new PlaylistInfoItemHolder(this, parent); - case COMMENT: - return new CommentInfoItemHolder(this, parent); - default: - throw new RuntimeException("InfoType not expected = " + infoType.name()); - } - } - - public Context getContext() { - return context; - } - - public OnClickGesture getOnStreamSelectedListener() { - return onStreamSelectedListener; - } - - public void setOnStreamSelectedListener(final OnClickGesture listener) { - this.onStreamSelectedListener = listener; - } - - public OnClickGesture getOnChannelSelectedListener() { - return onChannelSelectedListener; - } - - public void setOnChannelSelectedListener(final OnClickGesture listener) { - this.onChannelSelectedListener = listener; - } - - public OnClickGesture getOnPlaylistSelectedListener() { - return onPlaylistSelectedListener; - } - - public void setOnPlaylistSelectedListener(final OnClickGesture listener) { - this.onPlaylistSelectedListener = listener; - } - - public OnClickGesture getOnCommentsSelectedListener() { - return onCommentsSelectedListener; - } - - public void setOnCommentsSelectedListener( - final OnClickGesture onCommentsSelectedListener) { - this.onCommentsSelectedListener = onCommentsSelectedListener; - } -} diff --git a/app/src/main/java/org/schabi/newpipe/info_list/InfoItemBuilder.kt b/app/src/main/java/org/schabi/newpipe/info_list/InfoItemBuilder.kt new file mode 100644 index 000000000..cf674180e --- /dev/null +++ b/app/src/main/java/org/schabi/newpipe/info_list/InfoItemBuilder.kt @@ -0,0 +1,20 @@ +/* + * SPDX-FileCopyrightText: 2016-2026 NewPipe contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +package org.schabi.newpipe.info_list + +import android.content.Context +import org.schabi.newpipe.extractor.channel.ChannelInfoItem +import org.schabi.newpipe.extractor.comments.CommentsInfoItem +import org.schabi.newpipe.extractor.playlist.PlaylistInfoItem +import org.schabi.newpipe.extractor.stream.StreamInfoItem +import org.schabi.newpipe.util.OnClickGesture + +class InfoItemBuilder(val context: Context) { + var onStreamSelectedListener: OnClickGesture? = null + var onChannelSelectedListener: OnClickGesture? = null + var onPlaylistSelectedListener: OnClickGesture? = null + var onCommentsSelectedListener: OnClickGesture? = null +}