Episode Dialog when clicked onn teaser and episode in SeasonActivity : Ui and functionality
Playing trailer of every season according to the category chosen Solving issues in cache syncing for webshow's fav data Hindi strings updates opening SeasonActivity when clicked on webshows on MyListFragment like synching and boookmark syncing in MyListFragment
This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
package com.woka.home.fragments
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import androidx.fragment.app.Fragment
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.activity.result.ActivityResultLauncher
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.recyclerview.widget.SimpleItemAnimator
|
||||
@@ -19,6 +23,8 @@ import com.woka.home.mylist.models.BookmarkedShowData
|
||||
import com.woka.networking.ApiResult
|
||||
import com.woka.utils.hide
|
||||
import com.woka.utils.show
|
||||
import com.woka.webseries.models.ShowData
|
||||
import com.woka.webseries.views.SeasonActivity
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class MyListFragment : Fragment() {
|
||||
@@ -31,6 +37,8 @@ class MyListFragment : Fragment() {
|
||||
private lateinit var karaokeAdapter: KaraokeAdapter
|
||||
private lateinit var gamesAdapter: GamesAdapter
|
||||
|
||||
private var webShowIntentLauncher: ActivityResultLauncher<Intent>? = null
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
@@ -50,14 +58,21 @@ class MyListFragment : Fragment() {
|
||||
|
||||
setObservers()
|
||||
|
||||
registerIntentLaunchers()
|
||||
|
||||
return binding.root
|
||||
}
|
||||
|
||||
private fun initViews() {
|
||||
binding.apply {
|
||||
(rvWebSeriesEnglish.itemAnimator as SimpleItemAnimator).supportsChangeAnimations = false
|
||||
(rvWebSeriesHindi.itemAnimator as SimpleItemAnimator).supportsChangeAnimations = false
|
||||
rvWebSeriesEnglish.adapter = webSeriesEAdapter
|
||||
rvWebSeriesHindi.adapter = webSeriesHAdapter
|
||||
|
||||
webSeriesHAdapter.onShowClickListener = ::onWebShowClicked
|
||||
webSeriesEAdapter.onShowClickListener = ::onWebShowClicked
|
||||
|
||||
rvAudioBooks.adapter = audioBooksAdapter
|
||||
rvKaraoke.adapter = karaokeAdapter
|
||||
rvGames.adapter = gamesAdapter
|
||||
@@ -72,6 +87,28 @@ class MyListFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun registerIntentLaunchers(){
|
||||
webShowIntentLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()){
|
||||
if (it.resultCode == AppCompatActivity.RESULT_OK){
|
||||
it.data?.getIntExtra(SeasonActivity.EXTRA_SHOW_POSITION, -1)?.let { position ->
|
||||
it.data?.getStringExtra(SeasonActivity.EXTRA_SHOW_CATEGORY_DATA)?.let {categoryId ->
|
||||
if (categoryId == "1"){
|
||||
// english
|
||||
if (position > -1 && position < webSeriesEAdapter.itemCount){
|
||||
webSeriesEAdapter.notifyItemChanged(position)
|
||||
}
|
||||
}else if (categoryId == "18"){
|
||||
// hindi
|
||||
if (position > -1 && position < webSeriesHAdapter.itemCount){
|
||||
webSeriesHAdapter.notifyItemChanged(position)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setObservers(){
|
||||
binding.apply {
|
||||
MyListRepository.myFavListLiveData.observe(viewLifecycleOwner){
|
||||
@@ -206,6 +243,14 @@ class MyListFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun onWebShowClicked(showData: BookmarkedShowData, position:Int, categoryId: String){
|
||||
webShowIntentLauncher?.launch(Intent(context, SeasonActivity::class.java).apply {
|
||||
putExtra(SeasonActivity.EXTRA_SHOW_ID, showData.id)
|
||||
putExtra(SeasonActivity.EXTRA_SHOW_CATEGORY_DATA, categoryId)
|
||||
putExtra(SeasonActivity.EXTRA_SHOW_POSITION, position)
|
||||
})
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun newInstance() = MyListFragment()
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ object MyListRepository {
|
||||
|
||||
fun likePost(postId: String, postType: PostType, categoryId: String = "0"){
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
val response = RetrofitHelper.handleApiCall {
|
||||
RetrofitHelper.handleApiCall {
|
||||
myFavApiService.likePost(
|
||||
FormBody.Builder()
|
||||
.add("post_id", postId)
|
||||
@@ -83,13 +83,7 @@ object MyListRepository {
|
||||
)
|
||||
}
|
||||
|
||||
when (response){
|
||||
is ApiResult.Error -> {}
|
||||
is ApiResult.Loading -> {}
|
||||
is ApiResult.Success -> {
|
||||
changeLikeLocally(postId, postType, true)
|
||||
}
|
||||
}
|
||||
changeLikeLocally(postId, postType, true)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,13 +98,7 @@ object MyListRepository {
|
||||
)
|
||||
}
|
||||
|
||||
when (response) {
|
||||
is ApiResult.Error -> {}
|
||||
is ApiResult.Loading -> {}
|
||||
is ApiResult.Success -> {
|
||||
changeLikeLocally(postId, postType, false)
|
||||
}
|
||||
}
|
||||
changeLikeLocally(postId, postType, false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,7 +107,7 @@ object MyListRepository {
|
||||
categoryId: String){
|
||||
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
val response = RetrofitHelper.handleApiCall {
|
||||
RetrofitHelper.handleApiCall {
|
||||
if (addToFav){
|
||||
myFavApiService.addToFav(
|
||||
FormBody.Builder()
|
||||
@@ -139,45 +127,39 @@ object MyListRepository {
|
||||
}
|
||||
}
|
||||
|
||||
when (response){
|
||||
is ApiResult.Error -> {}
|
||||
is ApiResult.Loading -> {}
|
||||
is ApiResult.Success -> {
|
||||
if (myFavData == null && myFavListLiveData.isInitialized){
|
||||
loadMyFavList()
|
||||
}else{
|
||||
myFavData?.result?.show_data?.let {
|
||||
for (show in it){
|
||||
if (showData.id == show.id){
|
||||
if (addToFav){
|
||||
show.addAsBookMark(categoryId)
|
||||
}else{
|
||||
show.removeAsBookMark(categoryId)
|
||||
}
|
||||
}
|
||||
if (myFavData == null && myFavListLiveData.isInitialized){
|
||||
loadMyFavList()
|
||||
}else{
|
||||
myFavData?.result?.show_data?.let {
|
||||
for (show in it){
|
||||
if (showData.id == show.id){
|
||||
if (addToFav){
|
||||
show.addAsBookMark(categoryId)
|
||||
}else{
|
||||
show.removeAsBookMark(categoryId)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WebSeriesRepository.webSeriesData[categoryId]?.show_data?.let {
|
||||
for (show in it){
|
||||
var found = false
|
||||
|
||||
show?.let {data ->
|
||||
if (showData.id == data.id){
|
||||
found = true
|
||||
|
||||
if (addToFav){
|
||||
show.addAsBookMark(categoryId)
|
||||
}else{
|
||||
show.removeAsBookMark(categoryId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WebSeriesRepository.webSeriesData[categoryId]?.show_data?.let {
|
||||
for (show in it){
|
||||
var found = false
|
||||
|
||||
show?.let {data ->
|
||||
if (showData.id == data.id){
|
||||
found = true
|
||||
|
||||
if (addToFav){
|
||||
show.addAsBookMark(categoryId)
|
||||
}else{
|
||||
show.removeAsBookMark(categoryId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (found) break
|
||||
}
|
||||
}
|
||||
if (found) break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,12 +6,12 @@ import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.AsyncDifferConfig
|
||||
import androidx.recyclerview.widget.DiffUtil
|
||||
import androidx.recyclerview.widget.ListAdapter
|
||||
import com.bumptech.glide.Glide
|
||||
import com.woka.R
|
||||
import com.woka.WokaApp
|
||||
import com.woka.databinding.FavViewHolderBinding
|
||||
import com.woka.home.mylist.MyListRepository
|
||||
import com.woka.home.mylist.models.PostType
|
||||
import com.woka.home.mylist.models.BookmarkedShowData
|
||||
import com.woka.home.mylist.models.PostType
|
||||
import com.woka.utils.isNetworkConnected
|
||||
import com.woka.utils.show
|
||||
import com.woka.utils.toast
|
||||
@@ -38,6 +38,8 @@ class WebSeriesAdapter(private val context: Context,
|
||||
.build()
|
||||
}
|
||||
|
||||
var onShowClickListener: ((BookmarkedShowData, Int, String) -> Unit)? = null
|
||||
|
||||
constructor(context: Context,
|
||||
categoryId: String,
|
||||
onListEmptyListener: ((postType: PostType, isEng: Boolean) -> Unit)): this(context, categoryId, onListEmptyListener, DIFF_CONFIG)
|
||||
@@ -60,7 +62,17 @@ class WebSeriesAdapter(private val context: Context,
|
||||
image.loadImage(it)
|
||||
}
|
||||
|
||||
title.text = showData.title
|
||||
showData.content_more_details?.let {moreDetailsList ->
|
||||
title.text = if (moreDetailsList.isNotEmpty()){
|
||||
if (WokaApp.userPrefs?.appLanguage == "hi" && moreDetailsList.size > 1){
|
||||
moreDetailsList[1]?.title
|
||||
}else{
|
||||
moreDetailsList[0]?.title
|
||||
}
|
||||
}else{
|
||||
showData.title
|
||||
}
|
||||
}
|
||||
|
||||
likeCount.show()
|
||||
like.show()
|
||||
@@ -104,7 +116,17 @@ class WebSeriesAdapter(private val context: Context,
|
||||
}
|
||||
|
||||
fav.show()
|
||||
fav.isSelected = true
|
||||
if (showData.isBookMarked(categoryId)){
|
||||
fav.isSelected = true
|
||||
}else{
|
||||
val currentList = currentList.toMutableList()
|
||||
currentList.removeAt(holder.absoluteAdapterPosition)
|
||||
submitList(currentList)
|
||||
|
||||
if (currentList.isEmpty()){
|
||||
onListEmptyListener(PostType.WEB_SERIES, categoryId == "1")
|
||||
}
|
||||
}
|
||||
|
||||
fav.setOnClickListener {
|
||||
if (!context.isNetworkConnected()){
|
||||
@@ -128,6 +150,11 @@ class WebSeriesAdapter(private val context: Context,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
card.setOnClickListener {
|
||||
onShowClickListener?.invoke(showData, position, categoryId)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,8 +21,8 @@ data class BookmarkedShowData(
|
||||
val total_episodes: Int?,
|
||||
val total_seasons: Int?,
|
||||
val views_count: Int?
|
||||
){
|
||||
constructor(showData: ShowData, categoryIds: String): this(
|
||||
) {
|
||||
constructor(showData: ShowData, categoryIds: String) : this(
|
||||
showData.age_range_master_id,
|
||||
categoryIds,
|
||||
showData.bookmark_count,
|
||||
@@ -42,13 +42,29 @@ data class BookmarkedShowData(
|
||||
showData.views_count
|
||||
)
|
||||
|
||||
fun addAsBookMark(categoryId: String){
|
||||
val categories = bookmark_category_ids?.split(",")?.toMutableList()?: mutableListOf()
|
||||
fun isBookMarked(categoryId: String): Boolean {
|
||||
bookmark_category_ids?.split(",")?.toMutableList()?.let {
|
||||
return it.contains(categoryId)
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
fun addAsBookMark(categoryId: String) {
|
||||
val categories = bookmark_category_ids?.let {
|
||||
if (it.isEmpty()){
|
||||
ArrayList()
|
||||
}else{
|
||||
it.split(",").toMutableList()
|
||||
}
|
||||
}?:ArrayList()
|
||||
|
||||
categories.remove("0") // unwanted id
|
||||
categories.add(categoryId)
|
||||
bookmark_category_ids = categories.joinToString(",")
|
||||
}
|
||||
|
||||
fun removeAsBookMark(categoryId: String){
|
||||
fun removeAsBookMark(categoryId: String) {
|
||||
bookmark_category_ids?.split(",")?.toMutableList()?.let {
|
||||
it.remove(categoryId)
|
||||
bookmark_category_ids = it.joinToString(",")
|
||||
|
||||
@@ -89,12 +89,11 @@ class LiveStreamPlayerActivity : AppCompatActivity(), FullscreenHandler {
|
||||
override fun onFullscreenRequested() {}
|
||||
|
||||
override fun onFullscreenExitRequested() {
|
||||
player.stop()
|
||||
val windowInsetsController =
|
||||
WindowCompat.getInsetsController(window, window.decorView)
|
||||
windowInsetsController.show(WindowInsetsCompat.Type.systemBars())
|
||||
|
||||
finish()
|
||||
onBackPressedDispatcher.onBackPressed()
|
||||
}
|
||||
|
||||
override fun onAllowRotationChanged(allowRotation: Boolean) {}
|
||||
|
||||
@@ -70,12 +70,11 @@ class PlayerActivity : AppCompatActivity(), FullscreenHandler {
|
||||
override fun onFullscreenRequested() {}
|
||||
|
||||
override fun onFullscreenExitRequested() {
|
||||
player.stop()
|
||||
val windowInsetsController =
|
||||
WindowCompat.getInsetsController(window, window.decorView)
|
||||
windowInsetsController.show(WindowInsetsCompat.Type.systemBars())
|
||||
|
||||
finish()
|
||||
onBackPressedDispatcher.onBackPressed()
|
||||
}
|
||||
|
||||
override fun onAllowRotationChanged(allowRotation: Boolean) {}
|
||||
|
||||
@@ -329,7 +329,7 @@ object WebSeriesRepository {
|
||||
|
||||
fun likeUnLikeShow(postId: String, likeIt: Boolean, categoryId: String){
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
val response = RetrofitHelper.handleApiCall {
|
||||
RetrofitHelper.handleApiCall {
|
||||
if (likeIt){
|
||||
myFavApiService.likePost(
|
||||
FormBody.Builder()
|
||||
@@ -347,13 +347,7 @@ object WebSeriesRepository {
|
||||
}
|
||||
}
|
||||
|
||||
when (response){
|
||||
is ApiResult.Error -> {}
|
||||
is ApiResult.Loading -> {}
|
||||
is ApiResult.Success -> {
|
||||
changeLikeLocally(postId, likeIt)
|
||||
}
|
||||
}
|
||||
changeLikeLocally(postId, likeIt)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import androidx.recyclerview.widget.DiffUtil
|
||||
import androidx.recyclerview.widget.ListAdapter
|
||||
import androidx.recyclerview.widget.RecyclerView.ViewHolder
|
||||
import com.bumptech.glide.Glide
|
||||
import com.woka.WokaApp.Companion.userPrefs
|
||||
import com.woka.databinding.ContinueShowViewHolderBinding
|
||||
import com.woka.webseries.models.ContinueEpisodeData
|
||||
import java.util.concurrent.Executors
|
||||
@@ -48,13 +49,20 @@ class ContinueEpisodeAdapter(val context: Context,
|
||||
|
||||
holder.binding.apply {
|
||||
episode.thumbnail_path?.let {
|
||||
Glide.with(context.applicationContext)
|
||||
.load(it)
|
||||
.error(android.R.color.darker_gray)
|
||||
.into(image)
|
||||
image.loadImage(it)
|
||||
}
|
||||
|
||||
title.text = episode.episode_title
|
||||
title.text = episode.content_more_details?.let {moreDetailsList ->
|
||||
if (moreDetailsList.isNotEmpty()){
|
||||
if (userPrefs?.appLanguage == "hi" && moreDetailsList.size > 1){
|
||||
moreDetailsList[1].title
|
||||
}else{
|
||||
moreDetailsList[0].title
|
||||
}
|
||||
}else{
|
||||
episode.episode_title
|
||||
}
|
||||
}
|
||||
val detail = "S${episode.season_number}-E${episode.episode_number}"
|
||||
details.text = detail
|
||||
}
|
||||
|
||||
@@ -35,7 +35,8 @@ class EpisodeAdapter private constructor(val context: Context,
|
||||
|
||||
constructor(context: Context): this(context, DIFF_CONFIG)
|
||||
|
||||
var onEpisodeClicked: ((position: Int) -> Unit)? = null
|
||||
var onEpisodeClicked: ((position: Int, episodeData: EpisodeData) -> Unit)? = null
|
||||
var onEpisodePlayClicked: ((position: Int) -> Unit)? = null
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): EpisodeViewHolder {
|
||||
return EpisodeViewHolder(
|
||||
@@ -69,10 +70,12 @@ class EpisodeAdapter private constructor(val context: Context,
|
||||
}
|
||||
}
|
||||
|
||||
playBtn.setOnClickListener {
|
||||
onEpisodePlayClicked?.invoke(holder.absoluteAdapterPosition)
|
||||
}
|
||||
|
||||
card.setOnClickListener {
|
||||
episode.id?.let { episodeId ->
|
||||
onEpisodeClicked?.invoke(holder.absoluteAdapterPosition)
|
||||
}
|
||||
onEpisodeClicked?.invoke(position, episode)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.woka.webseries.adapters;
|
||||
|
||||
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
@@ -35,7 +34,8 @@ class TeaserAdapter private constructor(val context: Context,
|
||||
|
||||
constructor(context: Context): this(context, DIFF_CONFIG)
|
||||
|
||||
var onEpisodeClicked: ((position: Int) -> Unit)? = null
|
||||
var onEpisodeClicked: ((position: Int, teaserData: TeaserData) -> Unit)? = null
|
||||
var onEpisodePlayClicked: ((position: Int) -> Unit)? = null
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): EpisodeViewHolder {
|
||||
return EpisodeViewHolder(
|
||||
@@ -69,9 +69,14 @@ class TeaserAdapter private constructor(val context: Context,
|
||||
}
|
||||
}
|
||||
|
||||
card.setOnClickListener {
|
||||
onEpisodeClicked?.invoke(holder.absoluteAdapterPosition)
|
||||
playBtn.setOnClickListener {
|
||||
onEpisodePlayClicked?.invoke(holder.absoluteAdapterPosition)
|
||||
}
|
||||
|
||||
card.setOnClickListener {
|
||||
onEpisodeClicked?.invoke(position, episode)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.recyclerview.widget.RecyclerView.ViewHolder
|
||||
import com.woka.R
|
||||
import com.woka.WokaApp.Companion.userPrefs
|
||||
import com.woka.databinding.ShowViewHolderBinding
|
||||
import com.woka.utils.isNetworkConnected
|
||||
import com.woka.utils.show
|
||||
@@ -53,7 +54,17 @@ class WebSeriesShowAdapter(
|
||||
image.loadImage(it)
|
||||
}
|
||||
|
||||
title.text = showData.title
|
||||
showData.content_more_details?.let {moreDetailsList ->
|
||||
title.text = if (moreDetailsList.isNotEmpty()){
|
||||
if (userPrefs?.appLanguage == "hi" && moreDetailsList.size > 1){
|
||||
moreDetailsList[1]?.title
|
||||
}else{
|
||||
moreDetailsList[0]?.title
|
||||
}
|
||||
}else{
|
||||
showData.title
|
||||
}
|
||||
}
|
||||
|
||||
like.show()
|
||||
likeCount.show()
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
package com.woka.webseries.models
|
||||
|
||||
import android.util.Log
|
||||
import com.woka.home.mylist.models.BookmarkedShowData
|
||||
import com.woka.utils.TAG
|
||||
|
||||
data class ShowData(
|
||||
val age_range_data: List<AgeRangeData?>?,
|
||||
val age_range_master_id: String?,
|
||||
@@ -24,6 +28,30 @@ data class ShowData(
|
||||
val views_count: Int?
|
||||
){
|
||||
|
||||
constructor(bookMarkShowData: BookmarkedShowData): this(
|
||||
null,
|
||||
bookMarkShowData.age_range_master_id,
|
||||
bookMarkShowData.bookmark_count,
|
||||
null,
|
||||
bookMarkShowData.category_master_id,
|
||||
bookMarkShowData.content_more_details,
|
||||
bookMarkShowData.description,
|
||||
bookMarkShowData.bookmark_category_ids,
|
||||
null,
|
||||
bookMarkShowData.gender_master_id,
|
||||
bookMarkShowData.id,
|
||||
bookMarkShowData.is_liked,
|
||||
bookMarkShowData.bookmark_category_ids,
|
||||
bookMarkShowData.likes_count,
|
||||
bookMarkShowData.mark_as_favourite,
|
||||
bookMarkShowData.show_type,
|
||||
bookMarkShowData.thumbnail_path,
|
||||
bookMarkShowData.title,
|
||||
bookMarkShowData.total_episodes,
|
||||
bookMarkShowData.total_seasons,
|
||||
bookMarkShowData.views_count
|
||||
)
|
||||
|
||||
fun isBookMarked(categoryId: String): Boolean{
|
||||
favourite_category_ids?.split(",")?.toMutableList()?.let {
|
||||
return it.contains(categoryId)
|
||||
@@ -32,7 +60,15 @@ data class ShowData(
|
||||
return false
|
||||
}
|
||||
fun addAsBookMark(categoryId: String){
|
||||
val categories = favourite_category_ids?.split(",")?.toMutableList()?: mutableListOf()
|
||||
val categories = favourite_category_ids?.let {
|
||||
if (it.isEmpty()){
|
||||
ArrayList()
|
||||
}else{
|
||||
it.split(",").toMutableList()
|
||||
}
|
||||
}?:ArrayList()
|
||||
|
||||
categories.remove("0")
|
||||
categories.add(categoryId)
|
||||
favourite_category_ids = categories.joinToString(",")
|
||||
}
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
package com.woka.webseries.views
|
||||
|
||||
import android.app.Dialog
|
||||
import android.content.Intent
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.graphics.drawable.InsetDrawable
|
||||
import android.os.Bundle
|
||||
import android.os.Parcelable
|
||||
import android.text.Html
|
||||
import android.view.WindowManager
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.view.ViewCompat
|
||||
@@ -14,11 +19,15 @@ import com.jwplayer.pub.api.media.playlists.PlaylistItem
|
||||
import com.woka.R
|
||||
import com.woka.WokaApp.Companion.userPrefs
|
||||
import com.woka.databinding.ActivitySeasonBinding
|
||||
import com.woka.databinding.DialogEpisodeBinding
|
||||
import com.woka.home.mylist.MyListRepository
|
||||
import com.woka.home.mylist.models.BookmarkedShowData
|
||||
import com.woka.networking.ApiResult
|
||||
import com.woka.players.PlayerActivity
|
||||
import com.woka.players.PlayerActivity.Companion.EXTRA_EPISODE_INDEX
|
||||
import com.woka.players.PlayerActivity.Companion.EXTRA_PLAY_LIST
|
||||
import com.woka.utils.ProgressView
|
||||
import com.woka.utils.WokaBaseActivity
|
||||
import com.woka.utils.hide
|
||||
import com.woka.utils.isNetworkConnected
|
||||
import com.woka.utils.lightStatusBar
|
||||
@@ -28,11 +37,13 @@ import com.woka.webseries.WebSeriesRepository
|
||||
import com.woka.webseries.adapters.EpisodeAdapter
|
||||
import com.woka.webseries.adapters.TeaserAdapter
|
||||
import com.woka.webseries.models.ShowData
|
||||
import com.woka.webseries.models.episodedata.EpisodeData
|
||||
import com.woka.webseries.models.teaserdata.TeaserData
|
||||
import kotlin.math.max
|
||||
|
||||
class SeasonActivity : AppCompatActivity(), OnTabSelectedListener {
|
||||
class SeasonActivity : WokaBaseActivity(), OnTabSelectedListener {
|
||||
|
||||
companion object{
|
||||
companion object {
|
||||
const val EXTRA_SHOW_ID = "extra_show_id_data"
|
||||
const val EXTRA_SHOW_CATEGORY_DATA = "extra_show_category_data"
|
||||
const val EXTRA_SHOW_POSITION = "extra_show_position"
|
||||
@@ -53,6 +64,9 @@ class SeasonActivity : AppCompatActivity(), OnTabSelectedListener {
|
||||
|
||||
private var selectedSeasonId = -1
|
||||
|
||||
private lateinit var episodeDialogBinding: DialogEpisodeBinding
|
||||
private lateinit var episodeDialog: Dialog
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
enableEdgeToEdge()
|
||||
@@ -64,7 +78,7 @@ class SeasonActivity : AppCompatActivity(), OnTabSelectedListener {
|
||||
insets
|
||||
}
|
||||
|
||||
with(window){
|
||||
with(window) {
|
||||
statusBarColor = Color.parseColor("#D3EFF8")
|
||||
lightStatusBar(true)
|
||||
}
|
||||
@@ -73,7 +87,7 @@ class SeasonActivity : AppCompatActivity(), OnTabSelectedListener {
|
||||
categoryId = intent.getStringExtra(EXTRA_SHOW_CATEGORY_DATA)
|
||||
showPosition = intent.getIntExtra(EXTRA_SHOW_POSITION, -1)
|
||||
|
||||
if (showId == -1 || categoryId == null){
|
||||
if (showId == -1 || categoryId == null) {
|
||||
finish()
|
||||
return
|
||||
}
|
||||
@@ -85,16 +99,29 @@ class SeasonActivity : AppCompatActivity(), OnTabSelectedListener {
|
||||
progressView.show(getString(R.string.please_wait))
|
||||
|
||||
WebSeriesRepository.webSeriesData[categoryId]?.show_data?.let {
|
||||
for (show in it){
|
||||
if (showId == show?.id){
|
||||
for (show in it) {
|
||||
if (showId == show?.id) {
|
||||
showData = show
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (showData == null){
|
||||
MyListRepository.myFavData?.result?.show_data?.let {
|
||||
for (show in it){
|
||||
if (showId == show.id){
|
||||
showData = ShowData(show)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
initViews()
|
||||
|
||||
initEpisodeDialog()
|
||||
|
||||
clickEvents()
|
||||
|
||||
setObservers()
|
||||
@@ -115,44 +142,79 @@ class SeasonActivity : AppCompatActivity(), OnTabSelectedListener {
|
||||
|
||||
favSeason.isSelected = showData!!.isBookMarked(categoryId!!)
|
||||
|
||||
likeSeason.isSelected = showData!!.is_liked?:false
|
||||
likeSeason.isSelected = showData!!.is_liked ?: false
|
||||
|
||||
binding.seasonsTab.addOnTabSelectedListener(this@SeasonActivity)
|
||||
|
||||
image.onLoadSuccessListener = {playTrailer.show()}
|
||||
image.onLoadSuccessListener = { playTrailer.show() }
|
||||
|
||||
rvEpisodes.adapter = episodeAdapter
|
||||
episodeAdapter.onEpisodeClicked = ::onEpisodeClicked
|
||||
episodeAdapter.onEpisodePlayClicked = ::onEpisodePlayClicked
|
||||
|
||||
rvTeaser.adapter = teaserAdapter
|
||||
teaserAdapter.onEpisodeClicked = ::onTeaserClicked
|
||||
teaserAdapter.onEpisodePlayClicked = ::onTeaserPlayClicked
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun clickEvents(){
|
||||
|
||||
|
||||
private fun initEpisodeDialog(){
|
||||
episodeDialogBinding = DialogEpisodeBinding.inflate(layoutInflater)
|
||||
episodeDialog = Dialog(this)
|
||||
|
||||
episodeDialog.setContentView(episodeDialogBinding.root)
|
||||
|
||||
try {
|
||||
val back = ColorDrawable(Color.TRANSPARENT)
|
||||
val inset = InsetDrawable(back, 50)
|
||||
episodeDialog.window!!.setBackgroundDrawable(inset)
|
||||
} catch (e: Exception) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
try {
|
||||
val layoutParams = episodeDialog.window!!.attributes
|
||||
layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT
|
||||
layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT
|
||||
episodeDialog.window!!.setAttributes(layoutParams)
|
||||
} catch (e: Exception) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
episodeDialogBinding.close.setOnClickListener { episodeDialog.dismiss() }
|
||||
}
|
||||
|
||||
|
||||
private fun clickEvents() {
|
||||
binding.apply {
|
||||
backBtn.setOnClickListener {
|
||||
onBackPressedDispatcher.onBackPressed()
|
||||
}
|
||||
|
||||
watchCard.setOnClickListener {
|
||||
playTrailer.performClick()
|
||||
}
|
||||
|
||||
likeSeason.setOnClickListener {
|
||||
if (!isNetworkConnected()){
|
||||
if (!isNetworkConnected()) {
|
||||
toast(getString(R.string.no_internet))
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
categoryId?.let {
|
||||
if (likeSeason.isSelected){
|
||||
if (likeSeason.isSelected) {
|
||||
WebSeriesRepository.likeUnLikeShow("${showData?.id}", false, it)
|
||||
|
||||
showData?.likes_count?.let {likeCountInt ->
|
||||
showData?.likes_count?.let { likeCountInt ->
|
||||
likeCount.text = "${max(likeCountInt - 1, 0)}"
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
WebSeriesRepository.likeUnLikeShow("${showData?.id}", true, it)
|
||||
|
||||
showData?.likes_count?.let {likeCountInt ->
|
||||
showData?.likes_count?.let { likeCountInt ->
|
||||
val value = likeCountInt + 1
|
||||
likeCount.text = "$value"
|
||||
}
|
||||
@@ -161,12 +223,13 @@ class SeasonActivity : AppCompatActivity(), OnTabSelectedListener {
|
||||
likeSeason.isSelected = !likeSeason.isSelected
|
||||
setResult(RESULT_OK, Intent().apply {
|
||||
putExtra(EXTRA_SHOW_POSITION, showPosition)
|
||||
putExtra(EXTRA_SHOW_CATEGORY_DATA, categoryId)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
favSeason.setOnClickListener {
|
||||
if (!isNetworkConnected()){
|
||||
if (!isNetworkConnected()) {
|
||||
toast(getString(R.string.no_internet))
|
||||
return@setOnClickListener
|
||||
}
|
||||
@@ -184,56 +247,100 @@ class SeasonActivity : AppCompatActivity(), OnTabSelectedListener {
|
||||
|
||||
setResult(RESULT_OK, Intent().apply {
|
||||
putExtra(EXTRA_SHOW_POSITION, showPosition)
|
||||
putExtra(EXTRA_SHOW_CATEGORY_DATA, categoryId)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
playTrailer.setOnClickListener {
|
||||
if (seasonsTab.selectedTabPosition >= 0) {
|
||||
WebSeriesRepository.seasonDataMap["${showId}_${categoryId}"]?.result?.let { seasonList ->
|
||||
if (seasonsTab.selectedTabPosition < seasonList.size) {
|
||||
seasonList[seasonsTab.selectedTabPosition]?.season_more_details?.let {moreDetailsList ->
|
||||
if (moreDetailsList.isNotEmpty()){
|
||||
val playlistItem = PlaylistItem.Builder()
|
||||
|
||||
if (categoryId == "18" && moreDetailsList.size > 1){
|
||||
moreDetailsList[1]?.let {seasonData ->
|
||||
playlistItem.title(seasonData.title)
|
||||
playlistItem.image(seasonData.trailer_hd_url)
|
||||
playlistItem.file(seasonData.trailer_hd_url)
|
||||
}
|
||||
}else{
|
||||
moreDetailsList[0]?.let {seasonData ->
|
||||
playlistItem.title(seasonData.title)
|
||||
playlistItem.image(seasonData.trailer_hd_url)
|
||||
playlistItem.file(seasonData.trailer_hd_url)
|
||||
}
|
||||
}
|
||||
|
||||
startActivity(
|
||||
Intent(this@SeasonActivity, PlayerActivity::class.java)
|
||||
.apply {
|
||||
putParcelableArrayListExtra(EXTRA_PLAY_LIST, ArrayList<Parcelable?>().apply {
|
||||
add(playlistItem.build())
|
||||
})
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setObservers(){
|
||||
WebSeriesRepository.seasonDataLiveData.observe(this){
|
||||
private fun setObservers() {
|
||||
WebSeriesRepository.seasonDataLiveData.observe(this) {
|
||||
binding.seasonsTab.removeAllTabs()
|
||||
when(it){
|
||||
when (it) {
|
||||
is ApiResult.Error -> {
|
||||
progressView.hide()
|
||||
}
|
||||
|
||||
is ApiResult.Loading -> {
|
||||
progressView.show()
|
||||
}
|
||||
|
||||
is ApiResult.Success -> {
|
||||
progressView.hide()
|
||||
it.data?.result?.let {seasonList ->
|
||||
for (season in seasonList){
|
||||
it.data?.result?.let { seasonList ->
|
||||
for (season in seasonList) {
|
||||
if (season == null) continue
|
||||
binding.seasonsTab.addTab(binding.seasonsTab.newTab().setText("${season.season_number}"))
|
||||
binding.seasonsTab.addTab(
|
||||
binding.seasonsTab.newTab().setText("${season.season_number}")
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WebSeriesRepository.episodeDataLiveData.observe(this){
|
||||
when(it){
|
||||
WebSeriesRepository.episodeDataLiveData.observe(this) {
|
||||
when (it) {
|
||||
is ApiResult.Error -> {
|
||||
binding.epShimmer.hide()
|
||||
binding.rvEpisodes.hide()
|
||||
binding.seasonMediaType.hide()
|
||||
}
|
||||
|
||||
is ApiResult.Loading -> {
|
||||
binding.epShimmer.show()
|
||||
binding.rvEpisodes.hide()
|
||||
binding.seasonMediaType.hide()
|
||||
}
|
||||
is ApiResult.Success -> {
|
||||
it.data?.result?.filterNotNull()?.let {episodeList ->
|
||||
|
||||
if (episodeList.isNotEmpty()){
|
||||
episodeAdapter.submitList(episodeList){
|
||||
is ApiResult.Success -> {
|
||||
it.data?.result?.filterNotNull()?.let { episodeList ->
|
||||
|
||||
if (episodeList.isNotEmpty()) {
|
||||
episodeAdapter.submitList(episodeList) {
|
||||
binding.epShimmer.hide()
|
||||
binding.rvEpisodes.show()
|
||||
binding.seasonMediaType.show()
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
binding.epShimmer.hide()
|
||||
binding.seasonMediaType.hide()
|
||||
binding.rvEpisodes.hide()
|
||||
@@ -243,25 +350,27 @@ class SeasonActivity : AppCompatActivity(), OnTabSelectedListener {
|
||||
}
|
||||
}
|
||||
|
||||
WebSeriesRepository.teaserDataLiveData.observe(this){
|
||||
when(it){
|
||||
WebSeriesRepository.teaserDataLiveData.observe(this) {
|
||||
when (it) {
|
||||
is ApiResult.Error -> {
|
||||
binding.rvTeaser.hide()
|
||||
binding.teaserTxt.hide()
|
||||
}
|
||||
|
||||
is ApiResult.Loading -> {
|
||||
binding.rvTeaser.hide()
|
||||
binding.teaserTxt.hide()
|
||||
}
|
||||
is ApiResult.Success -> {
|
||||
it.data?.result?.filterNotNull()?.let {episodeList ->
|
||||
|
||||
if (episodeList.isNotEmpty()){
|
||||
teaserAdapter.submitList(episodeList){
|
||||
is ApiResult.Success -> {
|
||||
it.data?.result?.filterNotNull()?.let { episodeList ->
|
||||
|
||||
if (episodeList.isNotEmpty()) {
|
||||
teaserAdapter.submitList(episodeList) {
|
||||
binding.rvTeaser.show()
|
||||
binding.teaserTxt.show()
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
binding.teaserTxt.hide()
|
||||
binding.rvTeaser.hide()
|
||||
}
|
||||
@@ -273,10 +382,10 @@ class SeasonActivity : AppCompatActivity(), OnTabSelectedListener {
|
||||
|
||||
private fun loadSeasonData() {
|
||||
binding.apply {
|
||||
if (seasonsTab.selectedTabPosition >= 0){
|
||||
WebSeriesRepository.seasonDataMap["${showId}_${categoryId}"]?.result?.let {seasonList ->
|
||||
if (seasonsTab.selectedTabPosition < seasonList.size){
|
||||
seasonList[seasonsTab.selectedTabPosition]?.let {seasonData ->
|
||||
if (seasonsTab.selectedTabPosition >= 0) {
|
||||
WebSeriesRepository.seasonDataMap["${showId}_${categoryId}"]?.result?.let { seasonList ->
|
||||
if (seasonsTab.selectedTabPosition < seasonList.size) {
|
||||
seasonList[seasonsTab.selectedTabPosition]?.let { seasonData ->
|
||||
|
||||
// loading episode data
|
||||
seasonData.id?.let {
|
||||
@@ -285,8 +394,11 @@ class SeasonActivity : AppCompatActivity(), OnTabSelectedListener {
|
||||
WebSeriesRepository.loadTeaserData(showId, it)
|
||||
}
|
||||
|
||||
|
||||
|
||||
seasonYear.text = "${seasonData.release_year}"
|
||||
val noOfEpisodes = "${seasonData.no_of_episodes} ${seasonData.media_type}"
|
||||
val noOfEpisodes =
|
||||
"${seasonData.no_of_episodes} ${seasonData.media_type}"
|
||||
episodeNumber.text = noOfEpisodes
|
||||
|
||||
seasonMediaType.text = "${seasonData.media_type}"
|
||||
@@ -295,17 +407,27 @@ class SeasonActivity : AppCompatActivity(), OnTabSelectedListener {
|
||||
image.loadImage(it)
|
||||
}
|
||||
|
||||
seasonData.season_more_details?.let {moreDetailsList ->
|
||||
if (moreDetailsList.isNotEmpty()){
|
||||
if (userPrefs?.appLanguage == "hi" && moreDetailsList.size > 1){
|
||||
moreDetailsList[1]?.let {moreDetails ->
|
||||
seasonData.season_more_details?.let { moreDetailsList ->
|
||||
if (moreDetailsList.isNotEmpty()) {
|
||||
if (userPrefs?.appLanguage == "hi" && moreDetailsList.size > 1) {
|
||||
moreDetailsList[1]?.let { moreDetails ->
|
||||
seasonTitle.text = moreDetails.title?.uppercase()
|
||||
seasonDescription.text = Html.fromHtml(moreDetails.description?.replace("<br>", " "), Html.FROM_HTML_MODE_LEGACY)
|
||||
seasonDescription.text = Html.fromHtml(
|
||||
moreDetails.description?.replace(
|
||||
"<br>",
|
||||
" "
|
||||
), Html.FROM_HTML_MODE_LEGACY
|
||||
)
|
||||
}
|
||||
}else{
|
||||
moreDetailsList[0]?.let {moreDetails ->
|
||||
} else {
|
||||
moreDetailsList[0]?.let { moreDetails ->
|
||||
seasonTitle.text = moreDetails.title?.uppercase()
|
||||
seasonDescription.text = Html.fromHtml(moreDetails.description?.replace("<br>", " "), Html.FROM_HTML_MODE_LEGACY)
|
||||
seasonDescription.text = Html.fromHtml(
|
||||
moreDetails.description?.replace(
|
||||
"<br>",
|
||||
" "
|
||||
), Html.FROM_HTML_MODE_LEGACY
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -318,16 +440,148 @@ class SeasonActivity : AppCompatActivity(), OnTabSelectedListener {
|
||||
}
|
||||
}
|
||||
|
||||
private fun onEpisodeClicked(position: Int){
|
||||
private fun onEpisodeClicked(position: Int, episodeData: EpisodeData) {
|
||||
episodeDialogBinding.apply {
|
||||
episodeData.content_more_details?.let {moreDetailsList ->
|
||||
|
||||
episodeData.thumbnail_path?.let {
|
||||
image.loadImage(it)
|
||||
}
|
||||
|
||||
if (moreDetailsList.isNotEmpty()){
|
||||
|
||||
if (userPrefs?.appLanguage == "hi" && moreDetailsList.size > 1){
|
||||
moreDetailsList[1]?.let {data ->
|
||||
title.text = data.title
|
||||
description.text = Html.fromHtml(
|
||||
data.description?.replace(
|
||||
"<br>",
|
||||
" "
|
||||
), Html.FROM_HTML_MODE_LEGACY
|
||||
)
|
||||
val mediaType = "${getString(R.string.episode)} ${episodeData.episode_number}"
|
||||
mediaTypeNumber.text = mediaType
|
||||
duration.text = episodeData.episode_duration
|
||||
}
|
||||
}else{
|
||||
moreDetailsList[0]?.let {data ->
|
||||
title.text = data.title
|
||||
description.text = Html.fromHtml(
|
||||
data.description?.replace(
|
||||
"<br>",
|
||||
" "
|
||||
), Html.FROM_HTML_MODE_LEGACY
|
||||
)
|
||||
val mediaType = "${getString(R.string.episode)} ${episodeData.episode_number}"
|
||||
mediaTypeNumber.text = mediaType
|
||||
duration.text = episodeData.episode_duration
|
||||
}
|
||||
}
|
||||
}else{
|
||||
title.text = episodeData.episode_title
|
||||
description.text = Html.fromHtml(
|
||||
episodeData.episode_description?.replace(
|
||||
"<br>",
|
||||
" "
|
||||
), Html.FROM_HTML_MODE_LEGACY
|
||||
)
|
||||
val mediaType = "${getString(R.string.episode)} ${episodeData.episode_number}"
|
||||
mediaTypeNumber.text = mediaType
|
||||
duration.text = episodeData.episode_duration
|
||||
}
|
||||
|
||||
watchCard.setOnClickListener {
|
||||
onEpisodePlayClicked(position)
|
||||
}
|
||||
|
||||
close.setOnClickListener {
|
||||
episodeDialog.dismiss()
|
||||
}
|
||||
|
||||
episodeDialog.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun onEpisodePlayClicked(position: Int) {
|
||||
startActivity(Intent(this, PlayerActivity::class.java).apply {
|
||||
putParcelableArrayListExtra(EXTRA_PLAY_LIST, WebSeriesRepository.episodesPlaylistMap["${showId}_${selectedSeasonId}_$categoryId"])
|
||||
putParcelableArrayListExtra(
|
||||
EXTRA_PLAY_LIST,
|
||||
WebSeriesRepository.episodesPlaylistMap["${showId}_${selectedSeasonId}_$categoryId"]
|
||||
)
|
||||
putExtra(EXTRA_EPISODE_INDEX, position)
|
||||
})
|
||||
}
|
||||
|
||||
private fun onTeaserClicked(position: Int){
|
||||
private fun onTeaserClicked(position: Int, teaserData: TeaserData) {
|
||||
episodeDialogBinding.apply {
|
||||
teaserData.content_more_details?.let {moreDetailsList ->
|
||||
|
||||
teaserData.thumbnail_path?.let {
|
||||
image.loadImage(it)
|
||||
}
|
||||
|
||||
if (moreDetailsList.isNotEmpty()){
|
||||
|
||||
if (userPrefs?.appLanguage == "hi" && moreDetailsList.size > 1){
|
||||
moreDetailsList[1]?.let {data ->
|
||||
title.text = data.title
|
||||
description.text = Html.fromHtml(
|
||||
data.description?.replace(
|
||||
"<br>",
|
||||
" "
|
||||
), Html.FROM_HTML_MODE_LEGACY
|
||||
)
|
||||
val mediaType = "${getString(R.string.teasers)} ${teaserData.teaser_number}"
|
||||
mediaTypeNumber.text = mediaType
|
||||
duration.text = teaserData.teaser_duration
|
||||
}
|
||||
}else{
|
||||
moreDetailsList[0]?.let {data ->
|
||||
title.text = data.title
|
||||
description.text = Html.fromHtml(
|
||||
data.description?.replace(
|
||||
"<br>",
|
||||
" "
|
||||
), Html.FROM_HTML_MODE_LEGACY
|
||||
)
|
||||
val mediaType = "${getString(R.string.teasers)} ${teaserData.teaser_number}"
|
||||
mediaTypeNumber.text = mediaType
|
||||
duration.text = teaserData.teaser_duration
|
||||
}
|
||||
}
|
||||
}else{
|
||||
title.text = teaserData.teaser_title
|
||||
description.text = Html.fromHtml(
|
||||
teaserData.teaser_description?.replace(
|
||||
"<br>",
|
||||
" "
|
||||
), Html.FROM_HTML_MODE_LEGACY
|
||||
)
|
||||
val mediaType = "${getString(R.string.teasers)} ${teaserData.teaser_number}"
|
||||
mediaTypeNumber.text = mediaType
|
||||
duration.text = teaserData.teaser_duration
|
||||
}
|
||||
|
||||
watchCard.setOnClickListener {
|
||||
onTeaserPlayClicked(position)
|
||||
}
|
||||
|
||||
close.setOnClickListener {
|
||||
episodeDialog.dismiss()
|
||||
}
|
||||
|
||||
episodeDialog.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun onTeaserPlayClicked(position: Int) {
|
||||
startActivity(Intent(this, PlayerActivity::class.java).apply {
|
||||
putParcelableArrayListExtra(EXTRA_PLAY_LIST, WebSeriesRepository.teasersPlaylistMap["${showId}_${selectedSeasonId}_$categoryId"])
|
||||
putParcelableArrayListExtra(
|
||||
EXTRA_PLAY_LIST,
|
||||
WebSeriesRepository.teasersPlaylistMap["${showId}_${selectedSeasonId}_$categoryId"]
|
||||
)
|
||||
putExtra(EXTRA_EPISODE_INDEX, position)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
package com.woka.webseries.views
|
||||
|
||||
import android.app.Dialog
|
||||
import android.content.Intent
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.graphics.drawable.InsetDrawable
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.WindowManager
|
||||
import android.widget.AdapterView
|
||||
import android.widget.AdapterView.OnItemSelectedListener
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
@@ -16,6 +21,8 @@ import androidx.recyclerview.widget.SimpleItemAnimator
|
||||
import com.google.android.material.appbar.CollapsingToolbarLayout
|
||||
import com.woka.R
|
||||
import com.woka.databinding.ActivityWebSeriesBinding
|
||||
import com.woka.databinding.DialogBlogsBinding
|
||||
import com.woka.databinding.DialogEpisodeBinding
|
||||
import com.woka.modules.ModuleRepository
|
||||
import com.woka.networking.ApiResult
|
||||
import com.woka.utils.WokaBaseActivity
|
||||
@@ -90,7 +97,6 @@ class WebSeriesActivity : WokaBaseActivity(), Observer<ApiResult<HashMap<String,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun initViews(){
|
||||
|
||||
// adapters
|
||||
@@ -115,7 +121,7 @@ class WebSeriesActivity : WokaBaseActivity(), Observer<ApiResult<HashMap<String,
|
||||
showIntentLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()){
|
||||
if (it.resultCode == RESULT_OK){
|
||||
it.data?.getIntExtra(SeasonActivity.EXTRA_SHOW_POSITION, -1)?.let {position ->
|
||||
if (position > -1){
|
||||
if (position > -1 && position < showAdapter.itemCount){
|
||||
showAdapter.notifyItemChanged(position)
|
||||
}
|
||||
}
|
||||
@@ -136,7 +142,12 @@ class WebSeriesActivity : WokaBaseActivity(), Observer<ApiResult<HashMap<String,
|
||||
is ApiResult.Loading -> {}
|
||||
is ApiResult.Success -> {
|
||||
it.data?.result?.let {continueWatchList ->
|
||||
continueWatchAdapter.submitList(continueWatchList)
|
||||
if (continueWatchList.isNotEmpty()){
|
||||
binding.rvContinueWatch.show()
|
||||
continueWatchAdapter.submitList(continueWatchList.asReversed())
|
||||
}else{
|
||||
binding.rvContinueWatch.hide()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,38 +200,30 @@
|
||||
|
||||
/>
|
||||
|
||||
<com.woka.utils.PressableCard
|
||||
<Button
|
||||
android:id="@+id/watch_card"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:text="@string/watch"
|
||||
android:fontFamily="@font/exo_2_extrabold"
|
||||
android:textColor="@color/white"
|
||||
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/season_description"
|
||||
|
||||
app:isHapticEnabled="true">
|
||||
android:background="@drawable/round_bg_25"
|
||||
android:backgroundTint="#5E1FC4"
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:drawableStart="@drawable/ic_play_filled"
|
||||
|
||||
android:text="@string/watch"
|
||||
android:fontFamily="@font/exo_2_extrabold"
|
||||
android:textColor="@color/white"
|
||||
android:drawablePadding="15dp"
|
||||
|
||||
android:background="@drawable/round_bg_25"
|
||||
android:backgroundTint="#5E1FC4"
|
||||
android:paddingEnd="20dp"
|
||||
android:paddingStart="15dp"
|
||||
android:paddingVertical="10dp"
|
||||
|
||||
android:drawableStart="@drawable/ic_play_filled"
|
||||
|
||||
android:drawablePadding="15dp"
|
||||
|
||||
android:paddingEnd="20dp"
|
||||
android:paddingStart="15dp"
|
||||
android:paddingVertical="10dp"
|
||||
|
||||
/>
|
||||
|
||||
</com.woka.utils.PressableCard>
|
||||
/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/rate_season_ll"
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
android:layout_marginVertical="10dp"
|
||||
>
|
||||
|
||||
<ImageView
|
||||
<com.woka.utils.AdiImageView
|
||||
android:id="@+id/image"
|
||||
android:layout_width="@dimen/_240sdp"
|
||||
android:layout_height="@dimen/_120sdp"
|
||||
|
||||
152
app/src/main/res/layout/dialog_episode.xml
Normal file
152
app/src/main/res/layout/dialog_episode.xml
Normal file
@@ -0,0 +1,152 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:background="@drawable/round_15"
|
||||
android:orientation="vertical"
|
||||
android:paddingVertical="15dp">
|
||||
|
||||
<com.woka.utils.PressableImageView
|
||||
android:id="@+id/close"
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="25dp"
|
||||
android:src="@drawable/ic_close_filled"
|
||||
android:tint="@color/color_primary"
|
||||
android:contentDescription="@string/image"
|
||||
android:layout_gravity="end"
|
||||
android:layout_marginEnd="15dp"
|
||||
/>
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
app:cardBackgroundColor="@color/white"
|
||||
app:cardElevation="3dp"
|
||||
app:cardCornerRadius="15dp"
|
||||
android:layout_marginHorizontal="15dp"
|
||||
>
|
||||
|
||||
<com.woka.utils.AdiImageView
|
||||
android:id="@+id/image"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/_150sdp"
|
||||
android:src="@android:color/darker_gray"
|
||||
android:contentDescription="@string/image"
|
||||
android:scaleType="fitXY"
|
||||
app:imageCornerRadius="15dp"
|
||||
android:layout_margin="10dp"
|
||||
/>
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
tools:text="The title of the blog will be displayed here"
|
||||
android:fontFamily="@font/exo_2_bold"
|
||||
android:textColor="@color/color_primary"
|
||||
|
||||
android:layout_marginTop="15dp"
|
||||
android:layout_marginHorizontal="15dp"
|
||||
|
||||
android:maxLines="2"
|
||||
android:ellipsize="end"
|
||||
|
||||
/>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="15dp"
|
||||
>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/media_type_number"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
tools:text="Teaser 1"
|
||||
android:fontFamily="@font/exo_2_medium"
|
||||
android:textColor="@color/color_primary"
|
||||
|
||||
android:layout_marginTop="5dp"
|
||||
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/duration"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
tools:text="00:01:00"
|
||||
android:fontFamily="@font/exo_2_medium"
|
||||
android:textColor="@color/color_primary"
|
||||
|
||||
android:layout_alignParentEnd="true"
|
||||
|
||||
android:layout_marginTop="5dp"
|
||||
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
|
||||
/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/scrollView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginVertical="10dp"
|
||||
>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/description"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
tools:text="Description is here"
|
||||
android:fontFamily="@font/exo_2"
|
||||
android:textColor="@color/color_primary"
|
||||
|
||||
android:layout_marginHorizontal="15dp"
|
||||
/>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
<Button
|
||||
android:id="@+id/watch_card"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:text="@string/watch"
|
||||
android:fontFamily="@font/exo_2_extrabold"
|
||||
android:textColor="@color/white"
|
||||
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/season_description"
|
||||
|
||||
android:background="@drawable/round_bg_25"
|
||||
android:backgroundTint="#5E1FC4"
|
||||
|
||||
android:drawableStart="@drawable/ic_play_filled"
|
||||
|
||||
android:drawablePadding="15dp"
|
||||
|
||||
android:paddingEnd="20dp"
|
||||
android:paddingStart="15dp"
|
||||
android:paddingVertical="10dp"
|
||||
|
||||
android:layout_marginHorizontal="15dp"
|
||||
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/card"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
|
||||
@@ -129,4 +129,18 @@
|
||||
<string name="enter_your_child_s_name">अपने बच्चे का नाम दर्ज करें</string>
|
||||
<string name="woka_songs">वोका गाने</string>
|
||||
<string name="do_you_want_to_exit_from_the_woka_app">क्या आप WOKA ऐप से बाहर निकलना चाहते हैं?</string>
|
||||
<string name="retry">पुन: प्रयास करें</string>
|
||||
<string name="web_series_hindi">वेब सीरीज (हिन्दी)</string>
|
||||
<string name="web_series_english">वेब सीरीज (अंग्रेजी)</string>
|
||||
<string name="no_internet">कृपया इंटरनेट से कनेक्ट करें</string>
|
||||
<string name="trailer">ट्रेलर</string>
|
||||
<string name="select_video_language">वीडियो भाषा चुनें</string>
|
||||
<string name="continue_watching">देखना जारी रखें</string>
|
||||
<string name="watch">देखें</string>
|
||||
<string name="add">अप्रिय</string>
|
||||
<string name="rate">पसंदीदा</string>
|
||||
<string name="share">शेयर</string>
|
||||
<string name="couldnt_play_video">वीडियो नहीं चलाया जा सका</string>
|
||||
<string name="teasers">टीज़र</string>
|
||||
<string name="episode">एपिसोड</string>
|
||||
</resources>
|
||||
@@ -163,16 +163,16 @@
|
||||
<string name="woka_songs">WOKA Songs</string>
|
||||
<string name="app_name_caps" translatable="false">WOKA</string>
|
||||
<string name="do_you_want_to_exit_from_the_woka_app">Do you want to exit from the WOKA app?</string>
|
||||
<string name="_00_00">00:00</string>
|
||||
<string name="slash">/</string>
|
||||
<string name="notifications">Notifications</string>
|
||||
<string name="_00_00" translatable="false">00:00</string>
|
||||
<string name="slash" translatable="false">/</string>
|
||||
<string name="notifications" translatable="false">Notifications</string>
|
||||
<string name="retry">Retry</string>
|
||||
<string name="no_notifications_found">No notifications found</string>
|
||||
<string name="favorites">Favorites</string>
|
||||
<string name="no_notifications_found" translatable="false">No notifications found</string>
|
||||
<string name="favorites" translatable="false">Favorites</string>
|
||||
<string name="web_series_hindi">WEB SERIES (HINDI)</string>
|
||||
<string name="web_series_english">WEB SERIES (ENGLISH)</string>
|
||||
<string name="no_favorites_added">No favorites added</string>
|
||||
<string name="_0">0</string>
|
||||
<string name="no_favorites_added" translatable="false">No favorites added</string>
|
||||
<string name="_0" translatable="false">0</string>
|
||||
<string name="no_internet">No internet</string>
|
||||
<string name="trailer">TRAILER</string>
|
||||
<string name="select_video_language">Select video language</string>
|
||||
@@ -183,4 +183,5 @@
|
||||
<string name="share">SHARE</string>
|
||||
<string name="couldnt_play_video">Couldn\'t play video</string>
|
||||
<string name="teasers">Teasers</string>
|
||||
<string name="episode">Episode</string>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user