| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "ios/chrome/browser/ui/bookmarks/bookmark_home_waiting_view.h" | 5 #import "ios/chrome/browser/ui/bookmarks/bookmark_home_waiting_view.h" |
| 6 | 6 |
| 7 #include "base/mac/objc_property_releaser.h" | 7 #include "base/mac/objc_release_properties.h" |
| 8 #include "base/mac/scoped_nsobject.h" | 8 #include "base/mac/scoped_nsobject.h" |
| 9 #import "ios/chrome/browser/ui/bookmarks/bookmark_utils_ios.h" | 9 #import "ios/chrome/browser/ui/bookmarks/bookmark_utils_ios.h" |
| 10 #import "ios/chrome/browser/ui/material_components/activity_indicator.h" | 10 #import "ios/chrome/browser/ui/material_components/activity_indicator.h" |
| 11 #import "ios/chrome/browser/ui/rtl_geometry.h" | 11 #import "ios/chrome/browser/ui/rtl_geometry.h" |
| 12 #import "ios/third_party/material_components_ios/src/components/ActivityIndicato
r/src/MaterialActivityIndicator.h" | 12 #import "ios/third_party/material_components_ios/src/components/ActivityIndicato
r/src/MaterialActivityIndicator.h" |
| 13 | 13 |
| 14 @interface BookmarkHomeWaitingView ()<MDCActivityIndicatorDelegate> { | 14 @interface BookmarkHomeWaitingView ()<MDCActivityIndicatorDelegate> |
| 15 base::mac::ObjCPropertyReleaser _propertyReleaser_BookmarkHomeWaitingView; | |
| 16 } | |
| 17 @property(nonatomic, retain) MDCActivityIndicator* activityIndicator; | 15 @property(nonatomic, retain) MDCActivityIndicator* activityIndicator; |
| 18 @property(nonatomic, copy) ProceduralBlock animateOutCompletionBlock; | 16 @property(nonatomic, copy) ProceduralBlock animateOutCompletionBlock; |
| 19 @end | 17 @end |
| 20 | 18 |
| 21 @implementation BookmarkHomeWaitingView | 19 @implementation BookmarkHomeWaitingView |
| 22 | 20 |
| 23 @synthesize activityIndicator = _activityIndicator; | 21 @synthesize activityIndicator = _activityIndicator; |
| 24 @synthesize animateOutCompletionBlock = _animateOutCompletionBlock; | 22 @synthesize animateOutCompletionBlock = _animateOutCompletionBlock; |
| 25 | 23 |
| 26 - (instancetype)initWithFrame:(CGRect)frame { | 24 - (instancetype)initWithFrame:(CGRect)frame { |
| 27 self = [super initWithFrame:frame]; | 25 self = [super initWithFrame:frame]; |
| 28 if (self) { | 26 if (self) { |
| 29 _propertyReleaser_BookmarkHomeWaitingView.Init( | |
| 30 self, [BookmarkHomeWaitingView class]); | |
| 31 self.backgroundColor = bookmark_utils_ios::mainBackgroundColor(); | 27 self.backgroundColor = bookmark_utils_ios::mainBackgroundColor(); |
| 32 self.autoresizingMask = | 28 self.autoresizingMask = |
| 33 UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; | 29 UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; |
| 34 } | 30 } |
| 35 return self; | 31 return self; |
| 36 } | 32 } |
| 37 | 33 |
| 34 - (void)dealloc { |
| 35 base::mac::ReleaseProperties(self); |
| 36 [super dealloc]; |
| 37 } |
| 38 |
| 38 - (void)startWaiting { | 39 - (void)startWaiting { |
| 39 dispatch_time_t delayForIndicatorAppearance = | 40 dispatch_time_t delayForIndicatorAppearance = |
| 40 dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)); | 41 dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)); |
| 41 dispatch_after(delayForIndicatorAppearance, dispatch_get_main_queue(), ^{ | 42 dispatch_after(delayForIndicatorAppearance, dispatch_get_main_queue(), ^{ |
| 42 base::scoped_nsobject<MDCActivityIndicator> activityIndicator( | 43 base::scoped_nsobject<MDCActivityIndicator> activityIndicator( |
| 43 [[MDCActivityIndicator alloc] initWithFrame:CGRectMake(0, 0, 24, 24)]); | 44 [[MDCActivityIndicator alloc] initWithFrame:CGRectMake(0, 0, 24, 24)]); |
| 44 self.activityIndicator = activityIndicator; | 45 self.activityIndicator = activityIndicator; |
| 45 self.activityIndicator.delegate = self; | 46 self.activityIndicator.delegate = self; |
| 46 self.activityIndicator.autoresizingMask = | 47 self.activityIndicator.autoresizingMask = |
| 47 UIViewAutoresizingFlexibleLeadingMargin() | | 48 UIViewAutoresizingFlexibleLeadingMargin() | |
| (...skipping 22 matching lines...) Expand all Loading... |
| 70 - (void)activityIndicatorAnimationDidFinish: | 71 - (void)activityIndicatorAnimationDidFinish: |
| 71 (MDCActivityIndicator*)activityIndicator { | 72 (MDCActivityIndicator*)activityIndicator { |
| 72 [self.activityIndicator removeFromSuperview]; | 73 [self.activityIndicator removeFromSuperview]; |
| 73 self.activityIndicator = nil; | 74 self.activityIndicator = nil; |
| 74 if (self.animateOutCompletionBlock) | 75 if (self.animateOutCompletionBlock) |
| 75 self.animateOutCompletionBlock(); | 76 self.animateOutCompletionBlock(); |
| 76 self.animateOutCompletionBlock = nil; | 77 self.animateOutCompletionBlock = nil; |
| 77 } | 78 } |
| 78 | 79 |
| 79 @end | 80 @end |
| OLD | NEW |