MWPhotoProtocol.h 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. // This file is based on third party code, see below for the original author
  2. // and original license.
  3. // Modifications are (c) by Threema GmbH and licensed under the AGPLv3.
  4. //
  5. // MWPhotoProtocol.h
  6. // MWPhotoBrowser
  7. //
  8. // Created by Michael Waterfall on 02/01/2012.
  9. // Copyright (c) 2012 __MyCompanyName__. All rights reserved.
  10. //
  11. #import <Foundation/Foundation.h>
  12. // Notifications
  13. #define MWPHOTO_LOADING_DID_END_NOTIFICATION @"MWPHOTO_LOADING_DID_END_NOTIFICATION"
  14. #define MWPHOTO_PROGRESS_NOTIFICATION @"MWPHOTO_PROGRESS_NOTIFICATION"
  15. // If you wish to use your own data models for photo then they must conform
  16. // to this protocol. See instructions for details on each method.
  17. // Otherwise you can use the MWPhoto object or subclass it yourself to
  18. // store more information per photo.
  19. //
  20. // You can see the MWPhoto class for an example implementation of this protocol
  21. //
  22. @protocol MWPhoto <NSObject>
  23. @required
  24. // Return underlying UIImage to be displayed
  25. // Return nil if the image is not immediately available (loaded into memory, preferably
  26. // already decompressed) and needs to be loaded from a source (cache, file, web, etc)
  27. // IMPORTANT: You should *NOT* use this method to initiate
  28. // fetching of images from any external of source. That should be handled
  29. // in -loadUnderlyingImageAndNotify: which may be called by the photo browser if this
  30. // methods returns nil.
  31. @property (nonatomic, strong) UIImage *underlyingImage;
  32. // Called when the browser has determined the underlying images is not
  33. // already loaded into memory but needs it.
  34. - (void)loadUnderlyingImageAndNotify;
  35. // Fetch the image data from a source and notify when complete.
  36. // You must load the image asyncronously (and decompress it for better performance).
  37. // It is recommended that you use SDWebImageDecoder to perform the decompression.
  38. // See MWPhoto object for an example implementation.
  39. // When the underlying UIImage is loaded (or failed to load) you should post the following
  40. // notification:
  41. // [[NSNotificationCenter defaultCenter] postNotificationName:MWPHOTO_LOADING_DID_END_NOTIFICATION
  42. // object:self];
  43. - (void)performLoadUnderlyingImageAndNotify;
  44. // This is called when the photo browser has determined the photo data
  45. // is no longer needed or there are low memory conditions
  46. // You should release any underlying (possibly large and decompressed) image data
  47. // as long as the image can be re-loaded (from cache, file, or URL)
  48. - (void)unloadUnderlyingImage;
  49. @optional
  50. // If photo is empty, in which case, don't show loading error icons
  51. @property (nonatomic) BOOL emptyImage;
  52. // Video
  53. @property (nonatomic) BOOL isVideo;
  54. - (void)getVideoURL:(void (^)(NSURL *url))completion;
  55. // Return a caption string to be displayed over the image
  56. // Return nil to display no caption
  57. - (NSString *)caption;
  58. // Cancel any background loading of image data
  59. - (void)cancelAnyLoading;
  60. /***** BEGIN THREEMA MODIFICATION: video *********/
  61. // always show controls for this photo
  62. - (BOOL)showControls;
  63. // for individual single tap handling for this photo
  64. - (void)handleSingleTap:(CGPoint)touchPoint;
  65. // determine if this image can be scaled
  66. - (BOOL)canScaleImage;
  67. - (NSURL *)urlForExportData:(NSString *)tmpFileName;
  68. - (NSString *)accessibilityLabelForContent;
  69. /***** END THREEMA MODIFICATION: video *********/
  70. @end