Permalink
Browse files

Added automatic Interface refresh when receive notification and downl…

…oad PDf

Moved pdf located into Document folder to cache Folder
  • Loading branch information...
1 parent fbd3710 commit 5a2f49301b91a8fb9f99742ac5d639b173059319 Gianluca committed Nov 9, 2011
@@ -110,7 +110,7 @@ - (void)viewDidLoad {
// Paths to the cover and the document.
- paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+ paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
documentsDirectory = [paths objectAtIndex:0];
pdfPath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@/%@.pdf",page,page]];
@@ -296,7 +296,7 @@ -(void)actionremovePdf:(id)sender{
NSString *documentsDirectory = nil;
NSString *pdfPath = nil;
- paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+ paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
documentsDirectory = [paths objectAtIndex:0];
pdfPath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@",page]];
@@ -449,7 +449,7 @@ -(void)downloadPDF:(id)sender withUrl:(NSString *)sourceURL andName:(NSString *)
// Filename path.
- paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+ paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
documentsDirectory = [paths objectAtIndex:0];
pathContainPdf = [NSString stringWithString:[NSString stringWithFormat:@"/%@/",namePdf]];
@@ -615,7 +615,7 @@ - (void)connectionDidFinishDownloading:(NSURLConnection *)connection destination
NSString *suffix = nil;
NSString *path = nil;
- NSArray * paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+ NSArray * paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
path = [[paths objectAtIndex:0] stringByAppendingPathComponent:filename];
@@ -659,7 +659,7 @@ - (BOOL)handleFPKFile {
NSString * newPath = nil;
- NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *unzippedDestination = [documentsDirectory stringByAppendingString:[NSString stringWithFormat:@"/%@/",page]];
NSString *saveLocation = [documentsDirectory stringByAppendingString:[NSString stringWithFormat:@"/%@/%@.fpk",page,page]];
@@ -806,7 +806,7 @@ -(void)requestFinished:(ASIHTTPRequest *)request{
NSString * newPath = nil;
//set the directory for the Unzip and use ZipArchive library to unzip the file and the multimedia file
- NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *unzippedDestination = [documentsDirectory stringByAppendingString:[NSString stringWithFormat:@"/%@/",page]];
NSString *saveLocation = [documentsDirectory stringByAppendingString:[NSString stringWithFormat:@"/%@/%@.fpk",page,page]];
@@ -25,16 +25,20 @@
NSMutableDictionary * imgDict;
NSMutableArray *documentsList;
+
+ UIScrollView *scrollView;
BOOL graphicsMode;
}
-(IBAction)actionOpenPlainDocument:(NSString *)documentName;
+-(void)buildInterface;
//-(void)showViewDownload;
//-(void)hideViewDownload;
//@property (nonatomic, retain) MFDocumentManager *document;
@property (nonatomic, retain) NSMutableArray *documentsList;
+@property (nonatomic,retain) UIScrollView *scrollView;
//@property (nonatomic,retain ) UIProgressView *downloadProgressView;
//@property (nonatomic,retain ) UIView *downloadProgressContainerView;
@@ -24,6 +24,7 @@ @implementation MenuViewController_Kiosk
@synthesize progressViewDict,imgDict;
@synthesize documentsList;
@synthesize graphicsMode;
+@synthesize scrollView;
-(IBAction)actionOpenPlainDocument:(NSString *)documentName {
@@ -36,7 +37,7 @@ -(IBAction)actionOpenPlainDocument:(NSString *)documentName {
NSString *pdfPath = nil;
NSURL *documentUrl = nil;
- paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+ paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
documentsDirectory = [paths objectAtIndex:0];
pdfPath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@/%@.pdf",documentName,documentName]];
documentUrl = [NSURL fileURLWithPath:pdfPath];
@@ -84,7 +85,14 @@ - (void)viewDidLoad {
[super viewDidLoad];
- XMLParser *parser = nil;
+ [self buildInterface];
+
+}
+
+
+-(void)buildInterface{
+
+ XMLParser *parser = nil;
NSURL * xmlUrl = nil;
UIScrollView * aScrollView = nil;
@@ -161,10 +169,29 @@ - (void)viewDidLoad {
[parser release];
- documentsCount = [documentsList count];
+ documentsCount = [documentsList count];
+
+ if (scrollView) {
+ [scrollView removeFromSuperview];
+ }else{
+
+ // Border.
+
+ if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
+ yBorder = scrollViewVOffset-3 ;
+ }else {
+ yBorder = scrollViewVOffset-1 ;
+ }
+
+ anImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, yBorder, scrollViewWidth, 40)];
+ [anImageView setImage:[UIImage imageWithContentsOfFile:MF_BUNDLED_RESOURCE(@"FPKKioskBundle",@"border",@"png")]];
+ [self.view addSubview:anImageView];
+ [anImageView release];
+
+ }
aScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, scrollViewVOffset, scrollViewWidth, scrollViewHeight)];
- aScrollView.backgroundColor = [UIColor whiteColor];
+ aScrollView.backgroundColor = [UIColor clearColor];
aScrollView.contentSize = CGSizeMake(scrollViewWidth, detailViewHeight * ((documentsCount/2)+(documentsCount%2)));
for (int i=1; i<= documentsCount ; i++) {
@@ -205,27 +232,17 @@ - (void)viewDidLoad {
[viewPdf release];
}
-
- [self.view addSubview:aScrollView];
+ scrollView = aScrollView;
+ [self.view addSubview:scrollView];
// self.scrollView = aScrollView; // Not referenced anywhere else.
[aScrollView release];
-
- // Border.
-
- if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
- yBorder = scrollViewVOffset-3 ;
- }else {
- yBorder = scrollViewVOffset-1 ;
- }
-
- anImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, yBorder, scrollViewWidth, 40)];
- [anImageView setImage:[UIImage imageWithContentsOfFile:MF_BUNDLED_RESOURCE(@"FPKKioskBundle",@"border",@"png")]];
- [self.view addSubview:anImageView];
- [anImageView release];
-
+
}
+
+
+
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
@@ -270,6 +287,8 @@ - (void)dealloc {
[downloadProgressContainerView release];
[downloadProgressView release];
+ [scrollView release];
+
[homeListPdfs release];
[super dealloc];
@@ -8,16 +8,19 @@
#import <UIKit/UIKit.h>
#import <Newsstandkit/NewsstandKit.h>
+#import "MenuViewController_Kiosk.h"
@interface FastPDFKit_KioskAppDelegate : NSObject <UIApplicationDelegate,NSURLConnectionDownloadDelegate> {
UIWindow *window;
UINavigationController *navigationController;
UIBackgroundTaskIdentifier bgTask;
+ MenuViewController_Kiosk *menuVC_Kiosk;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) UINavigationController *navigationController;
+@property (nonatomic,retain ) MenuViewController_Kiosk *menuVC_Kiosk;
- (BOOL)handleFPKFile:(NSString *)namePdf;
@@ -10,8 +10,11 @@
#import "MenuViewController_Kiosk.h"
#import "ZipArchive.h"
+
+
@implementation FastPDFKit_KioskAppDelegate
@synthesize window,navigationController;
+@synthesize menuVC_Kiosk;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
@@ -50,8 +53,10 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
} else {
aMenuViewController = [[MenuViewController_Kiosk alloc]initWithNibName:@"Kiosk_phone" bundle:MF_BUNDLED_BUNDLE(@"FPKKioskBundle")];
}
-
- UINavigationController *aNavController = [[UINavigationController alloc]initWithRootViewController:aMenuViewController];
+
+ menuVC_Kiosk = aMenuViewController;
+
+ UINavigationController *aNavController = [[UINavigationController alloc]initWithRootViewController:menuVC_Kiosk];
[aNavController setNavigationBarHidden:YES];
[self setNavigationController:aNavController];
@@ -168,7 +173,7 @@ - (void)connectionDidFinishDownloading:(NSURLConnection *)connection destination
NSArray *tempArray = [NSArray arrayWithObjects:filename, [NSNumber numberWithInt:[filename intValue]], nil];
- NSArray * paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+ NSArray * paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
path = [[paths objectAtIndex:0] stringByAppendingPathComponent:filename];
@@ -196,6 +201,13 @@ - (void)connectionDidFinishDownloading:(NSURLConnection *)connection destination
[[NSNotificationCenter defaultCenter] postNotificationName:@"down_Doc_OK" object:tempArray];
}
+ //reload interface
+ if (menuVC_Kiosk) {
+ [menuVC_Kiosk buildInterface];
+ }
+
+
+
}
- (void)connection:(NSURLConnection *)connection didWriteData:(long long)bytesWritten totalBytesWritten:(long long)totalBytesWritten expectedTotalBytes:(long long)expectedTotalBytes{
@@ -214,7 +226,7 @@ - (BOOL)handleFPKFile:(NSString *)namePdf {
NSString * newPath = nil;
- NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *unzippedDestination = [documentsDirectory stringByAppendingString:[NSString stringWithFormat:@"/%@/",namePdf]];
NSString *saveLocation = [documentsDirectory stringByAppendingString:[NSString stringWithFormat:@"/%@/%@.fpk",namePdf,namePdf]];
@@ -299,6 +311,7 @@ - (void)dealloc {
[navigationController release];
[window release];
+ [menuVC_Kiosk release];
[super dealloc];
}
@@ -1990,7 +1990,8 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
- CODE_SIGN_IDENTITY = "iPhone Developer";
+ CODE_SIGN_IDENTITY = "iPhone Developer: Gianluca Orsini (9T4EXXT4HH)";
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer: Gianluca Orsini (9T4EXXT4HH)";
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
@@ -2009,7 +2010,8 @@
);
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "FastPdfKit Kiosk";
- PROVISIONING_PROFILE = "";
+ PROVISIONING_PROFILE = "C0B27C15-C18D-480B-BA36-A6F14D925A41";
+ "PROVISIONING_PROFILE[sdk=iphoneos*]" = "C0B27C15-C18D-480B-BA36-A6F14D925A41";
SDKROOT = iphoneos;
SKIP_INSTALL = NO;
};
@@ -2019,7 +2021,8 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
- CODE_SIGN_IDENTITY = "iPhone Developer";
+ CODE_SIGN_IDENTITY = "iPhone Developer: Gianluca Orsini (9T4EXXT4HH)";
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer: Gianluca Orsini (9T4EXXT4HH)";
COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_PRECOMPILE_PREFIX_HEADER = YES;
@@ -2037,7 +2040,8 @@
);
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "FastPdfKit Kiosk";
- PROVISIONING_PROFILE = "";
+ PROVISIONING_PROFILE = "C0B27C15-C18D-480B-BA36-A6F14D925A41";
+ "PROVISIONING_PROFILE[sdk=iphoneos*]" = "C0B27C15-C18D-480B-BA36-A6F14D925A41";
SDKROOT = iphoneos;
SKIP_INSTALL = NO;
ZERO_LINK = NO;
@@ -2048,7 +2052,8 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
- CODE_SIGN_IDENTITY = "iPhone Developer";
+ CODE_SIGN_IDENTITY = "iPhone Developer: Gianluca Orsini (9T4EXXT4HH)";
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer: Gianluca Orsini (9T4EXXT4HH)";
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "OtherSources/FastPDFKitKiosk-Prefix.pch";
HEADER_SEARCH_PATHS = (
@@ -2064,7 +2069,8 @@
);
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "FastPdfKit Kiosk";
- PROVISIONING_PROFILE = "";
+ PROVISIONING_PROFILE = "C0B27C15-C18D-480B-BA36-A6F14D925A41";
+ "PROVISIONING_PROFILE[sdk=iphoneos*]" = "C0B27C15-C18D-480B-BA36-A6F14D925A41";
SDKROOT = iphoneos;
SKIP_INSTALL = NO;
};

0 comments on commit 5a2f493

Please sign in to comment.