mirror of
https://github.com/revanced/revanced-patches
synced 2025-02-21 23:31:11 +01:00
38 lines
1.1 KiB
Java
38 lines
1.1 KiB
Java
package app.revanced.tiktok.utils;
|
|
|
|
import android.annotation.SuppressLint;
|
|
import android.content.Context;
|
|
import app.revanced.tiktok.settings.SettingsEnum;
|
|
|
|
public class ReVancedUtils {
|
|
|
|
@SuppressLint("StaticFieldLeak")
|
|
public static Context context;
|
|
|
|
public static Context getAppContext() {
|
|
if (context != null) {
|
|
return context;
|
|
}
|
|
LogHelper.printException(ReVancedUtils.class, "Context is null!");
|
|
return null;
|
|
}
|
|
|
|
public static long[] parseMinMax(SettingsEnum setting) {
|
|
if (setting.returnType == SettingsEnum.ReturnType.STRING) {
|
|
final String[] minMax = setting.getString().split("-");
|
|
|
|
if (minMax.length == 2)
|
|
try {
|
|
final long min = Long.parseLong(minMax[0]);
|
|
final long max = Long.parseLong(minMax[1]);
|
|
|
|
if (min <= max && min >= 0) return new long[]{min, max};
|
|
|
|
} catch (NumberFormatException ignored) {
|
|
}
|
|
}
|
|
|
|
setting.saveValue("0-" + Long.MAX_VALUE);
|
|
return new long[]{0L, Long.MAX_VALUE};
|
|
}
|
|
} |