Permalink
Browse files

25112011

- Renamed MFHomeListPdf to BookItemView (watch out for subclasses).
- Cleaned up things.
  • Loading branch information...
1 parent 05da06b commit 9a95543627222eed46aa8348aace614e4094034c @s1g53gv s1g53gv committed Nov 25, 2011
@@ -11,7 +11,7 @@
#import "MenuViewController_Kiosk.h"
#import <Newsstandkit/NewsstandKit.h>
-@interface MFHomeListPdf : UIViewController <UIActionSheetDelegate,NSURLConnectionDownloadDelegate>{
+@interface BookItemView : UIViewController <UIActionSheetDelegate,NSURLConnectionDownloadDelegate>{
id object;
NSString *thumbName;
@@ -6,7 +6,7 @@
// Copyright 2009 MobFarm s.r.l.. All rights reserved.
//
-#import "MFHomeListPdf.h"
+#import "BookItemView.h"
#import "MenuViewController_Kiosk.h"
#import "ZipArchive.h"
#import "FastPDFKit_KioskAppDelegate.h"
@@ -16,7 +16,7 @@
#define TITLE_REMOVE @"Remove"
#define TITLE_RESUME @"Resume"
-@implementation MFHomeListPdf
+@implementation BookItemView
@synthesize object, temp, dataSource ,corner,documentNumber;
@synthesize menuViewController;
@synthesize page,titleOfPdf;
@@ -43,6 +43,7 @@ - (id)initWithName:(NSString *)Page andTitoloPdf:(NSString *)titlePdf andLinkPdf
documentNumber = numDoc;
temp = NO;
+
return self;
}
@@ -901,7 +902,6 @@ - (void)dealloc {
[page release];
[downloadUrl release];
- [thumbName release];
[removeButton release];
[openButton release];
[thumbImage release];
@@ -14,11 +14,8 @@
@interface MenuViewController_Kiosk : UIViewController {
- UIView * downloadProgressContainerView;
-
- UIProgressView * downloadProgressView;
-
- NSMutableArray * homeListPdfs;
+ NSMutableArray * bookItemViews;
+
NSMutableDictionary * buttonRemoveDict;
NSMutableDictionary * openButtons;
NSMutableDictionary * progressViewDict;
@@ -27,24 +24,22 @@
NSMutableArray *documentsList;
UIScrollView *scrollView;
+
+ UIView * downloadProgressContainerView;
+ UIProgressView * downloadProgressView;
BOOL graphicsMode;
BOOL interfaceLoaded;
+
+ BOOL xmlDirty;
}
-(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;
-//@property (nonatomic, assign) UIAlertView *passwordAlertView;
-//@property (nonatomic, assign) NSString *documentName;
@property (nonatomic,retain ) NSDictionary *buttonRemoveDict;
@property (nonatomic,retain ) NSDictionary *openButtons;
@property (nonatomic,retain ) NSDictionary *progressViewDict;
@@ -9,7 +9,7 @@
#import "MenuViewController_Kiosk.h"
#import "MFDocumentManager.h"
#import "ReaderViewController.h"
-#import "MFHomeListPdf.h"
+#import "BookItemView.h"
#import "XMLParser.h"
#include <stdio.h>
#include <stdlib.h>
@@ -47,8 +47,6 @@ -(IBAction)actionOpenPlainDocument:(NSString *)documentName {
pdfPath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@",documentName]];
-
-
// Now that we have the URL, we can allocate an istance of the MFDocumentManager class and use
// it to initialize an MFDocumentViewController subclass
@@ -76,7 +74,9 @@ -(id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
progressViewDict = [[NSMutableDictionary alloc] init];
imgDict = [[NSMutableDictionary alloc] init];
- homeListPdfs = [[NSMutableArray alloc]init];
+ bookItemViews = [[NSMutableArray alloc]init];
+
+ xmlDirty = YES;
}
@@ -91,45 +91,39 @@ - (void)viewDidLoad {
XMLParser *parser = nil;
NSURL * xmlUrl = nil;
- parser = [[XMLParser alloc] init];
- xmlUrl = [NSURL URLWithString:FPK_KIOSK_XML_URL];
- [parser parseXMLFileAtURL:xmlUrl];
-
- [self.documentsList retain];
- self.documentsList = nil;
-
- NSMutableArray *anArray = [[NSMutableArray alloc]init];
-
- // Try to parse the remote URL. If it fails, fallback to the local xml.
-
- if([parser isDone]) {
-
- self.documentsList = [parser parsedItems];
-
+ if(xmlDirty) {
- } else {
-
- xmlUrl = [MF_BUNDLED_BUNDLE(@"FPKKioskBundle") URLForResource:FPK_KIOSK_XML_NAME withExtension:@"xml"];
+ xmlDirty = NO;
+
+ parser = [[XMLParser alloc] init];
+ xmlUrl = [NSURL URLWithString:FPK_KIOSK_XML_URL];
[parser parseXMLFileAtURL:xmlUrl];
-
+
if([parser isDone]) {
+
self.documentsList = [parser parsedItems];
+
+ } else {
+
+ xmlUrl = [MF_BUNDLED_BUNDLE(@"FPKKioskBundle") URLForResource:FPK_KIOSK_XML_NAME withExtension:@"xml"];
+
+ [parser parseXMLFileAtURL:xmlUrl];
+
+ if([parser isDone]) {
+ self.documentsList = [parser parsedItems];
+ }
}
+
+ [parser release];
}
-
- [parser release];
-
-
- [self performSelector:@selector(buildInterface) withObject:nil afterDelay:0.5];
-
+ //[self performSelector:@selector(buildInterface) withObject:nil afterDelay:0.5];
+ [self buildInterface];
}
-(void)buildInterface{
-
-
UIScrollView * aScrollView = nil;
CGFloat yBorder = 0 ;
UIImageView * anImageView = nil;
@@ -140,7 +134,7 @@ -(void)buildInterface{
NSString * linkPdf = nil;
NSString * copertinaPdf = nil;
- MFHomeListPdf * viewPdf = nil;
+ BookItemView * bookItemView = nil;
int documentsCount; // Used to iterate over each item in the list.
@@ -183,13 +177,7 @@ -(void)buildInterface{
documentsCount = [documentsList count];
- NSLog(@"Documents Count %i",documentsCount);
-
- if (scrollView) {
- [scrollView removeFromSuperview];
- }else{
-
- // Border.
+ // Border.
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
yBorder = scrollViewVOffset-3 ;
@@ -201,9 +189,7 @@ -(void)buildInterface{
[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.contentSize = CGSizeMake(scrollViewWidth, detailViewHeight * ((documentsCount/2)+(documentsCount%2)));
@@ -215,7 +201,7 @@ -(void)buildInterface{
linkPdf = [[documentsList objectAtIndex: i-1] objectForKey: @"link"];
copertinaPdf = [[documentsList objectAtIndex: i-1] objectForKey: @"cover"];
- viewPdf = [[MFHomeListPdf alloc] initWithName:titoloPdfNoSpace andTitoloPdf:titoloPdf andLinkPdf:linkPdf andnumOfDoc:i andImage:copertinaPdf andSize:CGSizeMake(thumbWidth, thumbHeight)];
+ bookItemView = [[BookItemView alloc] initWithName:titoloPdfNoSpace andTitoloPdf:titoloPdf andLinkPdf:linkPdf andnumOfDoc:i andImage:copertinaPdf andSize:CGSizeMake(thumbWidth, thumbHeight)];
frame = self.view.frame;
@@ -231,27 +217,28 @@ -(void)buildInterface{
frame.size.height = detailViewHeight;
}
- viewPdf.view.frame = frame;
- viewPdf.menuViewController = self;
- [aScrollView addSubview:viewPdf.view];
+ bookItemView.view.frame = frame;
+ bookItemView.menuViewController = self;
+ [aScrollView addSubview:bookItemView.view];
// Adding stuff to their respective containers.
- [imgDict setValue:viewPdf.openButtonFromImage forKey:titoloPdfNoSpace];
- [openButtons setValue:viewPdf.openButton forKey:titoloPdfNoSpace];
- [buttonRemoveDict setValue:viewPdf.removeButton forKey:titoloPdfNoSpace];
- [progressViewDict setValue:viewPdf.progressDownload forKey:titoloPdfNoSpace];
+ [imgDict setValue:bookItemView.openButtonFromImage forKey:titoloPdfNoSpace];
+ [openButtons setValue:bookItemView.openButton forKey:titoloPdfNoSpace];
+ [buttonRemoveDict setValue:bookItemView.removeButton forKey:titoloPdfNoSpace];
+ [progressViewDict setValue:bookItemView.progressDownload forKey:titoloPdfNoSpace];
- [homeListPdfs addObject:viewPdf];
- [viewPdf release];
+ [bookItemViews addObject:bookItemView];
+ [bookItemView release];
}
- scrollView = aScrollView;
+
+ self.scrollView = aScrollView;
+ [aScrollView release];
+
[self.view addSubview:scrollView];
+
interfaceLoaded = YES;
- // self.scrollView = aScrollView; // Not referenced anywhere else.
- [aScrollView release];
-
}
@@ -280,15 +267,15 @@ - (void)didReceiveMemoryWarning {
- (void)viewDidUnload {
- [super viewDidUnload];
-
[buttonRemoveDict removeAllObjects];
[openButtons removeAllObjects];
[progressViewDict removeAllObjects];
[imgDict removeAllObjects];
- [homeListPdfs removeAllObjects];
- scrollView = nil;
-
+ [bookItemViews removeAllObjects];
+
+ self.scrollView = nil;
+
+ [super viewDidUnload];
}
@@ -305,7 +292,7 @@ - (void)dealloc {
[scrollView release];
- [homeListPdfs release];
+ [bookItemViews release];
[super dealloc];
}
Oops, something went wrong.

0 comments on commit 9a95543

Please sign in to comment.