Skip to content

Commit cf11299

Browse files
committed
优化了一个逻辑问题
1 parent e71ec26 commit cf11299

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

DYYY.xm

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,19 @@ static UIImage *DYYYLoadCustomImage(NSString *fileName, CGSize targetSize) {
176176
return resultImage;
177177
}
178178

179+
static BOOL DYYYShouldHandleSpeedFeatures(void) {
180+
if (isFloatSpeedButtonEnabled) {
181+
return YES;
182+
}
183+
184+
float defaultSpeed = [[NSUserDefaults standardUserDefaults] floatForKey:@"DYYYDefaultSpeed"];
185+
if (defaultSpeed <= 0.0f) {
186+
return NO;
187+
}
188+
189+
return fabsf(defaultSpeed - 1.0f) > FLT_EPSILON;
190+
}
191+
179192
// 关闭不可见水印
180193
%hook AWEHPChannelInvisibleWaterMarkModel
181194

@@ -5978,6 +5991,9 @@ void applyGlobalTransparency(id targetObject) {
59785991

59795992
- (void)setIsAutoPlay:(BOOL)arg0 {
59805993
%orig(arg0);
5994+
if (!DYYYShouldHandleSpeedFeatures()) {
5995+
return;
5996+
}
59815997
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
59825998
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DYYYUserAgreementAccepted"]) {
59835999
float defaultSpeed = [[NSUserDefaults standardUserDefaults] floatForKey:@"DYYYDefaultSpeed"];
@@ -5998,6 +6014,9 @@ void applyGlobalTransparency(id targetObject) {
59986014

59996015
- (void)prepareForDisplay {
60006016
%orig;
6017+
if (!DYYYShouldHandleSpeedFeatures()) {
6018+
return;
6019+
}
60016020

60026021
BOOL autoRestoreSpeed = [[NSUserDefaults standardUserDefaults] boolForKey:@"DYYYAutoRestoreSpeed"];
60036022
if (autoRestoreSpeed) {
@@ -6040,6 +6059,9 @@ void applyGlobalTransparency(id targetObject) {
60406059

60416060
- (void)setIsAutoPlay:(BOOL)arg0 {
60426061
%orig(arg0);
6062+
if (!DYYYShouldHandleSpeedFeatures()) {
6063+
return;
6064+
}
60436065
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
60446066
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DYYYUserAgreementAccepted"]) {
60456067
float defaultSpeed = [[NSUserDefaults standardUserDefaults] floatForKey:@"DYYYDefaultSpeed"];
@@ -6060,6 +6082,9 @@ void applyGlobalTransparency(id targetObject) {
60606082

60616083
- (void)prepareForDisplay {
60626084
%orig;
6085+
if (!DYYYShouldHandleSpeedFeatures()) {
6086+
return;
6087+
}
60636088
BOOL autoRestoreSpeed = [[NSUserDefaults standardUserDefaults] boolForKey:@"DYYYAutoRestoreSpeed"];
60646089
if (autoRestoreSpeed) {
60656090
setCurrentSpeedIndex(0);

0 commit comments

Comments
 (0)