RASettingActionModel.m 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. //
  2. // RASettingActionModel.m
  3. // Apex And Drivers
  4. //
  5. // Created by Jack on 2018/9/12.
  6. // Copyright © 2018年 USAI. All rights reserved.
  7. //
  8. #import "RASettingActionModel.h"
  9. @implementation RASettingActionModel
  10. - (CGFloat)height {
  11. return 60.0f;
  12. }
  13. - (void)setActive:(BOOL)active{
  14. _active = active;
  15. if (self.actionType == RASettingActionTypeCleanCache) {
  16. [self updateCacheSize];
  17. }
  18. if (self.delegate && [self.delegate respondsToSelector:@selector(refreshUI)]) {
  19. [self.delegate refreshUI];
  20. }
  21. }
  22. - (void)setActionType:(RASettingActionType)actionType {
  23. _actionType = actionType;
  24. if (actionType == RASettingActionTypeCleanCache) {
  25. [self updateCacheSize];
  26. }
  27. }
  28. - (void)updateCacheSize {
  29. NSString *cacheDir = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject];
  30. NSString *imageCacheDir = [cacheDir stringByAppendingPathComponent:@"ImageCache"];
  31. float cacheSize = [RAUtils fileSizeForDir:imageCacheDir];
  32. self.detail = ({
  33. NSString *detail = [NSString stringWithFormat:@"%.1fM",cacheSize];
  34. detail;
  35. });
  36. }
  37. @end