webseries activity
scrolling trailer view api integration for webseries iterated in recyclerview like button working
This commit is contained in:
8
.idea/misc.xml
generated
8
.idea/misc.xml
generated
@@ -1,3 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
||||
@@ -6,4 +7,11 @@
|
||||
<component name="ProjectType">
|
||||
<option name="id" value="Android" />
|
||||
</component>
|
||||
<component name="VisualizationToolProject">
|
||||
<option name="state">
|
||||
<ProjectState>
|
||||
<option name="scale" value="1.898535342027322" />
|
||||
</ProjectState>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
@@ -15,6 +15,10 @@
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.Woka"
|
||||
tools:targetApi="31">
|
||||
<activity
|
||||
android:name=".webseries.views.WebSeriesActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"/>
|
||||
<activity
|
||||
android:name=".home.FMActivity"
|
||||
android:exported="false"
|
||||
|
||||
@@ -14,7 +14,6 @@ import com.woka.databinding.ActivityExploreWokaBinding
|
||||
import com.woka.players.LiveStreamPlayerActivity
|
||||
import com.woka.utils.WokaBaseActivity
|
||||
import com.woka.utils.lightStatusBar
|
||||
import com.woka.utils.toast
|
||||
|
||||
class ExploreWokaActivity : WokaBaseActivity() {
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.woka.utils.UserType
|
||||
import com.woka.utils.hide
|
||||
import com.woka.utils.scaleAnimate
|
||||
import com.woka.utils.show
|
||||
import com.woka.webseries.views.WebSeriesActivity
|
||||
|
||||
|
||||
class Home1Fragment : Fragment() {
|
||||
@@ -170,6 +171,12 @@ class Home1Fragment : Fragment() {
|
||||
startActivity(Intent(it, LiveStreamPlayerActivity::class.java))
|
||||
}
|
||||
}
|
||||
|
||||
webSeries.setOnClickListener {
|
||||
activity?.let {
|
||||
startActivity(Intent(it, WebSeriesActivity::class.java))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import com.woka.home.mylist.adapters.GamesAdapter
|
||||
import com.woka.home.mylist.adapters.KaraokeAdapter
|
||||
import com.woka.home.mylist.adapters.WebSeriesAdapter
|
||||
import com.woka.home.mylist.models.PostType
|
||||
import com.woka.home.mylist.models.ShowData
|
||||
import com.woka.home.mylist.models.BookmarkedShowData
|
||||
import com.woka.networking.ApiResult
|
||||
import com.woka.utils.hide
|
||||
import com.woka.utils.show
|
||||
@@ -91,8 +91,8 @@ class MyListFragment : Fragment() {
|
||||
|
||||
result.show_data?.let {showData ->
|
||||
if (showData.isNotEmpty()){
|
||||
val engList = mutableListOf<ShowData>()
|
||||
val hinList = mutableListOf<ShowData>()
|
||||
val engList = mutableListOf<BookmarkedShowData>()
|
||||
val hinList = mutableListOf<BookmarkedShowData>()
|
||||
|
||||
for (show in showData){
|
||||
val ids = show.bookmark_category_ids?.split(",")
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
package com.woka.home.mylist
|
||||
|
||||
import android.util.Log
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.woka.home.mylist.models.AudioData
|
||||
import com.woka.home.mylist.models.GameData
|
||||
import com.woka.home.mylist.models.MyListResponse
|
||||
import com.woka.home.mylist.models.PostType
|
||||
import com.woka.home.mylist.models.ShowData
|
||||
import com.woka.home.mylist.models.BookmarkedShowData
|
||||
import com.woka.home.mylist.models.SingKaraokeData
|
||||
import com.woka.networking.ApiResult
|
||||
import com.woka.networking.RetrofitHelper
|
||||
import com.woka.userdata.UserRepository
|
||||
import com.woka.utils.TAG
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
@@ -75,14 +73,13 @@ object MyListRepository {
|
||||
}
|
||||
}
|
||||
|
||||
fun unLikePost(postId: String, postType: PostType, categoryId: String = "0") {
|
||||
fun unLikePost(postId: String, postType: PostType) {
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
val response = RetrofitHelper.handleApiCall {
|
||||
myFavApiService.unLikePost(
|
||||
FormBody.Builder()
|
||||
.add("post_id", postId)
|
||||
.add("post_type", postType.value)
|
||||
.add("category", categoryId)
|
||||
.build()
|
||||
)
|
||||
}
|
||||
@@ -97,7 +94,7 @@ object MyListRepository {
|
||||
}
|
||||
}
|
||||
|
||||
fun markAsFavShowLocally(showData: ShowData, addToFav: Boolean){
|
||||
fun markAsFavShowLocally(showData: BookmarkedShowData, addToFav: Boolean){
|
||||
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
val response = RetrofitHelper.handleApiCall {
|
||||
|
||||
@@ -11,7 +11,7 @@ import com.woka.R
|
||||
import com.woka.databinding.FavViewHolderBinding
|
||||
import com.woka.home.mylist.MyListRepository
|
||||
import com.woka.home.mylist.models.PostType
|
||||
import com.woka.home.mylist.models.ShowData
|
||||
import com.woka.home.mylist.models.BookmarkedShowData
|
||||
import com.woka.utils.isNetworkConnected
|
||||
import com.woka.utils.toast
|
||||
import java.util.concurrent.Executors
|
||||
@@ -20,12 +20,12 @@ import kotlin.math.max
|
||||
class WebSeriesAdapter(private val context: Context,
|
||||
private val categoryId: String,
|
||||
private val onListEmptyListener: ((postType: PostType, isEng: Boolean) -> Unit),
|
||||
config: AsyncDifferConfig<ShowData>): ListAdapter<ShowData, FavoriteViewHolder>(config) {
|
||||
config: AsyncDifferConfig<BookmarkedShowData>): ListAdapter<BookmarkedShowData, FavoriteViewHolder>(config) {
|
||||
|
||||
companion object{
|
||||
private val DIFF_UTIL = object : DiffUtil.ItemCallback<ShowData>(){
|
||||
override fun areItemsTheSame(oldItem: ShowData, newItem: ShowData): Boolean = oldItem.id == newItem.id
|
||||
override fun areContentsTheSame(oldItem: ShowData, newItem: ShowData): Boolean {
|
||||
private val DIFF_UTIL = object : DiffUtil.ItemCallback<BookmarkedShowData>(){
|
||||
override fun areItemsTheSame(oldItem: BookmarkedShowData, newItem: BookmarkedShowData): Boolean = oldItem.id == newItem.id
|
||||
override fun areContentsTheSame(oldItem: BookmarkedShowData, newItem: BookmarkedShowData): Boolean {
|
||||
return oldItem.title == newItem.title &&
|
||||
oldItem.is_liked == newItem.is_liked &&
|
||||
oldItem.likes_count == newItem.likes_count
|
||||
@@ -80,8 +80,7 @@ class WebSeriesAdapter(private val context: Context,
|
||||
if (like.isSelected){
|
||||
MyListRepository.unLikePost(
|
||||
"${showData.id}",
|
||||
PostType.WEB_SERIES,
|
||||
categoryId
|
||||
PostType.WEB_SERIES
|
||||
)
|
||||
|
||||
showData.likes_count?.let {
|
||||
@@ -90,8 +89,7 @@ class WebSeriesAdapter(private val context: Context,
|
||||
}else{
|
||||
MyListRepository.likePost(
|
||||
"${showData.id}",
|
||||
PostType.WEB_SERIES,
|
||||
categoryId
|
||||
PostType.WEB_SERIES
|
||||
)
|
||||
|
||||
showData.likes_count?.let {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.woka.home.mylist.models
|
||||
|
||||
data class ShowData(
|
||||
data class BookmarkedShowData(
|
||||
val age_range_master_id: String?,
|
||||
val bookmark_category_ids: String?,
|
||||
val bookmark_count: Int?,
|
||||
@@ -3,7 +3,7 @@ package com.woka.home.mylist.models
|
||||
data class Result(
|
||||
val audio_data: MutableList<AudioData>?,
|
||||
val game_data: MutableList<GameData>?,
|
||||
val show_data: MutableList<ShowData>?,
|
||||
val show_data: MutableList<BookmarkedShowData>?,
|
||||
val sing_karaoke_data: MutableList<SingKaraokeData>?,
|
||||
val video_data: MutableList<Any>?
|
||||
)
|
||||
12
app/src/main/java/com/woka/webseries/WebSeriesApiService.kt
Normal file
12
app/src/main/java/com/woka/webseries/WebSeriesApiService.kt
Normal file
@@ -0,0 +1,12 @@
|
||||
package com.woka.webseries
|
||||
|
||||
import com.woka.networking.ApiResponse
|
||||
import com.woka.webseries.models.WebSeriesResponse
|
||||
import retrofit2.Response
|
||||
import retrofit2.http.POST
|
||||
|
||||
interface WebSeriesApiService {
|
||||
|
||||
@POST("watch_show_listing")
|
||||
suspend fun getWebSeries(): Response<ApiResponse<WebSeriesResponse>>
|
||||
}
|
||||
104
app/src/main/java/com/woka/webseries/WebSeriesRepository.kt
Normal file
104
app/src/main/java/com/woka/webseries/WebSeriesRepository.kt
Normal file
@@ -0,0 +1,104 @@
|
||||
package com.woka.webseries
|
||||
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.woka.home.mylist.MyFavApiService
|
||||
import com.woka.home.mylist.models.PostType
|
||||
import com.woka.networking.ApiResult
|
||||
import com.woka.networking.RetrofitHelper
|
||||
import com.woka.webseries.models.WebSeriesResponse
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import okhttp3.FormBody
|
||||
import kotlin.math.max
|
||||
|
||||
object WebSeriesRepository {
|
||||
private val apiService = RetrofitHelper.getRetrofit().create(WebSeriesApiService::class.java)
|
||||
private val myFavApiService = RetrofitHelper.getRetrofit().create(MyFavApiService::class.java)
|
||||
|
||||
private val _webSeriesLiveData = MutableLiveData<ApiResult<WebSeriesResponse>>()
|
||||
val webSeriesLiveData: LiveData<ApiResult<WebSeriesResponse>>
|
||||
get() = _webSeriesLiveData
|
||||
|
||||
private var webSeriesData: WebSeriesResponse? = null
|
||||
|
||||
init {
|
||||
loadWebSeries()
|
||||
}
|
||||
|
||||
private fun loadWebSeries(){
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
if (webSeriesData != null){
|
||||
_webSeriesLiveData.postValue(ApiResult.Success(webSeriesData))
|
||||
}else{
|
||||
_webSeriesLiveData.postValue(ApiResult.Loading())
|
||||
}
|
||||
|
||||
val response = RetrofitHelper.handleApiCall {
|
||||
apiService.getWebSeries()
|
||||
}
|
||||
|
||||
when (response){
|
||||
is ApiResult.Error -> {}
|
||||
is ApiResult.Loading -> {}
|
||||
is ApiResult.Success -> {
|
||||
webSeriesData = response.data
|
||||
}
|
||||
}
|
||||
|
||||
_webSeriesLiveData.postValue(response)
|
||||
}
|
||||
}
|
||||
|
||||
fun likeUnLikeShow(postId: String, likeIt: Boolean){
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
val response = RetrofitHelper.handleApiCall {
|
||||
if (likeIt){
|
||||
myFavApiService.likePost(
|
||||
FormBody.Builder()
|
||||
.add("post_id", postId)
|
||||
.add("post_type", PostType.WEB_SERIES.value)
|
||||
.build()
|
||||
)
|
||||
}else{
|
||||
myFavApiService.unLikePost(
|
||||
FormBody.Builder()
|
||||
.add("post_id", postId)
|
||||
.add("post_type", PostType.WEB_SERIES.value)
|
||||
.build()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
when (response){
|
||||
is ApiResult.Error -> {}
|
||||
is ApiResult.Loading -> {}
|
||||
is ApiResult.Success -> {
|
||||
changeLikeLocally(postId, likeIt)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun changeLikeLocally(id: String, isLiked: Boolean){
|
||||
|
||||
webSeriesData?.show_data?.let{
|
||||
for (show in it){
|
||||
var found = false
|
||||
show?.let {data ->
|
||||
if ("${data.id}" == id){
|
||||
data.is_liked = isLiked
|
||||
data.likes_count?.let { count ->
|
||||
data.likes_count = if (isLiked) count + 1
|
||||
else max(0, count - 1)
|
||||
}
|
||||
|
||||
found = true
|
||||
}
|
||||
}
|
||||
if (found) break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package com.woka.webseries.adapters
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.AsyncDifferConfig
|
||||
import androidx.recyclerview.widget.DiffUtil
|
||||
import androidx.recyclerview.widget.ListAdapter
|
||||
import androidx.recyclerview.widget.RecyclerView.ViewHolder
|
||||
import com.bumptech.glide.Glide
|
||||
import com.woka.R
|
||||
import com.woka.databinding.ShowViewHolderBinding
|
||||
import com.woka.utils.TAG
|
||||
import com.woka.utils.isNetworkConnected
|
||||
import com.woka.utils.toast
|
||||
import com.woka.webseries.WebSeriesRepository
|
||||
import com.woka.webseries.models.ShowData
|
||||
import java.util.concurrent.Executors
|
||||
import kotlin.math.max
|
||||
|
||||
class WebSeriesShowAdapter(private val context: Context,
|
||||
config: AsyncDifferConfig<ShowData>): ListAdapter<ShowData, WebSeriesShowAdapter.ShowViewHolder>(config) {
|
||||
companion object{
|
||||
private val DIFF_UTIL = object : DiffUtil.ItemCallback<ShowData>(){
|
||||
override fun areItemsTheSame(oldItem: ShowData, newItem: ShowData): Boolean = oldItem.id == newItem.id
|
||||
override fun areContentsTheSame(oldItem: ShowData, newItem: ShowData): Boolean {
|
||||
val value = oldItem.title == newItem.title &&
|
||||
oldItem.is_liked == newItem.is_liked &&
|
||||
oldItem.likes_count == newItem.likes_count
|
||||
Log.d(TAG, "areContentsTheSame: $value")
|
||||
return value
|
||||
}
|
||||
}
|
||||
|
||||
private val DIFF_CONFIG = AsyncDifferConfig.Builder(DIFF_UTIL)
|
||||
.setBackgroundThreadExecutor(Executors.newSingleThreadExecutor())
|
||||
.build()
|
||||
}
|
||||
|
||||
inner class ShowViewHolder(val binding: ShowViewHolderBinding): ViewHolder(binding.root)
|
||||
|
||||
constructor(context: Context): this(context, DIFF_CONFIG)
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ShowViewHolder {
|
||||
return ShowViewHolder(
|
||||
ShowViewHolderBinding.inflate(
|
||||
LayoutInflater.from(parent.context),
|
||||
parent,
|
||||
false
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ShowViewHolder, pos: Int) {
|
||||
val showData = getItem(holder.absoluteAdapterPosition)
|
||||
|
||||
holder.binding.apply {
|
||||
showData.thumbnail_path?.let {
|
||||
Glide.with(root.context)
|
||||
.load(it)
|
||||
.into(image)
|
||||
}
|
||||
|
||||
title.text = showData.title
|
||||
|
||||
showData.likes_count?.let {
|
||||
likeCount.text = "$it"
|
||||
}
|
||||
|
||||
showData.is_liked?.let {
|
||||
like.isSelected = it
|
||||
}
|
||||
|
||||
like.setOnClickListener {
|
||||
if (!context.isNetworkConnected()){
|
||||
context.toast(context.getString(R.string.no_internet))
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
if (like.isSelected){
|
||||
WebSeriesRepository.likeUnLikeShow("${showData.id}", false)
|
||||
|
||||
showData.likes_count?.let {
|
||||
likeCount.text = "${max(it - 1, 0)}"
|
||||
}
|
||||
}else{
|
||||
WebSeriesRepository.likeUnLikeShow("${showData.id}", true)
|
||||
|
||||
showData.likes_count?.let {
|
||||
val value = it + 1
|
||||
likeCount.text = "$value"
|
||||
}
|
||||
}
|
||||
|
||||
like.isSelected = !like.isSelected
|
||||
}
|
||||
|
||||
fav.isSelected = showData.mark_as_favourite == true
|
||||
|
||||
fav.setOnClickListener {
|
||||
if (!context.isNetworkConnected()){
|
||||
context.toast(context.getString(R.string.no_internet))
|
||||
return@setOnClickListener
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.woka.webseries.models
|
||||
|
||||
data class AgeRangeData(
|
||||
val age_range: String?,
|
||||
val id: Int?
|
||||
)
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.woka.webseries.models
|
||||
|
||||
data class CategoryData(
|
||||
val category_name: String?,
|
||||
val id: Int?
|
||||
)
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.woka.webseries.models
|
||||
|
||||
data class ContentMoreDetail(
|
||||
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?
|
||||
)
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.woka.webseries.models
|
||||
|
||||
data class GenderData(
|
||||
val gender_name: String?,
|
||||
val id: Int?
|
||||
)
|
||||
17
app/src/main/java/com/woka/webseries/models/SeasonData.kt
Normal file
17
app/src/main/java/com/woka/webseries/models/SeasonData.kt
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.woka.webseries.models
|
||||
|
||||
data class SeasonData(
|
||||
val id: Int?,
|
||||
val no_of_episodes: Int?,
|
||||
val release_date: String?,
|
||||
val release_year: Int?,
|
||||
val season_description: String?,
|
||||
val season_more_details: List<SeasonMoreDetail?>?,
|
||||
val season_number: String?,
|
||||
val season_title: String?,
|
||||
val tags_keyword: String?,
|
||||
val thumbnail_img_url: Any?,
|
||||
val thumbnail_path: String?,
|
||||
val trailer_url: String?,
|
||||
val watch_shows_master_id: Int?
|
||||
)
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.woka.webseries.models
|
||||
|
||||
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?
|
||||
)
|
||||
26
app/src/main/java/com/woka/webseries/models/ShowData.kt
Normal file
26
app/src/main/java/com/woka/webseries/models/ShowData.kt
Normal file
@@ -0,0 +1,26 @@
|
||||
package com.woka.webseries.models
|
||||
|
||||
data class ShowData(
|
||||
val age_range_data: List<AgeRangeData?>?,
|
||||
val age_range_master_id: String?,
|
||||
val bookmark_count: Int?,
|
||||
val category_data: List<CategoryData?>?,
|
||||
val category_master_id: String?,
|
||||
val content_more_details: List<ContentMoreDetail?>?,
|
||||
val description: String?,
|
||||
val favourite_category_ids: Int?,
|
||||
val gender_data: List<GenderData?>?,
|
||||
val gender_master_id: String?,
|
||||
val id: Int?,
|
||||
var is_liked: Boolean?,
|
||||
val liked_category_ids: Int?,
|
||||
var likes_count: Int?,
|
||||
val mark_as_favourite: Boolean?,
|
||||
val season_data: List<SeasonData?>?,
|
||||
val show_type: String?,
|
||||
val thumbnail_path: String?,
|
||||
val title: String?,
|
||||
val total_episodes: Int?,
|
||||
val total_seasons: Int?,
|
||||
val views_count: Int?
|
||||
)
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.woka.webseries.models
|
||||
|
||||
data class WebSeriesResponse(
|
||||
val show_data: List<ShowData?>?,
|
||||
val total_records: Int?
|
||||
)
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.woka.webseries.viewmodel
|
||||
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import com.woka.networking.ApiResult
|
||||
import com.woka.webseries.WebSeriesRepository
|
||||
import com.woka.webseries.models.WebSeriesResponse
|
||||
|
||||
class WebSeriesViewModel: ViewModel() {
|
||||
|
||||
val webSeriesData: LiveData<ApiResult<WebSeriesResponse>>
|
||||
get() = WebSeriesRepository.webSeriesLiveData
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package com.woka.webseries.views
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import com.google.android.material.appbar.CollapsingToolbarLayout
|
||||
import com.woka.R
|
||||
import com.woka.databinding.ActivityWebSeriesBinding
|
||||
import com.woka.networking.ApiResult
|
||||
import com.woka.utils.WokaBaseActivity
|
||||
import com.woka.webseries.adapters.WebSeriesShowAdapter
|
||||
import com.woka.webseries.viewmodel.WebSeriesViewModel
|
||||
|
||||
class WebSeriesActivity : WokaBaseActivity() {
|
||||
|
||||
private lateinit var binding: ActivityWebSeriesBinding
|
||||
|
||||
private lateinit var viewmodel: WebSeriesViewModel
|
||||
|
||||
private lateinit var showAdapter: WebSeriesShowAdapter
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
enableEdgeToEdge()
|
||||
binding = ActivityWebSeriesBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
|
||||
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
|
||||
insets
|
||||
}
|
||||
|
||||
viewmodel = ViewModelProvider(this)[WebSeriesViewModel::class.java]
|
||||
|
||||
window.navigationBarColor = getColor(R.color.color_primary_dark)
|
||||
|
||||
initViews()
|
||||
|
||||
clickEvents()
|
||||
|
||||
setObservers()
|
||||
}
|
||||
|
||||
private fun clickEvents() {
|
||||
binding.apply {
|
||||
toolbar.backBtn.setOnClickListener {
|
||||
onBackPressedDispatcher.onBackPressed()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun initViews(){
|
||||
|
||||
// adapters
|
||||
showAdapter = WebSeriesShowAdapter(this)
|
||||
|
||||
binding.apply {
|
||||
// making space for masila image
|
||||
topPinnedView.post {
|
||||
val imgParams = masilaImage.layoutParams as CollapsingToolbarLayout.LayoutParams
|
||||
imgParams.setMargins(0, 0, 0, topPinnedView.height)
|
||||
masilaImage.layoutParams = imgParams
|
||||
}
|
||||
|
||||
toolbar.title.text = getString(R.string.web_series)
|
||||
|
||||
rvWebSeries.adapter = showAdapter
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun setObservers(){
|
||||
viewmodel.webSeriesData.observe(this){
|
||||
when(it){
|
||||
is ApiResult.Error -> {}
|
||||
is ApiResult.Loading -> {}
|
||||
is ApiResult.Success -> {
|
||||
it.data?.show_data?.let { showData ->
|
||||
showAdapter.submitList(showData)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
8
app/src/main/res/drawable/gradient_web_series.xml
Normal file
8
app/src/main/res/drawable/gradient_web_series.xml
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<gradient android:startColor="#5E1FC4"
|
||||
android:endColor="#9742E4"
|
||||
/>
|
||||
|
||||
</shape>
|
||||
120
app/src/main/res/layout/activity_web_series.xml
Normal file
120
app/src/main/res/layout/activity_web_series.xml
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/main"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/gradient_web_series"
|
||||
android:orientation="vertical"
|
||||
tools:context=".webseries.views.WebSeriesActivity">
|
||||
|
||||
<include android:id="@+id/toolbar"
|
||||
layout="@layout/layout_toolbar"/>
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
>
|
||||
|
||||
<com.google.android.material.appbar.CollapsingToolbarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_scrollFlags="scroll|snap|exitUntilCollapsed">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/masila_image"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/_160sdp"
|
||||
android:contentDescription="@string/image"
|
||||
android:src="@drawable/img_masila_tn_small"
|
||||
android:scaleType="fitXY"
|
||||
app:layout_collapseMode="parallax"
|
||||
android:layout_gravity="top"
|
||||
/>
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/top_pinned_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/color_primary_dark"
|
||||
app:layout_collapseMode="pin"
|
||||
app:contentInsetStart="0dp"
|
||||
app:contentInsetLeft="0dp"
|
||||
app:contentInsetStartWithNavigation="0dp"
|
||||
android:layout_gravity="bottom">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="15dp"
|
||||
android:gravity="center"
|
||||
>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:text="@string/masila"
|
||||
android:fontFamily="@font/exo_2_bold"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="@dimen/_16ssp"
|
||||
|
||||
/>
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:text="@string/trailer"
|
||||
android:fontFamily="@font/exo_2_bold"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="@dimen/_14ssp"
|
||||
|
||||
android:paddingHorizontal="25dp"
|
||||
android:layout_marginTop="15dp"
|
||||
|
||||
android:background="@drawable/grad_btn_bg_4"
|
||||
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.appcompat.widget.Toolbar>
|
||||
|
||||
</com.google.android.material.appbar.CollapsingToolbarLayout>
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/color_primary_dark"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_web_series"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
tools:listitem="@layout/show_view_holder"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
||||
</LinearLayout>
|
||||
35
app/src/main/res/layout/layout_toolbar.xml
Normal file
35
app/src/main/res/layout/layout_toolbar.xml
Normal file
@@ -0,0 +1,35 @@
|
||||
<?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="?actionBarSize"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:background="@android:color/transparent"
|
||||
android:orientation="horizontal"
|
||||
android:paddingHorizontal="15dp"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/back_btn"
|
||||
android:layout_width="@dimen/_25sdp"
|
||||
android:layout_height="@dimen/_25sdp"
|
||||
android:contentDescription="@string/image"
|
||||
android:src="@drawable/ic_arrow_back_full"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:fontFamily="@font/exo_2_bold"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="@dimen/_14ssp"
|
||||
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
|
||||
android:layout_marginStart="15dp"
|
||||
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
112
app/src/main/res/layout/show_view_holder.xml
Normal file
112
app/src/main/res/layout/show_view_holder.xml
Normal file
@@ -0,0 +1,112 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
|
||||
android:layout_marginHorizontal="15dp"
|
||||
android:layout_marginVertical="10dp"
|
||||
|
||||
app:cardCornerRadius="5dp"
|
||||
app:cardBackgroundColor="@color/white">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="10dp"
|
||||
android:layout_marginVertical="10dp"
|
||||
>
|
||||
|
||||
<ImageView
|
||||
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:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
tools:text="Woka title of show"
|
||||
android:fontFamily="@font/exo_2_bold"
|
||||
android:textColor="@color/color_primary"
|
||||
android:textSize="@dimen/_14ssp"
|
||||
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
|
||||
app:layout_constraintTop_toBottomOf="@id/image"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/like"
|
||||
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
|
||||
/>
|
||||
|
||||
<com.woka.utils.PressableImageView
|
||||
android:id="@+id/like"
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="24dp"
|
||||
android:contentDescription="@string/image"
|
||||
android:src="@drawable/ic_like_selector"
|
||||
android:scaleType="fitXY"
|
||||
app:tint="@color/color_primary"
|
||||
|
||||
app:layout_constraintEnd_toStartOf="@id/like_count"
|
||||
app:layout_constraintTop_toBottomOf="@id/image"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginEnd="2dp"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/like_count"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:text="@string/_0"
|
||||
android:fontFamily="@font/exo_2_semibold"
|
||||
android:textColor="@color/color_primary"
|
||||
android:textSize="@dimen/_14ssp"
|
||||
android:textAlignment="center"
|
||||
|
||||
app:layout_constraintEnd_toStartOf="@id/fav"
|
||||
app:layout_constraintTop_toBottomOf="@id/image"
|
||||
app:layout_constraintBottom_toBottomOf="@id/like"
|
||||
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
|
||||
/>
|
||||
|
||||
<com.woka.utils.PressableImageView
|
||||
android:id="@+id/fav"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="19dp"
|
||||
android:contentDescription="@string/image"
|
||||
android:src="@drawable/ic_heart_select"
|
||||
android:scaleType="fitXY"
|
||||
app:tint="@color/color_primary"
|
||||
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/image"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
|
||||
android:layout_marginTop="8dp"
|
||||
/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
@@ -174,4 +174,5 @@
|
||||
<string name="no_favorites_added">No favorites added</string>
|
||||
<string name="_0">0</string>
|
||||
<string name="no_internet">No internet</string>
|
||||
<string name="trailer">TRAILER</string>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user