Skip to content

Commit

Permalink
加入 DaiPortal, update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
DaidoujiChen committed Nov 26, 2014
1 parent 33ccc30 commit f318634
Show file tree
Hide file tree
Showing 15 changed files with 825 additions and 28 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,10 @@ [email protected]
- 提供一些不同於系統色的一些額外色調.

- Icons8 App
- 可以免費取得一些 icon 的小工具.
- 可以免費取得一些 icon 的小工具.

- DaiInboxHUD
- 我自己隔壁棚的工具, 是個模仿 inbox app 等待中的 hud.

- DaiPortalV2
- 我自己隔壁棚的工具, 導進來試用看看, 一邊做調整, 目前的定位還不是太清楚, 試用中.
38 changes: 38 additions & 0 deletions e-Hentai.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@
0180D92C1A02140E002554FC /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 0180D92A1A02140E002554FC /* [email protected] */; };
0180D92F1A0214AD002554FC /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 0180D92D1A0214AD002554FC /* [email protected] */; };
0180D9301A0214AD002554FC /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 0180D92E1A0214AD002554FC /* [email protected] */; };
019290211A25D6C70094B423 /* DaiPortal.m in Sources */ = {isa = PBXBuildFile; fileRef = 019290181A25D6C70094B423 /* DaiPortal.m */; };
019290221A25D6C70094B423 /* DaiPortalBlockAnalysis.m in Sources */ = {isa = PBXBuildFile; fileRef = 0192901A1A25D6C70094B423 /* DaiPortalBlockAnalysis.m */; };
019290231A25D6C70094B423 /* DaiPortalPerformHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 0192901C1A25D6C70094B423 /* DaiPortalPerformHelper.m */; };
019290241A25D6C70094B423 /* DaiPortalWarehouse.m in Sources */ = {isa = PBXBuildFile; fileRef = 0192901E1A25D6C70094B423 /* DaiPortalWarehouse.m */; };
019290251A25D6C70094B423 /* NSObject+DaiPortal.m in Sources */ = {isa = PBXBuildFile; fileRef = 019290201A25D6C70094B423 /* NSObject+DaiPortal.m */; };
0199268919ADDB83009F814B /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0199268819ADDB83009F814B /* Foundation.framework */; };
0199268B19ADDB83009F814B /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0199268A19ADDB83009F814B /* CoreGraphics.framework */; };
0199268D19ADDB83009F814B /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0199268C19ADDB83009F814B /* UIKit.framework */; };
Expand Down Expand Up @@ -189,6 +194,16 @@
0180D92A1A02140E002554FC /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
0180D92D1A0214AD002554FC /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
0180D92E1A0214AD002554FC /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
019290171A25D6C70094B423 /* DaiPortal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DaiPortal.h; sourceTree = "<group>"; };
019290181A25D6C70094B423 /* DaiPortal.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DaiPortal.m; sourceTree = "<group>"; };
019290191A25D6C70094B423 /* DaiPortalBlockAnalysis.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DaiPortalBlockAnalysis.h; sourceTree = "<group>"; };
0192901A1A25D6C70094B423 /* DaiPortalBlockAnalysis.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DaiPortalBlockAnalysis.m; sourceTree = "<group>"; };
0192901B1A25D6C70094B423 /* DaiPortalPerformHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DaiPortalPerformHelper.h; sourceTree = "<group>"; };
0192901C1A25D6C70094B423 /* DaiPortalPerformHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DaiPortalPerformHelper.m; sourceTree = "<group>"; };
0192901D1A25D6C70094B423 /* DaiPortalWarehouse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DaiPortalWarehouse.h; sourceTree = "<group>"; };
0192901E1A25D6C70094B423 /* DaiPortalWarehouse.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DaiPortalWarehouse.m; sourceTree = "<group>"; };
0192901F1A25D6C70094B423 /* NSObject+DaiPortal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSObject+DaiPortal.h"; sourceTree = "<group>"; };
019290201A25D6C70094B423 /* NSObject+DaiPortal.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSObject+DaiPortal.m"; sourceTree = "<group>"; };
0199268519ADDB83009F814B /* e-Hentai.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "e-Hentai.app"; sourceTree = BUILT_PRODUCTS_DIR; };
0199268819ADDB83009F814B /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
0199268A19ADDB83009F814B /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
Expand Down Expand Up @@ -342,6 +357,7 @@
0150033619B6E5E90055F47D /* ThirdParty */ = {
isa = PBXGroup;
children = (
019290161A25D6C70094B423 /* DaiPortal */,
01624CDF1A0B5A6400568EC8 /* DaiInboxHUD */,
016DAD9419E392F900E528BE /* GooglePlus */,
016BBEF919B94E4F0015E11E /* FilesManager */,
Expand Down Expand Up @@ -486,6 +502,23 @@
path = MenuViewController;
sourceTree = "<group>";
};
019290161A25D6C70094B423 /* DaiPortal */ = {
isa = PBXGroup;
children = (
019290171A25D6C70094B423 /* DaiPortal.h */,
019290181A25D6C70094B423 /* DaiPortal.m */,
019290191A25D6C70094B423 /* DaiPortalBlockAnalysis.h */,
0192901A1A25D6C70094B423 /* DaiPortalBlockAnalysis.m */,
0192901B1A25D6C70094B423 /* DaiPortalPerformHelper.h */,
0192901C1A25D6C70094B423 /* DaiPortalPerformHelper.m */,
0192901D1A25D6C70094B423 /* DaiPortalWarehouse.h */,
0192901E1A25D6C70094B423 /* DaiPortalWarehouse.m */,
0192901F1A25D6C70094B423 /* NSObject+DaiPortal.h */,
019290201A25D6C70094B423 /* NSObject+DaiPortal.m */,
);
path = DaiPortal;
sourceTree = "<group>";
};
0199267C19ADDB83009F814B = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -747,6 +780,7 @@
016BBF0D19B94E4F0015E11E /* LightWeightPlist+AccessObject.m in Sources */,
0150034519B6E5E90055F47D /* TFHppleElement.m in Sources */,
016BBF0C19B94E4F0015E11E /* FMStream.m in Sources */,
019290221A25D6C70094B423 /* DaiPortalBlockAnalysis.m in Sources */,
0150034619B6E5E90055F47D /* XPathQuery.m in Sources */,
01624CE81A0B5A6400568EC8 /* DaiInboxHUD.m in Sources */,
01FB6FD419E23FB4006CBEF2 /* NSString+Hentai.m in Sources */,
Expand All @@ -760,16 +794,20 @@
01BFAD5119DE435700A5649F /* SettingViewController.m in Sources */,
0118081519B6F06200FE0DA1 /* FakeViewController.m in Sources */,
01624CEB1A0B5A6400568EC8 /* DaiIndoxWindow.m in Sources */,
019290241A25D6C70094B423 /* DaiPortalWarehouse.m in Sources */,
017AE5C21A00D24600317939 /* SearchFilterViewController.m in Sources */,
0118081B19B6F06200FE0DA1 /* PhotoViewController.m in Sources */,
0137F40F19C1695800528359 /* HentaiDownloadBookOperation.m in Sources */,
016BBF1019B94E4F0015E11E /* LightWeightPlist+SourceFromDisk.m in Sources */,
019290231A25D6C70094B423 /* DaiPortalPerformHelper.m in Sources */,
01A166EC19E28D5E00203360 /* NSDictionary+Hentai.m in Sources */,
01BC52251A0CC04B00B37891 /* DaiInboxDisplayLink.m in Sources */,
011AEA5119DD28DE00A15CA5 /* SliderViewController.m in Sources */,
01624CEA1A0B5A6400568EC8 /* DaiInboxViewController.m in Sources */,
019290251A25D6C70094B423 /* NSObject+DaiPortal.m in Sources */,
01BBD60119E3D428003538CF /* HentaiPhotoCell.m in Sources */,
016BBF1119B94E4F0015E11E /* LightWeightPlist.m in Sources */,
019290211A25D6C70094B423 /* DaiPortal.m in Sources */,
016BBF0B19B94E4F0015E11E /* FilesManager.m in Sources */,
0163C7D719D8FD5300105ECF /* DownloadedViewController.m in Sources */,
01624CE91A0B5A6400568EC8 /* DaiInboxView.m in Sources */,
Expand Down
26 changes: 9 additions & 17 deletions e-Hentai/HentaiDownloadCenter/HentaiDownloadBookOperation.m
Original file line number Diff line number Diff line change
Expand Up @@ -166,22 +166,14 @@ - (void)checkEndOfFile {
@weakify(self);
[HentaiParser requestImagesAtURL:self.hentaiInfo[@"url"] atIndex:self.hentaiIndex completion: ^(HentaiParserStatus status, NSArray *images) {
@strongify(self);
if (![self isCancelled]) {
switch (status) {
case HentaiParserStatusSuccess:
[self.hentaiImageURLs addObjectsFromArray:images];
[self preloadImages:images];
[self waitingOnDownloadFinish];
break;
case HentaiParserStatusNetworkFail:
[UIAlertView hentai_alertViewWithTitle:self.hentaiInfo[@"title"] message:@"網路失敗~所以無法下載~" cancelButtonTitle:@"好~ O3O"];
[self hentaiFinish];
break;
case HentaiParserStatusParseFail:
[UIAlertView hentai_alertViewWithTitle:self.hentaiInfo[@"title"] message:@"被移除囉~所以無法下載~" cancelButtonTitle:@"好~ O3O"];
[self hentaiFinish];
break;
}
if (status && ![self isCancelled] && [images count]) {
[self.hentaiImageURLs addObjectsFromArray:images];
[self preloadImages:images];
[self waitingOnDownloadFinish];
}
else {
[UIAlertView hentai_alertViewWithTitle:self.hentaiInfo[@"title"] message:@"被移除囉~所以無法下載~" cancelButtonTitle:@"好~ O3O"];
[self hentaiFinish];
}
}];
}
Expand All @@ -196,7 +188,7 @@ - (void)checkEndOfFile {
[HentaiCacheLibraryDictionary removeObjectForKey:self.hentaiKey];
LWPForceWrite();
)
[[NSNotificationCenter defaultCenter] postNotificationName:HentaiDownloadSuccessNotification object:self.hentaiInfo[@"title"]];
[[self portal:HentaiDownloadSuccessNotification] send:[DaiPortalPackage item:self.hentaiInfo[@"title"]]];
[self hentaiFinish];
}
else {
Expand Down
17 changes: 7 additions & 10 deletions e-Hentai/MainViewController/MainViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,11 @@ - (void)reloadDatas {
//把 request 的判斷都放到這個 method 裡面來
- (void)loadList:(void (^)(BOOL successed, NSArray *listArray))completion {
[HentaiParser requestListAtFilterUrl:self.filterString completion: ^(HentaiParserStatus status, NSArray *listArray) {
switch (status) {
case HentaiParserStatusSuccess:
completion(YES, listArray);
break;
case HentaiParserStatusParseFail:
case HentaiParserStatusNetworkFail:
completion(NO, nil);
break;
if (status && [listArray count]) {
completion(YES, listArray);
}
else {
completion(NO, nil);
}
}];
}
Expand Down Expand Up @@ -228,10 +225,10 @@ - (void)setupRecvNotifications {

//接 HentaiDownloadSuccessNotification
@weakify(self);
[[[NSNotificationCenter defaultCenter] rac_addObserverForName:HentaiDownloadSuccessNotification object:nil] subscribeNext: ^(NSNotification *notification) {
[[self portal:HentaiDownloadSuccessNotification] recv: ^(NSString *alertViewMessage) {
@strongify(self);
if (self && [UIApplication sharedApplication].keyWindow.rootViewController.presentedViewController == nil) {
[UIAlertView hentai_alertViewWithTitle:@"下載完成!" message:notification.object cancelButtonTitle:@"好~ O3O"];
[UIAlertView hentai_alertViewWithTitle:@"下載完成!" message:alertViewMessage cancelButtonTitle:@"好~ O3O"];
}
}];
}
Expand Down
59 changes: 59 additions & 0 deletions e-Hentai/ThirdParty/DaiPortal/DaiPortal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
//
// DaiPortal.h
// DaiPortalV2
//
// Created by 啟倫 陳 on 2014/11/24.
// Copyright (c) 2014年 ChilunChen. All rights reserved.
//

#import <Foundation/Foundation.h>

//為了統一傳進跟回傳的東西, 所以用一個固定的格式來規範
@interface DaiPortalPackage : NSObject

//空的包包, 什麼都沒有
+ (DaiPortalPackage *)empty;

//只有一個物件
+ (DaiPortalPackage *)item:(id)anItem;

//很多的物件
+ (DaiPortalPackage *)items:(id)firstItem, ...NS_REQUIRES_NIL_TERMINATION;

@end

typedef void (^VoidBlock)();
typedef DaiPortalPackage *(^PackageBlock)();

@interface DaiPortal : NSObject

//分別是該傳送門的識別名稱跟所依附的物件
@property (nonatomic, strong) NSString *identifier;
@property (nonatomic, weak) id dependObject;

@end

//建立用來接收資料的部分, 收到觸發時會運行 aBlock 的內容, 帶上 warp 結尾的 method, block 內的 code 會以非同步方式運行
@interface DaiPortal (Reciver)

- (void)recv:(VoidBlock)aBlock;
- (void)recv_warp:(VoidBlock)aBlock;
- (void)respond:(PackageBlock)aBlock;
- (void)respond_warp:(PackageBlock)aBlock;

@end

//用來傳送資料的部分, 負責觸發已建立的傳送門, 帶上 warp 結尾的 method, block 內的 code 會以非同步方式運行
@interface DaiPortal (Sender)

//send 為傳一個以上的東西過去, send 則為純粹的觸發
- (void)send:(DaiPortalPackage *)package;
- (void)send;

//帶上 result 的話可以收到回傳的訊息
- (void)send:(DaiPortalPackage *)package completion:(VoidBlock)completion;
- (void)send:(DaiPortalPackage *)package completion_warp:(VoidBlock)completion;
- (void)completion:(VoidBlock)completion;
- (void)completion_warp:(VoidBlock)completion;

@end
Loading

0 comments on commit f318634

Please sign in to comment.