[Bandcamp] Add Radio stream segments

Display channel / creator / artist name when given
This commit is contained in:
TobiGr 2021-04-11 23:14:18 +02:00
parent b025bdf0c7
commit e5457e5029
3 changed files with 25 additions and 6 deletions

View File

@ -180,7 +180,7 @@ dependencies {
/** NewPipe libraries **/ /** NewPipe libraries **/
// You can use a local version by uncommenting a few lines in settings.gradle // You can use a local version by uncommenting a few lines in settings.gradle
implementation 'com.github.TeamNewPipe:nanojson:1d9e1aea9049fc9f85e68b43ba39fe7be1c1f751' implementation 'com.github.TeamNewPipe:nanojson:1d9e1aea9049fc9f85e68b43ba39fe7be1c1f751'
implementation 'com.github.TeamNewPipe:NewPipeExtractor:55e0f8e725e45f06513d43875fee6644ea9a8066' implementation 'com.github.TeamNewPipe:NewPipeExtractor:82d11386df42567959d6afc35a856fb9ee1e1327'
/** Checkstyle **/ /** Checkstyle **/
checkstyle "com.puppycrawl.tools:checkstyle:${checkstyleVersion}" checkstyle "com.puppycrawl.tools:checkstyle:${checkstyleVersion}"

View File

@ -1,5 +1,6 @@
package org.schabi.newpipe.info_list package org.schabi.newpipe.info_list
import android.view.View
import android.widget.ImageView import android.widget.ImageView
import android.widget.TextView import android.widget.TextView
import com.nostra13.universalimageloader.core.ImageLoader import com.nostra13.universalimageloader.core.ImageLoader
@ -29,6 +30,17 @@ class StreamSegmentItem(
) )
} }
viewHolder.root.findViewById<TextView>(R.id.textViewTitle).text = item.title viewHolder.root.findViewById<TextView>(R.id.textViewTitle).text = item.title
if (item.channelName == null) {
viewHolder.root.findViewById<TextView>(R.id.textViewChannel).visibility = View.GONE
// When the channel name is displayed there is less space
// and thus the segment title needs to be only one line height.
// But when there is no channel name displayed, the title can be two lines long.
// The default maxLines value is set to 1 to display all elements in the AS preview,
viewHolder.root.findViewById<TextView>(R.id.textViewTitle).maxLines = 2
} else {
viewHolder.root.findViewById<TextView>(R.id.textViewChannel).text = item.channelName
viewHolder.root.findViewById<TextView>(R.id.textViewChannel).visibility = View.VISIBLE
}
viewHolder.root.findViewById<TextView>(R.id.textViewStartSeconds).text = viewHolder.root.findViewById<TextView>(R.id.textViewStartSeconds).text =
Localization.getDurationString(item.startTimeSeconds.toLong()) Localization.getDurationString(item.startTimeSeconds.toLong())
viewHolder.root.setOnClickListener { onClick.onItemClick(this, item.startTimeSeconds) } viewHolder.root.setOnClickListener { onClick.onItemClick(this, item.startTimeSeconds) }

View File

@ -41,13 +41,22 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="2" android:maxLines="1"
android:textAppearance="@style/PlayQueueItemTitle" android:textAppearance="@style/PlayQueueItemTitle"
android:textSize="@dimen/video_item_search_title_text_size" android:textSize="@dimen/video_item_search_title_text_size"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="Lorem ipusum is widely used to create long sample text which is used here too" /> tools:text="Lorem ipusum is widely used to create long sample text which is used here too" />
<TextView
android:id="@+id/textViewChannel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:textAppearance="@style/PlayQueueItemSubtitle"
android:textSize="@dimen/video_item_search_title_text_size"
tools:text="Lorem ipsum creator" />
<TextView <TextView
android:id="@+id/textViewStartSeconds" android:id="@+id/textViewStartSeconds"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -55,8 +64,6 @@
android:layout_marginTop="2dp" android:layout_marginTop="2dp"
android:textAppearance="@style/PlayQueueItemSubtitle" android:textAppearance="@style/PlayQueueItemSubtitle"
android:textSize="@dimen/video_item_search_upload_date_text_size" android:textSize="@dimen/video_item_search_upload_date_text_size"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/textViewTitle"
tools:text="04:26" /> tools:text="04:26" />
</LinearLayout> </LinearLayout>