Skip to content

Commit

Permalink
refactored adparams and boost
Browse files Browse the repository at this point in the history
  • Loading branch information
gdlbo committed Feb 3, 2024
1 parent bac53b2 commit 137133e
Showing 1 changed file with 26 additions and 25 deletions.
51 changes: 26 additions & 25 deletions app/src/main/java/ru/vtosters/hooks/NewsfeedHook.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
import androidx.recyclerview.widget.RecyclerView;
import com.vk.core.preference.Preference;
import com.vk.discover.DiscoverItemDecorator;
import ru.vtosters.hooks.other.Preferences;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;

Expand All @@ -22,8 +24,7 @@ public static long getUpdateNewsfeed(boolean refresh_timeout) {
return switch (getString("newsupdate")) {
case "no_update" -> MAX_VALUE;
case "imd_update" -> 10000L;
default ->
Preference.b().getLong(refresh_timeout ? "refresh_timeout_top" : "refresh_timeout_recent", 600000L);
default -> Preference.b().getLong(refresh_timeout ? "refresh_timeout_top" : "refresh_timeout_recent", 600000L);
};
}

Expand Down Expand Up @@ -53,41 +54,41 @@ public static List hideElement(ArrayList list) {
}

public static String[] feedParams() {
HashSet<String> params = new HashSet<>();
params.add("post");
params.add("photo");
params.add("photo_tag");
List<String> params = List.of("post", "photo", "photo_tag", "friends_recomm", "app_widget", "promo_button", "authors_rec");

if (!friendsrecomm()) {
params.add("friends_recomm");
}
HashSet<String> filteredParams = new HashSet<>();

if (!ads()) {
params.add("app_widget");
params.add("promo_button");
for (String param : params) {
if (!isDisabled(param)) {
filteredParams.add(param);
}
}

if (!authorsrecomm()) {
params.add("authors_rec");
}
return filteredParams.toArray(new String[0]);
}

return params.toArray(new String[0]);
private static boolean isDisabled(String param) {
return switch (param) {
case "friends_recomm" -> friendsrecomm();
case "app_widget", "promo_button" -> ads();
case "authors_rec" -> authorsrecomm();
default -> false;
};
}

public static void adsParams(HashSet<String> hashSet) {
String[] adsParams = {"ads_disabled", "ads_app_slider", "ads_site_slider", "ads_app", "ads_site", "ads_post", "ads_app_video", "ads_post_pretty_cards", "ads_post_snippet_video"};

if (ads()) {
hashSet.add("ads_disabled");
hashSet.add(adsParams[0]);
hashSet.add(adsParams[1]);
} else {
hashSet.add("ads_app_slider");
hashSet.add("ads_site_slider");
Collections.addAll(hashSet, adsParams);
}

hashSet.add("ads_app");
hashSet.add("ads_site");
hashSet.add("ads_post");
hashSet.add("ads_app_video");
hashSet.add("ads_post_pretty_cards");
hashSet.add("ads_post_snippet_video");
if (Preferences.milkshake()) {
hashSet.remove(adsParams[1]);
}
}

public static boolean isPowerSaveMode() {
Expand Down

0 comments on commit 137133e

Please sign in to comment.