Commit 3c080ec1 authored by Felix Paul Kühne's avatar Felix Paul Kühne

Library: implement library upgrading (newly introduced to MLKit) with visual feedback for the user

parent 1e215e53
......@@ -45,5 +45,6 @@
@property (nonatomic, strong) IBOutlet UILabel *emptyLibraryLabel;
@property (nonatomic, strong) IBOutlet UILabel *emptyLibraryLongDescriptionLabel;
@property (nonatomic, strong) IBOutlet UIActivityIndicatorView *activityIndicator;
@end
......@@ -21,7 +21,7 @@
@implementation EmptyLibraryView
@end
@interface VLCPlaylistViewController () <AQGridViewDataSource, AQGridViewDelegate, UITableViewDataSource, UITableViewDelegate> {
@interface VLCPlaylistViewController () <AQGridViewDataSource, AQGridViewDelegate, UITableViewDataSource, UITableViewDelegate, MLMediaLibrary> {
NSMutableArray *_foundMedia;
NSUInteger _libraryMode;
UIBarButtonItem *_menuButton;
......@@ -104,10 +104,24 @@
{
[super viewDidAppear:animated];
if ([[MLMediaLibrary sharedMediaLibrary] libraryNeedsUpgrade]) {
self.navigationItem.rightBarButtonItem = nil;
self.navigationItem.leftBarButtonItem = nil;
self.emptyLibraryView.emptyLibraryLabel.text = NSLocalizedString(@"UPGRADING_LIBRARY", @"");
self.emptyLibraryView.emptyLibraryLongDescriptionLabel.hidden = YES;
[self.emptyLibraryView.activityIndicator startAnimating];
self.emptyLibraryView.frame = self.view.frame;
self.title = @"";
[self.view addSubview:self.emptyLibraryView];
[[MLMediaLibrary sharedMediaLibrary] setDelegate: self];
[[MLMediaLibrary sharedMediaLibrary] performSelectorInBackground:@selector(upgradeLibrary) withObject:nil];
return;
}
if (_foundMedia.count < 1)
[self performSelector:@selector(reloadContents) withObject:nil afterDelay:.0];
[[MLMediaLibrary sharedMediaLibrary] performSelector:@selector(libraryDidAppear) withObject:nil afterDelay:1.];
}
- (void)viewDidDisappear:(BOOL)animated
......@@ -170,6 +184,18 @@
}
}
- (void)libraryUpgradeComplete
{
self.emptyLibraryView.emptyLibraryLongDescriptionLabel.hidden = NO;
self.emptyLibraryView.emptyLibraryLabel.text = NSLocalizedString(@"EMPTY_LIBRARY", @"");
[self.emptyLibraryView.activityIndicator stopAnimating];
self.title = NSLocalizedString(@"LIBRARY_ALL_FILES", @"");
self.navigationItem.leftBarButtonItem = _menuButton;
[self.emptyLibraryView removeFromSuperview];
[self reloadContents];
}
- (void)reloadContents
{
if (_libraryMode == kVLCLibraryModeAllAlbums) {
......
......@@ -2,7 +2,7 @@
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.iPad.XIB" version="8.00">
<data>
<int key="IBDocument.SystemTarget">1296</int>
<string key="IBDocument.SystemVersion">12F9</string>
<string key="IBDocument.SystemVersion">12F33</string>
<string key="IBDocument.InterfaceBuilderVersion">3084</string>
<string key="IBDocument.AppKitVersion">1187.39</string>
<string key="IBDocument.HIToolboxVersion">626.00</string>
......@@ -12,6 +12,7 @@
</object>
<array key="IBDocument.IntegratedClassDependencies">
<string>IBProxyObject</string>
<string>IBUIActivityIndicatorView</string>
<string>IBUIImageView</string>
<string>IBUILabel</string>
<string>IBUIView</string>
......@@ -121,6 +122,17 @@
</object>
<bool key="IBUIAdjustsFontSizeToFit">NO</bool>
</object>
<object class="IBUIActivityIndicatorView" id="43520374">
<reference key="NSNextResponder" ref="586773713"/>
<int key="NSvFlags">-2147483355</int>
<string key="NSFrame">{{188, 319}, {37, 37}}</string>
<reference key="NSSuperview" ref="586773713"/>
<reference key="NSWindow"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
<string key="targetRuntimeIdentifier">IBIPadFramework</string>
<int key="IBUIStyle">0</int>
</object>
</array>
<string key="NSFrame">{{0, 268}, {412, 460}}</string>
<reference key="NSSuperview" ref="25978252"/>
......@@ -168,6 +180,14 @@
</object>
<int key="connectionID">119</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">activityIndicator</string>
<reference key="source" ref="25978252"/>
<reference key="destination" ref="43520374"/>
</object>
<int key="connectionID">123</int>
</object>
</array>
<object class="IBMutableOrderedSet" key="objectRecords">
<array key="orderedObjects">
......@@ -203,6 +223,7 @@
<reference ref="222554551"/>
<reference ref="644368754"/>
<reference ref="247429863"/>
<reference ref="43520374"/>
</array>
<reference key="parent" ref="25978252"/>
</object>
......@@ -221,6 +242,11 @@
<reference key="object" ref="247429863"/>
<reference key="parent" ref="586773713"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">122</int>
<reference key="object" ref="43520374"/>
<reference key="parent" ref="586773713"/>
</object>
</array>
</object>
<dictionary class="NSMutableDictionary" key="flattenedProperties">
......@@ -233,12 +259,13 @@
<string key="114.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="115.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="121.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="122.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
<int key="maxID">121</int>
<int key="maxID">123</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
......@@ -246,10 +273,15 @@
<string key="className">EmptyLibraryView</string>
<string key="superclassName">UIView</string>
<dictionary class="NSMutableDictionary" key="outlets">
<string key="activityIndicator">UIActivityIndicatorView</string>
<string key="emptyLibraryLabel">UILabel</string>
<string key="emptyLibraryLongDescriptionLabel">UILabel</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="toOneOutletInfosByName">
<object class="IBToOneOutletInfo" key="activityIndicator">
<string key="name">activityIndicator</string>
<string key="candidateClassName">UIActivityIndicatorView</string>
</object>
<object class="IBToOneOutletInfo" key="emptyLibraryLabel">
<string key="name">emptyLibraryLabel</string>
<string key="candidateClassName">UILabel</string>
......
......@@ -2,7 +2,7 @@
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="8.00">
<data>
<int key="IBDocument.SystemTarget">1296</int>
<string key="IBDocument.SystemVersion">12F9</string>
<string key="IBDocument.SystemVersion">12F33</string>
<string key="IBDocument.InterfaceBuilderVersion">3084</string>
<string key="IBDocument.AppKitVersion">1187.39</string>
<string key="IBDocument.HIToolboxVersion">626.00</string>
......@@ -12,6 +12,7 @@
</object>
<array key="IBDocument.IntegratedClassDependencies">
<string>IBProxyObject</string>
<string>IBUIActivityIndicatorView</string>
<string>IBUIImageView</string>
<string>IBUILabel</string>
<string>IBUIView</string>
......@@ -121,6 +122,17 @@
<bool key="IBUIAdjustsFontSizeToFit">NO</bool>
<double key="preferredMaxLayoutWidth">280</double>
</object>
<object class="IBUIActivityIndicatorView" id="1000936468">
<reference key="NSNextResponder" ref="887075663"/>
<int key="NSvFlags">-2147483355</int>
<string key="NSFrame">{{142, 337}, {37, 37}}</string>
<reference key="NSSuperview" ref="887075663"/>
<reference key="NSWindow"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<int key="IBUIStyle">0</int>
</object>
</array>
<string key="NSFrameSize">{320, 525}</string>
<reference key="NSSuperview" ref="36174295"/>
......@@ -168,6 +180,14 @@
</object>
<int key="connectionID">28</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">activityIndicator</string>
<reference key="source" ref="36174295"/>
<reference key="destination" ref="1000936468"/>
</object>
<int key="connectionID">31</int>
</object>
</array>
<object class="IBMutableOrderedSet" key="objectRecords">
<array key="orderedObjects">
......@@ -203,6 +223,7 @@
<reference ref="438742621"/>
<reference ref="335509625"/>
<reference ref="145484960"/>
<reference ref="1000936468"/>
</array>
<reference key="parent" ref="36174295"/>
</object>
......@@ -221,6 +242,11 @@
<reference key="object" ref="335509625"/>
<reference key="parent" ref="887075663"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">30</int>
<reference key="object" ref="1000936468"/>
<reference key="parent" ref="887075663"/>
</object>
</array>
</object>
<dictionary class="NSMutableDictionary" key="flattenedProperties">
......@@ -233,12 +259,13 @@
<string key="22.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="23.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="29.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="30.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
<int key="maxID">29</int>
<int key="maxID">31</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
......@@ -246,10 +273,15 @@
<string key="className">EmptyLibraryView</string>
<string key="superclassName">UIView</string>
<dictionary class="NSMutableDictionary" key="outlets">
<string key="activityIndicator">UIActivityIndicatorView</string>
<string key="emptyLibraryLabel">UILabel</string>
<string key="emptyLibraryLongDescriptionLabel">UILabel</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="toOneOutletInfosByName">
<object class="IBToOneOutletInfo" key="activityIndicator">
<string key="name">activityIndicator</string>
<string key="candidateClassName">UIActivityIndicatorView</string>
</object>
<object class="IBToOneOutletInfo" key="emptyLibraryLabel">
<string key="name">emptyLibraryLabel</string>
<string key="candidateClassName">UILabel</string>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment