| @ -61,7 +61,6 @@ class PlayerViewModel(application: Application) : AndroidViewModel(application) | ||||
|     } | ||||
|  | ||||
|     fun setLanguage(language: Locale) { | ||||
|         println("new language is: $language") | ||||
|         currentLanguage = language | ||||
|  | ||||
|         val seekTime = player.currentPosition | ||||
|  | ||||
| @ -34,6 +34,7 @@ class EpisodesListPlayer @JvmOverloads constructor( | ||||
|                 (this.parent as ViewGroup).removeView(this) | ||||
|                 model.playEpisode(model.media.episodes[position], replace = true) | ||||
|             } | ||||
|             adapterRecEpisodes.currentSelected = model.currentEpisode.number - 1 | ||||
|  | ||||
|             binding.recyclerEpisodesPlayer.adapter = adapterRecEpisodes | ||||
|             binding.recyclerEpisodesPlayer.scrollToPosition(model.currentEpisode.number - 1) // number != index | ||||
|  | ||||
| @ -1,6 +1,7 @@ | ||||
| package org.mosad.teapod.util.adapter | ||||
|  | ||||
| import android.view.LayoutInflater | ||||
| import android.view.View | ||||
| import android.view.ViewGroup | ||||
| import androidx.recyclerview.widget.RecyclerView | ||||
| import com.bumptech.glide.Glide | ||||
| @ -13,6 +14,7 @@ import org.mosad.teapod.util.Episode | ||||
| class PlayerEpisodeItemAdapter(private val episodes: List<Episode>) : RecyclerView.Adapter<PlayerEpisodeItemAdapter.EpisodeViewHolder>() { | ||||
|  | ||||
|     var onImageClick: ((String, Int) -> Unit)? = null | ||||
|     var currentSelected: Int = -1 // -1, since position should never be < 0 | ||||
|  | ||||
|     override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): EpisodeViewHolder { | ||||
|         return EpisodeViewHolder(ItemEpisodePlayerBinding.inflate(LayoutInflater.from(parent.context), parent, false)) | ||||
| @ -36,6 +38,11 @@ class PlayerEpisodeItemAdapter(private val episodes: List<Episode>) : RecyclerVi | ||||
|                 .apply(RequestOptions.bitmapTransform(RoundedCornersTransformation(10, 0))) | ||||
|                 .into(holder.binding.imageEpisode) | ||||
|         } | ||||
|  | ||||
|         // hide the play icon, if it's the current episode | ||||
|         if (currentSelected == position) { | ||||
|             holder.binding.imageEpisodePlay.visibility = View.GONE | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     override fun getItemCount(): Int { | ||||
| @ -45,7 +52,10 @@ class PlayerEpisodeItemAdapter(private val episodes: List<Episode>) : RecyclerVi | ||||
|     inner class EpisodeViewHolder(val binding: ItemEpisodePlayerBinding) : RecyclerView.ViewHolder(binding.root) { | ||||
|         init { | ||||
|             binding.imageEpisode.setOnClickListener { | ||||
|                 onImageClick?.invoke(episodes[adapterPosition].title, adapterPosition) | ||||
|                 // don't execute, if it's the current episode | ||||
|                 if (currentSelected != adapterPosition) { | ||||
|                     onImageClick?.invoke(episodes[adapterPosition].title, adapterPosition) | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @ -38,6 +38,14 @@ | ||||
|         android:textColor="@color/textPrimaryDark" | ||||
|         android:textSize="16sp" /> | ||||
|  | ||||
|     <View | ||||
|         android:id="@+id/divider" | ||||
|         android:layout_width="match_parent" | ||||
|         android:layout_height="1dp" | ||||
|         android:layout_marginTop="5dp" | ||||
|         android:layout_marginBottom="5dp" | ||||
|         android:background="@color/textSecondaryDark" /> | ||||
|  | ||||
|     <TextView | ||||
|         android:id="@+id/text_episode_desc2" | ||||
|         android:layout_width="match_parent" | ||||
|  | ||||
		Reference in New Issue
	
	Block a user