summaryrefslogtreecommitdiff
path: root/ios
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2011-11-01 19:32:01 +0100
committerTor Andersson <tor.andersson@artifex.com>2011-11-01 23:46:58 +0100
commit85957d57f4661c0df8fe7e022728ffceafb2faf8 (patch)
tree4ab91ac06d7f0de8d95048fa2031b02626c1c574 /ios
parent590369c0b7a50795e21af1d4c6469b0f888cb397 (diff)
downloadmupdf-85957d57f4661c0df8fe7e022728ffceafb2faf8.tar.xz
Use timer to reload list of files when the library view is open.
We can't use applicationDidBecomeActive in iOS 5 to trigger a reload, since the file sync can happen in the background.
Diffstat (limited to 'ios')
-rw-r--r--ios/main.m24
1 files changed, 18 insertions, 6 deletions
diff --git a/ios/main.m b/ios/main.m
index 6f5fc97e..72cbaa42 100644
--- a/ios/main.m
+++ b/ios/main.m
@@ -14,11 +14,11 @@
static dispatch_queue_t queue;
static fz_glyph_cache *glyphcache = NULL;
static UIImage *loadingImage = nil;
-static UIBarButtonItem *flexibleSpace = nil;
static NSString *docdir = nil;
@interface MuLibraryController : UITableViewController
{
+ NSTimer *timer;
NSArray *files;
}
- (void) openDocument: (NSString*)filename;
@@ -192,6 +192,23 @@ static UIImage *renderPage(pdf_xref *xref, int number, float width, float height
@implementation MuLibraryController
+- (void) viewWillAppear: (BOOL)animated
+{
+ [self reload];
+
+ timer = [NSTimer timerWithTimeInterval: 1
+ target: self selector: @selector(reload) userInfo: nil
+ repeats: YES];
+
+ [[NSRunLoop currentRunLoop] addTimer: timer forMode: NSDefaultRunLoopMode];
+}
+
+- (void) viewWillDisappear: (BOOL)animated
+{
+ [timer invalidate];
+ timer = nil;
+}
+
- (void) reload
{
[self setTitle: @"MuPDF"];
@@ -754,10 +771,6 @@ static UIImage *renderPage(pdf_xref *xref, int number, float width, float height
loadingImage = [[UIImage imageNamed: @"loading.png"] retain];
- flexibleSpace = [[UIBarButtonItem alloc]
- initWithBarButtonSystemItem: UIBarButtonSystemItemFlexibleSpace
- target: nil action: nil];
-
library = [[MuLibraryController alloc] initWithStyle: UITableViewStylePlain];
navigator = [[UINavigationController alloc] initWithRootViewController: library];
@@ -791,7 +804,6 @@ static UIImage *renderPage(pdf_xref *xref, int number, float width, float height
- (void)applicationDidBecomeActive:(UIApplication *)application
{
printf("applicationDidBecomeActive!\n");
- [library reload];
}
- (void)applicationWillTerminate:(UIApplication *)application