ReaderThumbRequest.m 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. //
  2. // ReaderThumbRequest.m
  3. // Reader v2.8.6
  4. //
  5. // Created by Julius Oklamcak on 2011-09-01.
  6. // Copyright © 2011-2015 Julius Oklamcak. All rights reserved.
  7. //
  8. // Permission is hereby granted, free of charge, to any person obtaining a copy
  9. // of this software and associated documentation files (the "Software"), to deal
  10. // in the Software without restriction, including without limitation the rights to
  11. // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  12. // of the Software, and to permit persons to whom the Software is furnished to
  13. // do so, subject to the following conditions:
  14. //
  15. // The above copyright notice and this permission notice shall be included in all
  16. // copies or substantial portions of the Software.
  17. //
  18. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  19. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  22. // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  23. // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  24. //
  25. #import "ReaderThumbRequest.h"
  26. #import "ReaderThumbView.h"
  27. @implementation ReaderThumbRequest
  28. {
  29. NSURL *_fileURL;
  30. NSString *_guid;
  31. NSString *_password;
  32. NSString *_cacheKey;
  33. NSString *_thumbName;
  34. ReaderThumbView *_thumbView;
  35. NSUInteger _targetTag;
  36. NSInteger _thumbPage;
  37. CGSize _thumbSize;
  38. CGFloat _scale;
  39. }
  40. #pragma mark - Properties
  41. @synthesize guid = _guid;
  42. @synthesize fileURL = _fileURL;
  43. @synthesize password = _password;
  44. @synthesize thumbView = _thumbView;
  45. @synthesize thumbPage = _thumbPage;
  46. @synthesize thumbSize = _thumbSize;
  47. @synthesize thumbName = _thumbName;
  48. @synthesize targetTag = _targetTag;
  49. @synthesize cacheKey = _cacheKey;
  50. @synthesize scale = _scale;
  51. #pragma mark - ReaderThumbRequest class methods
  52. + (instancetype)newForView:(ReaderThumbView *)view fileURL:(NSURL *)url password:(NSString *)phrase guid:(NSString *)guid page:(NSInteger)page size:(CGSize)size
  53. {
  54. return [[ReaderThumbRequest alloc] initForView:view fileURL:url password:phrase guid:guid page:page size:size];
  55. }
  56. #pragma mark - ReaderThumbRequest instance methods
  57. - (instancetype)initForView:(ReaderThumbView *)view fileURL:(NSURL *)url password:(NSString *)phrase guid:(NSString *)guid page:(NSInteger)page size:(CGSize)size
  58. {
  59. if ((self = [super init])) // Initialize object
  60. {
  61. NSInteger w = size.width; NSInteger h = size.height;
  62. _thumbView = view; _thumbPage = page; _thumbSize = size;
  63. _fileURL = [url copy]; _password = [phrase copy]; _guid = [guid copy];
  64. _thumbName = [[NSString alloc] initWithFormat:@"%07i-%04ix%04i", (int)page, (int)w, (int)h];
  65. _cacheKey = [[NSString alloc] initWithFormat:@"%@+%@", _thumbName, _guid];
  66. _targetTag = [_cacheKey hash]; _thumbView.targetTag = _targetTag;
  67. _scale = [[UIScreen mainScreen] scale]; // Thumb screen scale
  68. }
  69. return self;
  70. }
  71. @end