1.2.2VIP问题修复版

This commit is contained in:
QinFendeZhou 2024-09-26 14:07:13 +08:00
parent 0c4a1df6dd
commit 87edde2707
38 changed files with 684 additions and 93 deletions

View File

@ -270,6 +270,9 @@
CBDBDDF42C40D03F00767F0B /* MPPositive_SearchGrideCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBDBDDF32C40D03F00767F0B /* MPPositive_SearchGrideCollectionViewCell.swift */; }; CBDBDDF42C40D03F00767F0B /* MPPositive_SearchGrideCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBDBDDF32C40D03F00767F0B /* MPPositive_SearchGrideCollectionViewCell.swift */; };
CBDBDDF62C40FFC600767F0B /* MPPositive_GrideMoodViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBDBDDF52C40FFC600767F0B /* MPPositive_GrideMoodViewController.swift */; }; CBDBDDF62C40FFC600767F0B /* MPPositive_GrideMoodViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBDBDDF52C40FFC600767F0B /* MPPositive_GrideMoodViewController.swift */; };
CBDC4A292C61B88300960649 /* relax.offline.mp3.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = CBDC4A272C61B88300960649 /* relax.offline.mp3.xcdatamodeld */; }; CBDC4A292C61B88300960649 /* relax.offline.mp3.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = CBDC4A272C61B88300960649 /* relax.offline.mp3.xcdatamodeld */; };
CBEC78BF2CA28FB700666A7F /* MPPositive_AddSongsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBEC78BE2CA28FB700666A7F /* MPPositive_AddSongsViewController.swift */; };
CBEC78C12CA2963100666A7F /* MPPositive_AddSongsShowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBEC78C02CA2963100666A7F /* MPPositive_AddSongsShowView.swift */; };
CBEC78C32CA2A0CB00666A7F /* MPPositive_AddSongTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBEC78C22CA2A0CB00666A7F /* MPPositive_AddSongTableViewCell.swift */; };
CBF3AEDA2C255B1200947AFC /* MPPositive_PlayListsShowTypeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBF3AED92C255B1200947AFC /* MPPositive_PlayListsShowTypeView.swift */; }; CBF3AEDA2C255B1200947AFC /* MPPositive_PlayListsShowTypeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBF3AED92C255B1200947AFC /* MPPositive_PlayListsShowTypeView.swift */; };
CBF769992C95678A00EF9B45 /* Devices.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBF769982C95678A00EF9B45 /* Devices.swift */; }; CBF769992C95678A00EF9B45 /* Devices.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBF769982C95678A00EF9B45 /* Devices.swift */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
@ -566,6 +569,9 @@
CBDBDDF32C40D03F00767F0B /* MPPositive_SearchGrideCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MPPositive_SearchGrideCollectionViewCell.swift; sourceTree = "<group>"; }; CBDBDDF32C40D03F00767F0B /* MPPositive_SearchGrideCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MPPositive_SearchGrideCollectionViewCell.swift; sourceTree = "<group>"; };
CBDBDDF52C40FFC600767F0B /* MPPositive_GrideMoodViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MPPositive_GrideMoodViewController.swift; sourceTree = "<group>"; }; CBDBDDF52C40FFC600767F0B /* MPPositive_GrideMoodViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MPPositive_GrideMoodViewController.swift; sourceTree = "<group>"; };
CBDC4A282C61B88300960649 /* MusicPlayer.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = MusicPlayer.xcdatamodel; sourceTree = "<group>"; }; CBDC4A282C61B88300960649 /* MusicPlayer.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = MusicPlayer.xcdatamodel; sourceTree = "<group>"; };
CBEC78BE2CA28FB700666A7F /* MPPositive_AddSongsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MPPositive_AddSongsViewController.swift; sourceTree = "<group>"; };
CBEC78C02CA2963100666A7F /* MPPositive_AddSongsShowView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MPPositive_AddSongsShowView.swift; sourceTree = "<group>"; };
CBEC78C22CA2A0CB00666A7F /* MPPositive_AddSongTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MPPositive_AddSongTableViewCell.swift; sourceTree = "<group>"; };
CBF3AED92C255B1200947AFC /* MPPositive_PlayListsShowTypeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MPPositive_PlayListsShowTypeView.swift; sourceTree = "<group>"; }; CBF3AED92C255B1200947AFC /* MPPositive_PlayListsShowTypeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MPPositive_PlayListsShowTypeView.swift; sourceTree = "<group>"; };
CBF769982C95678A00EF9B45 /* Devices.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Devices.swift; sourceTree = "<group>"; }; CBF769982C95678A00EF9B45 /* Devices.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Devices.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
@ -921,6 +927,7 @@
children = ( children = (
CBAFCA662C0A10500054500E /* MPPositive_LibraryViewController.swift */, CBAFCA662C0A10500054500E /* MPPositive_LibraryViewController.swift */,
CB0033F32C294DBF00B18FD3 /* MPPositive_CustomPlayListViewController.swift */, CB0033F32C294DBF00B18FD3 /* MPPositive_CustomPlayListViewController.swift */,
CBEC78BE2CA28FB700666A7F /* MPPositive_AddSongsViewController.swift */,
CB0033FB2C29753D00B18FD3 /* MPPositive_PlayListMoreViewController.swift */, CB0033FB2C29753D00B18FD3 /* MPPositive_PlayListMoreViewController.swift */,
CBCBA7D82C6DFD93004E5BEF /* MPPositive_SortTypeViewController.swift */, CBCBA7D82C6DFD93004E5BEF /* MPPositive_SortTypeViewController.swift */,
CB0033F72C29626900B18FD3 /* MPPositive_ChoosePlayListViewController.swift */, CB0033F72C29626900B18FD3 /* MPPositive_ChoosePlayListViewController.swift */,
@ -994,6 +1001,8 @@
CBF3AED92C255B1200947AFC /* MPPositive_PlayListsShowTypeView.swift */, CBF3AED92C255B1200947AFC /* MPPositive_PlayListsShowTypeView.swift */,
CB0033F12C291C7700B18FD3 /* MPPositive_CollectionListsShowTypeView.swift */, CB0033F12C291C7700B18FD3 /* MPPositive_CollectionListsShowTypeView.swift */,
CBDAC60D2C2BE1B6008B8D34 /* MPPositive_ChooseNewPlayListTableViewCell.swift */, CBDAC60D2C2BE1B6008B8D34 /* MPPositive_ChooseNewPlayListTableViewCell.swift */,
CBEC78C02CA2963100666A7F /* MPPositive_AddSongsShowView.swift */,
CBEC78C22CA2A0CB00666A7F /* MPPositive_AddSongTableViewCell.swift */,
CB7FC5472C2AC25C00292A43 /* MPPositive_CenterListSearchView.swift */, CB7FC5472C2AC25C00292A43 /* MPPositive_CenterListSearchView.swift */,
CBAFCA7E2C0A10500054500E /* MPPositive_LibraryTableViewCell.swift */, CBAFCA7E2C0A10500054500E /* MPPositive_LibraryTableViewCell.swift */,
CBAFCA7F2C0A10500054500E /* MPPositive_LoveArtistTableViewCell.swift */, CBAFCA7F2C0A10500054500E /* MPPositive_LoveArtistTableViewCell.swift */,
@ -1541,6 +1550,7 @@
CBDBDDF62C40FFC600767F0B /* MPPositive_GrideMoodViewController.swift in Sources */, CBDBDDF62C40FFC600767F0B /* MPPositive_GrideMoodViewController.swift in Sources */,
CBAFCB932C0A10500054500E /* MPSideA_PlayerViewController.swift in Sources */, CBAFCB932C0A10500054500E /* MPSideA_PlayerViewController.swift in Sources */,
CBAFCB512C0A10500054500E /* MPPositive_SearchResultShowViewController.swift in Sources */, CBAFCB512C0A10500054500E /* MPPositive_SearchResultShowViewController.swift in Sources */,
CBEC78C32CA2A0CB00666A7F /* MPPositive_AddSongTableViewCell.swift in Sources */,
CBAFCB4C2C0A10500054500E /* MPPositive_ListShowViewController.swift in Sources */, CBAFCB4C2C0A10500054500E /* MPPositive_ListShowViewController.swift in Sources */,
CBAFCB682C0A10500054500E /* MPPositive_MusicItemShowTableViewCell.swift in Sources */, CBAFCB682C0A10500054500E /* MPPositive_MusicItemShowTableViewCell.swift in Sources */,
CBAFCB5B2C0A10500054500E /* MPPositive_ArtistShowCollectionViewCell.swift in Sources */, CBAFCB5B2C0A10500054500E /* MPPositive_ArtistShowCollectionViewCell.swift in Sources */,
@ -1575,6 +1585,7 @@
CBAFCB7E2C0A10500054500E /* MPSideA_TabBarController.swift in Sources */, CBAFCB7E2C0A10500054500E /* MPSideA_TabBarController.swift in Sources */,
CBAFCB1D2C0A10500054500E /* MPPositive_JsonPlayer.swift in Sources */, CBAFCB1D2C0A10500054500E /* MPPositive_JsonPlayer.swift in Sources */,
CBC1FB7C2C509B7300AC0633 /* MPPositive_LibraryViewModel.swift in Sources */, CBC1FB7C2C509B7300AC0633 /* MPPositive_LibraryViewModel.swift in Sources */,
CBEC78C12CA2963100666A7F /* MPPositive_AddSongsShowView.swift in Sources */,
CBAFCB602C0A10500054500E /* MPPositive_ArtistShowTypeView.swift in Sources */, CBAFCB602C0A10500054500E /* MPPositive_ArtistShowTypeView.swift in Sources */,
CBAFCB6F2C0A10500054500E /* MPPositive_SearchResultPreviewShowView.swift in Sources */, CBAFCB6F2C0A10500054500E /* MPPositive_SearchResultPreviewShowView.swift in Sources */,
CB0033F42C294DBF00B18FD3 /* MPPositive_CustomPlayListViewController.swift in Sources */, CB0033F42C294DBF00B18FD3 /* MPPositive_CustomPlayListViewController.swift in Sources */,
@ -1648,6 +1659,7 @@
CBAFCB9B2C0A10500054500E /* MPSideA_CenterTableViewCell.swift in Sources */, CBAFCB9B2C0A10500054500E /* MPSideA_CenterTableViewCell.swift in Sources */,
CBC3F2B22C3E76160075DC74 /* MPPositive_AdItemModel.swift in Sources */, CBC3F2B22C3E76160075DC74 /* MPPositive_AdItemModel.swift in Sources */,
CBAFCB412C0A10500054500E /* MPPositive_BaseViewController.swift in Sources */, CBAFCB412C0A10500054500E /* MPPositive_BaseViewController.swift in Sources */,
CBEC78BF2CA28FB700666A7F /* MPPositive_AddSongsViewController.swift in Sources */,
CBCBA7D92C6DFD93004E5BEF /* MPPositive_SortTypeViewController.swift in Sources */, CBCBA7D92C6DFD93004E5BEF /* MPPositive_SortTypeViewController.swift in Sources */,
CBAFCB4E2C0A10500054500E /* MPPositive_PlayerListShowViewController.swift in Sources */, CBAFCB4E2C0A10500054500E /* MPPositive_PlayerListShowViewController.swift in Sources */,
CBD1E19F2C57650F00DF20E5 /* MP_IAPManager.swift in Sources */, CBD1E19F2C57650F00DF20E5 /* MP_IAPManager.swift in Sources */,

