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 b7d0a47 commit 371d893
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 3 deletions.
10 changes: 9 additions & 1 deletion BaiduFM/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,9 @@
<outlet property="bgImageView" destination="8Co-1s-it1" id="zxg-dB-UGt"/>
<outlet property="imgView" destination="10f-TH-a2W" id="K3C-M6-2jb"/>
<outlet property="nameLabel" destination="d5T-oP-9VV" id="5dO-8m-gIA"/>
<outlet property="nextButton" destination="2pu-Bg-AiJ" id="iiz-hC-WBl"/>
<outlet property="playButton" destination="G9O-eE-5Qo" id="tOX-0d-Mka"/>
<outlet property="prevButton" destination="p9J-6j-7ga" id="nM8-Fj-L1Q"/>
<outlet property="progressView" destination="ZHu-Jg-8aM" id="UWl-P0-zgg"/>
<outlet property="songTimeLengthLabel" destination="YBN-PX-Qx0" id="yVh-8d-a6h"/>
<outlet property="songTimePlayLabel" destination="lk4-Kj-DMK" id="xmc-K8-r5X"/>
Expand Down Expand Up @@ -377,7 +379,13 @@
<outlet property="delegate" destination="5G2-De-H6U" id="NaS-zm-K6r"/>
</connections>
</tableView>
<navigationItem key="navigationItem" title="下载列表" id="uId-9w-RdI"/>
<navigationItem key="navigationItem" title="下载列表" id="uId-9w-RdI">
<barButtonItem key="rightBarButtonItem" systemItem="trash" id="GEG-2R-Q3f">
<connections>
<action selector="delAllSong:" destination="5G2-De-H6U" id="dP2-Re-Rrb"/>
</connections>
</barButtonItem>
</navigationItem>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="uf5-Tn-8LR" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
Expand Down
10 changes: 10 additions & 0 deletions BaiduFM/Common.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,15 @@ class Common {
var musicPath = musicDir.stringByAppendingPathComponent(songId + "." + format)
return musicPath
}

class func cleanAllDownloadSong(){

//删除歌曲文件夹
var musicDir = Utils.documentPath().stringByAppendingPathComponent("download")
NSFileManager.defaultManager().removeItemAtPath(musicDir, error: nil)

//更新db
DataCenter.shareDataCenter.dbSongList.cleanDownloadList()
}

}
7 changes: 7 additions & 0 deletions BaiduFM/DownloadTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ class DownloadTableViewController: UITableViewController {
})
}

@IBAction func delAllSong(sender: UIBarButtonItem) {

Common.cleanAllDownloadSong()
self.loadData()
}


/*
// Override to support conditional editing of the table view.
override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
Expand Down
10 changes: 10 additions & 0 deletions BaiduFM/SongList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,16 @@ 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 Down
21 changes: 19 additions & 2 deletions BaiduFM/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ class ViewController: UIViewController {
@IBOutlet weak var progressView: UIProgressView!
@IBOutlet weak var txtView: UITextView!
@IBOutlet weak var playButton: UIButton!
@IBOutlet weak var prevButton: UIButton!
@IBOutlet weak var nextButton: UIButton!


var timer:NSTimer? = nil
var currentChannel = ""
Expand Down Expand Up @@ -159,7 +162,21 @@ class ViewController: UIViewController {
func start(index:Int){
DataCenter.shareDataCenter.curPlayIndex = index
// println(DataCenter.shareDataCenter.curPlayIndex)

Async.main{

if index == 0 {
self.prevButton.enabled = false
}else{
self.prevButton.enabled = true
}

if index == DataCenter.shareDataCenter.curShowAllSongId.count - 1 {
self.nextButton.enabled = false
}else{
self.nextButton.enabled = true
}

var info = DataCenter.shareDataCenter.curPlaySongInfo
var link = DataCenter.shareDataCenter.curPlaySongLink

Expand Down Expand Up @@ -275,8 +292,8 @@ class ViewController: UIViewController {

//锁屏显示歌曲专辑信息
func showNowPlay(songPic:String,name:String,artistName:String,albumName:String){

//var showImg = Common.getIndexPageImage(info)
//var showImg = Common.getIndexPageImage(info)
var img = UIImage(data: NSData(contentsOfURL: NSURL(string: songPic)!)!)
var item = MPMediaItemArtwork(image: img)

Expand Down

0 comments on commit 371d893

Please sign in to comment.