diff --git a/KAIBatteryPlatter.h b/KAIBatteryPlatter.h deleted file mode 100755 index b5467be..0000000 --- a/KAIBatteryPlatter.h +++ /dev/null @@ -1,13 +0,0 @@ -@interface KAIBatteryPlatter : UIScrollView -@property (nonatomic, assign) NSInteger number; -@property (nonatomic, assign) NSInteger oldCountOfDevices; -@property (nonatomic, strong) NSLayoutConstraint *heightConstraint; -@property (nonatomic, strong) KAIStackView *stack; -@property (nonatomic, assign) BOOL isUpdating; -@property (nonatomic, assign) BOOL queued; -+(KAIBatteryPlatter *)sharedInstance; --(instancetype)initWithFrame:(CGRect)arg1; --(void)refreshForPrefs; --(void)updateBattery; --(void)calculateHeight; -@end \ No newline at end of file diff --git a/KAIBatteryPlatter.mm b/KAIBatteryPlatter.mm index 801ddb2..76781a6 100755 --- a/KAIBatteryPlatter.mm +++ b/KAIBatteryPlatter.mm @@ -1,4 +1,3 @@ -#import "KAIBatteryPlatter.h" KAIBatteryPlatter *instance; NSTimer *queueTimer = nil; @@ -192,7 +191,8 @@ long long lastPercentage; if(self.number==0) { [(UIStackView *)(self.superview) removeArrangedSubview:self]; } else if(self.number!=0 && !self.superview) { - [[[objc_getClass("CSAdjunctListView") class] sharedListViewForKai] addArrangedSubview:self]; + [[[[objc_getClass("CSAdjunctListView") class] sharedListViewForKai] stackView] addArrangedSubview:self]; + [self performSelector:@selector(calculateHeight) withObject:self afterDelay:0.1]; } } diff --git a/KAIStackView.h b/KAIStackView.h index 5b91e35..9232e6f 100644 --- a/KAIStackView.h +++ b/KAIStackView.h @@ -1,3 +1,17 @@ @interface KAIStackView : UIStackView @property (nonatomic, strong) NSLayoutConstraint *heightConstraint; +@end + +@interface KAIBatteryPlatter : UIScrollView +@property (nonatomic, assign) NSInteger number; +@property (nonatomic, assign) NSInteger oldCountOfDevices; +@property (nonatomic, strong) NSLayoutConstraint *heightConstraint; +@property (nonatomic, strong) KAIStackView *stack; +@property (nonatomic, assign) BOOL isUpdating; +@property (nonatomic, assign) BOOL queued; ++(KAIBatteryPlatter *)sharedInstance; +-(instancetype)initWithFrame:(CGRect)arg1; +-(void)refreshForPrefs; +-(void)updateBattery; +-(void)calculateHeight; @end \ No newline at end of file diff --git a/KAIStackView.mm b/KAIStackView.mm index 92677d0..4b97397 100644 --- a/KAIStackView.mm +++ b/KAIStackView.mm @@ -13,4 +13,9 @@ [(UIScrollView *)self.superview setContentSize:self.frame.size]; } +-(void)layoutSubviews { + [super layoutSubviews]; + [(KAIBatteryPlatter *)(self.superview) calculateHeight]; +} + @end \ No newline at end of file diff --git a/Kai.xm b/Kai.xm index d575f93..5e0836b 100755 --- a/Kai.xm +++ b/Kai.xm @@ -31,16 +31,6 @@ CSAdjunctListView *list; %orig; } --(void)removeArrangedSubview:(id)arg1 { - %orig; - [[KAIBatteryPlatter sharedInstance] calculateHeight]; -} - --(void)addArrangedSubview:(id)arg1 { - %orig; - [[KAIBatteryPlatter sharedInstance] calculateHeight]; -} - -(void)setStackView:(UIStackView *)arg1 { if(!KAISelf.hasKai) {