View File

@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "complete@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "complete@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "add_btn@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "add_btn@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "add@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "add@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Group_1597880767@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Group_1597880767@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 642 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Group_1597880779@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Group_1597880779@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 711 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Rectangle_161124246@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Rectangle_161124246@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

View File

@ -78,6 +78,7 @@ class MP_LunchViewController: UIViewController {
} }
override func viewWillDisappear(_ animated: Bool) { override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated) super.viewWillDisappear(animated)
NotificationCenter.default.removeObserver(self)
} }
// //
@ -132,15 +133,7 @@ class MP_LunchViewController: UIViewController {
MPPositive_BrowseLoadViewModel.shared.reloadBrowseLists() MPPositive_BrowseLoadViewModel.shared.reloadBrowseLists()
} }
} }
MP_ADSimpleManager.shared.loadMoreAds() loadAds()
MP_ADSimpleManager.shared.showOpenAdIfAvailable(.ICE) { [weak self] (ad, isOpen, platform) in
guard let self = self else {return}
addValue = 3
//广
adShowBlock = {
self.adPresent(ad: ad, isOpen: isOpen, platform: platform)
}
}
//B //B
self.completionBlock = { self.completionBlock = {
//b //b
@ -170,16 +163,7 @@ class MP_LunchViewController: UIViewController {
MP_AnalyticsManager.shared.getOpenStatus { [weak self] open in MP_AnalyticsManager.shared.getOpenStatus { [weak self] open in
guard let self = self else {return} guard let self = self else {return}
if open { if open {
//ID广 loadAds()
MP_ADSimpleManager.shared.loadMoreAds()
MP_ADSimpleManager.shared.showOpenAdIfAvailable(.ICE) { [weak self] (ad, isOpen, platform) in
guard let self = self else {return}
addValue = 3
//广
adShowBlock = {
self.adPresent(ad: ad, isOpen: isOpen, platform: platform)
}
}
//ip //ip
MP_NetWorkManager.shared.requestIPInfo { statu in MP_NetWorkManager.shared.requestIPInfo { statu in
if statu == true { if statu == true {
@ -258,16 +242,7 @@ class MP_LunchViewController: UIViewController {
} }
} }
}else { }else {
//ID广 loadAds()
MP_ADSimpleManager.shared.loadMoreAds()
MP_ADSimpleManager.shared.showOpenAdIfAvailable(.ICE) { [weak self] (ad, isOpen, platform) in
guard let self = self else {return}
addValue = 3
//广
adShowBlock = {
self.adPresent(ad: ad, isOpen: isOpen, platform: platform)
}
}
print("ALog") print("ALog")
//A //A
if self.maxTimes > self.currentTimes { if self.maxTimes > self.currentTimes {
@ -299,6 +274,29 @@ class MP_LunchViewController: UIViewController {
} }
} }
} }
//广
private func loadAds(){
if MP_ADSimpleManager.shared.openAdStatus {
//ID广
MP_ADSimpleManager.shared.loadMoreAds()
MP_ADSimpleManager.shared.showOpenAdIfAvailable(.ICE) { [weak self] (ad, isOpen, platform) in
self?.addValue = 3
guard let self = self else {return}
//广
adShowBlock = {
self.adPresent(ad: ad, isOpen: isOpen, platform: platform)
}
}
}else {
//
NotificationCenter.notificationKey.add(observer: self, selector: #selector(resourceAction(_ :)), notificationName: .positive_browses_reload)
}
}
@objc func resourceAction(_ sender:Notification) {
if MPPositive_BrowseLoadViewModel.shared.browseModuleLists.isEmpty == false {
self.addValue = 3
}
}
//广 //广
private func adPresent(ad: AnyObject, isOpen:Bool, platform:Bool) { private func adPresent(ad: AnyObject, isOpen:Bool, platform:Bool) {
DispatchQueue.main.async { DispatchQueue.main.async {

View File

@ -47,7 +47,13 @@ class MP_ADSimpleManager: NSObject {
} }
} }
///广 ///广
var openAdStatus:Bool = true var openAdStatus:Bool{
if let bool = UserDefaults.standard.object(forKey: "UserVIPLevels") as? Bool{
return bool
}else {
return true
}
}
///使广 ///使广
var internalAdStatus:Bool = true var internalAdStatus:Bool = true
///广 ///广
@ -55,7 +61,7 @@ class MP_ADSimpleManager: NSObject {
DispatchQueue.main.async { DispatchQueue.main.async {
[weak self] in [weak self] in
guard let self = self else {return} guard let self = self else {return}
openAdStatus = bool UserDefaults.standard.set(bool, forKey: "UserVIPLevels")
} }
} }
///广 ///广
@ -109,7 +115,9 @@ class MP_ADSimpleManager: NSObject {
} }
///广 ///广
func showOpenAdIfAvailable(_ type:OpenType, completion:((_ ad:AnyObject, _ isOpen:Bool, _ platform:Bool) -> Void)?) { func showOpenAdIfAvailable(_ type:OpenType, completion:((_ ad:AnyObject, _ isOpen:Bool, _ platform:Bool) -> Void)?) {
guard openAdStatus, internalAdStatus else {return} guard openAdStatus, internalAdStatus else {
return
}
if platform { if platform {
if let block = completion { if let block = completion {
MP_AppLovinManager.shared.showOpenAdIfAvailable {[weak self] ad in MP_AppLovinManager.shared.showOpenAdIfAvailable {[weak self] ad in
@ -153,7 +161,10 @@ class MP_ADSimpleManager: NSObject {
} }
///广 ///广
func showPlayInterstitialAdIfAvailable(_ completion:((AnyObject?, Bool) -> Void)?) { func showPlayInterstitialAdIfAvailable(_ completion:((AnyObject?, Bool) -> Void)?) {
guard openAdStatus, internalAdStatus else {return} guard openAdStatus, internalAdStatus else {
completion?(nil, false)
return
}
if platform { if platform {
if let block = completion { if let block = completion {
MP_AppLovinManager.shared.showPlayInterstitialAdIfAvailable { ad in MP_AppLovinManager.shared.showPlayInterstitialAdIfAvailable { ad in

View File

@ -7,6 +7,9 @@
import UIKit import UIKit
import SVProgressHUD import SVProgressHUD
let HUDBackColor:UIColor = .init(hex: "#808080", alpha: 0.7)
let HUDTextColor:UIColor = .white
///hud ///hud
class MP_HUD: NSObject { class MP_HUD: NSObject {
//HUD //HUD
@ -28,8 +31,8 @@ class MP_HUD: NSObject {
static func loading(){ static func loading(){
SVProgressHUD.setDefaultStyle(.light) SVProgressHUD.setDefaultStyle(.light)
SVProgressHUD.setDefaultMaskType(.clear) SVProgressHUD.setDefaultMaskType(.clear)
SVProgressHUD.setBackgroundColor(.init(hex: "#80F988", alpha: 0.15)) SVProgressHUD.setBackgroundColor(HUDBackColor)
SVProgressHUD.setForegroundColor(.init(hex: "#80F988")) SVProgressHUD.setForegroundColor(HUDTextColor)
SVProgressHUD.setOffsetFromCenter(.init(horizontal: 0, vertical: 0)) SVProgressHUD.setOffsetFromCenter(.init(horizontal: 0, vertical: 0))
if MP_ADSimpleManager.shared.getInterstitialSwitch() { if MP_ADSimpleManager.shared.getInterstitialSwitch() {
// //
@ -43,8 +46,8 @@ class MP_HUD: NSObject {
static func downloadText(_ text:String, delay:TimeInterval, completion:(() -> Void)?) { static func downloadText(_ text:String, delay:TimeInterval, completion:(() -> Void)?) {
SVProgressHUD.setDefaultStyle(.light) SVProgressHUD.setDefaultStyle(.light)
SVProgressHUD.setDefaultMaskType(.none) SVProgressHUD.setDefaultMaskType(.none)
SVProgressHUD.setBackgroundColor(.init(hex: "#80F988", alpha: 0.15)) SVProgressHUD.setBackgroundColor(HUDBackColor)
SVProgressHUD.setForegroundColor(.init(hex: "#80F988")) SVProgressHUD.setForegroundColor(HUDTextColor)
SVProgressHUD.setOffsetFromCenter(.init(horizontal: 0, vertical: 0)) SVProgressHUD.setOffsetFromCenter(.init(horizontal: 0, vertical: 0))
if MP_ADSimpleManager.shared.getInterstitialSwitch() { if MP_ADSimpleManager.shared.getInterstitialSwitch() {
// //
@ -101,8 +104,8 @@ class MP_HUD: NSObject {
static func showWithStatus(hudStatus status: status, text: String?, delay: TimeInterval ,completion:(() -> Void)?) { static func showWithStatus(hudStatus status: status, text: String?, delay: TimeInterval ,completion:(() -> Void)?) {
SVProgressHUD.setDefaultStyle(.light) SVProgressHUD.setDefaultStyle(.light)
SVProgressHUD.setDefaultMaskType(.clear) SVProgressHUD.setDefaultMaskType(.clear)
SVProgressHUD.setBackgroundColor(.init(hex: "#80F988", alpha: 0.15)) SVProgressHUD.setBackgroundColor(HUDBackColor)
SVProgressHUD.setForegroundColor(.init(hex: "#80F988")) SVProgressHUD.setForegroundColor(HUDTextColor)
SVProgressHUD.setOffsetFromCenter(.init(horizontal: 0, vertical: 0)) SVProgressHUD.setOffsetFromCenter(.init(horizontal: 0, vertical: 0))
if MP_ADSimpleManager.shared.getInterstitialSwitch() { if MP_ADSimpleManager.shared.getInterstitialSwitch() {
// //
@ -113,12 +116,12 @@ class MP_HUD: NSObject {
}else { }else {
switch status { switch status {
case .success: case .success:
SVProgressHUD.setBackgroundColor(.init(hex: "#80F988", alpha: 0.15)) SVProgressHUD.setBackgroundColor(HUDBackColor)
SVProgressHUD.showSuccess(withStatus: text) SVProgressHUD.showSuccess(withStatus: text)
SVProgressHUD.setMinimumSize(CGSize(width: 100 * width, height: 80 * width)) SVProgressHUD.setMinimumSize(CGSize(width: 100 * width, height: 80 * width))
SVProgressHUD.show(UIImage(), status: text) SVProgressHUD.show(UIImage(), status: text)
case .error: case .error:
SVProgressHUD.setBackgroundColor(.init(hex: "#80F988", alpha: 0.15)) SVProgressHUD.setBackgroundColor(HUDBackColor)
SVProgressHUD.showError(withStatus: text) SVProgressHUD.showError(withStatus: text)
case .onlyText: case .onlyText:
SVProgressHUD.setMinimumSize(CGSize(width: 100 * width, height: 40 * width)) SVProgressHUD.setMinimumSize(CGSize(width: 100 * width, height: 40 * width))

View File

@ -2055,7 +2055,7 @@ extension MP_NetWorkManager {
}else { }else {
//IP //IP
failure?(true) failure?(true)
MP_HUD.error("Failed to obtain resource, please try again later", delay: 1.0, completion: nil) MP_HUD.error("Failed to obtain resource, please try again later".localizableString(), delay: 1.0, completion: nil)
MP_AnalyticsManager.shared.player_resource_failureAction(locaton ?? "HK") MP_AnalyticsManager.shared.player_resource_failureAction(locaton ?? "HK")
} }
} }

View File

@ -511,7 +511,9 @@ class MP_PlayerManager:NSObject{
guard let self = self else {return} guard let self = self else {return}
//10 //10
if playState != .Playing { if playState != .Playing {
MP_HUD.text("Failed to obtain resource, please try again later".localizableString(), delay: 2.0, completion: nil) if isLast == true {
MP_HUD.text("Failed to obtain resource, please try again later".localizableString(), delay: 2.0, completion: nil)
}
} }
} }
} }

View File

@ -66,7 +66,8 @@ class MPPositive_MoreSongOperationsViewController: UIViewController, UIViewContr
subtitleLabel.text = song.shortBylineText subtitleLabel.text = song.shortBylineText
// //
MPPositive_CollectionSongModel.fetch(predicate: .init(format: "videoId == %@", (song.videoId ?? ""))) { [weak self] results in MPPositive_CollectionSongModel.fetch(predicate: .init(format: "videoId == %@", (song.videoId ?? ""))) { [weak self] results in
self?.collectionBtn.isSelected = results.count != 0 guard let self = self else {return}
collectionBtn.isSelected = results.count != 0
} }
tableView.reloadData() tableView.reloadData()
} }
@ -254,6 +255,11 @@ class MPPositive_MoreSongOperationsViewController: UIViewController, UIViewContr
view.layer.masksToBounds = true view.layer.masksToBounds = true
view.layer.maskedCorners = [.layerMinXMinYCorner,.layerMaxXMinYCorner] view.layer.maskedCorners = [.layerMinXMinYCorner,.layerMaxXMinYCorner]
view.layer.cornerRadius = 18*width view.layer.cornerRadius = 18*width
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
if MP_NetWorkManager.shared.netWorkStatu != .reachable {
MP_HUD.onlytext("Bad connection~", delay: 1.0, completion: nil)
}
}
configure() configure()
} }
override func viewWillAppear(_ animated: Bool) { override func viewWillAppear(_ animated: Bool) {

View File

@ -0,0 +1,96 @@
//
// MPPositive_AddSongsViewController.swift
// relax.offline.mp3.music
//
// Created by Mr.Zhou on 2024/9/24.
//
import UIKit
class MPPositive_AddSongsViewController: MPPositive_BaseViewController {
//View
lazy var segmentView:JXSegmentedView = {
var jxSegmentView = JXSegmentedView()
jxSegmentView.backgroundColor = .init(hex: "1A1A1A")
return jxSegmentView
}()
//
private lazy var dataSource:JXSegmentedTitleDataSource = {
var dataSource = JXSegmentedTitleDataSource()
dataSource.titles = ["Love Songs".localizableString(), "Offline Songs".localizableString()]
//
dataSource.titleNormalColor = .init(hex: "#666666")
dataSource.titleNormalFont = .systemFont(ofSize: 16*width, weight: .regular)
//
dataSource.titleSelectedColor = .init(hex: "#80F988")
dataSource.titleSelectedFont = .systemFont(ofSize: 16*width, weight: .bold)
//
dataSource.isTitleColorGradientEnabled = true
dataSource.isSelectedAnimable = true
dataSource.isItemTransitionEnabled = true
return dataSource
}()
//
private lazy var indicator:JXSegmentedIndicatorLineView = {
let indicator = JXSegmentedIndicatorLineView()
indicator.indicatorWidth = 16*width
indicator.indicatorHeight = 3*width
indicator.indicatorCornerRadius = 1.5*width
indicator.indicatorColor = .init(hex: "#80F988")
indicator.indicatorPosition = .bottom
return indicator
}()
//
fileprivate lazy var listContainerView:JXSegmentedListContainerView = {
let listContainerView = JXSegmentedListContainerView(dataSource: self)
listContainerView.backgroundColor = .clear
return listContainerView
}()
var list:MPPositive_CustomPlayListModel!
init(playList:MPPositive_CustomPlayListModel) {
super.init(nibName: nil, bundle: nil)
self.list = playList
}
required init?(coder: NSCoder) {
super.init(coder: coder)
}
override func viewDidLoad() {
super.viewDidLoad()
setTitle("Add Songs")
setPopBtn()
configure()
}
private func configure() {
//
segmentView.indicators = [indicator]
segmentView.dataSource = dataSource
view.addSubview(segmentView)
segmentView.snp.makeConstraints { make in
make.top.equalTo(navView.snp.bottom)
make.left.right.equalToSuperview()
make.height.equalTo(60*width)
}
view.addSubview(listContainerView)
listContainerView.snp.makeConstraints { (make) in
make.left.right.bottom.equalToSuperview().priority(999)
make.top.equalTo(segmentView.snp.bottom).priority(999)
}
segmentView.contentScrollView = listContainerView.scrollView
segmentView.listContainer = listContainerView
}
}
//MARK: - JXSegmentedTitleDataSource
extension MPPositive_AddSongsViewController: JXSegmentedListContainerViewDataSource, JXSegmentedViewDelegate {
func numberOfLists(in listContainerView: JXSegmentedListContainerView) -> Int {
return dataSource.titles.count
}
func listContainerView(_ listContainerView: JXSegmentedListContainerView, initListAt index: Int) -> any JXSegmentedListContainerViewListDelegate {
let showView:MPPositive_AddSongsShowView = .init(frame: listContainerView.frame, playList: list)
showView.selectedIndex = index
return showView
}
}

View File

@ -85,6 +85,17 @@ class MPPositive_CustomPlayListViewController: MPPositive_BaseViewController, UI
btn.addTarget(self, action: #selector(shuffleClick(_ :)), for: .touchUpInside) btn.addTarget(self, action: #selector(shuffleClick(_ :)), for: .touchUpInside)
return btn return btn
}() }()
///
private lazy var addBtn:UIButton = {
let btn = UIButton()
btn.setImage(UIImage(named: "New_AddSong'logo"), for: .normal)
//
btn.setTitle(" Add", for: .normal)
btn.setTitleColor(.white, for: .normal)
btn.titleLabel?.font = .systemFont(ofSize: 14*width, weight: .regular)
btn.addTarget(self, action: #selector(addSongActionClick(_ :)), for: .touchUpInside)
return btn
}()
/// ///
private lazy var searchBtn:UIButton = { private lazy var searchBtn:UIButton = {
let btn = UIButton() let btn = UIButton()
@ -185,6 +196,9 @@ class MPPositive_CustomPlayListViewController: MPPositive_BaseViewController, UI
} }
override func viewWillAppear(_ animated: Bool) { override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated) super.viewWillAppear(animated)
if list != nil {
reload(list)
}
} }
override func viewWillDisappear(_ animated: Bool) { override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated) super.viewWillDisappear(animated)
@ -279,7 +293,13 @@ class MPPositive_CustomPlayListViewController: MPPositive_BaseViewController, UI
// //
sectionShowView.addSubview(shuffleBtn) sectionShowView.addSubview(shuffleBtn)
shuffleBtn.snp.makeConstraints { make in shuffleBtn.snp.makeConstraints { make in
make.left.equalTo(playAllBtn.snp.right).offset(18*width) make.left.equalTo(playAllBtn.snp.right).offset(14*width)
make.centerY.equalTo(playAllBtn)
}
//
sectionShowView.addSubview(addBtn)
addBtn.snp.makeConstraints { make in
make.left.equalTo(shuffleBtn.snp.right).offset(14*width)
make.centerY.equalTo(playAllBtn) make.centerY.equalTo(playAllBtn)
} }
// //
@ -378,6 +398,7 @@ class MPPositive_CustomPlayListViewController: MPPositive_BaseViewController, UI
} }
// //
@objc private func playAllClick(_ sender:UIButton) { @objc private func playAllClick(_ sender:UIButton) {
view.endEditing(true)
guard list.videosArray.count != 0 else {return} guard list.videosArray.count != 0 else {return}
MPPositive_Debouncer.shared.call { MPPositive_Debouncer.shared.call {
[weak self] in [weak self] in
@ -416,6 +437,7 @@ class MPPositive_CustomPlayListViewController: MPPositive_BaseViewController, UI
} }
// //
@objc private func shuffleClick(_ sender:UIButton) { @objc private func shuffleClick(_ sender:UIButton) {
view.endEditing(true)
guard list.videosArray.count != 0 else {return} guard list.videosArray.count != 0 else {return}
MPPositive_Debouncer.shared.call { MPPositive_Debouncer.shared.call {
[weak self] in [weak self] in
@ -454,8 +476,17 @@ class MPPositive_CustomPlayListViewController: MPPositive_BaseViewController, UI
MP_AnalyticsManager.shared.player_b_listAction() MP_AnalyticsManager.shared.player_b_listAction()
} }
} }
//
@objc private func addSongActionClick(_ sender:UIButton) {
view.endEditing(true)
cancelSearchAction()
//Add
let addVC = MPPositive_AddSongsViewController(playList: list)
navigationController?.pushViewController(addVC, animated: true)
}
// //
@objc private func searchActionShowClick(_ sender:UIButton) { @objc private func searchActionShowClick(_ sender:UIButton) {
view.endEditing(true)
// //
UIView.animate(withDuration: 0.2) { UIView.animate(withDuration: 0.2) {
[weak self] in [weak self] in

View File

@ -44,13 +44,13 @@ class MPPositive_PlayerViewController: MPPositive_BaseViewController, UIViewCont
private lazy var songBtn:UIButton = createStatueBtn("SONG", color: .init(hex: "#FFFFFF", alpha: 0.85), tag: 0) private lazy var songBtn:UIButton = createStatueBtn("SONG", color: .init(hex: "#FFFFFF", alpha: 0.85), tag: 0)
//LYRICS //LYRICS
private lazy var lyricsBtn:UIButton = createStatueBtn("LYRICS", color: .init(hex: "#FFFFFF", alpha: 0.45), tag: 1) private lazy var lyricsBtn:UIButton = createStatueBtn("LYRICS", color: .init(hex: "#FFFFFF", alpha: 0.45), tag: 1)
// // //
private lazy var relatedBtn:UIButton = { // private lazy var relatedBtn:UIButton = {
let btn = UIButton() // let btn = UIButton()
btn.setBackgroundImage(UIImage(named: "Player_Related'logo"), for: .normal) // btn.setBackgroundImage(UIImage(named: "Player_Related'logo"), for: .normal)
btn.addTarget(self, action: #selector(relatedContentClick(_ :)), for: .touchUpInside) // btn.addTarget(self, action: #selector(relatedContentClick(_ :)), for: .touchUpInside)
return btn // return btn
}() // }()
//MARK: - //MARK: -
// //
@ -154,6 +154,28 @@ class MPPositive_PlayerViewController: MPPositive_BaseViewController, UIViewCont
activityIndicator.color = .black activityIndicator.color = .black
return activityIndicator return activityIndicator
}() }()
//
private lazy var relatedBtn:UIButton = {
let btn:UIButton = .init()
btn.setBackgroundImage(UIImage(named: "Player_SmallBack'logo"), for: .normal)
btn.setImage(UIImage(named: "Player_Related'logo 1"), for: .normal)
btn.setTitle(" Related", for: .normal)
btn.setTitleColor(.white, for: .normal)
btn.titleLabel?.font = .systemFont(ofSize: 14*width)
btn.addTarget(self, action: #selector(relatedContentClick(_ :)), for: .touchUpInside)
return btn
}()
//
private lazy var addPlayListBtn:UIButton = {
let btn:UIButton = .init()
btn.setBackgroundImage(UIImage(named: "Player_SmallBack'logo"), for: .normal)
btn.setImage(UIImage(named: "Player_AddPlayList'logo"), for: .normal)
btn.setTitle(" Add Playlist", for: .normal)
btn.setTitleColor(.white, for: .normal)
btn.titleLabel?.font = .systemFont(ofSize: 14*width)
btn.addTarget(self, action: #selector(addPlayListClick(_ :)), for: .touchUpInside)
return btn
}()
// //
private lazy var leadMaskView:UIView = { private lazy var leadMaskView:UIView = {
let maskView = UIView(frame: .init(x: 0, y: 0, width: screen_Width, height: screen_Height)) let maskView = UIView(frame: .init(x: 0, y: 0, width: screen_Width, height: screen_Height))
@ -309,12 +331,12 @@ class MPPositive_PlayerViewController: MPPositive_BaseViewController, UIViewCont
make.left.equalToSuperview().offset(16*width) make.left.equalToSuperview().offset(16*width)
make.centerY.equalToSuperview() make.centerY.equalToSuperview()
} }
navView.addSubview(relatedBtn) // navView.addSubview(relatedBtn)
relatedBtn.snp.makeConstraints { make in // relatedBtn.snp.makeConstraints { make in
make.width.height.equalTo(24*width) // make.width.height.equalTo(24*width)
make.right.equalToSuperview().offset(-16*width) // make.right.equalToSuperview().offset(-16*width)
make.centerY.equalToSuperview() // make.centerY.equalToSuperview()
} // }
navView.addSubview(switchActionView) navView.addSubview(switchActionView)
switchActionView.snp.makeConstraints { make in switchActionView.snp.makeConstraints { make in
make.height.equalToSuperview() make.height.equalToSuperview()
@ -425,7 +447,7 @@ class MPPositive_PlayerViewController: MPPositive_BaseViewController, UIViewCont
playBtn.snp.makeConstraints { make in playBtn.snp.makeConstraints { make in
make.width.height.equalTo(66*width) make.width.height.equalTo(66*width)
make.centerX.equalToSuperview() make.centerX.equalToSuperview()
make.centerY.equalToSuperview().multipliedBy(1.1) make.centerY.equalToSuperview().multipliedBy(1.1).offset(-bottomPadding)
} }
bottomView.addSubview(activityIndicator) bottomView.addSubview(activityIndicator)
activityIndicator.snp.makeConstraints { make in activityIndicator.snp.makeConstraints { make in
@ -465,6 +487,18 @@ class MPPositive_PlayerViewController: MPPositive_BaseViewController, UIViewCont
make.centerY.equalTo(playBtn.snp.centerY) make.centerY.equalTo(playBtn.snp.centerY)
make.left.equalToSuperview().offset(98*width) make.left.equalToSuperview().offset(98*width)
} }
bottomView.addSubview(relatedBtn)
relatedBtn.snp.makeConstraints { make in
make.top.equalTo(playBtn.snp.bottom).offset(15*width)
make.size.equalTo(CGSize(width: 151*width, height: 39*width))
make.centerX.equalToSuperview().multipliedBy(0.5)
}
bottomView.addSubview(addPlayListBtn)
addPlayListBtn.snp.makeConstraints { make in
make.top.equalTo(relatedBtn)
make.size.equalTo(relatedBtn.snp.size)
make.centerX.equalToSuperview().multipliedBy(1.5)
}
return bottomView return bottomView
} }
// //
@ -661,6 +695,9 @@ class MPPositive_PlayerViewController: MPPositive_BaseViewController, UIViewCont
coverView.alpha = 0.1 coverView.alpha = 0.1
songBtn.setTitleColor(.init(hex: "#FFFFFF", alpha: 0.45), for: .normal) songBtn.setTitleColor(.init(hex: "#FFFFFF", alpha: 0.45), for: .normal)
lyricsBtn.setTitleColor(.init(hex: "#FFFFFF", alpha: 0.85), for: .normal) lyricsBtn.setTitleColor(.init(hex: "#FFFFFF", alpha: 0.85), for: .normal)
if let currentVideo = MP_PlayerManager.shared.loadPlayer?.currentVideo {
lyricsView.lyricsLabel.text = currentVideo.lyrics ?? "No Lyrics"
}
} completion: { [weak self] (_) in } completion: { [weak self] (_) in
guard let self = self else {return} guard let self = self else {return}
//coverView //coverView
@ -683,7 +720,22 @@ class MPPositive_PlayerViewController: MPPositive_BaseViewController, UIViewCont
} }
dismiss(animated: true) dismiss(animated: true)
} }
//
@objc private func addPlayListClick(_ sender:UIButton) {
guard let currentVideo = MP_PlayerManager.shared.loadPlayer?.currentVideo else {
return
}
//
MPPositive_ModalType = .MoreOperations
let chooseVC = MPPositive_ChoosePlayListViewController(currentVideo.song)
chooseVC.disMissBlock = {
[weak self] in
print("Add Successfull")
}
chooseVC.transitioningDelegate = self
chooseVC.modalPresentationStyle = .custom
present(chooseVC, animated: true)
}
//// ////
@objc private func playClick(_ sender:UIButton) { @objc private func playClick(_ sender:UIButton) {

View File

@ -54,7 +54,7 @@ class MPPositive_CustomTabBarItem: UIView {
// //
addSubview(circleImageView) addSubview(circleImageView)
circleImageView.snp.makeConstraints { make in circleImageView.snp.makeConstraints { make in
make.width.height.equalToSuperview() make.width.height.equalTo(36*width)
make.center.equalToSuperview() make.center.equalToSuperview()
} }
circleImageView.isHidden = true circleImageView.isHidden = true

View File

@ -57,7 +57,8 @@ class MPPositive_CustomTabBarView: UIView {
addSubview(item) addSubview(item)
item.snp.makeConstraints { make in item.snp.makeConstraints { make in
make.centerY.equalToSuperview() make.centerY.equalToSuperview()
make.width.height.equalTo(36*width) make.width.equalToSuperview().multipliedBy(0.28)
make.height.equalToSuperview()
make.centerX.equalToSuperview().multipliedBy(0.45 + 0.55*Double(item.tag)) make.centerX.equalToSuperview().multipliedBy(0.45 + 0.55*Double(item.tag))
} }
} }

View File

@ -0,0 +1,102 @@
//
// MPPositive_AddSongTableViewCell.swift
// relax.offline.mp3.music
//
// Created by Mr.Zhou on 2024/9/24.
//
import UIKit
import Kingfisher
class MPPositive_AddSongTableViewCell: UITableViewCell {
//
private lazy var iconImageView:UIImageView = {
let imageView:UIImageView = .init()
imageView.contentMode = .scaleAspectFill
imageView.layer.masksToBounds = true
imageView.layer.cornerRadius = 8*width
return imageView
}()
private lazy var titleLabel:UILabel = createLabel(font: .systemFont(ofSize: 16*width, weight: .regular), textColor: .white, textAlignment: .left)
private lazy var subtitleLabel:UILabel = createLabel(font: .systemFont(ofSize: 12*width, weight: .regular), textColor: .init(hex: "#999999"), textAlignment: .left)
//
lazy var statuImageView:UIImageView = {
let imageView:UIImageView = .init()
imageView.contentMode = .scaleAspectFill
return imageView
}()
var list:MPPositive_CustomPlayListModel?
var love:MPPositive_CollectionSongViewModel!{
didSet{
love.setImage(iconImageView)
titleLabel.text = love.title
subtitleLabel.text = love.subtitle
//list
if let array = list?.videosArray.filter({$0.videoId == love.collectionSong.videoId}), array.isEmpty == true {
statuImageView.image = UIImage(named: "UnAdd_PlayLists'logo")
}else {
statuImageView.image = UIImage(named: "Added_PlayList'logo")
}
}
}
var offline:MPPositive_DownloadViewModel!{
didSet{
offline.setImage(iconImageView)
titleLabel.text = offline.title
subtitleLabel.text = offline.subtitle
//list
if let array = list?.videosArray.filter({$0.videoId == offline.loadItem.videoId}), array.isEmpty == true {
statuImageView.image = UIImage(named: "UnAdd_PlayLists'logo")
}else {
statuImageView.image = UIImage(named: "Added_PlayList'logo")
}
}
}
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
selectionStyle = .none
backgroundColor = .clear
configure()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
}
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
private func configure() {
contentView.addSubview(iconImageView)
iconImageView.snp.makeConstraints { make in
make.width.height.equalTo(60*width)
make.top.equalToSuperview().offset(12*width).priority(999)
make.bottom.equalToSuperview().offset(-12*width)
make.left.equalToSuperview().offset(16*width)
}
contentView.addSubview(titleLabel)
titleLabel.snp.makeConstraints { make in
make.top.equalTo(iconImageView.snp.top).offset(8*width)
make.left.equalTo(iconImageView.snp.right).offset(14*width)
make.right.equalToSuperview().offset(-16*width)
}
contentView.addSubview(subtitleLabel)
subtitleLabel.snp.makeConstraints { make in
make.bottom.equalTo(iconImageView.snp.bottom).offset(-8*width)
make.left.equalTo(titleLabel.snp.left)
make.right.equalTo(titleLabel.snp.right)
}
contentView.addSubview(statuImageView)
statuImageView.snp.makeConstraints { make in
make.size.equalTo(CGSize(width: 24*width, height: 24*width))
make.centerY.equalToSuperview()
make.right.equalTo(-18*width)
}
}
}

View File

@ -0,0 +1,143 @@
//
// MPPositive_AddSongsShowView.swift
// relax.offline.mp3.music
//
// Created by Mr.Zhou on 2024/9/24.
//
import UIKit
///
class MPPositive_AddSongsShowView: UIView, JXSegmentedListContainerViewListDelegate {
private lazy var tableView:UITableView = {
let tableView = UITableView()
if #available(iOS 15.0, *) {
tableView.sectionHeaderTopPadding = 0
}
tableView.backgroundColor = .clear
tableView.separatorStyle = .none
tableView.estimatedRowHeight = 200
tableView.rowHeight = UITableView.automaticDimension
tableView.dataSource = self
tableView.delegate = self
tableView.contentInset = .init(top: 0, left: 0, bottom: 70*width, right: 0)
tableView.register(MPPositive_AddSongTableViewCell.self, forCellReuseIdentifier: MPPositive_AddSongTableViewCellID)
return tableView
}()
private let MPPositive_AddSongTableViewCellID = "MPPositive_AddSongTableViewCell"
//
var selectedIndex:Int = 0
///
var list:MPPositive_CustomPlayListModel?
//
private var loves:[MPPositive_CollectionSongViewModel] = []
//线
private var offlines:[MPPositive_DownloadViewModel] = []
init(frame: CGRect, playList:MPPositive_CustomPlayListModel) {
super.init(frame: frame)
self.list = playList
backgroundColor = .init(hex: "1A1A1A")
configure()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
}
//MARK: -
func listView() -> UIView {
return self
}
func listWillAppear() {
reload()
}
//
private func reload() {
if selectedIndex == 0 {
//
MPPositive_LoadCoreModel.shared.reloadCollectionSongViewModel {
[weak self] in
guard let self = self else {return}
loves = MPPositive_LoadCoreModel.shared.songViewModels
tableView.showMessage(loves.count)
tableView.reloadData()
}
}else {
//线
MPPositive_LoadCoreModel.shared.reloadLoadSongViewModel {
[weak self] in
guard let self = self else {return}
offlines = MPPositive_LoadCoreModel.shared.loadViewModels
tableView.showMessage(offlines.count)
tableView.reloadData()
}
}
}
//
private func configure() {
addSubview(tableView)
tableView.snp.makeConstraints { make in
make.left.top.right.bottom.equalToSuperview()
}
}
}
//MARK: - tableView
extension MPPositive_AddSongsShowView:UITableViewDataSource, UITableViewDelegate {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return selectedIndex == 0 ? loves.count:offlines.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: MPPositive_AddSongTableViewCellID, for: indexPath) as! MPPositive_AddSongTableViewCell
cell.list = list
if selectedIndex == 0 {
cell.love = loves[indexPath.row]
}else {
cell.offline = offlines[indexPath.row]
}
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if selectedIndex == 0 {
let item = loves[indexPath.row]
guard let array = list?.videosArray.filter({$0.videoId == item.collectionSong.videoId}), array.isEmpty == true else {
return
}
//
let video = try? MPPositive_CustomVideoModel.create()
video?.coverImageURL = item.coverURL
video?.title = item.title
video?.subtitle = item.collectionSong.subtitle
video?.videoId = item.collectionSong.videoId
video?.lyricsID = item.collectionSong.lyricsID
video?.relatedID = item.collectionSong.relatedID
video?.addTime = Date().timeZone()
video?.playList = list
MPPositive_CustomVideoModel.save()
MP_HUD.onlytext("Successfully added to the playlist".localizableString(), delay: 1.0) {
[weak self] in
self?.tableView.reloadData()
}
}else {
let item = offlines[indexPath.row]
guard let array = list?.videosArray.filter({$0.videoId == item.loadItem.videoId}), array.isEmpty == true else {
return
}
//
let video = try? MPPositive_CustomVideoModel.create()
video?.coverImageURL = item.reviewURL
video?.title = item.title
video?.subtitle = item.loadItem.shortBylineText
video?.videoId = item.loadItem.videoId
video?.lyricsID = item.loadItem.lyricsID
video?.relatedID = item.loadItem.relatedID
video?.addTime = Date().timeZone()
video?.playList = list
MPPositive_CustomVideoModel.save()
MP_HUD.onlytext("Successfully added to the playlist".localizableString(), delay: 1.0) {
[weak self] in
self?.tableView.reloadData()
}
}
}
}

View File

@ -224,10 +224,10 @@ class MPPositive_ArtistShowSongTableViewCell: UITableViewCell, PKDownloadButtonD
} }
// //
@objc private func moreActionClick(_ sender:UIButton) { @objc private func moreActionClick(_ sender:UIButton) {
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else { // guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
MP_HUD.text("Bad connection~".localizableString(), delay: 2.0, completion: nil) // MP_HUD.text("Bad connection~".localizableString(), delay: 2.0, completion: nil)
return // return
} // }
guard moreBlock != nil else { guard moreBlock != nil else {
return return
} }

View File

@ -232,10 +232,10 @@ class MPPositive_HomeSingleCollectionViewCell: UICollectionViewCell, PKDownloadB
switch state { switch state {
case .startDownload:// case .startDownload://
// //
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else { // guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
MP_HUD.text("Bad connection~".localizableString(), delay: 2.0, completion: nil) // MP_HUD.text("Bad connection~".localizableString(), delay: 2.0, completion: nil)
return // return
} // }
// //
guard let videoId = itemViewModel.browseItem.videoId else { guard let videoId = itemViewModel.browseItem.videoId else {
return return

View File

@ -249,10 +249,10 @@ class MPPositive_MusicItemShowTableViewCell: UITableViewCell, PKDownloadButtonDe
} }
// //
@objc private func moreActionClick(_ sender:UIButton) { @objc private func moreActionClick(_ sender:UIButton) {
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else { // guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
MP_HUD.text("Bad connection~".localizableString(), delay: 2.0, completion: nil) // MP_HUD.text("Bad connection~".localizableString(), delay: 2.0, completion: nil)
return // return
} // }
guard moreBlock != nil else { guard moreBlock != nil else {
return return
} }

View File

@ -298,37 +298,39 @@ class MPPositive_PlayerCoverView: UIView, PKDownloadButtonDelegate {
} }
// //
@objc private func collectionSwitchClick(_ sender:UIButton) { @objc private func collectionSwitchClick(_ sender:UIButton) {
//
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
MP_HUD.text("Bad connection~".localizableString(), delay: 2.0, completion: nil)
return
}
if self.collectionSongBtn.isSelected == true{ if self.collectionSongBtn.isSelected == true{
//
self.collectionSongBtn.isSelected = false self.collectionSongBtn.isSelected = false
if MP_PlayerManager.shared.loadPlayer?.currentVideo != nil{ if let currentVideo = MP_PlayerManager.shared.loadPlayer?.currentVideo{
MPPositive_CollectionSongModel.fetch(predicate: .init(format: "videoId == %@", (MP_PlayerManager.shared.loadPlayer?.currentVideo?.song.videoId ?? ""))) { [weak self] results in //
MPPositive_CollectionSongModel.fetch(predicate: .init(format: "videoId == %@", (currentVideo.song.videoId ?? ""))) { [weak self] results in
results.forEach { i in results.forEach { i in
if i.videoId == MP_PlayerManager.shared.loadPlayer?.currentVideo?.song.videoId{ if i.videoId == currentVideo.song.videoId{
MPPositive_CollectionSongModel.delete(i) MPPositive_CollectionSongModel.delete(i)
} }
} }
//
MP_PlayerManager.shared.loadPlayer?.currentVideo?.reloadCollectionAndDownLoad() MP_PlayerManager.shared.loadPlayer?.currentVideo?.reloadCollectionAndDownLoad()
MPPositive_LoadCoreModel.shared.reloadCollectionSongViewModel(nil) MPPositive_LoadCoreModel.shared.reloadCollectionSongViewModel(nil)
} }
MP_AnalyticsManager.shared.player_b_unlove_clickAction(MP_PlayerManager.shared.loadPlayer?.currentVideo?.song.videoId ?? "", videoname: MP_PlayerManager.shared.loadPlayer?.currentVideo?.song.title ?? "", artistname: MP_PlayerManager.shared.loadPlayer?.currentVideo?.song.shortBylineText ?? "") MP_AnalyticsManager.shared.player_b_unlove_clickAction(MP_PlayerManager.shared.loadPlayer?.currentVideo?.song.videoId ?? "", videoname: MP_PlayerManager.shared.loadPlayer?.currentVideo?.song.title ?? "", artistname: MP_PlayerManager.shared.loadPlayer?.currentVideo?.song.shortBylineText ?? "")
} }
}else{ }else{
//
self.collectionSongBtn.isSelected = true self.collectionSongBtn.isSelected = true
if MP_PlayerManager.shared.loadPlayer?.currentVideo != nil{ if let currentVideo = MP_PlayerManager.shared.loadPlayer?.currentVideo{
//
let item = try? MPPositive_CollectionSongModel.create() let item = try? MPPositive_CollectionSongModel.create()
item?.title = MP_PlayerManager.shared.loadPlayer?.currentVideo.title item?.title = currentVideo.title
item?.videoId = MP_PlayerManager.shared.loadPlayer?.currentVideo.song.videoId item?.videoId = currentVideo.song.videoId
item?.subtitle = MP_PlayerManager.shared.loadPlayer?.currentVideo.subtitle item?.subtitle = currentVideo.subtitle
item?.coverImage = MP_PlayerManager.shared.loadPlayer?.currentVideo.coverUrl item?.coverImage = currentVideo.coverUrl
item?.lyricsID = MP_PlayerManager.shared.loadPlayer?.currentVideo.song.lyricsID item?.lyricsID = currentVideo.song.lyricsID
item?.relatedID = MP_PlayerManager.shared.loadPlayer?.currentVideo.song.relatedID item?.relatedID = currentVideo.song.relatedID
item?.addTime = Date() item?.addTime = Date()
MPPositive_CollectionSongModel.save() MPPositive_CollectionSongModel.save()
//
MP_PlayerManager.shared.loadPlayer?.currentVideo.reloadCollectionAndDownLoad() MP_PlayerManager.shared.loadPlayer?.currentVideo.reloadCollectionAndDownLoad()
MPPositive_LoadCoreModel.shared.reloadCollectionSongViewModel(nil) MPPositive_LoadCoreModel.shared.reloadCollectionSongViewModel(nil)
MP_AnalyticsManager.shared.player_b_love_clickAction(MP_PlayerManager.shared.loadPlayer?.currentVideo?.song.videoId ?? "", videoname: MP_PlayerManager.shared.loadPlayer?.currentVideo?.song.title ?? "", artistname: MP_PlayerManager.shared.loadPlayer?.currentVideo?.song.shortBylineText ?? "") MP_AnalyticsManager.shared.player_b_love_clickAction(MP_PlayerManager.shared.loadPlayer?.currentVideo?.song.videoId ?? "", videoname: MP_PlayerManager.shared.loadPlayer?.currentVideo?.song.title ?? "", artistname: MP_PlayerManager.shared.loadPlayer?.currentVideo?.song.shortBylineText ?? "")

View File

@ -277,10 +277,10 @@ class MPPositive_SearchResultShowTableViewCell: UITableViewCell, PKDownloadButto
// //
@objc private func moreActionClick(_ sender:UIButton) { @objc private func moreActionClick(_ sender:UIButton) {
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else { // guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
MP_HUD.text("Bad connection~".localizableString(), delay: 2.0, completion: nil) // MP_HUD.text("Bad connection~".localizableString(), delay: 2.0, completion: nil)
return // return
} // }
if moreBlock != nil { if moreBlock != nil {
moreBlock!() moreBlock!()
} }