Completed My List

This commit is contained in:
2024-08-14 20:06:28 +05:30
parent dcbc96f9e6
commit c6ed16cad2
19 changed files with 383 additions and 105 deletions

View File

@@ -103,6 +103,7 @@
527AC6FD2C173A5100434FB7 /* SongListCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 527AC6FB2C173A5100434FB7 /* SongListCell.swift */; };
527AC6FE2C173A5100434FB7 /* SongListCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 527AC6FC2C173A5100434FB7 /* SongListCell.xib */; };
527AC7012C182DCE00434FB7 /* TimeStringToSeconds.swift in Sources */ = {isa = PBXBuildFile; fileRef = 527AC7002C182DCE00434FB7 /* TimeStringToSeconds.swift */; };
527CA43A2C6C7FBF00EEDD91 /* WOKA.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 527CA4382C6C7FBE00EEDD91 /* WOKA.xcdatamodeld */; };
528BEF602C2C372900FFDAB8 /* ContinueWatchingVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 528BEF5F2C2C372900FFDAB8 /* ContinueWatchingVC.swift */; };
528E5F1B2C24531200E33E4E /* SeasonListingDM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 528E5F1A2C24531200E33E4E /* SeasonListingDM.swift */; };
528E5F222C24660F00E33E4E /* SeasonCategoryCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 528E5F202C24660F00E33E4E /* SeasonCategoryCell.swift */; };
@@ -348,7 +349,6 @@
9CDAEB142C54132E00890C47 /* CheckEddDM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9CDAEB132C54132E00890C47 /* CheckEddDM.swift */; };
9CDC343C2BDBBC6B00093089 /* SelectAgeVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9CDC343B2BDBBC6B00093089 /* SelectAgeVC.swift */; };
9CDCE1452BDB9B9A003FEF11 /* OnBoardMainSound.m4a in Resources */ = {isa = PBXBuildFile; fileRef = 9CDCE1442BDB9B9A003FEF11 /* OnBoardMainSound.m4a */; };
9CF5BA9F2C6BCE9E00BD77F9 /* WOKA.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 9CF5BA9D2C6BCE9E00BD77F9 /* WOKA.xcdatamodeld */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -494,6 +494,7 @@
527AC6FB2C173A5100434FB7 /* SongListCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SongListCell.swift; sourceTree = "<group>"; };
527AC6FC2C173A5100434FB7 /* SongListCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = SongListCell.xib; sourceTree = "<group>"; };
527AC7002C182DCE00434FB7 /* TimeStringToSeconds.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimeStringToSeconds.swift; sourceTree = "<group>"; };
527CA4392C6C7FBE00EEDD91 /* WOKA.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = WOKA.xcdatamodel; sourceTree = "<group>"; };
528BEF5F2C2C372900FFDAB8 /* ContinueWatchingVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContinueWatchingVC.swift; sourceTree = "<group>"; };
528E5F1A2C24531200E33E4E /* SeasonListingDM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SeasonListingDM.swift; sourceTree = "<group>"; };
528E5F202C24660F00E33E4E /* SeasonCategoryCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SeasonCategoryCell.swift; sourceTree = "<group>"; };
@@ -731,7 +732,6 @@
9CDCE1412BDB94BA003FEF11 /* hi */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = hi; path = hi.lproj/Main.strings; sourceTree = "<group>"; };
9CDCE1422BDB94BD003FEF11 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Main.strings; sourceTree = "<group>"; };
9CDCE1442BDB9B9A003FEF11 /* OnBoardMainSound.m4a */ = {isa = PBXFileReference; lastKnownFileType = file; path = OnBoardMainSound.m4a; sourceTree = "<group>"; };
9CF5BA9E2C6BCE9E00BD77F9 /* WOKA.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = WOKA.xcdatamodel; sourceTree = "<group>"; };
C83A2BA3B8F575DC890CC5DD /* Pods-WOKA.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WOKA.debug.xcconfig"; path = "Target Support Files/Pods-WOKA/Pods-WOKA.debug.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */
@@ -930,7 +930,7 @@
9C535DC82C00C34000DA6DCD /* Theme */,
52DAC6462C21761700E2F85B /* WebSeries */,
9C834ED92C1C20EC00B29A9C /* WOKA.entitlements */,
9CF5BA9D2C6BCE9E00BD77F9 /* WOKA.xcdatamodeld */,
527CA4382C6C7FBE00EEDD91 /* WOKA.xcdatamodeld */,
52ACC1292C610EC900791528 /* PersistentStorage.swift */,
);
path = WOKA;
@@ -2314,7 +2314,7 @@
52A6DCA02C4E3AA600F63C51 /* ShopListingCell.swift in Sources */,
525954192BE8CC3400191286 /* ConstantString.swift in Sources */,
52D774EB2BDFC0BF001D87DE /* OTPVC.swift in Sources */,
9CF5BA9F2C6BCE9E00BD77F9 /* WOKA.xcdatamodeld in Sources */,
527CA43A2C6C7FBF00EEDD91 /* WOKA.xcdatamodeld in Sources */,
9C8446872C40FC6E003E3E53 /* AVPlayerTesting.swift in Sources */,
52AF71F42C36C40B00BC5972 /* GamesWebViewVC.swift in Sources */,
9C007F202C255DF200F798C2 /* EpisodeListingDM.swift in Sources */,
@@ -2738,7 +2738,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = WOKA/WOKA.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 3;
CURRENT_PROJECT_VERSION = 4;
DEVELOPMENT_TEAM = 4S9A74ZB6H;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
GENERATE_INFOPLIST_FILE = YES;
@@ -2778,7 +2778,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = WOKA/WOKA.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 3;
CURRENT_PROJECT_VERSION = 4;
DEVELOPMENT_TEAM = 4S9A74ZB6H;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
GENERATE_INFOPLIST_FILE = YES;
@@ -3070,14 +3070,14 @@
/* End XCSwiftPackageProductDependency section */
/* Begin XCVersionGroup section */
9CF5BA9D2C6BCE9E00BD77F9 /* WOKA.xcdatamodeld */ = {
527CA4382C6C7FBE00EEDD91 /* WOKA.xcdatamodeld */ = {
isa = XCVersionGroup;
children = (
9CF5BA9E2C6BCE9E00BD77F9 /* WOKA.xcdatamodel */,
527CA4392C6C7FBE00EEDD91 /* WOKA.xcdatamodel */,
);
currentVersion = 9CF5BA9E2C6BCE9E00BD77F9 /* WOKA.xcdatamodel */;
currentVersion = 527CA4392C6C7FBE00EEDD91 /* WOKA.xcdatamodel */;
name = WOKA.xcdatamodeld;
path = /Users/bilal/Desktop/woka_native_ios_swift/WOKA/WOKA.xcdatamodeld;
path = /Users/macbookpro/Desktop/WOKA/WOKA/WOKA.xcdatamodeld;
sourceTree = "<group>";
versionGroupType = wrapper.xcdatamodel;
};

View File

@@ -33,6 +33,10 @@ class AudioBookDetailsVC : UIViewController{
// var continueAudioData : ListenAudioListingDM.AudioDatum?
var audioIndex = 0
typealias btnTappedBlock = ( _ from : FavCellCLick) -> Void
var btnTapped : btnTappedBlock?
var reloadType : FavCellCLick?
override func viewDidLoad() {
super.viewDidLoad()
initView()
@@ -50,6 +54,13 @@ class AudioBookDetailsVC : UIViewController{
if let postID = audioData?.id{
PersistentStorage.shared.addAudioCount(postID: postID)
}
if let reloadType{
if btnTapped != nil {
btnTapped?(reloadType)
}
}
self.dismiss(animated: true)
}
}
@@ -78,7 +89,7 @@ class AudioBookDetailsVC : UIViewController{
// }
K.GVar.reloadMyListAudioBooks = true
self.reloadType = .favourite
self.delegate?.updateRows(index: self.audioIndex, type: .favourite, isFav: false, isLike: nil, id: showID)
self.initView()
}
@@ -92,7 +103,7 @@ class AudioBookDetailsVC : UIViewController{
// }
K.GVar.reloadMyListAudioBooks = true
self.reloadType = .favourite
self.delegate?.updateRows(index: self.audioIndex, type: .favourite, isFav: true, isLike: nil, id: showID)
self.initView()
}
@@ -149,6 +160,7 @@ class AudioBookDetailsVC : UIViewController{
MyListDataTemp.shareInstance.favListingData?.audioData?[index].likesCount! -= 1
K.GVar.myListSoftReload = true
}
self.reloadType = .favourite
self.delegate?.updateRows(index: self.audioIndex, type: .liked, isFav: nil, isLike: false, id: showID)
self.initView()
}
@@ -162,7 +174,7 @@ class AudioBookDetailsVC : UIViewController{
MyListDataTemp.shareInstance.favListingData?.audioData?[index].likesCount! += 1
K.GVar.myListSoftReload = true
}
self.reloadType = .favourite
self.delegate?.updateRows(index: self.audioIndex, type: .liked, isFav: nil, isLike: true, id: showID)
self.initView()
}
@@ -356,6 +368,11 @@ class AudioBookDetailsVC : UIViewController{
if let postID = audioData?.id{
PersistentStorage.shared.addAudioCount(postID: postID)
}
if let reloadType{
if btnTapped != nil {
btnTapped?(reloadType)
}
}
self.dismiss(animated: true)
}
}

