|
@@ -13,10 +13,14 @@
|
|
|
#import "RAUtils.h"
|
|
#import "RAUtils.h"
|
|
|
#import "JLRefreshHeader.h"
|
|
#import "JLRefreshHeader.h"
|
|
|
#import "JLRefreshFooter.h"
|
|
#import "JLRefreshFooter.h"
|
|
|
|
|
+#import <QuickLook/QuickLook.h>
|
|
|
|
|
|
|
|
static const int delta = 25;
|
|
static const int delta = 25;
|
|
|
|
|
|
|
|
-@interface ResultViewController () <JLRefreshDelegate>
|
|
|
|
|
|
|
+@interface ResultViewController () <JLRefreshDelegate,QLPreviewControllerDataSource,QLPreviewControllerDelegate>
|
|
|
|
|
+
|
|
|
|
|
+@property (nonatomic,strong) QLPreviewController *quickLook;
|
|
|
|
|
+@property (nonatomic,copy) NSString *documentPath;
|
|
|
|
|
|
|
|
@property (nonatomic,assign) NSInteger offset;
|
|
@property (nonatomic,assign) NSInteger offset;
|
|
|
@property (nonatomic,strong) NSDictionary *params;
|
|
@property (nonatomic,strong) NSDictionary *params;
|
|
@@ -398,6 +402,21 @@ static const int delta = 25;
|
|
|
|
|
|
|
|
- (void)downloadItemClick:(UIBarButtonItem *)sender {
|
|
- (void)downloadItemClick:(UIBarButtonItem *)sender {
|
|
|
|
|
|
|
|
|
|
+ __weak typeof(self) weakSelf = self;
|
|
|
|
|
+ dispatch_async(dispatch_get_global_queue(0, 0), ^{
|
|
|
|
|
+
|
|
|
|
|
+ NSMutableDictionary *params = self.params.mutableCopy;
|
|
|
|
|
+ NSString *path = [RANetwork download_query:params];
|
|
|
|
|
+ weakSelf.documentPath = path;
|
|
|
|
|
+
|
|
|
|
|
+ if (path) {
|
|
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
|
+ [weakSelf.navigationController pushViewController:weakSelf.quickLook animated:YES];
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- (NSInteger)resultItemCount {
|
|
- (NSInteger)resultItemCount {
|
|
@@ -527,4 +546,40 @@ static const int delta = 25;
|
|
|
}];
|
|
}];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+#pragma mark - Quick Look
|
|
|
|
|
+
|
|
|
|
|
+- (QLPreviewController *)quickLook {
|
|
|
|
|
+ if (!_quickLook) {
|
|
|
|
|
+ _quickLook = [[QLPreviewController alloc] init];
|
|
|
|
|
+ _quickLook.delegate = self;
|
|
|
|
|
+ _quickLook.dataSource = self;
|
|
|
|
|
+ }
|
|
|
|
|
+ return _quickLook;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+#pragma mark - QuickLook Data Source
|
|
|
|
|
+
|
|
|
|
|
+- (NSInteger)numberOfPreviewItemsInPreviewController:(QLPreviewController *)controller {
|
|
|
|
|
+ return 1;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+- (id <QLPreviewItem>) previewController:(QLPreviewController *)controller previewItemAtIndex:(NSInteger)index {
|
|
|
|
|
+
|
|
|
|
|
+ return [NSURL fileURLWithPath:self.documentPath];
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+#pragma mark - QuickLook Delegate
|
|
|
|
|
+
|
|
|
|
|
+- (void) previewControllerDidDismiss:(QLPreviewController *)controller {
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 文件内部链接点击不进行外部跳转
|
|
|
|
|
+ */
|
|
|
|
|
+- (BOOL) previewController:(QLPreviewController *)controller shouldOpenURL:(NSURL *)url forPreviewItem:(id<QLPreviewItem>)item {
|
|
|
|
|
+ return NO;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
@end
|
|
@end
|