Bookmark and like syncing between SeasonActivity, MyListFragment and WebSeriesActivity
Custom imageview with loading state and other handling recyclerview inside nested scroll view problem created ui for tab_view in episodelisting screen tab background integrated api and cached data for seasonlisting and inflated tabs
This commit is contained in:
@@ -58,7 +58,7 @@ import com.woka.utils.PRIVACY_N_POLICY_URL
|
||||
import com.woka.utils.ProgressView
|
||||
import com.woka.utils.TAG
|
||||
import com.woka.utils.TERMS_N_CONDITIONS_URL
|
||||
import com.woka.utils.UserType
|
||||
import com.woka.userPreference.UserType
|
||||
import com.woka.utils.WokaBaseActivity
|
||||
import com.woka.utils.changeLocale
|
||||
import com.woka.utils.hide
|
||||
|
||||
@@ -26,7 +26,7 @@ import com.woka.home.TimePeriod
|
||||
import com.woka.userdata.userDataModels.UserDataResponse
|
||||
import com.woka.networking.ApiResult
|
||||
import com.woka.players.LiveStreamPlayerActivity
|
||||
import com.woka.utils.UserType
|
||||
import com.woka.userPreference.UserType
|
||||
import com.woka.utils.hide
|
||||
import com.woka.utils.scaleAnimate
|
||||
import com.woka.utils.show
|
||||
|
||||
@@ -15,7 +15,7 @@ import com.woka.home.HomeViewModel
|
||||
import com.woka.userdata.userDataModels.UserDataResponse
|
||||
import com.woka.networking.ApiResult
|
||||
import com.woka.players.LiveStreamPlayerActivity
|
||||
import com.woka.utils.UserType
|
||||
import com.woka.userPreference.UserType
|
||||
import com.woka.utils.hide
|
||||
import com.woka.utils.show
|
||||
|
||||
|
||||
@@ -95,6 +95,8 @@ class MyListFragment : Fragment() {
|
||||
val hinList = mutableListOf<BookmarkedShowData>()
|
||||
|
||||
for (show in showData){
|
||||
if (show.bookmark_category_ids?.isEmpty() == true) continue
|
||||
|
||||
val ids = show.bookmark_category_ids?.split(",")
|
||||
ids?.let {bIds ->
|
||||
if (bIds.isNotEmpty()) {
|
||||
|
||||
@@ -38,7 +38,7 @@ object MyListRepository {
|
||||
return _myFavListLiveData
|
||||
}
|
||||
|
||||
private var myFavData: MyListResponse? = null
|
||||
var myFavData: MyListResponse? = null
|
||||
|
||||
/*
|
||||
flag to load a new data whenever necessary
|
||||
@@ -147,11 +147,13 @@ object MyListRepository {
|
||||
loadMyFavList()
|
||||
}else{
|
||||
myFavData?.result?.show_data?.let {
|
||||
if (addToFav){
|
||||
it.add(showData)
|
||||
}else{
|
||||
it.removeIf { bShow ->
|
||||
bShow.id == showData.id
|
||||
for (show in it){
|
||||
if (showData.id == show.id){
|
||||
if (addToFav){
|
||||
show.addAsBookMark(categoryId)
|
||||
}else{
|
||||
show.removeAsBookMark(categoryId)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -287,21 +289,10 @@ object MyListRepository {
|
||||
}
|
||||
}
|
||||
}
|
||||
private fun changeLikeLocally(id: String, postType: PostType, isLiked: Boolean){
|
||||
fun changeLikeLocally(id: String, postType: PostType, isLiked: Boolean){
|
||||
when(postType){
|
||||
PostType.WEB_SERIES -> {
|
||||
myFavData?.result?.show_data?.let {
|
||||
for (show in it){
|
||||
if ("${show.id}" == id){
|
||||
show.is_liked = isLiked
|
||||
show.likes_count?.let { count ->
|
||||
show.likes_count = if (isLiked) count + 1
|
||||
else max(0, count - 1)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
WebSeriesRepository.changeLikeLocally(id, isLiked)
|
||||
}
|
||||
|
||||
PostType.AUDIO_BOOKS -> {
|
||||
|
||||
@@ -54,9 +54,7 @@ class AudioBooksAdapter(private val context: Context,
|
||||
|
||||
holder.binding.apply {
|
||||
audioData.thumbnail_path?.let {
|
||||
Glide.with(root.context)
|
||||
.load(it)
|
||||
.into(image)
|
||||
image.loadImage(it)
|
||||
}
|
||||
|
||||
title.text = audioData.title
|
||||
|
||||
@@ -54,9 +54,7 @@ class GamesAdapter(private val context: Context,
|
||||
|
||||
holder.binding.apply {
|
||||
gameData.thumbnail_path?.let {
|
||||
Glide.with(root.context)
|
||||
.load(it)
|
||||
.into(image)
|
||||
image.loadImage(it)
|
||||
}
|
||||
|
||||
title.text = gameData.title
|
||||
|
||||
@@ -55,9 +55,7 @@ class KaraokeAdapter(private val context: Context,
|
||||
|
||||
holder.binding.apply {
|
||||
karaokeData.thumbnail_path?.let {
|
||||
Glide.with(root.context)
|
||||
.load(it)
|
||||
.into(image)
|
||||
image.loadImage(it)
|
||||
}
|
||||
|
||||
title.text = karaokeData.title
|
||||
|
||||
@@ -57,9 +57,7 @@ class WebSeriesAdapter(private val context: Context,
|
||||
|
||||
holder.binding.apply {
|
||||
showData.thumbnail_path?.let {
|
||||
Glide.with(root.context)
|
||||
.load(it)
|
||||
.into(image)
|
||||
image.loadImage(it)
|
||||
}
|
||||
|
||||
title.text = showData.title
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.woka.webseries.models.ShowData
|
||||
|
||||
data class BookmarkedShowData(
|
||||
val age_range_master_id: String?,
|
||||
val bookmark_category_ids: String?,
|
||||
var bookmark_category_ids: String?,
|
||||
val bookmark_count: Int?,
|
||||
val category_master_id: String?,
|
||||
val content_more_details: List<ContentMoreDetail?>?,
|
||||
@@ -41,4 +41,17 @@ data class BookmarkedShowData(
|
||||
showData.total_seasons,
|
||||
showData.views_count
|
||||
)
|
||||
|
||||
fun addAsBookMark(categoryId: String){
|
||||
val categories = bookmark_category_ids?.split(",")?.toMutableList()?: mutableListOf()
|
||||
categories.add(categoryId)
|
||||
bookmark_category_ids = categories.joinToString(",")
|
||||
}
|
||||
|
||||
fun removeAsBookMark(categoryId: String){
|
||||
bookmark_category_ids?.split(",")?.toMutableList()?.let {
|
||||
it.remove(categoryId)
|
||||
bookmark_category_ids = it.joinToString(",")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,10 +2,7 @@ package com.woka.home.sidebar.profile
|
||||
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.transition.Slide
|
||||
import android.view.Gravity.END
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import androidx.core.content.res.ResourcesCompat
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.core.widget.addTextChangedListener
|
||||
@@ -18,7 +15,7 @@ import com.woka.userdata.userDataModels.UserData
|
||||
import com.woka.networking.ApiResult
|
||||
import com.woka.utils.Gender
|
||||
import com.woka.utils.ProgressView
|
||||
import com.woka.utils.UserType
|
||||
import com.woka.userPreference.UserType
|
||||
import com.woka.utils.WokaBaseActivity
|
||||
import com.woka.utils.hide
|
||||
import com.woka.utils.toast
|
||||
|
||||
@@ -16,7 +16,7 @@ import com.woka.WokaApp.Companion.userPrefs
|
||||
import com.woka.databinding.ActivitySupportBinding
|
||||
import com.woka.networking.ApiResult
|
||||
import com.woka.utils.ProgressView
|
||||
import com.woka.utils.UserType
|
||||
import com.woka.userPreference.UserType
|
||||
import com.woka.utils.WokaBaseActivity
|
||||
import com.woka.utils.hide
|
||||
import com.woka.utils.toast
|
||||
|
||||
@@ -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.jwplayer.pub.api.JWPlayer
|
||||
import com.woka.R
|
||||
import com.woka.WokaApp
|
||||
import com.woka.WokaApp.Companion.userPrefs
|
||||
@@ -47,11 +48,7 @@ class BlogsAdapter(private val onBlogClicked: KFunction1<Blog, Unit>, config: As
|
||||
holder.binding.apply {
|
||||
|
||||
blog.thumbnail_path?.let {
|
||||
Glide.with(holder.binding.image)
|
||||
.load(it)
|
||||
.placeholder(android.R.color.darker_gray)
|
||||
.error(R.drawable.woka_logo_half)
|
||||
.into(image)
|
||||
image.loadImage(it)
|
||||
}
|
||||
|
||||
card.setOnClickListener {
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
package com.woka.networking
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.provider.Settings
|
||||
import com.woka.BuildConfig
|
||||
import com.woka.WokaApp.Companion.userPrefs
|
||||
import com.woka.onboard.models.LoginResponse
|
||||
import com.woka.utils.NO_INTERNET_MESSAGE
|
||||
import com.woka.utils.UNKNOWN_ERROR_MESSAGE
|
||||
import com.woka.utils.UserType
|
||||
import kotlinx.coroutines.delay
|
||||
import com.woka.userPreference.UserType
|
||||
import okhttp3.Credentials
|
||||
import okhttp3.Interceptor
|
||||
import okhttp3.OkHttpClient
|
||||
|
||||
@@ -20,7 +20,7 @@ import com.woka.networking.ApiResult
|
||||
import com.woka.onboard.OnboardingAdapter
|
||||
import com.woka.onboard.mvvm.OnboardViewModel
|
||||
import com.woka.utils.ProgressView
|
||||
import com.woka.utils.UserType
|
||||
import com.woka.userPreference.UserType
|
||||
import com.woka.utils.toast
|
||||
|
||||
class OnboardFragment : Fragment() {
|
||||
|
||||
@@ -2,12 +2,10 @@ package com.woka.onboard.fragments
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import androidx.fragment.app.Fragment
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.Toast
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.woka.R
|
||||
@@ -15,19 +13,15 @@ import com.woka.WokaApp.Companion.userPrefs
|
||||
import com.woka.databinding.FragmentSelectAvatarBinding
|
||||
import com.woka.home.HomeActivity
|
||||
import com.woka.networking.ApiResult
|
||||
import com.woka.networking.RetrofitHelper
|
||||
import com.woka.onboard.AvatarAdapter
|
||||
import com.woka.onboard.fragments.GetEmailFragment.Companion.IS_UNDER_16
|
||||
import com.woka.onboard.models.Avatar
|
||||
import com.woka.onboard.models.RegisterRequestData
|
||||
import com.woka.onboard.mvvm.OnboardViewModel
|
||||
import com.woka.userdata.UserRepository
|
||||
import com.woka.utils.Gender
|
||||
import com.woka.utils.ProgressView
|
||||
import com.woka.utils.UserType
|
||||
import com.woka.userPreference.UserType
|
||||
import com.woka.utils.toast
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Locale
|
||||
|
||||
@@ -8,7 +8,6 @@ import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.WindowManager
|
||||
import android.widget.Toast
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import com.woka.R
|
||||
@@ -20,7 +19,7 @@ import com.woka.onboard.fragments.GetEmailFragment.Companion.IS_RESET_PASSWORD_I
|
||||
import com.woka.onboard.mvvm.OnboardViewModel
|
||||
import com.woka.utils.DecisionDialog
|
||||
import com.woka.utils.ProgressView
|
||||
import com.woka.utils.UserType
|
||||
import com.woka.userPreference.UserType
|
||||
import com.woka.utils.toast
|
||||
|
||||
class SignInFragment : Fragment() {
|
||||
|
||||
@@ -18,7 +18,7 @@ import com.woka.databinding.FragmentSplashBinding
|
||||
import com.woka.home.HomeActivity
|
||||
import com.woka.userdata.userDataModels.UserDataResponse
|
||||
import com.woka.networking.ApiResult
|
||||
import com.woka.utils.UserType
|
||||
import com.woka.userPreference.UserType
|
||||
import com.woka.utils.toast
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
@@ -15,7 +15,6 @@ import com.woka.onboard.OnboardActivity
|
||||
import com.woka.userdata.UserRepository
|
||||
import com.woka.userdata.userDataModels.UserData
|
||||
import com.woka.userdata.userDataModels.UserDataResponse
|
||||
import com.woka.utils.UserType
|
||||
import com.woka.webseries.WebSeriesRepository
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.woka.utils
|
||||
package com.woka.userPreference
|
||||
|
||||
enum class UserType(val id: Int) {
|
||||
CHILD(1),
|
||||
@@ -7,7 +7,7 @@ enum class UserType(val id: Int) {
|
||||
NONE(-1);
|
||||
|
||||
companion object{
|
||||
fun createUserType(id: Int?): UserType{
|
||||
fun createUserType(id: Int?): UserType {
|
||||
return when(id){
|
||||
1 -> CHILD
|
||||
2 -> GUARDIAN
|
||||
103
app/src/main/java/com/woka/utils/AdiImageView.kt
Normal file
103
app/src/main/java/com/woka/utils/AdiImageView.kt
Normal file
@@ -0,0 +1,103 @@
|
||||
package com.woka.utils
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.ColorStateList
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.util.AttributeSet
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.ImageView
|
||||
import android.widget.ProgressBar
|
||||
import androidx.appcompat.content.res.AppCompatResources
|
||||
import androidx.cardview.widget.CardView
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.load.DataSource
|
||||
import com.bumptech.glide.load.engine.GlideException
|
||||
import com.bumptech.glide.request.RequestListener
|
||||
import com.bumptech.glide.request.target.Target
|
||||
import com.woka.R
|
||||
|
||||
class AdiImageView: FrameLayout {
|
||||
|
||||
// attributes
|
||||
private var cornerRadius: Int = 0
|
||||
private var loadingColor: Int = android.R.color.darker_gray
|
||||
private var errorSrc: Drawable? = AppCompatResources.getDrawable(context, R.drawable.img_error_src)
|
||||
private var progressTintMode: Int = context.getColor(android.R.color.white)
|
||||
|
||||
// views
|
||||
private var imageView: ImageView? = null
|
||||
private var progressView: ProgressBar? = null
|
||||
private var cardView: CardView? = null
|
||||
|
||||
constructor(context: Context?) : super(context!!)
|
||||
constructor(context: Context?, attrs: AttributeSet?) : super(
|
||||
context!!, attrs
|
||||
){
|
||||
setAttributes(attrs)
|
||||
inflateView()
|
||||
}
|
||||
|
||||
constructor(context: Context?, attrs: AttributeSet?, defStyle: Int) : super(
|
||||
context!!, attrs, defStyle
|
||||
) {
|
||||
setAttributes(attrs)
|
||||
inflateView()
|
||||
}
|
||||
|
||||
private fun setAttributes(attrs: AttributeSet?){
|
||||
val attributes = context.obtainStyledAttributes(attrs, R.styleable.AdiImageView)
|
||||
|
||||
cornerRadius = attributes.getDimensionPixelSize(R.styleable.AdiImageView_imageCornerRadius, 0)
|
||||
errorSrc = attributes.getDrawable(R.styleable.AdiImageView_errorSrc)
|
||||
progressTintMode = attributes.getColor(R.styleable.AdiImageView_android_progressTintMode, progressTintMode)
|
||||
|
||||
attributes.recycle()
|
||||
}
|
||||
|
||||
private fun inflateView() {
|
||||
val view = inflate(context, R.layout.layout_adi_imageview, this)
|
||||
|
||||
imageView = view.findViewById(R.id.adi_image)
|
||||
progressView = view.findViewById(R.id.adi_progress)
|
||||
cardView = view.findViewById(R.id.adi_card)
|
||||
|
||||
progressView?.indeterminateTintList = ColorStateList.valueOf(progressTintMode)
|
||||
cardView?.radius = cornerRadius.toFloat()
|
||||
|
||||
}
|
||||
|
||||
fun loadImage(url: String?) {
|
||||
imageView?.let {
|
||||
|
||||
progressView?.show()
|
||||
|
||||
Glide.with(context.applicationContext)
|
||||
.load(url)
|
||||
.addListener(object: RequestListener<Drawable>{
|
||||
override fun onLoadFailed(
|
||||
e: GlideException?,
|
||||
model: Any?,
|
||||
target: Target<Drawable>,
|
||||
isFirstResource: Boolean
|
||||
): Boolean {
|
||||
progressView?.hide()
|
||||
imageView?.setImageDrawable(errorSrc)
|
||||
return false
|
||||
}
|
||||
|
||||
override fun onResourceReady(
|
||||
resource: Drawable,
|
||||
model: Any,
|
||||
target: Target<Drawable>?,
|
||||
dataSource: DataSource,
|
||||
isFirstResource: Boolean
|
||||
): Boolean {
|
||||
progressView?.hide()
|
||||
return false
|
||||
}
|
||||
})
|
||||
.placeholder(loadingColor)
|
||||
.into(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.woka.webseries
|
||||
|
||||
import com.woka.networking.ApiResponse
|
||||
import com.woka.webseries.models.WebSeriesResponse
|
||||
import com.woka.webseries.models.seasondata.SeasonDataResponse
|
||||
import okhttp3.FormBody
|
||||
import retrofit2.Response
|
||||
import retrofit2.http.Body
|
||||
@@ -11,4 +12,7 @@ interface WebSeriesApiService {
|
||||
|
||||
@POST("watch_show_listing")
|
||||
suspend fun getWebSeries(@Body formBody: FormBody): Response<ApiResponse<WebSeriesResponse>>
|
||||
|
||||
@POST("season_listing")
|
||||
suspend fun seasonListing(@Body formBody: FormBody): Response<ApiResponse<SeasonDataResponse>>
|
||||
}
|
||||
@@ -12,6 +12,8 @@ import com.woka.networking.RetrofitHelper
|
||||
import com.woka.webseries.models.ContinueEpisodeResponse
|
||||
import com.woka.webseries.models.ShowData
|
||||
import com.woka.webseries.models.WebSeriesResponse
|
||||
import com.woka.webseries.models.seasondata.SeasonData
|
||||
import com.woka.webseries.models.seasondata.SeasonDataResponse
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
@@ -58,10 +60,47 @@ object WebSeriesRepository {
|
||||
*/
|
||||
private var shallLoadNewContinueWatchData: Boolean = false
|
||||
|
||||
// seasonListing data
|
||||
private val _seasonDataLiveData = MutableLiveData<ApiResult<SeasonDataResponse>>()
|
||||
val seasonDataLiveData: LiveData<ApiResult<SeasonDataResponse>>
|
||||
get() = _seasonDataLiveData
|
||||
|
||||
private var seasonDataMap = HashMap<Int, SeasonDataResponse>()
|
||||
|
||||
init {
|
||||
loadContinueWatchData()
|
||||
}
|
||||
|
||||
fun loadSeasonListing(showId: Int, categoryId: String){
|
||||
if (seasonDataMap.containsKey(showId)){
|
||||
_seasonDataLiveData.postValue(ApiResult.Success(data = seasonDataMap[showId]))
|
||||
return
|
||||
}
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
_seasonDataLiveData.postValue(ApiResult.Loading())
|
||||
val response = RetrofitHelper.handleApiCall {
|
||||
apiService.seasonListing(
|
||||
FormBody.Builder()
|
||||
.add("watch_show_id", "$showId")
|
||||
.add("category_id", categoryId)
|
||||
.build()
|
||||
)
|
||||
}
|
||||
|
||||
when (response){
|
||||
is ApiResult.Error -> {}
|
||||
is ApiResult.Loading -> {}
|
||||
is ApiResult.Success -> {
|
||||
response.data?.let {seasonList ->
|
||||
seasonDataMap[showId] = seasonList
|
||||
}
|
||||
|
||||
_seasonDataLiveData.postValue(ApiResult.Success(response.data))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun loadContinueWatchData(){
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
_continueWatchLiveData.postValue(ApiResult.Loading())
|
||||
@@ -151,7 +190,8 @@ object WebSeriesRepository {
|
||||
}
|
||||
}
|
||||
|
||||
private fun changeLikeLocally(id: String, isLiked: Boolean){
|
||||
fun changeLikeLocally(id: String, isLiked: Boolean){
|
||||
// changing in web series locally
|
||||
for (showDataResponse in webSeriesData.values){
|
||||
showDataResponse.show_data?.let {shows ->
|
||||
for (show in shows){
|
||||
@@ -173,6 +213,20 @@ object WebSeriesRepository {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// changing in fav list locally
|
||||
MyListRepository.myFavData?.result?.show_data?.let {
|
||||
for (show in it){
|
||||
if ("${show.id}" == id){
|
||||
show.is_liked = isLiked
|
||||
show.likes_count?.let { count ->
|
||||
show.likes_count = if (isLiked) count + 1
|
||||
else max(0, count - 1)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun updateFavShow(showData: ShowData, addToBookmark: Boolean, categoryId: String){
|
||||
|
||||
@@ -16,7 +16,6 @@ data class ShowData(
|
||||
val liked_category_ids: String?,
|
||||
var likes_count: Int?,
|
||||
var mark_as_favourite: Boolean?,
|
||||
val season_data: List<SeasonData?>?,
|
||||
val show_type: String?,
|
||||
val thumbnail_path: String?,
|
||||
val title: String?,
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.woka.webseries.models
|
||||
package com.woka.webseries.models.seasondata
|
||||
|
||||
data class SeasonData(
|
||||
val category_master_id: String?,
|
||||
val id: Int?,
|
||||
val media_type: String?,
|
||||
val no_of_episodes: Int?,
|
||||
val release_date: String?,
|
||||
val release_year: Int?,
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.woka.webseries.models.seasondata
|
||||
|
||||
data class SeasonDataResponse(
|
||||
val result: List<SeasonData?>?,
|
||||
val total_records: Int?
|
||||
)
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.woka.webseries.models.seasondata
|
||||
|
||||
data class SeasonMoreDetail(
|
||||
val content_id: Int?,
|
||||
val description: String?,
|
||||
val id: Int?,
|
||||
val language_master_id: Int?,
|
||||
val post_type: Int?,
|
||||
val tags_keywords: String?,
|
||||
val title: String?,
|
||||
val trailer_hd_url: String?,
|
||||
val trailer_sd_url: String?
|
||||
)
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.woka.webseries.views
|
||||
|
||||
import android.content.Intent
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
@@ -7,17 +8,24 @@ import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import com.bumptech.glide.Glide
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
import com.google.android.material.tabs.TabLayout.OnTabSelectedListener
|
||||
import com.woka.R
|
||||
import com.woka.databinding.ActivitySeasonBinding
|
||||
import com.woka.networking.ApiResult
|
||||
import com.woka.utils.isNetworkConnected
|
||||
import com.woka.utils.lightStatusBar
|
||||
import com.woka.utils.toast
|
||||
import com.woka.webseries.WebSeriesRepository
|
||||
import com.woka.webseries.models.ShowData
|
||||
import kotlin.math.max
|
||||
|
||||
class SeasonActivity : AppCompatActivity() {
|
||||
class SeasonActivity : AppCompatActivity(), OnTabSelectedListener {
|
||||
|
||||
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"
|
||||
}
|
||||
|
||||
private lateinit var binding: ActivitySeasonBinding
|
||||
@@ -26,6 +34,8 @@ class SeasonActivity : AppCompatActivity() {
|
||||
|
||||
private var showData: ShowData? = null
|
||||
|
||||
private var showPosition: Int = -1
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
enableEdgeToEdge()
|
||||
@@ -44,6 +54,7 @@ class SeasonActivity : AppCompatActivity() {
|
||||
|
||||
showId = intent.getIntExtra(EXTRA_SHOW_ID, -1)
|
||||
categoryId = intent.getStringExtra(EXTRA_SHOW_CATEGORY_DATA)
|
||||
showPosition = intent.getIntExtra(EXTRA_SHOW_POSITION, -1)
|
||||
|
||||
if (showId == -1 || categoryId == null){
|
||||
finish()
|
||||
@@ -61,6 +72,12 @@ class SeasonActivity : AppCompatActivity() {
|
||||
|
||||
initViews()
|
||||
|
||||
clickEvents()
|
||||
|
||||
setObservers()
|
||||
|
||||
WebSeriesRepository.loadSeasonListing(showId, categoryId!!)
|
||||
|
||||
}
|
||||
|
||||
private fun initViews() {
|
||||
@@ -81,4 +98,87 @@ class SeasonActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun clickEvents(){
|
||||
binding.apply {
|
||||
backBtn.setOnClickListener {
|
||||
onBackPressedDispatcher.onBackPressed()
|
||||
}
|
||||
|
||||
likeSeason.setOnClickListener {
|
||||
if (!isNetworkConnected()){
|
||||
toast(getString(R.string.no_internet))
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
categoryId?.let {
|
||||
if (likeSeason.isSelected){
|
||||
WebSeriesRepository.likeUnLikeShow("${showData?.id}", false, it)
|
||||
|
||||
showData?.likes_count?.let {likeCountInt ->
|
||||
likeCount.text = "${max(likeCountInt - 1, 0)}"
|
||||
}
|
||||
}else{
|
||||
WebSeriesRepository.likeUnLikeShow("${showData?.id}", true, it)
|
||||
|
||||
showData?.likes_count?.let {likeCountInt ->
|
||||
val value = likeCountInt + 1
|
||||
likeCount.text = "$value"
|
||||
}
|
||||
}
|
||||
|
||||
likeSeason.isSelected = !likeSeason.isSelected
|
||||
setResult(RESULT_OK, Intent().apply {
|
||||
putExtra(EXTRA_SHOW_POSITION, showPosition)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
favSeason.setOnClickListener {
|
||||
if (!isNetworkConnected()){
|
||||
toast(getString(R.string.no_internet))
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
if (showData == null) return@setOnClickListener
|
||||
|
||||
categoryId?.let {
|
||||
WebSeriesRepository.updateFavShow(
|
||||
showData!!,
|
||||
!favSeason.isSelected,
|
||||
it
|
||||
)
|
||||
|
||||
favSeason.isSelected = !favSeason.isSelected
|
||||
|
||||
setResult(RESULT_OK, Intent().apply {
|
||||
putExtra(EXTRA_SHOW_POSITION, showPosition)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setObservers(){
|
||||
WebSeriesRepository.seasonDataLiveData.observe(this){
|
||||
when(it){
|
||||
is ApiResult.Error -> {}
|
||||
is ApiResult.Loading -> {}
|
||||
is ApiResult.Success -> {
|
||||
it.data?.result?.let {seasonList ->
|
||||
for (season in seasonList){
|
||||
if (season == null) continue
|
||||
binding.seasonsTab.addTab(binding.seasonsTab.newTab().setText("${season.season_number}"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onTabSelected(p0: TabLayout.Tab?) {}
|
||||
|
||||
override fun onTabUnselected(p0: TabLayout.Tab?) {}
|
||||
|
||||
override fun onTabReselected(p0: TabLayout.Tab?) {}
|
||||
}
|
||||
@@ -1,14 +1,15 @@
|
||||
package com.woka.webseries.views
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.widget.AdapterView
|
||||
import android.widget.AdapterView.OnItemSelectedListener
|
||||
import android.widget.ArrayAdapter
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import androidx.activity.result.ActivityResultLauncher
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.Observer
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.recyclerview.widget.SimpleItemAnimator
|
||||
@@ -24,6 +25,7 @@ import com.woka.webseries.WebSeriesRepository
|
||||
import com.woka.webseries.adapters.ContinueEpisodeAdapter
|
||||
import com.woka.webseries.adapters.SpinnerAdapter
|
||||
import com.woka.webseries.adapters.WebSeriesShowAdapter
|
||||
import com.woka.webseries.models.ShowData
|
||||
import com.woka.webseries.models.WebSeriesResponse
|
||||
import com.woka.webseries.viewmodel.WebSeriesViewModel
|
||||
|
||||
@@ -39,6 +41,8 @@ class WebSeriesActivity : WokaBaseActivity(), Observer<ApiResult<HashMap<String,
|
||||
|
||||
private var catSpinnerAdapter: SpinnerAdapter? = null
|
||||
|
||||
private var showIntentLauncher: ActivityResultLauncher<Intent>? = null
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
enableEdgeToEdge()
|
||||
@@ -60,6 +64,8 @@ class WebSeriesActivity : WokaBaseActivity(), Observer<ApiResult<HashMap<String,
|
||||
|
||||
setObservers()
|
||||
|
||||
resultLaunchers()
|
||||
|
||||
if(!ModuleRepository.showCategoryLiveData.isInitialized){
|
||||
ModuleRepository.showCategories()
|
||||
}
|
||||
@@ -88,7 +94,7 @@ class WebSeriesActivity : WokaBaseActivity(), Observer<ApiResult<HashMap<String,
|
||||
private fun initViews(){
|
||||
|
||||
// adapters
|
||||
showAdapter = WebSeriesShowAdapter(this)
|
||||
showAdapter = WebSeriesShowAdapter(this, ::onShowClicked)
|
||||
continueWatchAdapter = ContinueEpisodeAdapter(this)
|
||||
|
||||
binding.apply {
|
||||
@@ -105,6 +111,18 @@ class WebSeriesActivity : WokaBaseActivity(), Observer<ApiResult<HashMap<String,
|
||||
|
||||
}
|
||||
|
||||
private fun resultLaunchers(){
|
||||
showIntentLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()){
|
||||
if (it.resultCode == RESULT_OK){
|
||||
it.data?.getIntExtra(SeasonActivity.EXTRA_SHOW_POSITION, -1)?.let {position ->
|
||||
if (position > -1){
|
||||
showAdapter.notifyItemChanged(position)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setObservers(){
|
||||
|
||||
viewmodel.webSeriesLiveData.observe(this, this)
|
||||
@@ -215,4 +233,12 @@ class WebSeriesActivity : WokaBaseActivity(), Observer<ApiResult<HashMap<String,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun onShowClicked(showData: ShowData, position: Int, categoryId: String){
|
||||
showIntentLauncher?.launch(Intent(this, SeasonActivity::class.java).apply {
|
||||
putExtra(SeasonActivity.EXTRA_SHOW_ID, showData.id)
|
||||
putExtra(SeasonActivity.EXTRA_SHOW_CATEGORY_DATA, categoryId)
|
||||
putExtra(SeasonActivity.EXTRA_SHOW_POSITION, position)
|
||||
})
|
||||
}
|
||||
}
|
||||
BIN
app/src/main/res/drawable-hdpi/img_error_src.png
Normal file
BIN
app/src/main/res/drawable-hdpi/img_error_src.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 20 KiB |
BIN
app/src/main/res/drawable-ldpi/img_error_src.png
Normal file
BIN
app/src/main/res/drawable-ldpi/img_error_src.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.1 KiB |
BIN
app/src/main/res/drawable-mdpi/img_error_src.png
Normal file
BIN
app/src/main/res/drawable-mdpi/img_error_src.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.9 KiB |
BIN
app/src/main/res/drawable-xhdpi/img_error_src.png
Normal file
BIN
app/src/main/res/drawable-xhdpi/img_error_src.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 36 KiB |
BIN
app/src/main/res/drawable-xxhdpi/img_error_src.png
Normal file
BIN
app/src/main/res/drawable-xxhdpi/img_error_src.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 70 KiB |
BIN
app/src/main/res/drawable-xxxhdpi/img_error_src.png
Normal file
BIN
app/src/main/res/drawable-xxxhdpi/img_error_src.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 108 KiB |
23
app/src/main/res/drawable/season_tab_bg.xml
Normal file
23
app/src/main/res/drawable/season_tab_bg.xml
Normal file
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:aapt="http://schemas.android.com/aapt">
|
||||
<item android:state_focused="true" android:state_selected="true">
|
||||
<shape android:shape="rectangle">
|
||||
<stroke android:width="3dp" android:color="#5e1fc4"/>
|
||||
<corners android:radius="25dp"/>
|
||||
<solid android:color="@color/white"/>
|
||||
</shape>
|
||||
</item>
|
||||
<item android:state_selected="true">
|
||||
<shape android:shape="rectangle">
|
||||
<stroke android:width="3dp" android:color="@color/color_primary"/>
|
||||
<corners android:radius="25dp"/>
|
||||
<solid android:color="@color/white"/>
|
||||
</shape>
|
||||
</item>
|
||||
<item android:state_focused="true">
|
||||
<shape android:shape="rectangle">
|
||||
<stroke android:width="3dp" android:color="#5e1fc4"/>
|
||||
<corners android:radius="25dp"/>
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
||||
@@ -172,8 +172,8 @@
|
||||
>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="25dp"
|
||||
android:contentDescription="@string/image"
|
||||
android:src="@drawable/ic_like_filled"
|
||||
/>
|
||||
@@ -181,11 +181,12 @@
|
||||
<TextView
|
||||
android:id="@+id/like_count"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
tools:text="10"
|
||||
android:fontFamily="@font/exo_2_semibold"
|
||||
android:textColor="@color/color_primary"
|
||||
android:textSize="@dimen/_14ssp"
|
||||
|
||||
android:textAlignment="center"
|
||||
|
||||
@@ -265,8 +266,8 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/like_season"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="25dp"
|
||||
android:contentDescription="@string/image"
|
||||
android:src="@drawable/ic_like_selector"
|
||||
/>
|
||||
@@ -383,6 +384,33 @@
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<com.google.android.material.tabs.TabLayout
|
||||
android:id="@+id/seasons_tab"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="44dp"
|
||||
android:layout_marginStart="15dp"
|
||||
android:layout_marginTop="15dp"
|
||||
app:tabBackground="@drawable/season_tab_bg"
|
||||
app:tabGravity="start"
|
||||
app:tabIndicatorHeight="0dp"
|
||||
app:tabMode="scrollable"
|
||||
app:tabPaddingEnd="25dp"
|
||||
app:tabPaddingStart="25dp"
|
||||
app:tabRippleColor="@android:color/transparent"
|
||||
app:tabSelectedTextColor="@color/color_primary"
|
||||
app:tabTextColor="@color/white" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progress_bar"
|
||||
android:visibility="gone"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:indeterminateTint="@color/white"
|
||||
android:layout_gravity="center_horizontal"
|
||||
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
@@ -205,6 +205,7 @@
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:id="@+id/nested_scroll_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/color_primary_dark"
|
||||
@@ -258,7 +259,7 @@
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/spinner_card"
|
||||
android:visibility="visible"
|
||||
android:visibility="gone"
|
||||
android:layout_width="@dimen/_160sdp"
|
||||
android:layout_height="@dimen/_40sdp"
|
||||
|
||||
@@ -282,6 +283,7 @@
|
||||
|
||||
<com.facebook.shimmer.ShimmerFrameLayout
|
||||
android:id="@+id/shimmer_show_data"
|
||||
android:visibility="gone"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:shimmer_base_alpha="0.8"
|
||||
@@ -309,7 +311,7 @@
|
||||
android:id="@+id/rv_web_series"
|
||||
android:visibility="visible"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="1000dp"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
tools:listitem="@layout/show_view_holder"
|
||||
android:layout_marginTop="5dp"
|
||||
|
||||
@@ -21,26 +21,15 @@
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
<com.woka.utils.AdiImageView
|
||||
android:id="@+id/image"
|
||||
android:layout_width="@dimen/_110sdp"
|
||||
android:layout_height="@dimen/_70sdp"
|
||||
|
||||
app:imageCornerRadius="5dp"
|
||||
|
||||
android:layout_marginHorizontal="10dp"
|
||||
android:layout_marginTop="10dp"
|
||||
|
||||
app:cardBackgroundColor="@color/white"
|
||||
app:cardCornerRadius="5dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/image"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:contentDescription="@string/image"
|
||||
android:src="@drawable/woka_logo_half"
|
||||
android:scaleType="fitXY"
|
||||
/>
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
android:layout_marginTop="10dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
|
||||
@@ -18,13 +18,13 @@
|
||||
android:layout_marginVertical="10dp"
|
||||
>
|
||||
|
||||
<ImageView
|
||||
<com.woka.utils.AdiImageView
|
||||
android:id="@+id/image"
|
||||
android:layout_width="@dimen/_240sdp"
|
||||
android:layout_height="@dimen/_120sdp"
|
||||
android:contentDescription="@string/image"
|
||||
android:src="@android:color/darker_gray"
|
||||
android:scaleType="fitXY"
|
||||
|
||||
app:imageCornerRadius="5dp"
|
||||
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
|
||||
27
app/src/main/res/layout/layout_adi_imageview.xml
Normal file
27
app/src/main/res/layout/layout_adi_imageview.xml
Normal file
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/adi_card"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
app:cardElevation="0dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/adi_image"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:contentDescription="@string/image"
|
||||
android:src="@android:color/darker_gray"
|
||||
android:scaleType="fitXY"/>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/adi_progress"
|
||||
android:visibility="gone"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:layout_gravity="center"
|
||||
android:indeterminateTint="@color/white"
|
||||
/>
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
@@ -18,13 +18,12 @@
|
||||
android:layout_marginVertical="10dp"
|
||||
>
|
||||
|
||||
<ImageView
|
||||
<com.woka.utils.AdiImageView
|
||||
android:id="@+id/image"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/_120sdp"
|
||||
android:contentDescription="@string/image"
|
||||
android:src="@android:color/darker_gray"
|
||||
android:scaleType="fitXY"
|
||||
|
||||
app:imageCornerRadius="5dp"
|
||||
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
|
||||
@@ -15,4 +15,11 @@
|
||||
<attr name="isHapticEnabled" format="boolean"/>
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="AdiImageView">
|
||||
<attr name="imageCornerRadius" format="dimension"/>
|
||||
<attr name="loadingBackground" format="color"/>
|
||||
<attr name="errorSrc" format="reference"/>
|
||||
<attr name="android:progressTintMode" format="color"/>
|
||||
</declare-styleable>
|
||||
|
||||
</resources>
|
||||
Reference in New Issue
Block a user