ResultViewController.m 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251
  1. //
  2. // ViewController.m
  3. // phoneTest
  4. //
  5. // Created by Ray on 01/09/2017.
  6. //
  7. //
  8. #define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
  9. #import "ResultViewController.h"
  10. #import "FullyShowViewController.h"
  11. #import "RANetwork.h"
  12. #import "RAUtils.h"
  13. #import "JLRefreshHeader.h"
  14. #import "JLRefreshFooter.h"
  15. //#import "OrderDetailViewController.h"
  16. //#import "KVViewController.h"
  17. #import <QuickLook/QuickLook.h>
  18. #import "config.h"
  19. #import "RAConvertor.h"
  20. #import "RAUtils.h"
  21. //#import "RTLabel.h"
  22. #import "ResultCell.h"
  23. #import <AudioToolbox/AudioToolbox.h>
  24. const int delta = 25;
  25. @interface ResultViewController () <JLRefreshDelegate,QLPreviewControllerDataSource,QLPreviewControllerDelegate,UIViewControllerPreviewingDelegate,ResultCellTouchDelegate,UITableViewDelegate,UITableViewDataSource>
  26. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *w_constraint;
  27. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *h_constraint;
  28. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *trail_constraint;
  29. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *lead_constraint;
  30. @end
  31. @implementation ResultViewController
  32. + (instancetype)buildInstanceWithParams:(NSMutableDictionary *)params {
  33. id resultVC = [[self alloc] initWithNibName:@"Result" bundle:nil];
  34. ((ResultViewController *)resultVC).params = params;
  35. return resultVC;
  36. }
  37. - (void)labelClick {
  38. NSLog(@"underlineLabel被点击了");
  39. }
  40. - (void)resetContraint {
  41. for (NSLayoutConstraint *constraint in self.view.constraints) {
  42. if ([constraint.identifier isEqualToString:@"title_top"] ) {
  43. [self.view removeConstraint:constraint];
  44. }
  45. if ([constraint.identifier isEqualToString:@"scroll_bottom"]) {
  46. [self.view removeConstraint:constraint];
  47. }
  48. }
  49. NSLayoutConstraint *scroll_top = [NSLayoutConstraint constraintWithItem:self.titleBar
  50. attribute:NSLayoutAttributeTop
  51. relatedBy:NSLayoutRelationEqual
  52. toItem:self.topLayoutGuide
  53. attribute:NSLayoutAttributeBottom
  54. multiplier:1.0
  55. constant:0];
  56. NSLayoutConstraint *scroll_bottom = [NSLayoutConstraint constraintWithItem:self.scrollview
  57. attribute:NSLayoutAttributeBottom
  58. relatedBy:NSLayoutRelationEqual
  59. toItem:self.bottomLayoutGuide
  60. attribute:NSLayoutAttributeTop
  61. multiplier:1.0
  62. constant:0];
  63. [self.view addConstraint:scroll_top];
  64. [self.view addConstraint:scroll_bottom];
  65. CGFloat height = self.bottomLayoutGuide.length;
  66. self.bottom_mask_constraint.constant = height;
  67. }
  68. - (void)viewDidLayoutSubviews {
  69. [super viewDidLayoutSubviews];
  70. [self resetContraint];
  71. }
  72. - (void)viewDidLoad {
  73. [super viewDidLoad];
  74. self.default_row_text_size=14;
  75. self.default_title_text_size=17;
  76. self.default_line_color = 0x000000;
  77. self.titleLabel.text = nil;
  78. // self.labelTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(labelTapAction:)];
  79. //
  80. // self.labelTap.numberOfTouchesRequired = 1; //手指数
  81. // self.labelTap.numberOfTapsRequired = 2; //tap次数
  82. //
  83. //
  84. //
  85. //
  86. // self.cellDoubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(cellDoubleTapAction:)];
  87. //
  88. // self.cellDoubleTap.numberOfTouchesRequired = 1; //手指数
  89. // self.cellDoubleTap.numberOfTapsRequired = 2; //tap次数
  90. // UITapGestureRecognizer *singleFingerOne = [[UITapGestureRecognizer alloc] initWithTarget:self
  91. // action:nil];
  92. // singleFingerOne.numberOfTouchesRequired = 1; //手指数
  93. // singleFingerOne.numberOfTapsRequired = 1; //tap次数
  94. //
  95. //
  96. // singleFingerTwo.delegate = self;
  97. self.label = [MDHTMLLabel new];
  98. self.label.font = [UIFont systemFontOfSize:self.default_row_text_size];
  99. self.label.textInsets = UIEdgeInsetsMake(0.f, 8.f, 0.f, 8.f);
  100. // NSString* Path = [[NSBundle mainBundle] pathForResource:@"layout.json" ofType:nil];
  101. //
  102. // NSData *data = [NSData dataWithContentsOfFile:Path];
  103. // self.content_layout = [[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil] mutableCopy];
  104. //
  105. //
  106. // Path = [[NSBundle mainBundle] pathForResource:@"data.json" ofType:nil];
  107. //
  108. // data = [NSData dataWithContentsOfFile:Path];
  109. // self.content_data = [[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil] mutableCopy];
  110. // int width=[self.content_layout[@"header"][@"width"] intValue];
  111. // if(width<self.tableview.frame.size.width)
  112. // width=self.tableview.frame.size.width;
  113. //
  114. // CGRect frame = CGRectMake(self.tableview.frame.origin.x, self.tableview.frame.origin.y, width, self.tableview.frame.size.height);
  115. // self.tableview.frame=frame;
  116. // self.scrollview.contentSize=self.tableview.frame.size;
  117. // Do any additional setup after loading the view, typically from a nib.
  118. self.automaticallyAdjustsScrollViewInsets = NO;
  119. self.tableview.tableFooterView = [UIView new];
  120. [self setupNavigationBar];
  121. [self configureTableView];
  122. [self setupTableRefreshView];
  123. [self loadContent];
  124. // self.tableview.tableHeaderView = [self get_tableHeader];
  125. }
  126. - (void)viewWillAppear:(BOOL)animated {
  127. [super viewWillAppear:animated];
  128. }
  129. -(void)labelTapAction:(UIGestureRecognizer*)gestureRecognizer
  130. {
  131. NSLog(@"label touched");
  132. MDHTMLLabel* label = (MDHTMLLabel*)[gestureRecognizer view];
  133. self.label.htmlText = label.htmlText;
  134. [self.label sizeToFit];
  135. if(self.label.frame.size.width>label.frame.size.width||self.label.frame.size.height>label.frame.size.height)
  136. {
  137. FullyShowViewController *fullVC = [[UIStoryboard storyboardWithName:@"Result" bundle:nil] instantiateViewControllerWithIdentifier:@"fullyShowViewController"];
  138. fullVC.htmlText = label.htmlText;
  139. fullVC.preferredContentSize = CGSizeMake(200, 240);
  140. fullVC.modalPresentationStyle=UIModalPresentationPopover;
  141. UIPopoverPresentationController* popPc = fullVC.popoverPresentationController;
  142. popPc.permittedArrowDirections = UIPopoverArrowDirectionAny;
  143. CGRect rectl = [RAUtils relativeFrameForScreenWithView:label];
  144. CGRect rectv =[RAUtils relativeFrameForScreenWithView:self.view];
  145. CGRect intersection_rect=CGRectIntersection(rectl, rectv);
  146. UIWindow * window=[[[UIApplication sharedApplication] delegate] window];
  147. CGRect source_rect=[RAUtils relativeFrame:intersection_rect FromView:window toView:label];
  148. // CGRect rect=[v convertRect: v.bounds toView:window];
  149. popPc.sourceRect = source_rect;
  150. popPc.sourceView = label;
  151. // popPc.barButtonItem = label;
  152. popPc.delegate = self;
  153. [self presentViewController:fullVC animated:true completion:nil];
  154. }
  155. }
  156. - (void)didReceiveMemoryWarning {
  157. [super didReceiveMemoryWarning];
  158. // Dispose of any resources that can be recreated.
  159. }
  160. - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
  161. }
  162. -(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
  163. {
  164. // auto resizing
  165. // self.scrollview.contentSize=self.tableview.frame.size;
  166. // auto layout
  167. // int width=[self.content_layout[@"header"][@"width"] intValue];
  168. // if(width<self.view.frame.size.width)
  169. // width=self.view.frame.size.width;
  170. // self.w_constraint.constant = width - CGRectGetWidth(self.view.bounds);
  171. // self.h_constraint.constant = 0;
  172. [self updateTableFrame];
  173. }
  174. #pragma mark - TableView DataSource
  175. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  176. return [self.content_data[@"count"] intValue];
  177. // return 0;
  178. }
  179. //- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  180. //{
  181. // return 1;
  182. //}
  183. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  184. {
  185. int height=[self.content_layout[@"header"][@"height"] intValue];
  186. if(height==0)
  187. height=44;
  188. return height;
  189. }
  190. - (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  191. {
  192. NSArray* arr_col=self.content_layout[@"header"][@"col"];
  193. NSString* value =self.content_layout[@"header"][@"f_color"];//[DefaultAppearance get_noneappearance_value:@"DefaultTableHeaderView" valuename:@"title_text_color"];
  194. if(value==nil)
  195. value=@"";
  196. unsigned long fcolor = strtoul([value UTF8String],0,16);
  197. value =self.content_layout[@"header"][@"bg_color"];//[DefaultAppearance get_noneappearance_value:@"DefaultTableHeaderView" valuename:@"title_text_color"];
  198. if(value==nil)
  199. value=@"0xFFFFFF";
  200. unsigned long bgcolor = strtoul([value UTF8String],0,16);
  201. UIView* myView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 0.0001)];
  202. myView.backgroundColor = UIColorFromRGB(bgcolor);
  203. myView.layer.shadowPath =[UIBezierPath bezierPathWithRect:myView.bounds].CGPath;
  204. myView.layer.shadowColor = [UIColor blackColor].CGColor;
  205. myView.layer.shadowOffset = CGSizeMake(0, 0);
  206. myView.layer.shadowOpacity = 0.5;
  207. myView.layer.shadowRadius = 2.0;
  208. int x=0;//[self.content_layout[@"header"][@"margin_l"] intValue];
  209. int y=0;//[self.content_layout[@"header"][@"margin_t"] intValue];;
  210. int height = [self.content_layout[@"header"][@"height"] intValue];
  211. for(int i=0;i<arr_col.count;i++)
  212. {
  213. int width = [arr_col[i][@"width"] intValue];
  214. UILabel *headerlabel = [[UILabel alloc] initWithFrame:CGRectMake(x, y, width, height)];
  215. headerlabel.font = [UIFont boldSystemFontOfSize:self.default_title_text_size];
  216. headerlabel.textColor=UIColorFromRGB(fcolor);//UIColor.blackColor;
  217. headerlabel.backgroundColor = [UIColor clearColor];
  218. headerlabel.text=arr_col[i][@"name"];
  219. headerlabel.textAlignment= [self get_TextHAlign:arr_col[i][@"h_align"] ];
  220. // headerlabel.font = [UIFont boldSystemFontOfSize:20];
  221. // [headerlabel sizeToFit];
  222. headerlabel.layer.borderWidth=0.5;
  223. headerlabel.layer.borderColor = UIColorFromRGB(self.default_line_color).CGColor;
  224. [myView addSubview:headerlabel];
  225. x+=width;
  226. }
  227. myView.autoresizesSubviews=true;
  228. // [myView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin];
  229. // modellabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
  230. // pricelabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
  231. // timelabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
  232. myView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
  233. //
  234. return myView;
  235. }
  236. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  237. {
  238. int height=[self.content_layout[@"row"][@"height"] intValue];
  239. if(height==0)
  240. height=44;
  241. return height;
  242. }
  243. -(NSTextAlignment) get_TextHAlign:(NSString*)textHAlign
  244. {
  245. if([textHAlign.lowercaseString isEqualToString:@"center"])
  246. return NSTextAlignmentCenter;
  247. else if([textHAlign.lowercaseString isEqualToString:@"left"])
  248. return NSTextAlignmentLeft;
  249. else if([textHAlign.lowercaseString isEqualToString:@"right"])
  250. return NSTextAlignmentRight;
  251. return NSTextAlignmentLeft;
  252. }
  253. //-(RTTextAlignment) get_RTTextHAlign:(NSString*)textHAlign
  254. //{
  255. //
  256. //
  257. //
  258. //
  259. // if([textHAlign.lowercaseString isEqualToString:@"center"])
  260. // return RTTextAlignmentCenter;
  261. // else if([textHAlign.lowercaseString isEqualToString:@"left"])
  262. // return RTTextAlignmentLeft;
  263. // else if([textHAlign.lowercaseString isEqualToString:@"right"])
  264. // return RTTextAlignmentRight;
  265. //
  266. // return RTTextAlignmentLeft;
  267. //}
  268. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  269. {
  270. {
  271. NSString *CellIdentifier = @"tCell";
  272. ResultCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  273. cell.touchDelegate = self;
  274. for(UIGestureRecognizer* g in cell.gestureRecognizers)
  275. [ cell removeGestureRecognizer:g];
  276. // cell gesture
  277. // [cell removeGestureRecognizer:self.cellDoubleTap];
  278. for(UIView* v in cell.subviews)
  279. {
  280. for(UIGestureRecognizer* g in v.gestureRecognizers)
  281. [ v removeGestureRecognizer:g];
  282. [v removeFromSuperview];
  283. }
  284. // cell.detailTextLabel.text=@"detail";
  285. // cell.textLabel.text=[NSString stringWithFormat:@"%ld",indexPath.row];
  286. UITapGestureRecognizer *cellDoubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(cellDoubleTapAction:)];
  287. cellDoubleTap.numberOfTouchesRequired = 1; //手指数
  288. cellDoubleTap.numberOfTapsRequired = 2; //tap次数
  289. [cell addGestureRecognizer:cellDoubleTap];
  290. // 3D Touch
  291. // if (self.traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable) {
  292. // DebugLog(@"3D Touch 可用!");
  293. // //给cell注册3DTouch的peek(预览)和pop功能
  294. // [self registerForPreviewingWithDelegate:self sourceView:cell];
  295. // } else {
  296. // DebugLog(@"3D Touch 无效");
  297. // }
  298. NSArray* arr_col=self.content_layout[@"header"][@"col"];
  299. NSArray* item =self.content_data[[NSString stringWithFormat:@"item_%ld",indexPath.row]];
  300. NSString* value =self.content_layout[@"row"][@"f_color"];//[DefaultAppearance get_noneappearance_value:@"DefaultTableHeaderView" valuename:@"title_text_color"];
  301. if(value==nil)
  302. value=@"";
  303. unsigned long fcolor = strtoul([value UTF8String],0,16);
  304. value =self.content_layout[@"row"][@"color_0"];//[DefaultAppearance get_noneappearance_value:@"DefaultTableHeaderView" valuename:@"title_text_color"];
  305. if(value==nil)
  306. value=@"";
  307. unsigned long color0 = strtoul([value UTF8String],0,16);
  308. value =self.content_layout[@"row"][@"color_1"];//[DefaultAppearance get_noneappearance_value:@"DefaultTableHeaderView" valuename:@"title_text_color"];
  309. if(value==nil)
  310. value=@"";
  311. unsigned long color1 = strtoul([value UTF8String],0,16);
  312. int x=0;//[self.content_layout[@"header"][@"margin_l"] intValue];
  313. int y=0;//[self.content_layout[@"header"][@"margin_t"] intValue];;
  314. int height = [self.content_layout[@"row"][@"height"] intValue];
  315. for(int i=0;i<arr_col.count;i++)
  316. {
  317. int width = [arr_col[i][@"width"] intValue];;
  318. MDHTMLLabel *vallabel = [[MDHTMLLabel alloc] initWithFrame:CGRectMake(x, y, width, height)];
  319. vallabel.textInsets = UIEdgeInsetsMake(0.f, 8.f, 0.f, 8.f);
  320. vallabel.font = [UIFont systemFontOfSize:self.default_row_text_size];
  321. vallabel.textColor=UIColorFromRGB(fcolor);//UIColor.blackColor;
  322. vallabel.backgroundColor = [UIColor clearColor];
  323. NSString* text=@"";
  324. if(i>item.count-1)
  325. text=@"row data missing";
  326. else
  327. text=item[i];
  328. // RTTextLineBreakModeWordWrapping = kCTLineBreakByWordWrapping,
  329. // RTTextLineBreakModeCharWrapping = kCTLineBreakByCharWrapping,
  330. // RTTextLineBreakModeClip = kCTLineBreakByClipping,
  331. // NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:text];
  332. // vallabel.attributedText = attrStr;
  333. vallabel.htmlText = text;
  334. vallabel.textAlignment= [self get_TextHAlign:arr_col[i][@"h_align"] ];
  335. vallabel.layer.borderWidth=0.3;
  336. vallabel.layer.borderColor = UIColorFromRGB(self.default_line_color).CGColor;
  337. // UITapGestureRecognizer *gestureRecognizer = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(labelTapAction:)];
  338. UITapGestureRecognizer* labelTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(labelTapAction:)];
  339. labelTap.numberOfTouchesRequired = 1; //手指数
  340. labelTap.numberOfTapsRequired = 1; //tap次数
  341. [vallabel addGestureRecognizer:labelTap];
  342. [labelTap requireGestureRecognizerToFail:cellDoubleTap];
  343. // [vallabel addGestureRecognizer:self.cellDoubleTap];
  344. vallabel.userInteractionEnabled = YES;
  345. // [vallabel becomeFirstResponder];
  346. // vallabel.delegate = self;
  347. // [statuslabel sizeToFit];
  348. [cell addSubview:vallabel];
  349. x+=width;
  350. }
  351. if(indexPath.row%2==0)
  352. cell.backgroundColor=UIColorFromRGB(color0);//[UIColor whiteColor];
  353. else
  354. cell.backgroundColor=UIColorFromRGB(color1);//[UIColor lightGrayColor];
  355. return cell;
  356. }
  357. }
  358. - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
  359. cell.backgroundColor = [UIColor whiteColor];
  360. }
  361. //#pragma mark - TouchLabel Delegate
  362. //- (void)touchLabel:(TouchLabel *)touchLabel touchesWtihTag:(NSInteger)tag
  363. //{
  364. //
  365. //}
  366. //-(void) empty
  367. //{
  368. //
  369. //}
  370. #pragma mark - UIPopoverPresentationControllerDelegate Delegate
  371. //实现该代理方法,返回UIModalPresentationNone值,可以在iPhone设备实现popover效果
  372. -(UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller{
  373. return UIModalPresentationNone;//不适配(不区分ipad或iPhone)
  374. }
  375. #pragma mark - TableView Delegate
  376. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  377. {
  378. NSLog(@"cell selected");
  379. }
  380. - (UITableViewCellEditingStyle)tableView:(UITableView *)tv editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
  381. return UITableViewCellEditingStyleDelete;
  382. }
  383. #pragma mark - Public
  384. - (void)setQueryParams:(NSMutableDictionary *)params {
  385. self.params = params;
  386. }
  387. #pragma mark - Private
  388. - (void)setupTableRefreshView {
  389. __weak typeof(self) weakSelf = self;
  390. self.tableview.jl_header = [[JLRefreshHeader alloc] init];
  391. self.tableview.jl_header.refreshDelegate = self;
  392. self.tableview.jl_header.clear = YES;
  393. self.tableview.jl_header.offsetBlock = ^(CGFloat offset) {
  394. if (offset <= 0) {
  395. weakSelf.header_top_constraint.constant = -offset;
  396. }
  397. };
  398. self.tableview.jl_header.stateChangeBlock = ^(JLRefreshState state) {
  399. NSString *title = [weakSelf.tableview.jl_header refreshTitleForState:state];
  400. weakSelf.refreshHeaderTitleLb.text = title;
  401. };
  402. self.tableview.jl_footer = [[JLRefreshFooter alloc] init];
  403. self.tableview.jl_footer.refreshDelegate = self;
  404. self.tableview.jl_footer.clear = YES;
  405. self.tableview.jl_footer.offsetBlock = ^(CGFloat offset) {
  406. if (offset <= 0) {
  407. weakSelf.footer_top_constraint.constant = offset;
  408. }
  409. };
  410. self.tableview.jl_footer.stateChangeBlock = ^(JLRefreshState state) {
  411. NSString *title = [weakSelf.tableview.jl_footer refreshTitleForState:state];
  412. weakSelf.refreshFooterTitleLb.text = title;
  413. };
  414. }
  415. - (void)configureTableView {
  416. [self.tableview registerNib:[UINib nibWithNibName:@"ResultCell" bundle:nil] forCellReuseIdentifier:@"tCell"];
  417. }
  418. - (void)setupNavigationBar {
  419. if(self.content_menu==nil)
  420. {
  421. self.navigationItem.rightBarButtonItem=nil;
  422. return;
  423. }
  424. UIBarButtonItem *menuItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"ic_menu"] style:UIBarButtonItemStylePlain target:self action:@selector(MenuClick:)];
  425. self.navigationItem.rightBarButtonItem = menuItem;
  426. UIBarButtonItem *backItem = [[UIBarButtonItem alloc] init];
  427. backItem.title = @"Back";
  428. self.navigationItem.backBarButtonItem = backItem;
  429. }
  430. - (NSInteger)resultItemCount {
  431. return [[self.content_data objectForKey:@"count"] integerValue];
  432. }
  433. - (void)loadContent {
  434. [self loadContentWithOption:0 Complete:nil];
  435. }
  436. - (void)updateTableFrame {
  437. // auto resizing
  438. // int width=[self.content_layout[@"header"][@"width"] intValue];
  439. // if(width<self.tableview.frame.size.width)
  440. // width=self.tableview.frame.size.width;
  441. //
  442. // CGRect frame = CGRectMake(self.tableview.frame.origin.x, self.tableview.frame.origin.y, width, self.tableview.frame.size.height);
  443. // self.tableview.frame=frame;
  444. // self.scrollview.contentSize=self.tableview.frame.size;
  445. // auto layout
  446. int width=[self.content_layout[@"header"][@"width"] intValue];
  447. if(width<self.view.frame.size.width)
  448. width=self.view.frame.size.width;
  449. self.w_constraint.constant = width - CGRectGetWidth(self.view.bounds);
  450. self.h_constraint.constant = 0;
  451. // 约束修改后立即重新布局
  452. [self.view layoutIfNeeded];
  453. if (@available(iOS 11.0,*)) {
  454. UIEdgeInsets edgeInsets = [self.view safeAreaInsets];
  455. CGFloat left = edgeInsets.left;
  456. CGFloat right = edgeInsets.right;
  457. self.lead_constraint.constant = left;
  458. self.trail_constraint.constant = right;
  459. /*
  460. * lead 和 trail改变之前
  461. * scrollview.size.width = self.view.size.width;
  462. * 改变后
  463. * scrollview.size.width = self.view.size.width - left - right;
  464. * 由于w_contraint本质上是根据scrolliew.size.width决定,实际上使用self.view.size.width计算得到
  465. * 所以w_contraint需要 +left +right补偿偏差。
  466. */
  467. self.w_constraint.constant += left + right;
  468. // 约束修改后立即重新布局
  469. [self.view layoutIfNeeded];
  470. }
  471. }
  472. #pragma mark - RefreshDelegate
  473. - (void)jl_pullRefresh:(JLRefreshBasis *)refresh state:(JLRefreshState)state percentage:(float)percentage {
  474. // NSString *title = [refresh refreshTitleForState:state];
  475. // CGFloat offset = refresh.jl_height * percentage;
  476. if ([refresh isEqual:self.tableview.jl_header]) {
  477. // self.refreshHeaderTitleLb.text = title;
  478. // self.header_top_constraint.constant = offset;
  479. }
  480. if (refresh == self.tableview.jl_footer) {
  481. // self.refreshFooterTitleLb.text = title;
  482. // self.footer_top_constraint.constant = -offset;
  483. }
  484. }
  485. - (void)jl_endRefresh:(JLRefreshBasis *)refresh {
  486. // state == idle
  487. // refresh UI
  488. [self.tableview reloadData];
  489. if (refresh == self.tableview.jl_footer && refresh.state == JLRefreshStateNoMore) {
  490. }
  491. }
  492. - (void)jl_beginRefresh:(JLRefreshBasis *)refresh {
  493. // state == refreshing
  494. // load data
  495. // finish loading data
  496. int option = 0;
  497. if ([refresh isEqual:self.tableview.jl_header]) {
  498. option = 1;
  499. }
  500. if (refresh == self.tableview.jl_footer) {
  501. if(refresh.state==JLRefreshStateNoMore) //数据取完不再加载
  502. return;
  503. option = 2;
  504. }
  505. self.tableview.userInteractionEnabled = NO;
  506. __weak typeof(self) weakSelf = self;
  507. [self loadContentWithOption:option Complete:^(int result, int count) {
  508. weakSelf.tableview.userInteractionEnabled = YES;
  509. if ([refresh isEqual:weakSelf.tableview.jl_header]) {
  510. [weakSelf.tableview.jl_header performSelector:@selector(endRefresh)];
  511. }
  512. if (refresh == weakSelf.tableview.jl_footer) {
  513. [weakSelf.tableview.jl_footer performSelector:@selector(endRefresh)];
  514. if (result == 2 && count < delta) {
  515. [weakSelf.tableview.jl_footer performSelector:@selector(noMoreData)];
  516. }
  517. }
  518. }];
  519. }
  520. #pragma mark - Quick Look
  521. - (MyQLPreviewController *)quickLook {
  522. if (!_quickLook)
  523. {
  524. _quickLook = [[MyQLPreviewController alloc] init];
  525. _quickLook.delegate = self;
  526. _quickLook.dataSource = self;
  527. }
  528. else
  529. {
  530. [_quickLook reloadData];
  531. }
  532. return _quickLook;
  533. }
  534. #pragma mark - QuickLook Data Source
  535. - (NSInteger)numberOfPreviewItemsInPreviewController:(QLPreviewController *)controller {
  536. return 1;
  537. }
  538. - (id <QLPreviewItem>) previewController:(QLPreviewController *)controller previewItemAtIndex:(NSInteger)index {
  539. if(self.documentPath==nil)
  540. return nil;
  541. return [NSURL fileURLWithPath:self.documentPath];
  542. }
  543. #pragma mark - QuickLook Delegate
  544. - (void) previewControllerDidDismiss:(QLPreviewController *)controller {
  545. }
  546. /**
  547. * 文件内部链接点击不进行外部跳转
  548. */
  549. - (BOOL) previewController:(QLPreviewController *)controller shouldOpenURL:(NSURL *)url forPreviewItem:(id<QLPreviewItem>)item {
  550. return NO;
  551. }
  552. #pragma mark - customize editor
  553. - (UIView*)get_tableHeader
  554. {
  555. UILabel * headerview = [UILabel new];
  556. headerview.frame = CGRectMake(0, 0, self.tableview.frame.size.width, 44);
  557. headerview.numberOfLines = 0;
  558. headerview.textAlignment = NSTextAlignmentCenter;
  559. headerview.text = @"";
  560. return headerview;
  561. }
  562. -(void) resize_tableHeader
  563. {
  564. //利用systemLayoutSizeFittingSize:计算出真实高度
  565. CGFloat height = [self.tableview.tableHeaderView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;
  566. CGRect headerFrame = self.tableview.tableHeaderView.frame;
  567. headerFrame.size.height = height+20;//20是留的上下边距
  568. //修改tableHeaderView的frame
  569. self.tableview.tableHeaderView.frame = headerFrame;
  570. }
  571. #pragma mark - 3D Touch Delegate (PreviewingDelegate)
  572. // peek (预览)
  573. - (UIViewController *)previewingContext:(id<UIViewControllerPreviewing>)previewingContext viewControllerForLocation:(CGPoint)location {
  574. // [previewingContext sourceView]即为所按压的视图
  575. // UITableViewCell *view = (UITableViewCell *)[previewingContext sourceView];
  576. //
  577. // // 设置不被虚化的范围
  578. // CGRect rect = view.bounds;
  579. // [previewingContext setSourceRect:rect];
  580. //
  581. // NSIndexPath *indexPath = [self.tableview indexPathForCell:view];
  582. // // peek (预览界面)
  583. // UIViewController *tvc = [self viewControllerFor3DTouch:indexPath];
  584. //
  585. // tvc.preferredContentSize = CGSizeMake(0, 480); // 预览图的大小
  586. //
  587. // return tvc;
  588. // NSIndexPath *indexPath = [self.tableview indexPathForCell:view];
  589. // [self presses3DTouchForIndexPath:indexPath];
  590. return nil;
  591. }
  592. // pop (在预览基础上更用力按压)
  593. - (void)previewingContext:(id<UIViewControllerPreviewing>)previewingContext commitViewController:(UIViewController *)viewControllerToCommit {
  594. // [self showViewController:viewControllerToCommit sender:self];
  595. }
  596. #pragma mark - Cell Touch Delegate
  597. - (void)touchedCell:(ResultCell *)cell withForce:(float)force {
  598. if (force > 4.0f) {
  599. cell.handlingTouch = YES;
  600. // 1519: 普通短震,3D Touch 中 Peek 震动反馈
  601. // 1520: 普通短震,3D Touch 中 Pop 震动反馈
  602. // 1521: 连续三次短震
  603. // kSystemSoundID_Vibrate: 震动很暴力,不适合震动反馈
  604. AudioServicesPlaySystemSound(1519); // 支持震动的设备上会震动,不支持就什么都不做 kSystemSoundID_Vibrate
  605. NSIndexPath *indexPath = [self.tableview indexPathForCell:cell];
  606. [self presses3DTouchForIndexPath:indexPath];
  607. }
  608. NSLog(@"force %f",force);
  609. }
  610. #pragma mark - Child View Controller Override
  611. /**
  612. * 0: init load
  613. * 1: refresh
  614. * 2: load more
  615. */
  616. - (void)loadContentWithOption:(int)option Complete:(void (^)(int result,int count))finish {
  617. NSAssert(true, ([NSString stringWithFormat:@"%s loadContentWithOption not impl",object_getClassName([self class])]));
  618. // if (self.params) {
  619. //
  620. // NSMutableDictionary *dic = self.params.mutableCopy;
  621. // switch (option) {
  622. // case 0:
  623. // case 1: {
  624. // self.offset = 0;
  625. // self.content_layout =nil;
  626. // self.content_action = nil;
  627. // self.content_menu = nil;
  628. // self.content_data = nil;
  629. // }
  630. // break;
  631. // case 2: {
  632. // self.offset = [self resultItemCount];
  633. // }
  634. // break;
  635. // }
  636. //
  637. //// dic[@"criteria"] = self.params;
  638. //
  639. // [dic setObject:@(self.offset) forKey:@"offset"];
  640. // [dic setObject:@(delta) forKey:@"limit"];
  641. //// dic[@"criteria"] = [NSArray arrayWithObjects:@"aaa",@"bbb", nil];
  642. //
  643. // __weak typeof(self) weakSelf = self;
  644. // dispatch_async(dispatch_get_global_queue(0, 0), ^{
  645. // NSDictionary *contentDic = [RANetwork query:dic];
  646. // NSInteger result = [[contentDic objectForKey:@"result"] integerValue];
  647. // dispatch_async(dispatch_get_main_queue(), ^{
  648. // if (weakSelf) {
  649. // __strong typeof(weakSelf) strongSelf = weakSelf;
  650. // if (result == RESULT_TRUE) {
  651. // strongSelf.content_layout = [contentDic objectForKey:@"layout"];
  652. // strongSelf.content_action = [contentDic objectForKey:@"row_action"];
  653. // strongSelf.content_menu = [[contentDic objectForKey:@"menu"] mutableCopy];
  654. // [strongSelf setupNavigationBar];
  655. //
  656. // UILabel * headerview=(UILabel *)self.tableview.tableHeaderView;
  657. // headerview.text = contentDic[@"table_title"];
  658. // [self resize_tableHeader];
  659. //
  660. // if(strongSelf.content_data==nil)
  661. // strongSelf.content_data = [NSMutableDictionary new];
  662. // NSMutableDictionary* newdata = [[contentDic objectForKey:@"data"] mutableCopy];
  663. // for(int dc = 0;dc<[newdata[@"count"] intValue];dc++)
  664. // {
  665. // NSMutableDictionary * newdata_item = newdata[[NSString stringWithFormat:@"item_%d",dc]];
  666. //
  667. // strongSelf.content_data[[NSString stringWithFormat:@"item_%d",[strongSelf.content_data[@"count"] intValue] ]] = newdata_item;
  668. // strongSelf.content_data[@"count"] = @([strongSelf.content_data[@"count"] intValue]+1);
  669. // }
  670. //
  671. //// strongSelf.content_data = [contentDic objectForKey:@"data"];
  672. // [strongSelf updateTableFrame];
  673. // [strongSelf.tableview reloadData];
  674. // } else {
  675. // [RAUtils message_alert:[contentDic objectForKey:@"err_msg"] title:@"Warning" controller:strongSelf];
  676. // }
  677. //
  678. // if (finish) {
  679. // finish((int)result,(int)[self resultItemCount]);
  680. // }
  681. //
  682. // }
  683. //
  684. // });
  685. // });
  686. // }
  687. }
  688. - (void)MenuClick:(UIBarButtonItem *)sender {
  689. // UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
  690. // //block代码块取代了delegate
  691. //
  692. // __weak typeof(self) weakSelf = self;
  693. // for(int i=0;i<self.content_menu.count;i++)
  694. // {
  695. // NSMutableDictionary* json = self.content_menu[i];
  696. // NSString* title =json[@"title"];
  697. // NSString* actiontype = json[@"action"];
  698. // NSString* url = json[@"url"];
  699. //// NSMutableDictionary* add_params = json[@"params"];
  700. // UIAlertAction *actioni = [UIAlertAction actionWithTitle:title style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  701. // // DebugLog(@"Cancel");
  702. // if([actiontype isEqualToString:@"download"])
  703. // {
  704. // [weakSelf Export:url];
  705. // }
  706. // else if([actiontype isEqualToString:@"save"])
  707. // {
  708. // [weakSelf save];
  709. // }
  710. // }];
  711. // [alertControl addAction:actioni];
  712. // }
  713. //
  714. // UIAlertAction *actionCancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  715. // // DebugLog(@"Cancel");
  716. //
  717. // }];
  718. // [alertControl addAction:actionCancel];
  719. //
  720. //
  721. //
  722. //
  723. //
  724. // [self presentViewController:alertControl animated:NO completion:nil];
  725. }
  726. //- (void)save {
  727. //
  728. //}
  729. //
  730. //-(void)Export:(NSString*) url
  731. //{
  732. //
  733. // NSAssert(true, ([NSString stringWithFormat:@"%s Export not impl",object_getClassName([self class])]));
  734. //// if(self.download_query )
  735. //// {
  736. //// self.documentPath = self.download_query;
  737. //// [self.navigationController pushViewController:self.quickLook animated:NO];
  738. //// return;
  739. //// }
  740. ////
  741. //// __weak typeof(self) weakSelf = self;
  742. //// dispatch_async(dispatch_get_global_queue(0, 0), ^{
  743. ////
  744. ////// NSMutableDictionary *params = self.params.mutableCopy;
  745. ////// if(add_params!=nil)
  746. ////// [params addEntriesFromDictionary:add_params];
  747. //// NSString *path = [RANetwork download_query:url];
  748. //// weakSelf.download_query = path;
  749. //// weakSelf.documentPath = path;
  750. ////
  751. //// if (path) {
  752. //// dispatch_async(dispatch_get_main_queue(), ^{
  753. //// [weakSelf.navigationController pushViewController:weakSelf.quickLook animated:NO];
  754. //// });
  755. //// }
  756. ////
  757. //// });
  758. //}
  759. //- (void)downloadItemClick:(UIBarButtonItem *)sender {
  760. // NSAssert(true, ([NSString stringWithFormat:@"%s downloadItemClick not impl",object_getClassName([self class])]));
  761. ////
  762. ////
  763. //// if(self.download_query )
  764. //// {
  765. //// self.documentPath = self.download_query;
  766. //// [self.navigationController pushViewController:self.quickLook animated:NO];
  767. //// return;
  768. //// }
  769. ////
  770. //// __weak typeof(self) weakSelf = self;
  771. //// dispatch_async(dispatch_get_global_queue(0, 0), ^{
  772. ////
  773. //// NSMutableDictionary *params = self.params.mutableCopy;
  774. //// NSString *path = [RANetwork download_query:params];
  775. //// weakSelf.download_query = path;
  776. //// weakSelf.documentPath = path;
  777. ////
  778. //// if (path) {
  779. //// dispatch_async(dispatch_get_main_queue(), ^{
  780. //// [weakSelf.navigationController pushViewController:weakSelf.quickLook animated:NO];
  781. //// });
  782. //// }
  783. ////
  784. //// });
  785. ////
  786. //}
  787. - (void)presses3DTouchForIndexPath:(NSIndexPath *)indexPath {
  788. }
  789. -(void)cellDoubleTapAction:(UIGestureRecognizer*)gestureRecognizer
  790. {
  791. NSAssert(true, ([NSString stringWithFormat:@"%s cellDoubleTapAction not impl",object_getClassName([self class])]));
  792. }
  793. //{
  794. // NSLog(@"cell double tap");
  795. // UITableViewCell* cell = (UITableViewCell*)[gestureRecognizer view];
  796. // NSIndexPath* indexPath=[self.tableview indexPathForCell:cell];
  797. // //strongSelf.content_action
  798. // if(self.content_action!=nil)
  799. // {
  800. //
  801. // if(self.content_action.count==1)
  802. // {
  803. // NSDictionary* action =self.content_action.firstObject;
  804. // NSString * module = action[@"module"];
  805. // if([module isEqualToString:@"quick_look"])
  806. // {
  807. //
  808. // // +(NSString*)download_file : (NSMutableDictionary*) params url:(NSString*) url
  809. // NSMutableDictionary *params = action[@"params"];
  810. // NSString* URL =action[@"url"];
  811. // __weak typeof(self) weakSelf = self;
  812. // dispatch_async(dispatch_get_global_queue(0, 0), ^{
  813. //
  814. //
  815. // NSString *path = [RANetwork download_file:params url:URL];
  816. // weakSelf.documentPath = path;
  817. //
  818. // if (path) {
  819. // dispatch_async(dispatch_get_main_queue(), ^{
  820. // [weakSelf.navigationController pushViewController:weakSelf.quickLook animated:NO];
  821. // });
  822. // }
  823. //
  824. // });
  825. // }
  826. // else if([module isEqualToString:@"kv_detail"])
  827. // {
  828. // NSMutableDictionary *params = [NSMutableDictionary new];
  829. // params[@"query_id"] = self.params[@"query_id"];
  830. //
  831. // NSMutableDictionary *criteria =[NSMutableDictionary new];
  832. // for(NSString* key in [action[@"params"] allKeys] )
  833. // {
  834. // NSArray* item =self.content_data[[NSString stringWithFormat:@"item_%ld",indexPath.row]];
  835. // int idx =[action[@"params"][key] intValue];
  836. // criteria[key]=item[ idx];
  837. // }
  838. //
  839. //
  840. // params[@"criteria"]=[RAConvertor dict2string:criteria] ;
  841. //
  842. //
  843. //
  844. // UIAlertView * waitalert = [RAUtils waiting_alert:@"Loading..." title:@"Please wait"];
  845. //
  846. //
  847. // __weak typeof(self) weakself = self;
  848. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  849. //
  850. //
  851. //
  852. // NSDictionary* json =[RANetwork kv_detail:params];
  853. //
  854. // dispatch_async(dispatch_get_main_queue(), ^{
  855. // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  856. //
  857. //
  858. // if([[json valueForKey:@"result"] intValue]==2)
  859. // {
  860. // KVViewController *vc = [[UIStoryboard storyboardWithName:@"Detail" bundle:nil] instantiateViewControllerWithIdentifier:@"KVViewController"];
  861. // vc.content = [json mutableCopy];
  862. // [weakself.navigationController pushViewController:vc animated:NO];
  863. //
  864. // // weakself.content_data_download = [weakself CopyDirty:weakself.content_data_download to:[editor_json mutableCopy]];//[editor_json mutableCopy];
  865. // //
  866. // // weakself.content_data_control = [weakself translate_json:weakself.content_data_download changed: weakself.changed_data];
  867. // //
  868. // //
  869. // // [weakself download_success];
  870. // // [weakself.editorTable reloadData];
  871. //
  872. // }
  873. // else
  874. // {
  875. // [RAUtils message_alert:json[@"msg"] title:nil controller:weakself] ;
  876. // }
  877. //
  878. //
  879. //
  880. //
  881. // });
  882. // });
  883. // }
  884. // else if([module isEqualToString:@"order_detail"])
  885. // {
  886. //
  887. // OrderDetailViewController *vc = [[UIStoryboard storyboardWithName:@"Detail" bundle:nil] instantiateViewControllerWithIdentifier:@"OrderDetailViewController"];
  888. //
  889. //
  890. // vc.url_type = URL_REMOTE;
  891. // vc.request_url=URL_ORDER_DETAIL;
  892. //
  893. //
  894. // vc.params = [NSMutableDictionary dictionary];
  895. // // NSString *path = [[NSBundle mainBundle] pathForResource:@"search_ui.json" ofType:nil];
  896. // // NSData *data = [NSData dataWithContentsOfFile:path];
  897. // // vc.content_data_download = [[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil] mutableCopy];
  898. // [self.navigationController pushViewController:vc animated:NO];
  899. // return;
  900. // }
  901. // }
  902. // else
  903. // {
  904. //
  905. // UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"" message:nil preferredStyle:UIAlertControllerStyleAlert];
  906. // //block代码块取代了delegate
  907. //
  908. // __weak typeof(self) weakSelf = self;
  909. // for(int i=0;i<self.content_action.count;i++)
  910. // {
  911. // NSMutableDictionary* json = self.content_action[i];
  912. // NSString* title =json[@"title"];
  913. // NSString* module = json[@"module"];
  914. // NSMutableDictionary* add_params = json[@"params"];
  915. // UIAlertAction *actioni = [UIAlertAction actionWithTitle:title style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  916. //
  917. //
  918. // if([module isEqualToString:@"quick_look"])
  919. // {
  920. //
  921. // // +(NSString*)download_file : (NSMutableDictionary*) params url:(NSString*) url
  922. // NSMutableDictionary *params = json[@"params"];
  923. // NSString* URL =json[@"url"];
  924. // __weak typeof(self) weakSelf = self;
  925. // dispatch_async(dispatch_get_global_queue(0, 0), ^{
  926. //
  927. //
  928. // NSString *path = [RANetwork download_file:params url:URL];
  929. // weakSelf.documentPath = path;
  930. //
  931. // if (path) {
  932. // dispatch_async(dispatch_get_main_queue(), ^{
  933. // [weakSelf.navigationController pushViewController:weakSelf.quickLook animated:NO];
  934. // });
  935. // }
  936. //
  937. // });
  938. // }
  939. // else if([module isEqualToString:@"kv_detail"])
  940. // {
  941. // NSMutableDictionary *params = json[@"params"];
  942. //
  943. //
  944. // UIAlertView * waitalert = [RAUtils waiting_alert:@"Loading..." title:@"Please wait"];
  945. //
  946. //
  947. // __weak typeof(self) weakself = self;
  948. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  949. //
  950. //
  951. //
  952. // NSDictionary* json =[RANetwork kv_detail:params];
  953. //
  954. // dispatch_async(dispatch_get_main_queue(), ^{
  955. // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  956. //
  957. //
  958. // if([[json valueForKey:@"result"] intValue]==2)
  959. // {
  960. // KVViewController *vc = [[UIStoryboard storyboardWithName:@"Detail" bundle:nil] instantiateViewControllerWithIdentifier:@"KVViewController"];
  961. // vc.content = [json mutableCopy];
  962. // [weakself.navigationController pushViewController:vc animated:NO];
  963. //
  964. // // weakself.content_data_download = [weakself CopyDirty:weakself.content_data_download to:[editor_json mutableCopy]];//[editor_json mutableCopy];
  965. // //
  966. // // weakself.content_data_control = [weakself translate_json:weakself.content_data_download changed: weakself.changed_data];
  967. // //
  968. // //
  969. // // [weakself download_success];
  970. // // [weakself.editorTable reloadData];
  971. //
  972. // }
  973. // else
  974. // {
  975. // [RAUtils message_alert:json[@"msg"] title:nil controller:weakself] ;
  976. // }
  977. //
  978. //
  979. //
  980. //
  981. // });
  982. // });
  983. // }
  984. // else if([module isEqualToString:@"order_detail"])
  985. // {
  986. //
  987. // OrderDetailViewController *vc = [[UIStoryboard storyboardWithName:@"Detail" bundle:nil] instantiateViewControllerWithIdentifier:@"OrderDetailViewController"];
  988. //
  989. //
  990. // vc.url_type = URL_REMOTE;
  991. // vc.request_url=URL_ORDER_DETAIL;
  992. //
  993. //
  994. // vc.params = [NSMutableDictionary dictionary];
  995. // // NSString *path = [[NSBundle mainBundle] pathForResource:@"search_ui.json" ofType:nil];
  996. // // NSData *data = [NSData dataWithContentsOfFile:path];
  997. // // vc.content_data_download = [[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil] mutableCopy];
  998. // [self.navigationController pushViewController:vc animated:NO];
  999. // return;
  1000. // }
  1001. // // DebugLog(@"Cancel");
  1002. //// if([actiontype isEqualToString:@"download"])
  1003. //// {
  1004. //// [weakSelf Export:add_params];
  1005. //// }
  1006. //// else if([actiontype isEqualToString:@"save"])
  1007. //// {
  1008. //// }
  1009. // }];
  1010. // [alertControl addAction:actioni];
  1011. // }
  1012. //
  1013. // UIAlertAction *actionCancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  1014. // // DebugLog(@"Cancel");
  1015. //
  1016. // }];
  1017. // [alertControl addAction:actionCancel];
  1018. //
  1019. //
  1020. //
  1021. //
  1022. //
  1023. // [self presentViewController:alertControl animated:NO completion:nil];
  1024. //
  1025. // }
  1026. //
  1027. // }
  1028. //
  1029. //
  1030. //
  1031. //}
  1032. @end