Created FavAudioFragment, FavGameFragment, FavKaraokeFragment for view all of every module.
Integrated lazy loading in all of above. Category wise data loading of web series. Updating latest data of 3 when removed item from mylist in web series (both)
This commit is contained in:
@@ -14,7 +14,7 @@ import com.woka.audiobooks.models.audiodata.AudioBookData
|
||||
import com.woka.databinding.ShowViewHolderBinding
|
||||
import com.woka.userPreference.UserType
|
||||
import com.woka.utils.isNetworkConnected
|
||||
import com.woka.utils.show
|
||||
import com.woka.utils.setVisibility
|
||||
import com.woka.utils.toast
|
||||
import java.util.concurrent.Executors
|
||||
import kotlin.math.max
|
||||
@@ -23,6 +23,7 @@ class AudioBooksAdapter(
|
||||
private val context: Context,
|
||||
private var onBookClicked: (AudioBookData) -> Unit,
|
||||
private var onBookChanged: (id: Int, AudioBookData) -> Unit,
|
||||
private val showLikeAndFav: Boolean = true,
|
||||
private val noSignInListener: () -> Unit
|
||||
): ListAdapter<AudioBookData, AudioBooksAdapter.AudioBookViewHolder>(ASYNC_DIFF_UTIL) {
|
||||
|
||||
@@ -76,9 +77,9 @@ class AudioBooksAdapter(
|
||||
}
|
||||
}
|
||||
|
||||
like.show()
|
||||
likeCount.show()
|
||||
fav.show()
|
||||
like.setVisibility(showLikeAndFav)
|
||||
likeCount.setVisibility(showLikeAndFav)
|
||||
fav.setVisibility(showLikeAndFav)
|
||||
|
||||
audioBook.likes_count?.let {
|
||||
likeCount.text = "$it"
|
||||
|
||||
@@ -53,6 +53,7 @@ import com.woka.onboard.views.OnboardActivity
|
||||
import com.woka.players.models.VideoPlayList
|
||||
import com.woka.players.views.PlayerActivity
|
||||
import com.woka.userPreference.UserType
|
||||
import com.woka.userdata.UserRepository
|
||||
import com.woka.utils.hide
|
||||
import com.woka.utils.isNetworkConnected
|
||||
import com.woka.utils.setVisibility
|
||||
@@ -62,7 +63,6 @@ import com.woka.webseries.models.ShowData
|
||||
import com.woka.webseries.views.WebSeriesActivity
|
||||
import com.woka.webseries.views.WebSeriesActivity.Companion.EXTRA_SHOW_CATEGORY
|
||||
import com.woka.webseries.views.WebSeriesActivity.Companion.EXTRA_SHOW_DATA
|
||||
import com.woka.webseries.views.WebSeriesActivity.Companion.EXTRA_SHOW_ID
|
||||
import com.woka.wokagames.GamesRepository
|
||||
import com.woka.wokagames.models.listing.GameData
|
||||
import com.woka.wokagames.playerr.GamePlayerActivity
|
||||
@@ -87,6 +87,7 @@ class MyListFragment : Fragment() {
|
||||
|
||||
private lateinit var dialogBinding: DialogModuleShowerBinding
|
||||
private lateinit var moduleShowerDialog: Dialog
|
||||
private var itemRemovedFromDialog = false
|
||||
|
||||
private val clickHelper = ClicksHelper
|
||||
|
||||
@@ -98,11 +99,11 @@ class MyListFragment : Fragment() {
|
||||
viewModel = ViewModelProvider(requireActivity())[HomeViewModel::class.java]
|
||||
|
||||
// adapters
|
||||
webSeriesEAdapter = WebSeriesAdapter(requireContext(),"1", ::onListGotEmpty)
|
||||
webSeriesHAdapter = WebSeriesAdapter(requireContext(),"18", ::onListGotEmpty)
|
||||
audioBooksAdapter = FavAudioAdapter(requireContext(), ::onListGotEmpty, ::onAudioBookClicked)
|
||||
karaokeAdapter = FavKaraokeAdapter(requireContext(), ::onListGotEmpty, ::onKaraokeClicked)
|
||||
gamesAdapter = FavGamesAdapter(requireContext(), ::onListGotEmpty, ::onGameClicked)
|
||||
webSeriesEAdapter = WebSeriesAdapter("1")
|
||||
webSeriesHAdapter = WebSeriesAdapter("18")
|
||||
audioBooksAdapter = FavAudioAdapter()
|
||||
karaokeAdapter = FavKaraokeAdapter()
|
||||
gamesAdapter = FavGamesAdapter()
|
||||
|
||||
// dialogs
|
||||
dialogBinding = DialogModuleShowerBinding.inflate(layoutInflater)
|
||||
@@ -121,7 +122,7 @@ class MyListFragment : Fragment() {
|
||||
|
||||
if (userPrefs?.userType != UserType.GUEST) {
|
||||
loadFavoriteList()
|
||||
}else{
|
||||
} else {
|
||||
binding.noSignInView.show()
|
||||
}
|
||||
|
||||
@@ -137,19 +138,13 @@ class MyListFragment : Fragment() {
|
||||
rvWebSeriesEnglish.adapter = webSeriesEAdapter
|
||||
rvWebSeriesHindi.adapter = webSeriesHAdapter
|
||||
|
||||
webSeriesHAdapter.onShowClickListener = ::onWebShowClicked
|
||||
webSeriesHAdapter.onLikeChanged = ::onWebShowItemChanged
|
||||
|
||||
webSeriesEAdapter.onShowClickListener = ::onWebShowClicked
|
||||
webSeriesEAdapter.onLikeChanged = ::onWebShowItemChanged
|
||||
|
||||
rvAudioBooks.adapter = audioBooksAdapter
|
||||
rvKaraoke.adapter = karaokeAdapter
|
||||
rvGames.adapter = gamesAdapter
|
||||
}
|
||||
}
|
||||
|
||||
private fun clickEvents(){
|
||||
private fun clickEvents() {
|
||||
binding.apply {
|
||||
backBtn.setOnClickListener {
|
||||
@Suppress("DEPRECATION")
|
||||
@@ -169,8 +164,15 @@ class MyListFragment : Fragment() {
|
||||
clickHelper.upsertClickEvent(ContentType.OTHERS)
|
||||
}
|
||||
|
||||
webSeriesHAdapter.onShowClickListener = ::onWebShowClicked
|
||||
webSeriesEAdapter.onShowClickListener = ::onWebShowClicked
|
||||
|
||||
audioBooksAdapter.onBookClicked = ::onAudioBookClicked
|
||||
karaokeAdapter.onKaraokeClicked = ::onKaraokeClicked
|
||||
gamesAdapter.onGameClicked = ::onGameClicked
|
||||
|
||||
webSeriesEngViewAll.setOnClickListener {
|
||||
activity?.let {activity ->
|
||||
activity?.let { activity ->
|
||||
startActivity(Intent(activity, FavoritesActivity::class.java).apply {
|
||||
putExtra(EXTRA_FAVORITE_TITLE, getString(R.string.web_series_english))
|
||||
putExtra(EXTRA_FAVORITE_CONTENT_TYPE, ContentType.SERIES.id)
|
||||
@@ -178,32 +180,69 @@ class MyListFragment : Fragment() {
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun registerIntentLaunchers(){
|
||||
webShowIntentLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()){
|
||||
if (it.resultCode == AppCompatActivity.RESULT_OK){
|
||||
it.data?.getIntExtra(EXTRA_SHOW_ID, -1)?.let { showId ->
|
||||
if (showId != -1){
|
||||
onWebShowItemChanged(showId)
|
||||
}
|
||||
webSeriesHinViewAll.setOnClickListener {
|
||||
activity?.let { activity ->
|
||||
startActivity(Intent(activity, FavoritesActivity::class.java).apply {
|
||||
putExtra(EXTRA_FAVORITE_TITLE, getString(R.string.web_series_hindi))
|
||||
putExtra(EXTRA_FAVORITE_CONTENT_TYPE, ContentType.SERIES.id)
|
||||
putExtra(EXTRA_FAVORITE_WEB_SERIES_IS_ENGLISH, false)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
audioBooksViewAll.setOnClickListener {
|
||||
activity?.let { activity ->
|
||||
startActivity(Intent(activity, FavoritesActivity::class.java).apply {
|
||||
putExtra(EXTRA_FAVORITE_TITLE, getString(R.string.audio_books))
|
||||
putExtra(EXTRA_FAVORITE_CONTENT_TYPE, ContentType.AUDIO.id)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
gamesViewAll.setOnClickListener {
|
||||
activity?.let { activity ->
|
||||
startActivity(Intent(activity, FavoritesActivity::class.java).apply {
|
||||
putExtra(EXTRA_FAVORITE_TITLE, getString(R.string.games))
|
||||
putExtra(EXTRA_FAVORITE_CONTENT_TYPE, ContentType.GAME.id)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
karaokeViewAll.setOnClickListener {
|
||||
activity?.let { activity ->
|
||||
startActivity(Intent(activity, FavoritesActivity::class.java).apply {
|
||||
putExtra(EXTRA_FAVORITE_TITLE, getString(R.string.karaoke))
|
||||
putExtra(EXTRA_FAVORITE_CONTENT_TYPE, ContentType.KARAOKE_VIDEO.id)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun loadFavoriteList(){
|
||||
private fun registerIntentLaunchers() {
|
||||
webShowIntentLauncher =
|
||||
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
|
||||
if (it.resultCode == AppCompatActivity.RESULT_OK) {
|
||||
it.data?.getStringExtra(EXTRA_SHOW_CATEGORY)?.let { showCategory ->
|
||||
onWebShowItemChanged(showCategory)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun loadFavoriteList() {
|
||||
lifecycleScope.launch {
|
||||
binding.apply {
|
||||
progressBar.show()
|
||||
noData.hide()
|
||||
|
||||
when (val it = MyListRepository.loadMyFavList()){
|
||||
when (val it = MyListRepository.loadMyFavList()) {
|
||||
is ApiResult.Error -> {
|
||||
progressBar.hide()
|
||||
noData.show()
|
||||
}
|
||||
|
||||
is ApiResult.Loading -> {}
|
||||
is ApiResult.Success -> {
|
||||
it.data?.result?.let { result ->
|
||||
@@ -212,19 +251,22 @@ class MyListFragment : Fragment() {
|
||||
|
||||
progressBar.hide()
|
||||
|
||||
result.show_data?.let {showData ->
|
||||
if (showData.isNotEmpty()){
|
||||
result.show_data?.let { showData ->
|
||||
if (showData.isNotEmpty()) {
|
||||
val engList = mutableListOf<BookmarkedShowData>()
|
||||
val hinList = mutableListOf<BookmarkedShowData>()
|
||||
|
||||
for (show in showData){
|
||||
for (show in showData) {
|
||||
if (show.bookmark_category_ids?.isEmpty() == true) continue
|
||||
|
||||
val ids = show.bookmark_category_ids?.split(",")
|
||||
ids?.let {bIds ->
|
||||
ids?.let { bIds ->
|
||||
if (bIds.isNotEmpty()) {
|
||||
when (bIds.size) {
|
||||
1 -> if (bIds[0] == "1") engList.add(show) else hinList.add(show)
|
||||
1 -> if (bIds[0] == "1") engList.add(show) else hinList.add(
|
||||
show
|
||||
)
|
||||
|
||||
else -> {
|
||||
engList.add(show)
|
||||
hinList.add(show)
|
||||
@@ -234,27 +276,27 @@ class MyListFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
|
||||
if (engList.isNotEmpty()){
|
||||
if (engList.isNotEmpty()) {
|
||||
webSeriesEnglishView.show()
|
||||
dataLoaded = true
|
||||
webSeriesEAdapter.submitList(engList.reversed())
|
||||
webSeriesEAdapter.submitList(engList)
|
||||
|
||||
webSeriesEngViewAll.setVisibility(engList.size >= 3)
|
||||
}else{
|
||||
webSeriesEngViewAll.setVisibility(showData.size >= 3)
|
||||
} else {
|
||||
webSeriesEnglishView.hide()
|
||||
}
|
||||
|
||||
if (hinList.isNotEmpty()){
|
||||
if (hinList.isNotEmpty()) {
|
||||
webSeriesHindiView.show()
|
||||
dataLoaded = true
|
||||
webSeriesHAdapter.submitList(hinList.reversed())
|
||||
webSeriesHAdapter.submitList(hinList)
|
||||
|
||||
webSeriesHinViewAll.setVisibility(hinList.size >= 3)
|
||||
}else{
|
||||
webSeriesHinViewAll.setVisibility(showData.size >= 3)
|
||||
} else {
|
||||
webSeriesHindiView.hide()
|
||||
}
|
||||
|
||||
}else{
|
||||
} else {
|
||||
webSeriesEnglishView.hide()
|
||||
webSeriesHindiView.hide()
|
||||
}
|
||||
@@ -262,46 +304,46 @@ class MyListFragment : Fragment() {
|
||||
|
||||
result.audio_data?.let { audioData ->
|
||||
|
||||
if (audioData.isNotEmpty()){
|
||||
if (audioData.isNotEmpty()) {
|
||||
audioBooksView.show()
|
||||
|
||||
dataLoaded = true
|
||||
audioBooksAdapter.submitList(audioData.reversed())
|
||||
audioBooksAdapter.submitList(audioData)
|
||||
|
||||
audioBooksViewAll.setVisibility(audioData.size >= 3)
|
||||
}else{
|
||||
} else {
|
||||
audioBooksView.hide()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
result.sing_karaoke_data?.let { singKaraokeData ->
|
||||
if (singKaraokeData.isNotEmpty()){
|
||||
if (singKaraokeData.isNotEmpty()) {
|
||||
karaokeView.show()
|
||||
|
||||
dataLoaded = true
|
||||
karaokeAdapter.submitList(singKaraokeData.reversed())
|
||||
karaokeAdapter.submitList(singKaraokeData)
|
||||
karaokeViewAll.setVisibility(singKaraokeData.size >= 3)
|
||||
}else{
|
||||
} else {
|
||||
karaokeView.hide()
|
||||
}
|
||||
}
|
||||
|
||||
result.game_data?.let { gamesData ->
|
||||
if (gamesData.isNotEmpty()){
|
||||
if (gamesData.isNotEmpty()) {
|
||||
gamesView.show()
|
||||
|
||||
dataLoaded = true
|
||||
gamesAdapter.submitList(gamesData.reversed())
|
||||
gamesAdapter.submitList(gamesData)
|
||||
gamesViewAll.setVisibility(gamesData.size >= 3)
|
||||
}else{
|
||||
} else {
|
||||
gamesView.hide()
|
||||
}
|
||||
}
|
||||
|
||||
if (!dataLoaded){
|
||||
if (!dataLoaded) {
|
||||
noData.show()
|
||||
}else{
|
||||
} else {
|
||||
noData.hide()
|
||||
}
|
||||
}
|
||||
@@ -311,10 +353,9 @@ class MyListFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun setObservers(){
|
||||
private fun setObservers() {
|
||||
binding.apply {
|
||||
|
||||
viewModel.localeChangeLiveData.observe(viewLifecycleOwner){
|
||||
viewModel.localeChangeLiveData.observe(viewLifecycleOwner) {
|
||||
webSeriesEngTxt.text = getString(R.string.web_series_english)
|
||||
webSeriesHinTxt.text = getString(R.string.web_series_hindi)
|
||||
audioBooksTxt.text = getString(R.string.audio_books)
|
||||
@@ -323,23 +364,23 @@ class MyListFragment : Fragment() {
|
||||
|
||||
noDataTxt.text = getString(R.string.no_favorites_added)
|
||||
|
||||
if (webSeriesEAdapter.currentList.isNotEmpty()){
|
||||
if (webSeriesEAdapter.currentList.isNotEmpty()) {
|
||||
webSeriesEAdapter.notifyItemRangeChanged(0, webSeriesEAdapter.currentList.size)
|
||||
}
|
||||
|
||||
if (webSeriesHAdapter.currentList.isNotEmpty()){
|
||||
if (webSeriesHAdapter.currentList.isNotEmpty()) {
|
||||
webSeriesHAdapter.notifyItemRangeChanged(0, webSeriesHAdapter.currentList.size)
|
||||
}
|
||||
|
||||
if (audioBooksAdapter.currentList.isNotEmpty()){
|
||||
if (audioBooksAdapter.currentList.isNotEmpty()) {
|
||||
audioBooksAdapter.notifyItemRangeChanged(0, audioBooksAdapter.currentList.size)
|
||||
}
|
||||
|
||||
if (karaokeAdapter.currentList.isNotEmpty()){
|
||||
if (karaokeAdapter.currentList.isNotEmpty()) {
|
||||
karaokeAdapter.notifyItemRangeChanged(0, karaokeAdapter.currentList.size)
|
||||
}
|
||||
|
||||
if (gamesAdapter.currentList.isNotEmpty()){
|
||||
if (gamesAdapter.currentList.isNotEmpty()) {
|
||||
gamesAdapter.notifyItemRangeChanged(0, gamesAdapter.currentList.size)
|
||||
}
|
||||
}
|
||||
@@ -371,16 +412,17 @@ class MyListFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun onListGotEmpty(postType: PostType, isEng: Boolean = true){
|
||||
private fun onListGotEmpty(postType: PostType, isEng: Boolean = true) {
|
||||
binding.apply {
|
||||
when (postType){
|
||||
when (postType) {
|
||||
PostType.WEB_SERIES -> {
|
||||
if (isEng){
|
||||
if (isEng) {
|
||||
webSeriesEnglishView.hide()
|
||||
}else{
|
||||
} else {
|
||||
webSeriesHindiView.hide()
|
||||
}
|
||||
}
|
||||
|
||||
PostType.AUDIO_BOOKS -> audioBooksView.hide()
|
||||
PostType.KARAOKE -> karaokeView.hide()
|
||||
PostType.GAMES -> gamesView.hide()
|
||||
@@ -390,14 +432,15 @@ class MyListFragment : Fragment() {
|
||||
!webSeriesHindiView.isVisible &&
|
||||
!audioBooksView.isVisible &&
|
||||
!karaokeView.isVisible &&
|
||||
!gamesView.isVisible){
|
||||
!gamesView.isVisible
|
||||
) {
|
||||
noData.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// web show
|
||||
private fun onWebShowClicked(showData: BookmarkedShowData, categoryId: String){
|
||||
private fun onWebShowClicked(showData: BookmarkedShowData, categoryId: String) {
|
||||
webShowIntentLauncher?.launch(Intent(context, WebSeriesActivity::class.java).apply {
|
||||
putExtra(EXTRA_SHOW_DATA, ShowData(showData))
|
||||
putExtra(EXTRA_SHOW_CATEGORY, categoryId)
|
||||
@@ -406,20 +449,31 @@ class MyListFragment : Fragment() {
|
||||
clickHelper.upsertClickEvent(ContentType.SERIES, showData.id, categoryId)
|
||||
}
|
||||
|
||||
private fun onWebShowItemChanged(showId: Int){
|
||||
val englishPosition = webSeriesEAdapter.currentList.indexOfFirst { it.id == showId }
|
||||
if (englishPosition > -1 && englishPosition < webSeriesEAdapter.currentList.size){
|
||||
webSeriesEAdapter.notifyItemChanged(englishPosition)
|
||||
}
|
||||
private fun onWebShowItemChanged(showCategory: String) {
|
||||
lifecycleScope.launch {
|
||||
when (val response = UserRepository.loadMyFavList(
|
||||
ContentType.SERIES.id,
|
||||
0, 3, showCategory
|
||||
)) {
|
||||
is ApiResult.Error -> {}
|
||||
is ApiResult.Loading -> {}
|
||||
is ApiResult.Success -> {
|
||||
response.data?.result?.show_data?.let {
|
||||
if (showCategory == "1"){
|
||||
webSeriesEAdapter.submitList(it)
|
||||
}else if (showCategory == "18"){
|
||||
webSeriesHAdapter.submitList(it)
|
||||
}
|
||||
|
||||
val hindiPosition = webSeriesHAdapter.currentList.indexOfFirst { it.id == showId }
|
||||
if (hindiPosition > -1 && hindiPosition < webSeriesHAdapter.currentList.size){
|
||||
webSeriesHAdapter.notifyItemChanged(hindiPosition)
|
||||
MyListRepository.updateSeriesList(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// audio books
|
||||
private fun onAudioBookClicked(audioBookData: FavAudioBookData, position: Int){
|
||||
private fun onAudioBookClicked(audioBookData: FavAudioBookData, pos: Int) {
|
||||
dialogBinding.apply {
|
||||
audioBookData.content_more_details?.let { moreDetailsList ->
|
||||
|
||||
@@ -478,7 +532,8 @@ class MyListFragment : Fragment() {
|
||||
}
|
||||
|
||||
activity?.let {
|
||||
watchCard.backgroundTintList = ColorStateList.valueOf(it.getColor(R.color.audio_grad_one))
|
||||
watchCard.backgroundTintList =
|
||||
ColorStateList.valueOf(it.getColor(R.color.audio_grad_one))
|
||||
}
|
||||
watchCard.text = getString(R.string.listen_now)
|
||||
watchCard.setOnClickListener {
|
||||
@@ -491,15 +546,12 @@ class MyListFragment : Fragment() {
|
||||
!like.isSelected
|
||||
)
|
||||
|
||||
audioBookData.id?.let {
|
||||
onAudioItemChanged(it)
|
||||
}
|
||||
like.isSelected = !like.isSelected
|
||||
likeCount.text = "${audioBookData.likes_count}"
|
||||
}
|
||||
|
||||
fav.setOnClickListener {
|
||||
if (context?.isNetworkConnected() == false){
|
||||
if (context?.isNetworkConnected() == false) {
|
||||
toast(getString(R.string.no_internet))
|
||||
return@setOnClickListener
|
||||
}
|
||||
@@ -509,23 +561,27 @@ class MyListFragment : Fragment() {
|
||||
!fav.isSelected
|
||||
)
|
||||
|
||||
try {
|
||||
audioBooksAdapter.notifyItemRemoved(position)
|
||||
} catch (e: Exception) {
|
||||
// do nothing
|
||||
}
|
||||
fav.isSelected = !fav.isSelected
|
||||
|
||||
if (audioBooksAdapter.currentList.isEmpty()){
|
||||
onListGotEmpty(PostType.AUDIO_BOOKS, true)
|
||||
}
|
||||
|
||||
moduleShowerDialog.dismiss()
|
||||
itemRemovedFromDialog = !fav.isSelected
|
||||
}
|
||||
|
||||
close.setOnClickListener {
|
||||
moduleShowerDialog.dismiss()
|
||||
}
|
||||
|
||||
moduleShowerDialog.setOnDismissListener {
|
||||
if (itemRemovedFromDialog){
|
||||
// item was removed at last
|
||||
onAudioItemChanged()
|
||||
}else{
|
||||
// item was not at last removed
|
||||
MyListRepository.setLoadNewDataFlag(false)
|
||||
}
|
||||
}
|
||||
|
||||
itemRemovedFromDialog = false
|
||||
|
||||
moduleShowerDialog.show()
|
||||
}
|
||||
}
|
||||
@@ -533,11 +589,22 @@ class MyListFragment : Fragment() {
|
||||
clickHelper.upsertClickEvent(ContentType.AUDIO, audioBookData.id)
|
||||
}
|
||||
|
||||
private fun onAudioItemChanged(id: Int) {
|
||||
// updating book list
|
||||
val position = audioBooksAdapter.currentList.indexOfFirst { it.id == id }
|
||||
if (position >= 0 && position < audioBooksAdapter.currentList.size) {
|
||||
audioBooksAdapter.notifyItemChanged(position)
|
||||
private fun onAudioItemChanged() {
|
||||
lifecycleScope.launch {
|
||||
when (val response = UserRepository.loadMyFavList(
|
||||
ContentType.AUDIO.id,
|
||||
0, 3
|
||||
)) {
|
||||
is ApiResult.Error -> {}
|
||||
is ApiResult.Loading -> {}
|
||||
is ApiResult.Success -> {
|
||||
response.data?.result?.audio_data?.let {
|
||||
audioBooksAdapter.submitList(it)
|
||||
|
||||
MyListRepository.updateAudioList(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -546,22 +613,22 @@ class MyListFragment : Fragment() {
|
||||
var url: String? = null
|
||||
var title = ""
|
||||
|
||||
audioBookData.content_more_details?.let {moreDetails ->
|
||||
if (moreDetails.isNotEmpty()){
|
||||
if (userPrefs?.appLanguage == "hi" && moreDetails.size > 1){
|
||||
audioBookData.content_more_details?.let { moreDetails ->
|
||||
if (moreDetails.isNotEmpty()) {
|
||||
if (userPrefs?.appLanguage == "hi" && moreDetails.size > 1) {
|
||||
url = moreDetails[1]?.url
|
||||
title = moreDetails[1]?.title?:""
|
||||
}else{
|
||||
title = moreDetails[1]?.title ?: ""
|
||||
} else {
|
||||
url = moreDetails[0]?.url
|
||||
title = moreDetails[0]?.title?:""
|
||||
title = moreDetails[0]?.title ?: ""
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
url = audioBookData.audio_url
|
||||
title = audioBookData.title?:""
|
||||
title = audioBookData.title ?: ""
|
||||
}
|
||||
}
|
||||
|
||||
activity?.let {activity ->
|
||||
activity?.let { activity ->
|
||||
url?.let {
|
||||
startActivity(Intent(activity, PlayerActivity::class.java).apply {
|
||||
putExtra(
|
||||
@@ -588,7 +655,7 @@ class MyListFragment : Fragment() {
|
||||
}
|
||||
|
||||
// woka games
|
||||
private fun onGameClicked(gameData: FavGameData, position: Int){
|
||||
private fun onGameClicked(gameData: FavGameData, position: Int) {
|
||||
dialogBinding.apply {
|
||||
gameData.content_more_details?.let { moreDetailsList ->
|
||||
|
||||
@@ -647,14 +714,18 @@ class MyListFragment : Fragment() {
|
||||
}
|
||||
|
||||
activity?.let {
|
||||
watchCard.backgroundTintList = ColorStateList.valueOf(it.getColor(R.color.game_grad_one))
|
||||
watchCard.backgroundTintList =
|
||||
ColorStateList.valueOf(it.getColor(R.color.game_grad_one))
|
||||
}
|
||||
watchCard.text = getString(R.string.play_now)
|
||||
watchCard.setOnClickListener {
|
||||
activity?.let {activity ->
|
||||
activity?.let { activity ->
|
||||
gameData.game_url?.let {
|
||||
startActivity(Intent(activity, GamePlayerActivity::class.java).apply {
|
||||
putExtra(GamePlayerActivity.EXTRA_GAME_PLAYER_DATA, GamePlayerData(it, gameData.screen_orientation == "Landscape"))
|
||||
putExtra(
|
||||
GamePlayerActivity.EXTRA_GAME_PLAYER_DATA,
|
||||
GamePlayerData(it, gameData.screen_orientation == "Landscape")
|
||||
)
|
||||
})
|
||||
|
||||
clickHelper.upsertClickEvent(ContentType.GAME, gameData.id)
|
||||
@@ -676,7 +747,7 @@ class MyListFragment : Fragment() {
|
||||
}
|
||||
|
||||
fav.setOnClickListener {
|
||||
if (context?.isNetworkConnected() == false){
|
||||
if (context?.isNetworkConnected() == false) {
|
||||
toast(getString(R.string.no_internet))
|
||||
return@setOnClickListener
|
||||
}
|
||||
@@ -692,8 +763,8 @@ class MyListFragment : Fragment() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
if (gamesAdapter.currentList.isEmpty()){
|
||||
onListGotEmpty(PostType.GAMES, true)
|
||||
if (gamesAdapter.currentList.isEmpty()) {
|
||||
onListGotEmpty(PostType.GAMES)
|
||||
}
|
||||
|
||||
moduleShowerDialog.dismiss()
|
||||
@@ -778,16 +849,24 @@ class MyListFragment : Fragment() {
|
||||
}
|
||||
|
||||
activity?.let {
|
||||
watchCard.backgroundTintList = ColorStateList.valueOf(it.getColor(R.color.game_grad_one))
|
||||
watchCard.backgroundTintList =
|
||||
ColorStateList.valueOf(it.getColor(R.color.game_grad_one))
|
||||
}
|
||||
watchCard.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_mic, 0, 0, 0)
|
||||
watchCard.text = getString(R.string.sing_now)
|
||||
watchCard.setOnClickListener {
|
||||
activity?.let {activity ->
|
||||
activity?.let { activity ->
|
||||
karaokeData.video_url?.let {
|
||||
startActivity(Intent(activity, KaraokePlayerActivity::class.java).apply {
|
||||
putExtra(KaraokePlayerActivity.EXTRA_KARAOKE_DATA, KaraokePlayerData(it, karaokeData.title))
|
||||
})
|
||||
startActivity(
|
||||
Intent(
|
||||
activity,
|
||||
KaraokePlayerActivity::class.java
|
||||
).apply {
|
||||
putExtra(
|
||||
KaraokePlayerActivity.EXTRA_KARAOKE_DATA,
|
||||
KaraokePlayerData(it, karaokeData.title)
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
clickHelper.upsertClickEvent(ContentType.KARAOKE_VIDEO, karaokeData.id)
|
||||
@@ -807,7 +886,7 @@ class MyListFragment : Fragment() {
|
||||
}
|
||||
|
||||
fav.setOnClickListener {
|
||||
if (context?.isNetworkConnected() == false){
|
||||
if (context?.isNetworkConnected() == false) {
|
||||
toast(getString(R.string.no_internet))
|
||||
return@setOnClickListener
|
||||
}
|
||||
@@ -823,8 +902,8 @@ class MyListFragment : Fragment() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
if (karaokeAdapter.currentList.isEmpty()){
|
||||
onListGotEmpty(PostType.KARAOKE, true)
|
||||
if (karaokeAdapter.currentList.isEmpty()) {
|
||||
onListGotEmpty(PostType.KARAOKE)
|
||||
}
|
||||
|
||||
moduleShowerDialog.dismiss()
|
||||
@@ -852,9 +931,9 @@ class MyListFragment : Fragment() {
|
||||
companion object {
|
||||
private var instance: MyListFragment? = null
|
||||
private val any = Any()
|
||||
fun getInstance(): MyListFragment{
|
||||
return synchronized(any){
|
||||
if (instance == null){
|
||||
fun getInstance(): MyListFragment {
|
||||
return synchronized(any) {
|
||||
if (instance == null) {
|
||||
instance = MyListFragment()
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.woka.home.mylist
|
||||
|
||||
import com.woka.home.mylist.models.BookmarkedShowData
|
||||
import com.woka.home.mylist.models.FavAudioBookData
|
||||
import com.woka.home.mylist.models.MyListResponse
|
||||
import com.woka.home.mylist.models.Result
|
||||
import com.woka.networking.ApiResult
|
||||
@@ -12,7 +14,8 @@ object MyListRepository {
|
||||
mutableListOf(),
|
||||
mutableListOf(),
|
||||
mutableListOf(),
|
||||
mutableListOf()
|
||||
mutableListOf(),
|
||||
0
|
||||
))
|
||||
|
||||
/*
|
||||
@@ -26,6 +29,20 @@ object MyListRepository {
|
||||
this.shallLoadNewData = loadNew
|
||||
}
|
||||
|
||||
fun updateSeriesList(bookmarkedShowData: MutableList<BookmarkedShowData>) {
|
||||
myFavData.result?.show_data?.clear()
|
||||
myFavData.result?.show_data?.addAll(bookmarkedShowData)
|
||||
|
||||
shallLoadNewData = false
|
||||
}
|
||||
|
||||
fun updateAudioList(bookmarkedShowData: MutableList<FavAudioBookData>) {
|
||||
myFavData.result?.audio_data?.clear()
|
||||
myFavData.result?.audio_data?.addAll(bookmarkedShowData)
|
||||
|
||||
shallLoadNewData = false
|
||||
}
|
||||
|
||||
fun clearData(){
|
||||
shallLoadNewData = true
|
||||
myFavData.result?.let {
|
||||
|
||||
@@ -1,36 +1,22 @@
|
||||
package com.woka.home.mylist.adapters
|
||||
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.AsyncDifferConfig
|
||||
import androidx.recyclerview.widget.DiffUtil
|
||||
import androidx.recyclerview.widget.ListAdapter
|
||||
import com.woka.R
|
||||
import com.woka.WokaApp
|
||||
import com.woka.audiobooks.AudioBookRepository
|
||||
import com.woka.audiobooks.models.audiodata.AudioBookData
|
||||
import com.woka.databinding.FavViewHolderBinding
|
||||
import com.woka.home.mylist.models.FavAudioBookData
|
||||
import com.woka.home.mylist.models.PostType
|
||||
import com.woka.utils.isNetworkConnected
|
||||
import com.woka.utils.show
|
||||
import com.woka.utils.toast
|
||||
import java.util.concurrent.Executors
|
||||
|
||||
class FavAudioAdapter(private val context: Context,
|
||||
config: AsyncDifferConfig<FavAudioBookData>,
|
||||
private val onListEmptyListener: ((postType: PostType, isEng: Boolean) -> Unit),
|
||||
private var onBookClicked: (FavAudioBookData, Int) -> Unit): ListAdapter<FavAudioBookData, FavoriteViewHolder>(config) {
|
||||
class FavAudioAdapter: ListAdapter<FavAudioBookData, FavoriteViewHolder>(DIFF_CONFIG) {
|
||||
|
||||
companion object{
|
||||
private val DIFF_UTIL = object : DiffUtil.ItemCallback<FavAudioBookData>(){
|
||||
override fun areItemsTheSame(oldItem: FavAudioBookData, newItem: FavAudioBookData): Boolean = oldItem.id == newItem.id
|
||||
override fun areContentsTheSame(oldItem: FavAudioBookData, newItem: FavAudioBookData): Boolean {
|
||||
return oldItem.title == newItem.title &&
|
||||
oldItem.is_liked == newItem.is_liked &&
|
||||
oldItem.likes_count == newItem.likes_count &&
|
||||
oldItem.mark_as_favourite == newItem.mark_as_favourite
|
||||
return oldItem.title == newItem.title
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,9 +25,7 @@ class FavAudioAdapter(private val context: Context,
|
||||
.build()
|
||||
}
|
||||
|
||||
constructor(context: Context,
|
||||
onListEmptyListener: ((postType: PostType, isEng: Boolean) -> Unit),
|
||||
onBookClicked: (FavAudioBookData, Int) -> Unit): this(context, DIFF_CONFIG, onListEmptyListener, onBookClicked)
|
||||
var onBookClicked: ((FavAudioBookData, Int) -> Unit)? = null
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): FavoriteViewHolder {
|
||||
return FavoriteViewHolder(
|
||||
@@ -73,55 +57,8 @@ class FavAudioAdapter(private val context: Context,
|
||||
}
|
||||
}
|
||||
|
||||
like.show()
|
||||
likeCount.show()
|
||||
fav.show()
|
||||
|
||||
audioBook.likes_count?.let {
|
||||
likeCount.text = "$it"
|
||||
}
|
||||
|
||||
audioBook.is_liked?.let {
|
||||
like.isSelected = it
|
||||
}
|
||||
|
||||
like.setOnClickListener {
|
||||
if (!context.isNetworkConnected()){
|
||||
context.toast(context.getString(R.string.no_internet))
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
AudioBookRepository.likeUnLikeAudioBook(
|
||||
"${audioBook.id}",
|
||||
!like.isSelected
|
||||
)
|
||||
|
||||
like.isSelected = !like.isSelected
|
||||
likeCount.text = "${audioBook.likes_count}"
|
||||
}
|
||||
|
||||
fav.isSelected = audioBook.mark_as_favourite == true
|
||||
|
||||
fav.setOnClickListener {
|
||||
if (!context.isNetworkConnected()){
|
||||
context.toast(context.getString(R.string.no_internet))
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
AudioBookRepository.updateFavShow(
|
||||
AudioBookData(audioBook),
|
||||
!fav.isSelected
|
||||
)
|
||||
|
||||
notifyItemRemoved(holder.absoluteAdapterPosition)
|
||||
|
||||
if (currentList.isEmpty()){
|
||||
onListEmptyListener(PostType.AUDIO_BOOKS, true)
|
||||
}
|
||||
}
|
||||
|
||||
root.setOnClickListener {
|
||||
onBookClicked(audioBook, holder.absoluteAdapterPosition)
|
||||
onBookClicked?.invoke(audioBook, holder.absoluteAdapterPosition)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +1,16 @@
|
||||
package com.woka.home.mylist.adapters
|
||||
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.AsyncDifferConfig
|
||||
import androidx.recyclerview.widget.DiffUtil
|
||||
import androidx.recyclerview.widget.ListAdapter
|
||||
import com.woka.R
|
||||
import com.woka.WokaApp
|
||||
import com.woka.databinding.FavViewHolderBinding
|
||||
import com.woka.home.mylist.models.FavGameData
|
||||
import com.woka.home.mylist.models.PostType
|
||||
import com.woka.utils.isNetworkConnected
|
||||
import com.woka.utils.show
|
||||
import com.woka.utils.toast
|
||||
import com.woka.wokagames.GamesRepository
|
||||
import com.woka.wokagames.models.listing.GameData
|
||||
import java.util.concurrent.Executors
|
||||
|
||||
class FavGamesAdapter(private val context: Context,
|
||||
config: AsyncDifferConfig<FavGameData>,
|
||||
private val onListEmptyListener: ((postType: PostType, isEng: Boolean) -> Unit),
|
||||
private val onGameClicked: ((FavGameData, Int) -> Unit)):
|
||||
ListAdapter<FavGameData, FavoriteViewHolder>(config) {
|
||||
class FavGamesAdapter: ListAdapter<FavGameData, FavoriteViewHolder>(DIFF_CONFIG) {
|
||||
|
||||
companion object{
|
||||
private val DIFF_UTIL = object : DiffUtil.ItemCallback<FavGameData>(){
|
||||
@@ -39,9 +27,7 @@ class FavGamesAdapter(private val context: Context,
|
||||
.build()
|
||||
}
|
||||
|
||||
constructor(context: Context,
|
||||
onListEmptyListener: ((postType: PostType, isEng: Boolean) -> Unit),
|
||||
onGameClicked: ((gameData: FavGameData, pos: Int) -> Unit)): this(context, DIFF_CONFIG, onListEmptyListener, onGameClicked)
|
||||
var onGameClicked: ((FavGameData, Int) -> Unit)? = null
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): FavoriteViewHolder {
|
||||
return FavoriteViewHolder(
|
||||
@@ -73,55 +59,8 @@ class FavGamesAdapter(private val context: Context,
|
||||
}
|
||||
}
|
||||
|
||||
like.show()
|
||||
likeCount.show()
|
||||
fav.show()
|
||||
|
||||
gameData.likes_count?.let {
|
||||
likeCount.text = "$it"
|
||||
}
|
||||
|
||||
gameData.is_liked?.let {
|
||||
like.isSelected = it
|
||||
}
|
||||
|
||||
like.setOnClickListener {
|
||||
if (!context.isNetworkConnected()){
|
||||
context.toast(context.getString(R.string.no_internet))
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
GamesRepository.likeUnLikeGame(
|
||||
"${gameData.id}",
|
||||
!like.isSelected
|
||||
)
|
||||
|
||||
like.isSelected = !like.isSelected
|
||||
likeCount.text = "${gameData.likes_count}"
|
||||
}
|
||||
|
||||
fav.isSelected = gameData.mark_as_favourite == true
|
||||
|
||||
fav.setOnClickListener {
|
||||
if (!context.isNetworkConnected()){
|
||||
context.toast(context.getString(R.string.no_internet))
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
GamesRepository.updateFavShow(
|
||||
GameData(gameData),
|
||||
!fav.isSelected
|
||||
)
|
||||
|
||||
notifyItemRemoved(holder.absoluteAdapterPosition)
|
||||
|
||||
if (currentList.isEmpty()){
|
||||
onListEmptyListener(PostType.GAMES, true)
|
||||
}
|
||||
}
|
||||
|
||||
root.setOnClickListener {
|
||||
onGameClicked(gameData, holder.absoluteAdapterPosition)
|
||||
onGameClicked?.invoke(gameData, holder.absoluteAdapterPosition)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,16 @@
|
||||
package com.woka.home.mylist.adapters
|
||||
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.AsyncDifferConfig
|
||||
import androidx.recyclerview.widget.DiffUtil
|
||||
import androidx.recyclerview.widget.ListAdapter
|
||||
import com.woka.R
|
||||
import com.woka.WokaApp
|
||||
import com.woka.databinding.FavViewHolderBinding
|
||||
import com.woka.home.mylist.models.FavKaraokeData
|
||||
import com.woka.home.mylist.models.PostType
|
||||
import com.woka.karaoke.KaraokeRepository
|
||||
import com.woka.karaoke.models.listing.KaraokeData
|
||||
import com.woka.utils.isNetworkConnected
|
||||
import com.woka.utils.toast
|
||||
import java.util.concurrent.Executors
|
||||
|
||||
class FavKaraokeAdapter(private val context: Context,
|
||||
private val onListEmptyListener: ((postType: PostType, isEng: Boolean) -> Unit),
|
||||
private var onKaraokeClicked: (FavKaraokeData, Int) -> Unit)
|
||||
: ListAdapter<FavKaraokeData, FavoriteViewHolder>(DIFF_CONFIG) {
|
||||
class FavKaraokeAdapter : ListAdapter<FavKaraokeData, FavoriteViewHolder>(DIFF_CONFIG) {
|
||||
|
||||
companion object{
|
||||
private val DIFF_UTIL = object : DiffUtil.ItemCallback<FavKaraokeData>(){
|
||||
@@ -38,6 +29,8 @@ class FavKaraokeAdapter(private val context: Context,
|
||||
.build()
|
||||
}
|
||||
|
||||
var onKaraokeClicked: ((FavKaraokeData, Int) -> Unit)? = null
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): FavoriteViewHolder {
|
||||
return FavoriteViewHolder(
|
||||
FavViewHolderBinding.inflate(
|
||||
@@ -56,53 +49,20 @@ class FavKaraokeAdapter(private val context: Context,
|
||||
image.loadImage(it)
|
||||
}
|
||||
|
||||
title.text = karaokeData.title
|
||||
|
||||
karaokeData.likes_count?.let {
|
||||
likeCount.text = "$it"
|
||||
}
|
||||
|
||||
karaokeData.is_liked?.let {
|
||||
like.isSelected = it
|
||||
}
|
||||
|
||||
like.setOnClickListener {
|
||||
if (!context.isNetworkConnected()){
|
||||
context.toast(context.getString(R.string.no_internet))
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
KaraokeRepository.likeUnLikeSong(
|
||||
"${karaokeData.id}",
|
||||
!like.isSelected
|
||||
)
|
||||
|
||||
like.isSelected = !like.isSelected
|
||||
likeCount.text = "${karaokeData.likes_count}"
|
||||
}
|
||||
|
||||
fav.isSelected = true
|
||||
|
||||
fav.setOnClickListener {
|
||||
if (!context.isNetworkConnected()){
|
||||
context.toast(context.getString(R.string.no_internet))
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
KaraokeRepository.updateFavShow(
|
||||
KaraokeData(karaokeData),
|
||||
!fav.isSelected
|
||||
)
|
||||
|
||||
notifyItemRemoved(holder.absoluteAdapterPosition)
|
||||
|
||||
if (currentList.isEmpty()){
|
||||
onListEmptyListener(PostType.KARAOKE, true)
|
||||
karaokeData.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{
|
||||
karaokeData.title
|
||||
}
|
||||
}
|
||||
|
||||
root.setOnClickListener {
|
||||
onKaraokeClicked(karaokeData, holder.absoluteAdapterPosition)
|
||||
onKaraokeClicked?.invoke(karaokeData, holder.absoluteAdapterPosition)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +1,17 @@
|
||||
package com.woka.home.mylist.adapters
|
||||
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.AsyncDifferConfig
|
||||
import androidx.recyclerview.widget.DiffUtil
|
||||
import androidx.recyclerview.widget.ListAdapter
|
||||
import com.woka.R
|
||||
import com.woka.WokaApp.Companion.userPrefs
|
||||
import com.woka.databinding.FavViewHolderBinding
|
||||
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
|
||||
import com.woka.webseries.WebSeriesRepository
|
||||
import com.woka.webseries.models.ShowData
|
||||
import java.util.concurrent.Executors
|
||||
|
||||
class WebSeriesAdapter(
|
||||
private val context: Context,
|
||||
private val categoryId: String,
|
||||
private val onListEmptyListener: ((postType: PostType, isEng: Boolean) -> Unit)
|
||||
private val categoryId: String
|
||||
) : ListAdapter<BookmarkedShowData, FavoriteViewHolder>(DIFF_CONFIG) {
|
||||
|
||||
companion object {
|
||||
@@ -47,7 +37,6 @@ class WebSeriesAdapter(
|
||||
}
|
||||
|
||||
var onShowClickListener: ((BookmarkedShowData, String) -> Unit)? = null
|
||||
var onLikeChanged: ((Int) -> Unit)? = null
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): FavoriteViewHolder {
|
||||
return FavoriteViewHolder(
|
||||
@@ -79,74 +68,6 @@ class WebSeriesAdapter(
|
||||
}
|
||||
}
|
||||
|
||||
likeCount.show()
|
||||
like.show()
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
WebSeriesRepository.likeUnLikeShow(
|
||||
"${showData.id}",
|
||||
!like.isSelected
|
||||
)
|
||||
|
||||
like.isSelected = !like.isSelected
|
||||
likeCount.text = "${showData.likes_count}"
|
||||
showData.likes_count?.let {
|
||||
likeCount.text = "$it"
|
||||
}
|
||||
showData?.id?.let {
|
||||
onLikeChanged?.invoke(it)
|
||||
}
|
||||
}
|
||||
|
||||
fav.show()
|
||||
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()) {
|
||||
context.toast(context.getString(R.string.no_internet))
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
if (fav.isSelected) {
|
||||
WebSeriesRepository.updateFavShow(
|
||||
ShowData(showData),
|
||||
false,
|
||||
categoryId
|
||||
)
|
||||
|
||||
val currentList = currentList.toMutableList()
|
||||
currentList.removeAt(holder.absoluteAdapterPosition)
|
||||
submitList(currentList)
|
||||
|
||||
if (currentList.isEmpty()) {
|
||||
onListEmptyListener(PostType.WEB_SERIES, categoryId == "1")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
card.setOnClickListener {
|
||||
onShowClickListener?.invoke(showData, categoryId)
|
||||
}
|
||||
|
||||
@@ -5,5 +5,6 @@ data class Result(
|
||||
val game_data: MutableList<FavGameData>?,
|
||||
val show_data: MutableList<BookmarkedShowData>?,
|
||||
val sing_karaoke_data: MutableList<FavKaraokeData>?,
|
||||
val video_data: MutableList<Any>?
|
||||
val video_data: MutableList<Any>?,
|
||||
val total_records: Int?
|
||||
)
|
||||
@@ -11,15 +11,12 @@ import androidx.lifecycle.ViewModelProvider
|
||||
import com.woka.R
|
||||
import com.woka.database.models.clicks.ContentType
|
||||
import com.woka.databinding.ActivityFavoritesBinding
|
||||
import com.woka.home.mylist.adapters.WebSeriesAdapter
|
||||
import com.woka.home.mylist.models.PostType
|
||||
import com.woka.home.mylist.view.fragments.WebSeriesEngFragment
|
||||
import com.woka.home.mylist.view.fragments.FavAudioFragment
|
||||
import com.woka.home.mylist.view.fragments.FavGameFragment
|
||||
import com.woka.home.mylist.view.fragments.FavKaraokeFragment
|
||||
import com.woka.home.mylist.view.fragments.FavSeriesFragment
|
||||
import com.woka.home.mylist.viewmodel.FavoriteViewModel
|
||||
import com.woka.networking.ApiResult
|
||||
import com.woka.utils.hide
|
||||
import com.woka.utils.lightStatusBar
|
||||
import com.woka.utils.setVisibility
|
||||
import com.woka.utils.show
|
||||
|
||||
class FavoritesActivity : AppCompatActivity() {
|
||||
|
||||
@@ -32,8 +29,6 @@ class FavoritesActivity : AppCompatActivity() {
|
||||
private lateinit var binding: ActivityFavoritesBinding
|
||||
private lateinit var viewModel: FavoriteViewModel
|
||||
|
||||
private lateinit var adapter: WebSeriesAdapter
|
||||
|
||||
private var favTitle: String = ""
|
||||
private var contentType: ContentType? = null
|
||||
private var webSeriesIsEnglish = false
|
||||
@@ -49,13 +44,11 @@ class FavoritesActivity : AppCompatActivity() {
|
||||
insets
|
||||
}
|
||||
|
||||
window.lightStatusBar(false)
|
||||
window.lightStatusBar(true)
|
||||
window.navigationBarColor = Color.BLACK
|
||||
|
||||
viewModel = ViewModelProvider(this)[FavoriteViewModel::class.java]
|
||||
|
||||
adapter = WebSeriesAdapter(this, "1", ::onListEmptyListener)
|
||||
|
||||
favTitle = intent.getStringExtra(EXTRA_FAVORITE_TITLE)?:""
|
||||
contentType = ContentType.create(intent.getIntExtra(EXTRA_FAVORITE_CONTENT_TYPE, -1))
|
||||
webSeriesIsEnglish = intent.getBooleanExtra(EXTRA_FAVORITE_WEB_SERIES_IS_ENGLISH, false)
|
||||
@@ -65,12 +58,6 @@ class FavoritesActivity : AppCompatActivity() {
|
||||
clickEvents()
|
||||
|
||||
initFragment()
|
||||
|
||||
setObservers()
|
||||
}
|
||||
|
||||
private fun onListEmptyListener(postType: PostType, b: Boolean) {
|
||||
|
||||
}
|
||||
|
||||
private fun initViews(){
|
||||
@@ -94,15 +81,27 @@ class FavoritesActivity : AppCompatActivity() {
|
||||
viewModel.contentType = contentType
|
||||
viewModel.webSeriesIsEnglish = webSeriesIsEnglish
|
||||
|
||||
fragment = WebSeriesEngFragment()
|
||||
fragment = FavSeriesFragment()
|
||||
}
|
||||
ContentType.SEASON -> {}
|
||||
ContentType.EPISODE -> {}
|
||||
ContentType.VIDEO -> {}
|
||||
ContentType.PAINT -> {}
|
||||
ContentType.GAME -> {}
|
||||
ContentType.AUDIO -> {}
|
||||
ContentType.KARAOKE_VIDEO -> {}
|
||||
ContentType.GAME -> {
|
||||
viewModel.contentType = contentType
|
||||
|
||||
fragment = FavGameFragment()
|
||||
}
|
||||
ContentType.AUDIO -> {
|
||||
viewModel.contentType = contentType
|
||||
|
||||
fragment = FavAudioFragment()
|
||||
}
|
||||
ContentType.KARAOKE_VIDEO -> {
|
||||
viewModel.contentType = contentType
|
||||
|
||||
fragment = FavKaraokeFragment()
|
||||
}
|
||||
ContentType.SHOP_PRODUCT -> {}
|
||||
ContentType.PARENTAL_VIDEO -> {}
|
||||
ContentType.ARTICLE -> {}
|
||||
@@ -120,55 +119,4 @@ class FavoritesActivity : AppCompatActivity() {
|
||||
.commit()
|
||||
}
|
||||
}
|
||||
|
||||
private fun setObservers(){
|
||||
viewModel.favoritesLiveData.observe(this){
|
||||
binding.apply {
|
||||
when (it){
|
||||
is ApiResult.Error -> {
|
||||
if (adapter.currentList.isEmpty()){
|
||||
// no orders at all
|
||||
dataView.hide()
|
||||
noData.show()
|
||||
}else{
|
||||
// load more orders failed
|
||||
dataView.show()
|
||||
shimmer.hide()
|
||||
|
||||
loadMoreBtn.text = getString(R.string.retry)
|
||||
loadMoreBtn.show()
|
||||
}
|
||||
}
|
||||
is ApiResult.Loading -> {
|
||||
noData.hide()
|
||||
|
||||
dataView.show()
|
||||
shimmer.show()
|
||||
|
||||
loadMoreBtn.hide()
|
||||
}
|
||||
is ApiResult.Success -> {
|
||||
it.data?.let {ordersList ->
|
||||
noData.hide()
|
||||
|
||||
dataView.show()
|
||||
shimmer.hide()
|
||||
|
||||
loadMoreBtn.text = getString(R.string.load_more)
|
||||
loadMoreBtn.setVisibility(!viewModel.lastPage)
|
||||
|
||||
if (adapter.currentList.isEmpty()){
|
||||
adapter.submitList(ordersList)
|
||||
}else{
|
||||
adapter.notifyItemRangeInserted(
|
||||
adapter.currentList.size,
|
||||
ordersList.size
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
package com.woka.home.mylist.view.fragments
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import com.woka.R
|
||||
import com.woka.audiobooks.adapters.AudioBooksAdapter
|
||||
import com.woka.audiobooks.models.audiodata.AudioBookData
|
||||
import com.woka.database.models.clicks.ContentType
|
||||
import com.woka.databinding.FragmentFavoritesBinding
|
||||
import com.woka.home.mylist.viewmodel.FavoriteViewModel
|
||||
import com.woka.networking.ApiResult
|
||||
import com.woka.utils.hide
|
||||
import com.woka.utils.setVisibility
|
||||
import com.woka.utils.show
|
||||
|
||||
class FavAudioFragment : Fragment() {
|
||||
|
||||
private lateinit var binding: FragmentFavoritesBinding
|
||||
private lateinit var viewModel: FavoriteViewModel
|
||||
|
||||
private lateinit var adapter: AudioBooksAdapter
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
binding = FragmentFavoritesBinding.inflate(inflater, container, false)
|
||||
viewModel = ViewModelProvider(requireActivity())[FavoriteViewModel::class.java]
|
||||
adapter = AudioBooksAdapter(requireContext(), ::onBookClicked, ::onBookChanged, false){}
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
initViews()
|
||||
|
||||
clickEvents()
|
||||
|
||||
setObservers()
|
||||
|
||||
if (!viewModel.favoritesLiveData.isInitialized || viewModel.favoritesLiveData.value !is ApiResult.Success){
|
||||
viewModel.loadFavorites(ContentType.AUDIO)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun initViews(){
|
||||
binding.apply {
|
||||
rvFavorites.adapter = adapter
|
||||
}
|
||||
}
|
||||
|
||||
private fun clickEvents(){
|
||||
binding.apply {
|
||||
loadMoreBtn.setOnClickListener {
|
||||
viewModel.loadFavorites(ContentType.AUDIO)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setObservers(){
|
||||
viewModel.favoritesLiveData.observe(viewLifecycleOwner){
|
||||
binding.apply {
|
||||
when (it){
|
||||
is ApiResult.Error -> {
|
||||
if (adapter.itemCount == 0){
|
||||
// no orders at all
|
||||
dataView.hide()
|
||||
noData.show()
|
||||
}else{
|
||||
// load more orders failed
|
||||
dataView.show()
|
||||
shimmer.hide()
|
||||
|
||||
loadMoreBtn.text = getString(R.string.retry)
|
||||
loadMoreBtn.show()
|
||||
}
|
||||
}
|
||||
is ApiResult.Loading -> {
|
||||
noData.hide()
|
||||
|
||||
dataView.show()
|
||||
shimmer.show()
|
||||
|
||||
loadMoreBtn.hide()
|
||||
}
|
||||
is ApiResult.Success -> {
|
||||
it.data?.result?.audio_data?.let {audioList ->
|
||||
noData.hide()
|
||||
|
||||
dataView.show()
|
||||
shimmer.hide()
|
||||
|
||||
loadMoreBtn.text = getString(R.string.load_more)
|
||||
loadMoreBtn.setVisibility(!viewModel.lastPage)
|
||||
|
||||
adapter.submitList(audioList.map { AudioBookData(it) })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun onBookChanged(i: Int, audioBookData: AudioBookData) {
|
||||
|
||||
}
|
||||
|
||||
private fun onBookClicked(audioBookData: AudioBookData) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
package com.woka.home.mylist.view.fragments
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import com.woka.R
|
||||
import com.woka.database.models.clicks.ContentType
|
||||
import com.woka.databinding.FragmentFavoritesBinding
|
||||
import com.woka.home.mylist.viewmodel.FavoriteViewModel
|
||||
import com.woka.networking.ApiResult
|
||||
import com.woka.utils.hide
|
||||
import com.woka.utils.setVisibility
|
||||
import com.woka.utils.show
|
||||
import com.woka.wokagames.adapters.GamesAdapter
|
||||
import com.woka.wokagames.models.listing.GameData
|
||||
|
||||
class FavGameFragment : Fragment() {
|
||||
|
||||
private lateinit var binding: FragmentFavoritesBinding
|
||||
private lateinit var viewModel: FavoriteViewModel
|
||||
|
||||
private lateinit var adapter: GamesAdapter
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
binding = FragmentFavoritesBinding.inflate(inflater, container, false)
|
||||
viewModel = ViewModelProvider(requireActivity())[FavoriteViewModel::class.java]
|
||||
adapter = GamesAdapter(requireContext(), ::onGameClicked, false){}
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
initViews()
|
||||
|
||||
clickEvents()
|
||||
|
||||
setObservers()
|
||||
|
||||
if (!viewModel.favoritesLiveData.isInitialized || viewModel.favoritesLiveData.value !is ApiResult.Success){
|
||||
viewModel.loadFavorites(ContentType.GAME)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun initViews(){
|
||||
binding.apply {
|
||||
rvFavorites.adapter = adapter
|
||||
}
|
||||
}
|
||||
|
||||
private fun clickEvents(){
|
||||
binding.apply {
|
||||
loadMoreBtn.setOnClickListener {
|
||||
viewModel.loadFavorites(ContentType.GAME)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setObservers(){
|
||||
viewModel.favoritesLiveData.observe(viewLifecycleOwner){
|
||||
binding.apply {
|
||||
when (it){
|
||||
is ApiResult.Error -> {
|
||||
if (adapter.itemCount == 0){
|
||||
// no orders at all
|
||||
dataView.hide()
|
||||
noData.show()
|
||||
}else{
|
||||
// load more orders failed
|
||||
dataView.show()
|
||||
shimmer.hide()
|
||||
|
||||
loadMoreBtn.text = getString(R.string.retry)
|
||||
loadMoreBtn.show()
|
||||
}
|
||||
}
|
||||
is ApiResult.Loading -> {
|
||||
noData.hide()
|
||||
|
||||
dataView.show()
|
||||
shimmer.show()
|
||||
|
||||
loadMoreBtn.hide()
|
||||
}
|
||||
is ApiResult.Success -> {
|
||||
it.data?.result?.game_data?.let {gameList ->
|
||||
noData.hide()
|
||||
|
||||
dataView.show()
|
||||
shimmer.hide()
|
||||
|
||||
loadMoreBtn.text = getString(R.string.load_more)
|
||||
loadMoreBtn.setVisibility(!viewModel.lastPage)
|
||||
|
||||
adapter.submitList(gameList.map { GameData(it) })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun onGameClicked(gameData: GameData) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package com.woka.home.mylist.view.fragments
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import com.woka.R
|
||||
import com.woka.database.models.clicks.ContentType
|
||||
import com.woka.databinding.FragmentFavoritesBinding
|
||||
import com.woka.home.mylist.viewmodel.FavoriteViewModel
|
||||
import com.woka.karaoke.adapters.KaraokeAdapter
|
||||
import com.woka.karaoke.models.listing.KaraokeData
|
||||
import com.woka.networking.ApiResult
|
||||
import com.woka.utils.hide
|
||||
import com.woka.utils.setVisibility
|
||||
import com.woka.utils.show
|
||||
|
||||
class FavKaraokeFragment : Fragment() {
|
||||
|
||||
private lateinit var binding: FragmentFavoritesBinding
|
||||
private lateinit var viewModel: FavoriteViewModel
|
||||
|
||||
private lateinit var adapter: KaraokeAdapter
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
binding = FragmentFavoritesBinding.inflate(inflater, container, false)
|
||||
viewModel = ViewModelProvider(requireActivity())[FavoriteViewModel::class.java]
|
||||
adapter = KaraokeAdapter(requireContext(), ::onKaraokeClicked, ::onKaraokeChanged, false){}
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
initViews()
|
||||
|
||||
clickEvents()
|
||||
|
||||
setObservers()
|
||||
|
||||
if (!viewModel.favoritesLiveData.isInitialized || viewModel.favoritesLiveData.value !is ApiResult.Success){
|
||||
viewModel.loadFavorites(ContentType.KARAOKE_VIDEO)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun initViews(){
|
||||
binding.apply {
|
||||
rvFavorites.adapter = adapter
|
||||
}
|
||||
}
|
||||
|
||||
private fun clickEvents(){
|
||||
binding.apply {
|
||||
loadMoreBtn.setOnClickListener {
|
||||
viewModel.loadFavorites(ContentType.KARAOKE_VIDEO)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setObservers(){
|
||||
viewModel.favoritesLiveData.observe(viewLifecycleOwner){
|
||||
binding.apply {
|
||||
when (it){
|
||||
is ApiResult.Error -> {
|
||||
if (adapter.itemCount == 0){
|
||||
// no orders at all
|
||||
dataView.hide()
|
||||
noData.show()
|
||||
}else{
|
||||
// load more orders failed
|
||||
dataView.show()
|
||||
shimmer.hide()
|
||||
|
||||
loadMoreBtn.text = getString(R.string.retry)
|
||||
loadMoreBtn.show()
|
||||
}
|
||||
}
|
||||
is ApiResult.Loading -> {
|
||||
noData.hide()
|
||||
|
||||
dataView.show()
|
||||
shimmer.show()
|
||||
|
||||
loadMoreBtn.hide()
|
||||
}
|
||||
is ApiResult.Success -> {
|
||||
it.data?.result?.sing_karaoke_data?.let {karaokeList ->
|
||||
noData.hide()
|
||||
|
||||
dataView.show()
|
||||
shimmer.hide()
|
||||
|
||||
loadMoreBtn.text = getString(R.string.load_more)
|
||||
loadMoreBtn.setVisibility(!viewModel.lastPage)
|
||||
|
||||
adapter.submitList(karaokeList.map { KaraokeData(it) })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun onKaraokeChanged(i: Int, b: Boolean, karaokeData: KaraokeData) {
|
||||
|
||||
}
|
||||
|
||||
private fun onKaraokeClicked(karaokeData: KaraokeData) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package com.woka.home.mylist.view.fragments
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import com.woka.R
|
||||
import com.woka.database.models.clicks.ContentType
|
||||
import com.woka.databinding.FragmentFavoritesBinding
|
||||
import com.woka.home.mylist.viewmodel.FavoriteViewModel
|
||||
import com.woka.networking.ApiResult
|
||||
import com.woka.utils.hide
|
||||
import com.woka.utils.setVisibility
|
||||
import com.woka.utils.show
|
||||
import com.woka.webseries.adapters.WebSeriesShowAdapter
|
||||
import com.woka.webseries.models.ShowData
|
||||
|
||||
class FavSeriesFragment : Fragment() {
|
||||
|
||||
private lateinit var binding: FragmentFavoritesBinding
|
||||
private lateinit var viewModel: FavoriteViewModel
|
||||
|
||||
private lateinit var adapter: WebSeriesShowAdapter
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
binding = FragmentFavoritesBinding.inflate(inflater, container, false)
|
||||
viewModel = ViewModelProvider(requireActivity())[FavoriteViewModel::class.java]
|
||||
adapter = WebSeriesShowAdapter(requireContext(), ::onShowClicked, ::onShowCommonDataChanged, false){}
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
initViews()
|
||||
|
||||
clickEvents()
|
||||
|
||||
setObservers()
|
||||
|
||||
if (!viewModel.favoritesLiveData.isInitialized || viewModel.favoritesLiveData.value !is ApiResult.Success){
|
||||
viewModel.loadFavorites(ContentType.SERIES, if (viewModel.webSeriesIsEnglish) "1" else "18")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun initViews(){
|
||||
binding.apply {
|
||||
rvFavorites.adapter = adapter
|
||||
}
|
||||
}
|
||||
|
||||
private fun clickEvents(){
|
||||
binding.apply {
|
||||
loadMoreBtn.setOnClickListener {
|
||||
viewModel.loadFavorites(ContentType.SERIES, if (viewModel.webSeriesIsEnglish) "1" else "18")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setObservers(){
|
||||
viewModel.favoritesLiveData.observe(viewLifecycleOwner){
|
||||
binding.apply {
|
||||
when (it){
|
||||
is ApiResult.Error -> {
|
||||
if (adapter.itemCount == 0){
|
||||
// no orders at all
|
||||
dataView.hide()
|
||||
noData.show()
|
||||
}else{
|
||||
// load more orders failed
|
||||
dataView.show()
|
||||
shimmer.hide()
|
||||
|
||||
loadMoreBtn.text = getString(R.string.retry)
|
||||
loadMoreBtn.show()
|
||||
}
|
||||
}
|
||||
is ApiResult.Loading -> {
|
||||
noData.hide()
|
||||
|
||||
dataView.show()
|
||||
shimmer.show()
|
||||
|
||||
loadMoreBtn.hide()
|
||||
}
|
||||
is ApiResult.Success -> {
|
||||
it.data?.result?.show_data?.let {showList ->
|
||||
noData.hide()
|
||||
|
||||
dataView.show()
|
||||
shimmer.hide()
|
||||
|
||||
loadMoreBtn.text = getString(R.string.load_more)
|
||||
loadMoreBtn.setVisibility(!viewModel.lastPage)
|
||||
|
||||
adapter.submitListShowList(showList.map { ShowData(it) }, if (viewModel.webSeriesIsEnglish) "1" else "18")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun onShowCommonDataChanged(showData: ShowData, categoryId: String) {
|
||||
|
||||
}
|
||||
|
||||
private fun onShowClicked(showData: ShowData, categoryId: String) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package com.woka.home.mylist.view.fragments
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.fragment.app.Fragment
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import com.woka.R
|
||||
import com.woka.databinding.FragmentWebSeriesEngBinding
|
||||
import com.woka.home.mylist.viewmodel.FavoriteViewModel
|
||||
|
||||
class WebSeriesEngFragment : Fragment() {
|
||||
|
||||
private lateinit var binding: FragmentWebSeriesEngBinding
|
||||
private lateinit var viewModel: FavoriteViewModel
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
binding = FragmentWebSeriesEngBinding.inflate(inflater, container, false)
|
||||
viewModel = ViewModelProvider(requireActivity())[FavoriteViewModel::class.java]
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
}
|
||||
}
|
||||
@@ -5,13 +5,15 @@ import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.woka.database.models.clicks.ContentType
|
||||
import com.woka.home.mylist.MyListRepository
|
||||
import com.woka.home.mylist.models.MyListResponse
|
||||
import com.woka.home.mylist.models.Result
|
||||
import com.woka.networking.ApiResult
|
||||
import com.woka.userdata.UserRepository
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class FavoriteViewModel: ViewModel() {
|
||||
class FavoriteViewModel : ViewModel() {
|
||||
|
||||
private val userRepository = UserRepository
|
||||
|
||||
var contentType: ContentType? = null
|
||||
var webSeriesIsEnglish = false
|
||||
@@ -20,45 +22,49 @@ class FavoriteViewModel: ViewModel() {
|
||||
val favoritesLiveData: LiveData<ApiResult<MyListResponse>>
|
||||
get() = _favoritesLiveData
|
||||
|
||||
private val myListResponse = MyListResponse(Result(
|
||||
mutableListOf(),
|
||||
mutableListOf(),
|
||||
mutableListOf(),
|
||||
mutableListOf(),
|
||||
mutableListOf()
|
||||
))
|
||||
private val myListResponse = MyListResponse(
|
||||
Result(
|
||||
mutableListOf(), mutableListOf(), mutableListOf(), mutableListOf(), mutableListOf(), 0
|
||||
)
|
||||
)
|
||||
|
||||
private var nextPageToLoad: Int = 0
|
||||
private var quantityPerPage: Int = 6
|
||||
var lastPage = false
|
||||
|
||||
fun loadAudioSongs(contentType: ContentType) {
|
||||
fun loadFavorites(contentType: ContentType, categoryId: String? = null) {
|
||||
viewModelScope.launch {
|
||||
_favoritesLiveData.postValue(ApiResult.Loading())
|
||||
|
||||
when (val value = MyListRepository.loadMyFavList()) {
|
||||
when (val value = userRepository.loadMyFavList(
|
||||
contentType.id, nextPageToLoad, quantityPerPage, categoryId
|
||||
)) {
|
||||
is ApiResult.Error -> _favoritesLiveData.postValue(
|
||||
ApiResult.Error(
|
||||
value.errorMessage,
|
||||
value.error
|
||||
value.errorMessage, value.error
|
||||
)
|
||||
)
|
||||
|
||||
is ApiResult.Loading -> _favoritesLiveData.postValue(ApiResult.Loading())
|
||||
is ApiResult.Success -> {
|
||||
value.data?.let {
|
||||
when (contentType){
|
||||
when (contentType) {
|
||||
ContentType.SERIES -> {
|
||||
it.result?.show_data?.let { newList ->
|
||||
|
||||
myListResponse.result?.show_data?.addAll(newList)
|
||||
|
||||
lastPage = newList.size < quantityPerPage
|
||||
lastPage = myListResponse.result?.show_data?.size == it.result.total_records
|
||||
|
||||
_favoritesLiveData.postValue(ApiResult.Success(myListResponse))
|
||||
_favoritesLiveData.postValue(
|
||||
ApiResult.Success(
|
||||
myListResponse
|
||||
)
|
||||
)
|
||||
nextPageToLoad++
|
||||
}
|
||||
}
|
||||
|
||||
ContentType.SEASON -> {}
|
||||
ContentType.EPISODE -> {}
|
||||
ContentType.VIDEO -> {}
|
||||
@@ -68,34 +74,40 @@ class FavoriteViewModel: ViewModel() {
|
||||
|
||||
myListResponse.result?.game_data?.addAll(newList)
|
||||
|
||||
lastPage = newList.size < quantityPerPage
|
||||
lastPage =
|
||||
myListResponse.result?.game_data?.size == it.result.total_records
|
||||
|
||||
_favoritesLiveData.postValue(ApiResult.Success(myListResponse))
|
||||
nextPageToLoad++
|
||||
}
|
||||
}
|
||||
|
||||
ContentType.AUDIO -> {
|
||||
it.result?.audio_data?.let { newList ->
|
||||
|
||||
myListResponse.result?.audio_data?.addAll(newList)
|
||||
|
||||
lastPage = newList.size < quantityPerPage
|
||||
lastPage =
|
||||
myListResponse.result?.audio_data?.size == it.result.total_records
|
||||
|
||||
_favoritesLiveData.postValue(ApiResult.Success(myListResponse))
|
||||
nextPageToLoad++
|
||||
}
|
||||
}
|
||||
|
||||
ContentType.KARAOKE_VIDEO -> {
|
||||
it.result?.sing_karaoke_data?.let { newList ->
|
||||
|
||||
myListResponse.result?.sing_karaoke_data?.addAll(newList)
|
||||
|
||||
lastPage = newList.size < quantityPerPage
|
||||
lastPage =
|
||||
myListResponse.result?.sing_karaoke_data?.size == it.result.total_records
|
||||
|
||||
_favoritesLiveData.postValue(ApiResult.Success(myListResponse))
|
||||
nextPageToLoad++
|
||||
}
|
||||
}
|
||||
|
||||
ContentType.SHOP_PRODUCT -> {}
|
||||
ContentType.PARENTAL_VIDEO -> {}
|
||||
ContentType.ARTICLE -> {}
|
||||
|
||||
@@ -14,7 +14,7 @@ import com.woka.karaoke.KaraokeRepository
|
||||
import com.woka.karaoke.models.listing.KaraokeData
|
||||
import com.woka.userPreference.UserType
|
||||
import com.woka.utils.isNetworkConnected
|
||||
import com.woka.utils.show
|
||||
import com.woka.utils.setVisibility
|
||||
import com.woka.utils.toast
|
||||
import java.util.concurrent.Executors
|
||||
import kotlin.math.max
|
||||
@@ -23,6 +23,7 @@ class KaraokeAdapter(
|
||||
private val context: Context,
|
||||
private var onKaraokeClicked: (KaraokeData) -> Unit,
|
||||
private var onKaraokeChanged: (id: Int, isContinue: Boolean, KaraokeData) -> Unit,
|
||||
private val showLikeAndFav: Boolean = true,
|
||||
private val noSignInListener: () -> Unit
|
||||
): ListAdapter<KaraokeData, KaraokeAdapter.AudioBookViewHolder>(ASYNC_DIFF_UTIL) {
|
||||
|
||||
@@ -76,9 +77,9 @@ class KaraokeAdapter(
|
||||
}
|
||||
}
|
||||
|
||||
like.show()
|
||||
likeCount.show()
|
||||
fav.show()
|
||||
like.setVisibility(showLikeAndFav)
|
||||
likeCount.setVisibility(showLikeAndFav)
|
||||
fav.setVisibility(showLikeAndFav)
|
||||
|
||||
karaokeData.likes_count?.let {
|
||||
likeCount.text = "$it"
|
||||
|
||||
@@ -73,7 +73,7 @@ class MyOrdersActivity : WokaBaseActivity() {
|
||||
|
||||
setObservers()
|
||||
|
||||
if (!viewModel.ordersLiveData.isInitialized){
|
||||
if (!viewModel.ordersLiveData.isInitialized || viewModel.ordersLiveData.value !is ApiResult.Success){
|
||||
viewModel.loadOrders()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,12 +48,16 @@ object UserRepository {
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun loadMyFavList(): ApiResult<MyListResponse>{
|
||||
suspend fun loadMyFavList(postType: Int? = null, pageNo: Int? = null, limit: Int? = null, categoryId: String? = null): ApiResult<MyListResponse>{
|
||||
return handleApiCall {
|
||||
val formBuilder = FormBody.Builder()
|
||||
formBuilder.add("api_version", "v2")
|
||||
pageNo?.let { formBuilder.add("start", "$pageNo") }
|
||||
limit?.let { formBuilder.add("limit", "$limit") }
|
||||
postType?.let { formBuilder.add("post_type", "$postType") }
|
||||
categoryId?.let { formBuilder.add("category_id", "$categoryId") }
|
||||
userApiService.getMyFavList(
|
||||
FormBody.Builder()
|
||||
.add("api_version", "v2")
|
||||
.build()
|
||||
formBuilder.build()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,9 +12,7 @@ import com.woka.modules.categorymodels.Category
|
||||
import com.woka.utils.hide
|
||||
import com.woka.utils.show
|
||||
|
||||
class SpinnerAdapter(context: Context, private val list: List<Category>): ArrayAdapter<Category>(context, 0, list){
|
||||
|
||||
var currentSelection: Int = 0
|
||||
class SpinnerAdapter(context: Context, private val list: List<Category>, var currentSelection: Int = 0): ArrayAdapter<Category>(context, 0, list){
|
||||
|
||||
var selectedCategoryType: String? = null
|
||||
get() {
|
||||
|
||||
@@ -11,7 +11,7 @@ import com.woka.WokaApp.Companion.userPrefs
|
||||
import com.woka.databinding.ShowViewHolderBinding
|
||||
import com.woka.userPreference.UserType
|
||||
import com.woka.utils.isNetworkConnected
|
||||
import com.woka.utils.show
|
||||
import com.woka.utils.setVisibility
|
||||
import com.woka.utils.toast
|
||||
import com.woka.webseries.WebSeriesRepository
|
||||
import com.woka.webseries.models.ShowData
|
||||
@@ -21,6 +21,7 @@ class WebSeriesShowAdapter(
|
||||
private val context: Context,
|
||||
private var onShowClicked: (ShowData, String) -> Unit,
|
||||
private var onShowCommonDataChange: ((ShowData, String) -> Unit)? = null,
|
||||
private val showLikeAndFav: Boolean = true,
|
||||
private val noSignInListener: () -> Unit
|
||||
): RecyclerView.Adapter<WebSeriesShowAdapter.ShowViewHolder>() {
|
||||
|
||||
@@ -69,9 +70,9 @@ class WebSeriesShowAdapter(
|
||||
}
|
||||
}
|
||||
|
||||
like.show()
|
||||
likeCount.show()
|
||||
fav.show()
|
||||
like.setVisibility(showLikeAndFav)
|
||||
likeCount.setVisibility(showLikeAndFav)
|
||||
fav.setVisibility(showLikeAndFav)
|
||||
|
||||
showData.likes_count?.let {
|
||||
likeCount.text = "$it"
|
||||
|
||||
@@ -232,7 +232,7 @@ class WebSeriesFragment : Fragment() {
|
||||
binding.spinnerCard.show()
|
||||
binding.selectLangTxt.show()
|
||||
|
||||
catSpinnerAdapter = SpinnerAdapter(requireContext(), catList.filterNotNull())
|
||||
catSpinnerAdapter = SpinnerAdapter(requireContext(), catList.filterNotNull(), viewModel.selectedCategoryPos)
|
||||
binding.categorySpinner.setAdapter(catSpinnerAdapter)
|
||||
binding.categorySpinner.setSelection(viewModel.selectedCategoryPos)
|
||||
|
||||
|
||||
@@ -41,10 +41,10 @@ import com.woka.webseries.models.ShowData
|
||||
import com.woka.webseries.models.episodedata.EpisodeData
|
||||
import com.woka.webseries.models.teaserdata.TeaserData
|
||||
import com.woka.webseries.viewmodel.WebSeriesViewModel
|
||||
import com.woka.webseries.views.WebSeriesActivity.Companion.EXTRA_SHOW_ID
|
||||
import com.woka.webseries.views.WebSeriesActivity.Companion.EXTRA_SHOW_CATEGORY
|
||||
import kotlin.math.max
|
||||
|
||||
class WebShowFragment: Fragment(), TabLayout.OnTabSelectedListener {
|
||||
class WebShowFragment : Fragment(), TabLayout.OnTabSelectedListener {
|
||||
|
||||
private lateinit var binding: FragmentWebShowBinding
|
||||
private lateinit var viewModel: WebSeriesViewModel
|
||||
@@ -173,7 +173,7 @@ class WebShowFragment: Fragment(), TabLayout.OnTabSelectedListener {
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
if (userPrefs?.userType == UserType.GUEST || userPrefs?.userType == UserType.NONE){
|
||||
if (userPrefs?.userType == UserType.GUEST || userPrefs?.userType == UserType.NONE) {
|
||||
noSignInDialog.show()
|
||||
return@setOnClickListener
|
||||
}
|
||||
@@ -181,10 +181,10 @@ class WebShowFragment: Fragment(), TabLayout.OnTabSelectedListener {
|
||||
WebSeriesRepository.likeUnLikeShow("${showData.id}", showData.is_liked == false)
|
||||
|
||||
showData.likes_count?.let {
|
||||
showData.likes_count = if (likeSeason.isSelected){
|
||||
showData.likes_count = if (likeSeason.isSelected) {
|
||||
// unlike
|
||||
max(0, it - 1)
|
||||
}else{
|
||||
} else {
|
||||
// like
|
||||
it + 1
|
||||
}
|
||||
@@ -196,9 +196,6 @@ class WebShowFragment: Fragment(), TabLayout.OnTabSelectedListener {
|
||||
likeCount.text = "${showData.likes_count}"
|
||||
|
||||
showDataChanged = true
|
||||
activity?.setResult(RESULT_OK, Intent().apply {
|
||||
putExtra(EXTRA_SHOW_ID, showData.id?:-1)
|
||||
})
|
||||
}
|
||||
|
||||
favSeason.setOnClickListener {
|
||||
@@ -207,7 +204,7 @@ class WebShowFragment: Fragment(), TabLayout.OnTabSelectedListener {
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
if (userPrefs?.userType == UserType.GUEST || userPrefs?.userType == UserType.NONE){
|
||||
if (userPrefs?.userType == UserType.GUEST || userPrefs?.userType == UserType.NONE) {
|
||||
noSignInDialog.show()
|
||||
return@setOnClickListener
|
||||
}
|
||||
@@ -218,20 +215,21 @@ class WebShowFragment: Fragment(), TabLayout.OnTabSelectedListener {
|
||||
categoryId
|
||||
)
|
||||
|
||||
if (showData.isBookMarked(categoryId)){
|
||||
if (showData.isBookMarked(categoryId)) {
|
||||
// remove from fav
|
||||
showData.removeAsBookMark(categoryId)
|
||||
}else{
|
||||
} else {
|
||||
// add to fav
|
||||
showData.addAsBookMark(categoryId)
|
||||
}
|
||||
|
||||
favSeason.isSelected = !favSeason.isSelected
|
||||
|
||||
showDataChanged = true
|
||||
activity?.setResult(RESULT_OK, Intent().apply {
|
||||
putExtra(EXTRA_SHOW_ID, showData.id?:-1)
|
||||
putExtra(EXTRA_SHOW_CATEGORY, if (!favSeason.isSelected) categoryId else null)
|
||||
})
|
||||
|
||||
showDataChanged = true
|
||||
}
|
||||
|
||||
playTrailer.setOnClickListener {
|
||||
|
||||
@@ -12,7 +12,7 @@ import com.woka.WokaApp.Companion.userPrefs
|
||||
import com.woka.databinding.ShowViewHolderBinding
|
||||
import com.woka.userPreference.UserType
|
||||
import com.woka.utils.isNetworkConnected
|
||||
import com.woka.utils.show
|
||||
import com.woka.utils.setVisibility
|
||||
import com.woka.utils.toast
|
||||
import com.woka.wokagames.GamesRepository
|
||||
import com.woka.wokagames.models.listing.GameData
|
||||
@@ -22,6 +22,7 @@ import kotlin.math.max
|
||||
class GamesAdapter(
|
||||
var context: Context,
|
||||
private var onGameClicked: (GameData) -> Unit,
|
||||
private val showLikeAndLike: Boolean = true,
|
||||
private val noSignInListener: () -> Unit
|
||||
) : ListAdapter<GameData, GamesAdapter.GameViewHolder>(
|
||||
ASYNC_DIFF_UTIL
|
||||
@@ -77,9 +78,9 @@ class GamesAdapter(
|
||||
}
|
||||
}
|
||||
|
||||
like.show()
|
||||
likeCount.show()
|
||||
fav.show()
|
||||
like.setVisibility(showLikeAndLike)
|
||||
likeCount.setVisibility(showLikeAndLike)
|
||||
fav.setVisibility(showLikeAndLike)
|
||||
|
||||
gameData.likes_count?.let {
|
||||
likeCount.text = "$it"
|
||||
|
||||
@@ -53,6 +53,8 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
|
||||
android:translationZ="1dp"
|
||||
|
||||
app:layout_constraintTop_toBottomOf="@id/toolbar_view"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
/>
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
|
||||
<com.woka.utils.PressableImageView
|
||||
android:id="@+id/like"
|
||||
android:visibility="gone"
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="24dp"
|
||||
android:contentDescription="@string/image"
|
||||
@@ -74,6 +75,7 @@
|
||||
|
||||
<TextView
|
||||
android:id="@+id/like_count"
|
||||
android:visibility="gone"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -94,6 +96,7 @@
|
||||
|
||||
<com.woka.utils.PressableImageView
|
||||
android:id="@+id/fav"
|
||||
android:visibility="gone"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="19dp"
|
||||
android:contentDescription="@string/image"
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_web_series"
|
||||
android:id="@+id/rv_favorites"
|
||||
android:visibility="visible"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -443,7 +443,7 @@
|
||||
<com.google.android.material.tabs.TabLayout
|
||||
android:id="@+id/seasons_tab"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_marginStart="5dp"
|
||||
android:layout_marginTop="15dp"
|
||||
app:tabBackground="@drawable/season_tab_bg"
|
||||
@@ -505,6 +505,7 @@
|
||||
android:id="@+id/ep_shimmer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="15dp"
|
||||
android:visibility="gone"
|
||||
app:shimmer_auto_start="true"
|
||||
app:shimmer_base_alpha="0.6"
|
||||
|
||||
Reference in New Issue
Block a user