mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-29 15:52:40 +00:00
The topic animation was not restarted when the application was debackgrounded
This commit is contained in:
parent
d72bca8929
commit
b99d23ad46
2 changed files with 37 additions and 3 deletions
|
@ -31,6 +31,7 @@
|
|||
- (void)dismissKeyboard;
|
||||
|
||||
- (void)startTopicAnimation;
|
||||
- (void)stopTopicAnimation;
|
||||
// return YES if the animation has been stopped
|
||||
- (BOOL)stopTopicAnimation;
|
||||
|
||||
@end
|
|
@ -26,12 +26,26 @@
|
|||
|
||||
// do not start the topic animation asap
|
||||
NSTimer * animationTimer;
|
||||
|
||||
// restart a killed animation when the application is debackgrounded
|
||||
BOOL restartAnimationWhenActive;
|
||||
}
|
||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *displayNameTextFieldTopConstraint;
|
||||
@end
|
||||
|
||||
@implementation RoomTitleView
|
||||
|
||||
- (id) initWithCoder:(NSCoder *)aDecoder {
|
||||
self = [super initWithCoder:aDecoder];
|
||||
|
||||
if (self) {
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appEnteredBackground) name:UIApplicationDidEnterBackgroundNotification object:nil];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appEnteredForeground) name:UIApplicationWillEnterForegroundNotification object:nil];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
if (messagesListener && _mxRoom) {
|
||||
[_mxRoom removeListener:messagesListener];
|
||||
|
@ -41,6 +55,21 @@
|
|||
|
||||
// stop any animation
|
||||
[self stopTopicAnimation];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidEnterBackgroundNotification object:nil];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillEnterForegroundNotification object:nil];
|
||||
}
|
||||
|
||||
|
||||
- (void)appEnteredBackground {
|
||||
restartAnimationWhenActive = [self stopTopicAnimation];
|
||||
}
|
||||
|
||||
- (void)appEnteredForeground {
|
||||
if (restartAnimationWhenActive) {
|
||||
[self startTopicAnimation];
|
||||
restartAnimationWhenActive = NO;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)refreshDisplay {
|
||||
|
@ -179,7 +208,7 @@
|
|||
}];
|
||||
}
|
||||
|
||||
- (void)stopTopicAnimation {
|
||||
- (BOOL)stopTopicAnimation {
|
||||
// stop running timers
|
||||
if (animationTimer) {
|
||||
[animationTimer invalidate];
|
||||
|
@ -196,7 +225,11 @@
|
|||
label = nil;
|
||||
|
||||
[self addSubview:_topicTextField];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)dismissKeyboard {
|
||||
|
@ -209,7 +242,7 @@
|
|||
[self startTopicAnimation];
|
||||
}
|
||||
|
||||
- (void) setFrame:(CGRect)frame {
|
||||
- (void)setFrame:(CGRect)frame {
|
||||
|
||||
// restart only if there is a frame update
|
||||
BOOL restartAnimation = !CGRectEqualToRect(CGRectIntegral(frame), CGRectIntegral(self.frame));
|
||||
|
|
Loading…
Reference in a new issue