View File

@@ -122,7 +122,7 @@ class SelectAvatarVM{
AuthFunc.shareInstance.regData.language_id = "1"
}
AuthFunc.shareInstance.regData.language_id = AuthFunc.shareInstance.getOneSignalID()
AuthFunc.shareInstance.regData.one_signal_player_id = AuthFunc.shareInstance.getOneSignalID()
Utilities.startProgressHUD()
@@ -166,7 +166,7 @@ class SelectAvatarVM{
vcPush.mainTitleText = "Error"
vcPush.yesBtnText = "Retry?"
vcPush.onDoneBlock = { isDone in
self.getAvatarListing()
self.registerUser()
}
vcPush.modalPresentationStyle = .overCurrentContext
vcPush.modalTransitionStyle = .crossDissolve

View File

@@ -21,5 +21,8 @@ extension K{
static var reloadGames = false
static var reloadHindiWebseries = false
static var reloadEnglishWebseries = false
static var reloadMyListAll = 0 // 0 - null, 1 - add , 2- remove
static var reloadMyListAllID = 0
}
}

View File

@@ -30,6 +30,11 @@ class GamesDetailVC: UIViewController {
var delegate : ReloadSeriesFavLike?
var gameIndex = 0
//for myList
typealias btnTappedBlock = ( _ from : FavCellCLick) -> Void
var btnTapped : btnTappedBlock?
var reloadType : FavCellCLick?
override func viewDidLoad() {
super.viewDidLoad()
initView()
@@ -43,6 +48,11 @@ class GamesDetailVC: UIViewController {
if let postID = gameData?.id{
PersistentStorage.shared.addGamesCount(postID: postID)
}
if let reloadType{
if btnTapped != nil {
btnTapped?(reloadType)
}
}
self.dismiss(animated: true)
}
}
@@ -125,6 +135,11 @@ class GamesDetailVC: UIViewController {
// K.GVar.myListSoftReload = true
// }
K.GVar.reloadGames = true
self.reloadType = .favourite
// To reload MyListViewAllVC
K.GVar.reloadMyListAll = 2
K.GVar.reloadMyListAllID = showID
self.delegate?.updateRows(index: self.gameIndex, type: .favourite, isFav: false, isLike: nil, id: showID)
self.initView()
}
@@ -137,6 +152,10 @@ class GamesDetailVC: UIViewController {
// K.GVar.myListSoftReload = true
// }
K.GVar.reloadGames = true
self.reloadType = .favourite
// To reload MyListViewAllVC
K.GVar.reloadMyListAll = 1
K.GVar.reloadMyListAllID = showID
self.delegate?.updateRows(index: self.gameIndex, type: .favourite, isFav: true, isLike: nil, id: showID)
self.initView()
@@ -166,6 +185,7 @@ class GamesDetailVC: UIViewController {
}
self.delegate?.updateRows(index: self.gameIndex, type: .liked, isFav: nil, isLike: false, id: showID)
K.GVar.myListSoftReload = true
self.reloadType = .favourite
self.initView()
}
}else{
@@ -178,6 +198,7 @@ class GamesDetailVC: UIViewController {
}
self.delegate?.updateRows(index: self.gameIndex, type: .liked, isFav: nil, isLike: true, id: showID)
K.GVar.myListSoftReload = true
self.reloadType = .favourite
self.initView()
}
}
@@ -214,6 +235,11 @@ class GamesDetailVC: UIViewController {
if let postID = gameData?.id{
PersistentStorage.shared.addGamesCount(postID: postID)
}
if let reloadType{
if btnTapped != nil {
btnTapped?(reloadType)
}
}
self.dismiss(animated: true)
}
}

