Skip to content

Commit

Permalink
清空播放列表,最近播放列表
Browse files Browse the repository at this point in the history
  • Loading branch information
belm committed Apr 25, 2015
1 parent 371d893 commit 9332873
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 15 deletions.
16 changes: 14 additions & 2 deletions BaiduFM/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,13 @@
<outlet property="delegate" destination="izT-zR-8R6" id="CGS-dY-MSu"/>
</connections>
</tableView>
<navigationItem key="navigationItem" title="收藏列表" id="W7d-DW-2vw"/>
<navigationItem key="navigationItem" title="收藏列表" id="W7d-DW-2vw">
<barButtonItem key="rightBarButtonItem" systemItem="trash" id="l2V-se-prD">
<connections>
<action selector="delAllSong:" destination="izT-zR-8R6" id="QqX-f5-O4G"/>
</connections>
</barButtonItem>
</navigationItem>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="x6c-ni-hGF" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
Expand Down Expand Up @@ -467,7 +473,13 @@
<outlet property="delegate" destination="cq6-po-zvS" id="jbT-V3-9OJ"/>
</connections>
</tableView>
<navigationItem key="navigationItem" title="最近播放" id="rZL-84-edu"/>
<navigationItem key="navigationItem" title="最近播放" id="rZL-84-edu">
<barButtonItem key="rightBarButtonItem" systemItem="trash" id="G9G-bj-Xmp">
<connections>
<action selector="deleteAllSong:" destination="cq6-po-zvS" id="jVe-83-Gnl"/>
</connections>
</barButtonItem>
</navigationItem>
<simulatedStatusBarMetrics key="simulatedStatusBarMetrics"/>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="Psv-ad-bat" userLabel="First Responder" sceneMemberID="firstResponder"/>
Expand Down
5 changes: 4 additions & 1 deletion BaiduFM/HttpRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,11 @@ class HttpRequest {
}

class func downloadFile(songURL:String, musicPath:String, filePath:()->Void){

var canPlaySongURL = Common.getCanPlaySongUrl(songURL)

println("开始下载\(songURL)")
Alamofire.download(Method.GET, songURL, { (temporaryURL, response) in
Alamofire.download(Method.GET, canPlaySongURL, { (temporaryURL, response) in
let url = NSURL(fileURLWithPath: musicPath)!
return url
}).response { (request, response, _, error) -> Void in
Expand Down
8 changes: 8 additions & 0 deletions BaiduFM/LikeTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ class LikeTableViewController: UITableViewController {
})
}

@IBAction func delAllSong(sender: UIBarButtonItem) {

DataCenter.shareDataCenter.dbSongList.clearLikeList()
self.loadData()
}



/*
// Override to support rearranging the table view.
override func tableView(tableView: UITableView, moveRowAtIndexPath fromIndexPath: NSIndexPath, toIndexPath: NSIndexPath) {
Expand Down
7 changes: 7 additions & 0 deletions BaiduFM/RecentTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ class RecentTableViewController: UITableViewController {
})
}


@IBAction func deleteAllSong(sender: UIBarButtonItem) {

DataCenter.shareDataCenter.dbSongList.cleanRecentList()
self.loadData()
}

/*
// Override to support conditional editing of the table view.
override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
Expand Down
43 changes: 31 additions & 12 deletions BaiduFM/SongList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,6 @@ class SongList:BaseDb {
return false
}

func cleanDownloadList()->Bool{
if self.open(){
var sql = "update tbl_song_list set is_dl = 0"
var ret = self.db.executeUpdate(sql, withArgumentsInArray: nil)
self.close()
return ret
}
return false
}

func updateDownloadStatus(sid:String)->Bool{
if self.open(){
var sql = "UPDATE tbl_song_list set is_dl=1 WHERE sid=?"
Expand All @@ -161,9 +151,38 @@ class SongList:BaseDb {
}
return false
}

// MARK: - Clear
func clearLikeList()->Bool{
if self.open(){
var sql = "update tbl_song_list set is_like = 0"
var ret = self.db.executeUpdate(sql, withArgumentsInArray: nil)
self.close()
return ret
}
return false
}

//清理最近播放列表,只保留最近20首歌曲
func clearRecentPlayList(){
func cleanDownloadList()->Bool{
if self.open(){
var sql = "update tbl_song_list set is_dl = 0"
var ret = self.db.executeUpdate(sql, withArgumentsInArray: nil)
self.close()
return ret
}
return false
}

func cleanRecentList()->Bool{

if self.open(){
var sql = "update tbl_song_list set is_recent=0 where is_dl = 1 or is_like=1"
var ret1 = self.db.executeUpdate(sql, withArgumentsInArray: nil)
sql = "delete from tbl_song_list where is_recent = 1"
var ret2 = self.db.executeUpdate(sql, withArgumentsInArray: nil)
self.close()
return ret1 && ret2
}
return false
}
}
9 changes: 9 additions & 0 deletions BaiduFM/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,17 @@ class ViewController: UIViewController {
}
}

func resetUI(){
self.progressView.progress = 0
self.songTimePlayLabel.text = "00:00"
self.songTimeLengthLabel.text = "00:00"
self.txtView.text = ""
}

func show(showImg:String,name:String,artistName:String,albumName:String,songLink:String,time:Int, lrcLink:String,songId:String,format:String){

self.resetUI()

self.navigationItem.title = DataCenter.shareDataCenter.currentChannelName

//info
Expand Down

0 comments on commit 9332873

Please sign in to comment.