27
27
#import "NSDate+Extras.h"
28
28
#import "StreamingPlayer.h"
29
29
#import "Downloader.h"
30
#import "UIAlertView+Blocks.h"
31
32
@interface AlbumViewController (Private)
32
33
- (void)setupHeaderAndFooter;
141
142
Song *song = [self.songs objectAtIndex:indexPath.row];
143
144
// explicitly re-set the default state of the button/spinner
144
[cell.cacheButton setImage:[UIImage imageNamed:@"uncached"] forState:UIControlStateNormal];
145
[cell.cacheButton setImage:(canCache ? [UIImage imageNamed:@"uncached"] : [UIImage imageNamed:@"uncached-disabled"]) forState:UIControlStateNormal];
145
146
[cell.spinner stopAnimating];
147
148
cell.cacheButton.tag = indexPath.row;
270
270
- (void)toggleCacheForSong:(id)sender
272
272
// This is a binary toggle, and right now, we don't bother trying to cancel a download in progress.
274
273
int row = [(UIButton *)sender tag];
276
275
NSIndexPath *songPath = [NSIndexPath indexPathForRow:row inSection:0];
295
[cell.spinner startAnimating];
296
[[Downloader sharedDownloader] downloadFile:[[Subsonic sharedSubsonic] getStreamingURLForSongId:song.songId] withName:song.songId completionBlock:^(NSString *path) {
297
dispatch_async(dispatch_get_main_queue(), ^(void) {
298
song.cachedSongPath = path;
300
SongUITableViewCell *cell = (SongUITableViewCell *)[self.tableView cellForRowAtIndexPath:songPath];
301
[cell.spinner stopAnimating];
302
[cell.cacheButton setImage:[UIImage imageNamed:@"cached"] forState:UIControlStateNormal];
296
[cell.spinner startAnimating];
297
[[Downloader sharedDownloader] downloadFile:[[Subsonic sharedSubsonic] getStreamingURLForSongId:song.songId] withName:song.songId completionBlock:^(NSString *path) {
298
dispatch_async(dispatch_get_main_queue(), ^(void) {
299
song.cachedSongPath = path;
301
SongUITableViewCell *cell = (SongUITableViewCell *)[self.tableView cellForRowAtIndexPath:songPath];
302
[cell.spinner stopAnimating];
303
[cell.cacheButton setImage:[UIImage imageNamed:@"cached"] forState:UIControlStateNormal];
309
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
310
if (![defaults boolForKey:@"acknowledged-no-cache-on-3g"])
312
RIButtonItem *dismissButton = [RIButtonItem item];
313
dismissButton.label = NSLocalizedString(@"Dismiss", @"");
314
dismissButton.action = ^
316
[defaults setBool:YES forKey:@"acknowledged-no-cache-on-3g"];
319
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Caching Disabled", @"")
320
message:NSLocalizedString(@"Caching songs can only be done on WiFi networks.", @"")
321
cancelButtonItem:nil otherButtonItems:dismissButton, nil];