View File

@@ -82,19 +82,40 @@ class MyListVC: UIViewController{
vm.getFavouriteListing()
}
if K.GVar.myListSoftReload{
vm.reloadCollections()
vm.checkNil()
K.GVar.myListSoftReload = false
}
if MyListDataTemp.shareInstance.isDatafetched == false{
K.GVar.reloadMyListAudioBooks = false
K.GVar.reloadKaraoke = false
K.GVar.reloadGames = false
K.GVar.reloadHindiWebseries = false
K.GVar.reloadEnglishWebseries = false
return
}
if K.GVar.reloadMyListAudioBooks{
MyListDataTemp.shareInstance.updateAudioBooks() { isDone in
MyListDataTemp.shareInstance.updateAudioBooks() { [weak self] isDone in
guard let self else{return}
if isDone{
self.audioBooksCV.reloadData()
vm.checkNil()
vm.checkViewAll()
}
}
K.GVar.reloadMyListAudioBooks = false
}
if K.GVar.reloadKaraoke{
MyListDataTemp.shareInstance.updateKaraoke() { isDone in
MyListDataTemp.shareInstance.updateKaraoke() { [weak self] isDone in
guard let self else{return}
if isDone{
self.karaokeCV.reloadData()
vm.checkNil()
vm.checkViewAll()
}
}
K.GVar.reloadKaraoke = false
@@ -135,12 +156,7 @@ class MyListVC: UIViewController{
}
K.GVar.reloadHindiWebseries = false
}
if K.GVar.myListSoftReload{
vm.reloadCollections()
vm.checkNil()
K.GVar.myListSoftReload = false
}
}
@IBAction func sideBarBtnTapped(_ sender: UIButton) {
@@ -549,6 +565,16 @@ extension MyListVC : CollectionViewSRC{
vcPush.modalTransitionStyle = .crossDissolve
vcPush.audioData = audioData
// vcPush.delegate = self
vcPush.btnTapped = { (type) -> Void in
MyListDataTemp.shareInstance.updateAudioBooks() { [weak self] isDone in
guard let self else{return}
if isDone{
self.audioBooksCV.reloadData()
vm.checkNil()
vm.checkViewAll()
}
}
}
self.vm.selectedCollection = .audioBooksCV
self.present(vcPush, animated: true)
case karaokeCV:
@@ -563,6 +589,16 @@ extension MyListVC : CollectionViewSRC{
vcPush.karaokeData = karaokeData
vcPush.karaokeIndex = indexPath.row
// vcPush.delegate = self
vcPush.btnTapped = { (type) -> Void in
MyListDataTemp.shareInstance.updateKaraoke() { [weak self] isDone in
guard let self else{return}
if isDone{
self.karaokeCV.reloadData()
vm.checkNil()
vm.checkViewAll()
}
}
}
self.vm.selectedCollection = .karaokeCV
self.present(vcPush, animated: true)
case gamesCV:
@@ -577,6 +613,16 @@ extension MyListVC : CollectionViewSRC{
vcPush.gameData = gameData
vcPush.gameIndex = indexPath.row
// vcPush.delegate = self
vcPush.btnTapped = { (type) -> Void in
MyListDataTemp.shareInstance.updateGames() { [weak self] isDone in
guard let self else{return}
if isDone{
self.gamesCV.reloadData()
vm.checkNil()
vm.checkViewAll()
}
}
}
self.vm.selectedCollection = .gamesCV
self.present(vcPush, animated: true)
default:

View File

@@ -35,6 +35,117 @@ class MyListViewAllVC: UIViewController {
self.navigationController?.setColor(color: .black)
}
override func viewDidAppear(_ animated: Bool) {
if K.GVar.reloadMyListAll != 0{ // 0 - null, 1 - add , 2- remove
// first check if add or remove
if K.GVar.reloadMyListAll == 1{
switch vm.postType{
case 1: // webseries
if vm.catID == "1"{ // english
if let englishData = vm.favListingData?.showData?.english, let firstIndex = englishData.firstIndex(where: {$0.id == K.GVar.reloadMyListAllID}){
}else{
vm.pageNo = 0
vm.getFavouriteListing()
}
}else{// hindi
if let hindiData = vm.favListingData?.showData?.hindi, let firstIndex = hindiData.firstIndex(where: {$0.id == K.GVar.reloadMyListAllID}){
}else{
vm.pageNo = 0
vm.getFavouriteListing()
}
}
case 6: // Games
if let gameData = vm.favListingData?.gameData{
}
case 7:
if let audioData = vm.favListingData?.audioData{
}
case 8: //KAraoke
if let karaokeData = vm.favListingData?.singKaraokeData{
}
default:
break
}
}else if K.GVar.reloadMyListAll == 2{
switch vm.postType{
case 1: // webseries
if vm.catID == "1"{ // english
if let englishData = vm.favListingData?.showData?.english, let firstIndex = englishData.firstIndex(where: {$0.id == K.GVar.reloadMyListAllID}){
vm.favListingData?.showData?.english?.remove(at: firstIndex)
self.tableView.reloadData()
self.tableHeight.constant = self.tableView.contentSize.height + 100
self.tableView.layoutIfNeeded()
let webSeriesCount = vm.favListingData?.showData?.english?.count ?? 0
self.tableHeight.constant = CGFloat(webSeriesCount * 230)
}else{
vm.pageNo = 0
vm.getFavouriteListing()
}
}else{// hindi
if let hindiData = vm.favListingData?.showData?.hindi, let firstIndex = hindiData.firstIndex(where: {$0.id == K.GVar.reloadMyListAllID}){
vm.favListingData?.showData?.hindi?.remove(at: firstIndex)
self.tableView.reloadData()
self.tableHeight.constant = self.tableView.contentSize.height + 100
self.tableView.layoutIfNeeded()
let webSeriesCount = vm.favListingData?.showData?.hindi?.count ?? 0
self.tableHeight.constant = CGFloat(webSeriesCount * 230)
}else{
vm.pageNo = 0
vm.getFavouriteListing()
}
}
case 6: // Games
if let gameData = vm.favListingData?.gameData, let firstIndex = gameData.firstIndex(where: {$0.id == K.GVar.reloadMyListAllID}){
vm.favListingData?.gameData?.remove(at: firstIndex)
self.tableView.reloadData()
self.tableHeight.constant = self.tableView.contentSize.height + 100
self.tableView.layoutIfNeeded()
let webSeriesCount = vm.favListingData?.gameData?.count ?? 0
self.tableHeight.constant = CGFloat(webSeriesCount * 230)
}else{
vm.pageNo = 0
vm.getFavouriteListing()
}
case 7:
if let audioData = vm.favListingData?.audioData, let firstIndex = audioData.firstIndex(where: {$0.id == K.GVar.reloadMyListAllID}){
vm.favListingData?.audioData?.remove(at: firstIndex)
self.tableView.reloadData()
self.tableHeight.constant = self.tableView.contentSize.height + 100
self.tableView.layoutIfNeeded()
let webSeriesCount = vm.favListingData?.audioData?.count ?? 0
self.tableHeight.constant = CGFloat(webSeriesCount * 230)
}else{
vm.pageNo = 0
vm.getFavouriteListing()
}
case 8: //KAraoke
if let karaokeData = vm.favListingData?.singKaraokeData, let firstIndex = karaokeData.firstIndex(where: {$0.id == K.GVar.reloadMyListAllID}){
vm.favListingData?.singKaraokeData?.remove(at: firstIndex)
self.tableView.reloadData()
self.tableHeight.constant = self.tableView.contentSize.height + 100
self.tableView.layoutIfNeeded()
let webSeriesCount = vm.favListingData?.singKaraokeData?.count ?? 0
self.tableHeight.constant = CGFloat(webSeriesCount * 230)
}else{
vm.pageNo = 0
vm.getFavouriteListing()
}
default:
break
}
}
K.GVar.reloadMyListAll = 0 // reset to null
K.GVar.reloadMyListAllID = 0
}
print("Appear")
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
self.navigationController?.setNavigationBarHidden(true, animated: animated)
@@ -146,6 +257,7 @@ extension MyListViewAllVC : TableViewSRC{
vcPush.modalPresentationStyle = .overCurrentContext
vcPush.modalTransitionStyle = .crossDissolve
vcPush.karaokeData = karaokeData
self.present(vcPush, animated: true)
default:
break

View File

@@ -39,7 +39,8 @@ class MyListDataTemp{
switch data.success{
case 0:
Utilities.dismissProgressHUD()
onCompletion(false)
self?.favListingData?.audioData = []
onCompletion(true)
case 1:
Utilities.dismissProgressHUD()
guard let audioData = data.data?.result?.audioData else{
@@ -77,7 +78,8 @@ class MyListDataTemp{
switch data.success{
case 0:
Utilities.dismissProgressHUD()
onCompletion(false)
self?.favListingData?.singKaraokeData = []
onCompletion(true)
case 1:
Utilities.dismissProgressHUD()
guard let singKaraokeData = data.data?.result?.singKaraokeData else{
@@ -115,7 +117,8 @@ class MyListDataTemp{
switch data.success{
case 0:
Utilities.dismissProgressHUD()
onCompletion(false)
self?.favListingData?.gameData = []
onCompletion(true)
case 1:
Utilities.dismissProgressHUD()
guard let gameData = data.data?.result?.gameData else{

View File

@@ -153,6 +153,7 @@ class MyListVM{
// MyListDataTemp.shareInstance.webSeriesHindi.removeAll()
MyListDataTemp.shareInstance.favListingData = data
MyListDataTemp.shareInstance.isDatafetched = true
// if var hindiData = MyListDataTemp.shareInstance.favListingData?.showData{
//

View File

@@ -17,7 +17,7 @@ class MyListViewAllVM{
var catID = String()
var favListingData : FavouriteListingDM.ResultData?
var webSeriesHindi = [FavouriteListingDM.ResultData.ShowDatum]()
// var webSeriesHindi = [FavouriteListingDM.ResultData.ShowDatum]()
let refreshControl = UIRefreshControl()
func initView(){

View File

@@ -37,6 +37,11 @@ class KaraokeDetailsVC: UIViewController {
var karaokeIndex = 0
typealias btnTappedBlock = ( _ from : FavCellCLick) -> Void
var btnTapped : btnTappedBlock?
var reloadType : FavCellCLick?
override func viewDidLoad() {
super.viewDidLoad()
initView()
@@ -57,6 +62,12 @@ class KaraokeDetailsVC: UIViewController {
if let karaokeData , let postID = karaokeData.id{
PersistentStorage.shared.addKaraokeCount(postID: postID)
}
if let reloadType{
if btnTapped != nil {
btnTapped?(reloadType)
}
}
self.dismiss(animated: true)
}
}
@@ -138,7 +149,7 @@ class KaraokeDetailsVC: UIViewController {
// K.GVar.myListSoftReload = true
// }
K.GVar.reloadKaraoke = true
self.reloadType = .favourite
//if coming from mylist
self.delegate?.updateRows(index: self.karaokeIndex, type: .favourite, isFav: false, isLike: nil, id: showID)
self.initView()
@@ -152,7 +163,7 @@ class KaraokeDetailsVC: UIViewController {
// K.GVar.myListSoftReload = true
// }
K.GVar.reloadKaraoke = true
self.reloadType = .favourite
//if coming from mylist
self.delegate?.updateRows(index: self.karaokeIndex, type: .favourite, isFav: true, isLike: nil, id: showID)
self.initView()
@@ -179,7 +190,7 @@ class KaraokeDetailsVC: UIViewController {
MyListDataTemp.shareInstance.favListingData?.singKaraokeData?[index].likesCount! -= 1
K.GVar.myListSoftReload = true
}
self.reloadType = .liked
self.delegate?.updateRows(index: self.karaokeIndex, type: .liked, isFav: nil, isLike: false, id: showID)
self.initView()
@@ -194,7 +205,7 @@ class KaraokeDetailsVC: UIViewController {
MyListDataTemp.shareInstance.favListingData?.singKaraokeData?[index].likesCount! += 1
K.GVar.myListSoftReload = true
}
self.reloadType = .liked
self.delegate?.updateRows(index: self.karaokeIndex, type: .liked, isFav: nil, isLike: true, id: showID)
self.initView()
}
@@ -292,6 +303,11 @@ class KaraokeDetailsVC: UIViewController {
@IBAction func closeBtnTapped(_ sender: UIButton) {
PersistentStorage.shared.addOthersCount()
if let reloadType{
if btnTapped != nil {
btnTapped?(reloadType)
}
}
self.dismiss(animated: true)
}
}

View File

@@ -157,15 +157,40 @@ class NetworkManager{
/// - Parameter (header : HTTPHeaders , Params :[String : Any] , URL , Dedocable Generic T Struct.)
///
/// - Returns: This function returns a GENERIC response base on the T Model & ERROR .
func nwCallRawJSon<T: Decodable>(url : String, param : [String : Any],decodable: T.Type,onCompletion: @escaping (T?,Error?) -> Void){
AF.request(url, method: .post, parameters : param, encoding: JSONEncoding.default, headers: nil, requestModifier : { $0.timeoutInterval = 30 }).validate(contentType: ["application/json"]).responseDecodable { (response: DataResponse<T,AFError>) in
switch response.result {
case .success(let data):
onCompletion(data,nil)
case .failure(let error):
onCompletion(nil,error)
}
func nwCallRawJSON(clicksData : [ClicksAnalytics], onCompletion : @escaping (Bool) -> Void){
let loginCred = getLoginIDPass()
let encoder = JSONEncoder()
encoder.keyEncodingStrategy = .convertToSnakeCase
guard let jsonData = try? encoder.encode(clicksData),
let jsonArray = try? JSONSerialization.jsonObject(with: jsonData, options: .allowFragments) as? [[String: Any]] else {
print("Failed to encode totalClicks array to JSON")
return
}
let url = APIEndPoints.Analytics.user_clicks
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.headers = ["device-id" : AuthFunc.shareInstance.getDeviceUUID(),
"access-token" : AuthFunc.shareInstance.getAccessToken()]
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
do {
// Set the HTTP body with the JSON data
request.httpBody = try JSONSerialization.data(withJSONObject: jsonArray)
} catch let error {
print("Error: \(error.localizedDescription)")
return
}
AF.request(request).authenticate(username: loginCred.0, password: loginCred.1)
.validate(statusCode: 200..<300)
.responseDecodable(of: CommonResponseModel.self) { response in
switch response.result {
case .success(let data):
onCompletion(true)
case .failure(let error):
onCompletion(false)
}
}
}
}

View File

@@ -212,6 +212,69 @@ final class PersistentStorage
}
}
func getAllData() {
//We need to create a context from this container
let managedContext = PersistentStorage.shared.context
let fetchRequest:NSFetchRequest<NSFetchRequestResult> = NSFetchRequest.init(entityName: "UserClicks")
fetchRequest.fetchLimit = 4
do {
guard let result = try managedContext.fetch(fetchRequest) as? [UserClicks] else {return}
result.forEach { clicks in
// device type 1- android , 2 - iOS
print("ID:-" , PostType(rawValue: Int(clicks.post_type))!, "CatID:- ", clicks.category_id, "PostID:- ", clicks.post_id , "Count:-", clicks.click_counts)
}
}
catch let error
{
debugPrint(error)
}
}
func sendDataToServer() {
//We need to create a context from this container
let managedContext = PersistentStorage.shared.context
// let path = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
// debugPrint(path[0])
let fetchRequest:NSFetchRequest<NSFetchRequestResult> = NSFetchRequest.init(entityName: "UserClicks")
fetchRequest.fetchLimit = 4
do {
guard let result = try managedContext.fetch(fetchRequest) as? [UserClicks] else {return}
var userClicks = [ClicksAnalytics]()
result.forEach { clicks in
// device type 1- android , 2 - iOS
userClicks.append(ClicksAnalytics(postID: Int(clicks.post_id), postType: Int(clicks.post_type), numberOfClicks: Int(clicks.click_counts), deviceType: 2, categoryID: Int(clicks.category_id)))
print("ID:-" , PostType(rawValue: Int(clicks.post_type))!, "CatID:- ", clicks.category_id, "PostID:- ", clicks.post_id , "Count:-", clicks.click_counts)
}
NetworkManager.shareInstance.nwCallRawJSON(clicksData: userClicks) { isDone in
if isDone{
self.deleteData(result)
}
}
}
catch let error
{
debugPrint(error)
}
}
func deleteData(_ data: [UserClicks]) {
let managedContext = PersistentStorage.shared.context
data.forEach { clicks in
managedContext.delete(clicks)
}
do {
try managedContext.save()
getAllData()
print("Deleted data")
} catch let error {
debugPrint("Failed to delete data:", error)
}
}
// func updateData(){
// //We need to create a context from this container
// let managedContext = PersistentStorage.shared.context

View File

@@ -142,7 +142,9 @@ class PlayerVC: JWPlayerViewController, JWPlayerViewControllerDelegate {
let isPortrait = UIScreen.main.bounds.size.width < UIScreen.main.bounds.size.height
if isPortrait {
print("Device is in portrait mode")
self.dismiss(animated: true)
Timer.scheduledTimer(withTimeInterval: 0.4, repeats: false) { _ in
self.dismiss(animated: true)
}
} else {
print("Device is in landscape mode")
if isFullScreenBtn{

View File

@@ -42,8 +42,9 @@ class MoreVM{
vc.songTableView.showsHorizontalScrollIndicator = false
vc.homeBtn.addTapGesture {
PersistentStorage.shared.addOthersCount()
self.vc.dismiss(animated: true)
self.vc.dismiss(animated: true) {
PersistentStorage.shared.addOthersCount()
}
}
}

View File

@@ -40,7 +40,6 @@ class ThemeOneVM{
vc.nameLabel.setContentCompressionResistancePriority(.fittingSizeLevel, for: .horizontal)
handleBackground()
}
private func handleNotificationCenter(){
@@ -206,6 +205,8 @@ class ThemeOneVM{
vcPush.modalPresentationStyle = .fullScreen
vcPush.modalTransitionStyle = .crossDissolve
self.vc.present(vcPush, animated: true)
// PersistentStorage.shared.sendDataToServer()
}
/*
1 = series, 2 = season, 3= episode, 4 = video, 5 = paint, 6 = game, 7 = audio, 8 = kareoke video, 9 = shop product, 10 = parental video, 11 = article, 12 = live TV, 13 = FM, 14 = teaser, 15 others, 16 = Home
@@ -440,7 +441,7 @@ class ThemeOneVM{
vc.config = config
vc.dismissTapped = self.tapped
vc.contentType = .liveStream
// vc.modalPresentationStyle = .fullScreen
vc.modalPresentationStyle = .fullScreen
vc.modalTransitionStyle = .crossDissolve
// Present the PlayerVC
@@ -549,66 +550,11 @@ class ThemeOneVM{
func updateClicks(){
let headers : HTTPHeaders = ["access-token" : AuthFunc.shareInstance.getAccessToken()]
let params : [[String: Any]]
var totalClicks = [ClicksAnalytics]()
totalClicks.append(ClicksAnalytics(postID: 0, postType: 15, numberOfClicks: 12, deviceType: 2, categoryID: 0))
// NetworkManager.shareInstance.nwCallRawJSON(clicksData: totalClicks)
// Convert the array to a dictionary for the JSON body
do {
let encoder = JSONEncoder()
let jsonData = try encoder.encode(totalClicks)
let jsonArray = try JSONSerialization.jsonObject(with: jsonData, options: []) as? [[String: Any]]
if let jsonArray = jsonArray {
NetworkManager.shareInstance.nwCallRawJSon(url: "your_api_url", param: ["data": jsonArray], decodable: CommonResponseModel.self) { response, error in
switch response{
case .success:
guard let self else{
Utilities.dismissProgressHUD()
return
}
case .failure(let error):
guard let self else{
Utilities.dismissProgressHUD()
return
}
Utilities.dismissProgressHUD()
}
}
}
} catch {
print("Error encoding JSON: \(error)")
}
// NetworkManager.shareInstance.apiRequest(url: APIEndPoints.Analytics.user_clicks , method: .post,parameters: params,headers: headers) { [weak self](result : Result<BaseResponseModel<KaraokeListingDM>, NetworkManager.APIError>) in
// switch result{
// case .success(let data):
// guard let self else{
// Utilities.dismissProgressHUD()
// return
// }
// switch data.success{
// case 0:
// /*
// Error
// */
// Utilities.dismissProgressHUD()
//
// case 1:
// Utilities.dismissProgressHUD()
// default:
// break
// }
// case .failure(let error):
// guard let self else{
// Utilities.dismissProgressHUD()
// return
// }
// Utilities.dismissProgressHUD()
// }
// }
}
}

View File

@@ -70,12 +70,19 @@ class UserNotificationVM{
refreshControl.endRefreshing()
case 1:
Utilities.dismissProgressHUD()
guard let data = data.data else{return}
guard let data = data.data else{
self.vc.noDataStack.isHidden = false
return
}
self.userNotification.removeAll()
self.userNotification.append(contentsOf: data)
feedbackGenerator.impactOccurred()
self.vc.tableView.reloadData()
self.vc.noDataStack.isHidden = true
if data.count == 0{
self.vc.noDataStack.isHidden = false
}else{
self.vc.noDataStack.isHidden = true
}
self.vc.tableView.isHidden = false
refreshControl.endRefreshing()
default:

View File

@@ -372,12 +372,15 @@ extension WebSeriesSeasonVC : CollectionViewSRC{
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
vm.episodeSelectedCateogory = vm.seasonListingData[indexPath.row].id
if let seasonID = vm.seasonListingData[indexPath.row].id , let catID = vm.categoryID{
PersistentStorage.shared.addWebSeries(catID: catID, postID: seasonID, postType: .season)
}
if vm.episodeSelectedCateogory == vm.seasonListingData[indexPath.row].id{
return
}
vm.episodeSelectedCateogory = vm.seasonListingData[indexPath.row].id
vm.setSeasonData()
episodeTitle.isHidden = false
episodeTitle.text = ""

View File

@@ -53,6 +53,10 @@ class WebSeriesSeasonVM{
self.setShowData()
self.vc.likeFavDelegate?.updateRows(index: indexSelected, type: .favourite, isFav: false, isLike: nil, id: showID)
//For updating mylist allview
K.GVar.reloadMyListAll = 2
K.GVar.reloadMyListAllID = showID
if self.categoryID == 18{ // hindi
K.GVar.reloadHindiWebseries = true
// if let index = MyListDataTemp.shareInstance.favListingData?.showData?.hindi?.firstIndex(where: {$0.id == showID}){
@@ -75,6 +79,9 @@ class WebSeriesSeasonVM{
self.setShowData()
self.vc.likeFavDelegate?.updateRows(index: indexSelected, type: .favourite, isFav: true, isLike: nil, id: showID)
//For updating mylist allview
K.GVar.reloadMyListAll = 1
K.GVar.reloadMyListAllID = showID
// if self.categoryID == 18{ // hindi
// guard let showData = self.showData else{return}
// MyListDataTemp.shareInstance.favListingData?.showData?.hindi?.append(FavouriteListingDM.ResultData.ShowDatum(id: showData.id, title: showData.title, description: showData.description, thumbnailPath: showData.thumbnailPath, showType: showData.showType, totalSeasons: showData.totalSeasons, totalEpisodes: showData.totalEpisodes, ageRangeMasterID: showData.ageRangeMasterID, genderMasterID: showData.genderMasterID, categoryMasterID: self.categoryID?.toString(), contentMoreDetails: showData.contentMoreDetails, markAsFavourite: showData.markAsFavourite, isLiked: showData.isLiked, likesCount: showData.likesCount, viewsCount: showData.viewsCount, bookmarkCount: showData.bookmarkCount, bookmarkCategoryIDS: "18"))