Skip to content

Commit

Permalink
Clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
FongMi committed Oct 20, 2023
1 parent ab2ec2f commit 516e84e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
8 changes: 0 additions & 8 deletions catvod/src/main/java/com/github/catvod/utils/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Formatter;

public class Util {

public static final String CHROME = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36";
public static final String[] UNITS = new String[]{"bytes", "KB", "MB", "GB", "TB"};

public static String getDeviceId() {
return Settings.Secure.getString(Init.context().getContentResolver(), Settings.Secure.ANDROID_ID);
Expand Down Expand Up @@ -145,10 +143,4 @@ public static String fixHeader(String key) {
if (key.equalsIgnoreCase(HttpHeaders.COOKIE)) return HttpHeaders.COOKIE;
return key;
}

public static String size(long size) {
if (size <= 0) return "";
int group = (int) (Math.log10(size) / Math.log10(1024));
return "[" + new DecimalFormat("###0.#").format(size / Math.pow(1024, group)) + " " + UNITS[group] + "] ";
}
}
8 changes: 8 additions & 0 deletions thunder/src/main/java/com/xunlei/downloadlib/Util.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
package com.xunlei.downloadlib;

import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.List;

public class Util {

private static final List<String> VIDEO = Arrays.asList("avi", "flv", "mkv", "mov", "mp4", "mpeg", "mpe", "mpg", "wmv");
private static final List<String> AUDIO = Arrays.asList("aac", "ape", "flac", "mp3", "m4a", "ogg");
private static final String[] UNITS = new String[]{"bytes", "KB", "MB", "GB", "TB"};
private static final long MINIMAL = 30 * 1024 * 1024;

public static boolean isMedia(String ext, long size) {
return (VIDEO.contains(ext) || AUDIO.contains(ext)) && size > MINIMAL;
}

public static String size(long size) {
if (size <= 0) return "";
int group = (int) (Math.log10(size) / Math.log10(1024));
return "[" + new DecimalFormat("###0.#").format(size / Math.pow(1024, group)) + " " + UNITS[group] + "] ";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import android.text.TextUtils;

import com.github.catvod.utils.Util;
import com.xunlei.downloadlib.Util;

import java.io.File;
import java.util.Collections;
Expand Down

0 comments on commit 516e84e

Please sign in to comment.