Skip to content

Instantly share code, notes, and snippets.

⚽️
working

haohao haohaozaici

⚽️
working
Block or report user

Report or block haohaozaici

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View DisableFlagSecureModule.java
package fi.veetipaananen.android.disableflagsecure;
import android.os.Build;
import android.view.SurfaceView;
import android.view.Window;
import android.view.WindowManager;
import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedHelpers;
View AudioFocusManager.java
/**
* 用AudioManager获取音频焦点避免音视频声音重叠问题
*/
public class AudioFocusManager {
private static final String TAG = "AudioFocusManager";
private Context mContext;
private AudioManager mAudioManager;
private AudioManager.OnAudioFocusChangeListener mAudioFocusChangeListener;
View bytesToHex.java
private final static char[] hexArray = "0123456789ABCDEF".toCharArray();
public static String bytesToHex(byte[] bytes) {
char[] hexChars = new char[bytes.length * 2];
for ( int j = 0; j < bytes.length; j++ ) {
int v = bytes[j] & 0xFF;
hexChars[j * 2] = hexArray[v >>> 4];
hexChars[j * 2 + 1] = hexArray[v & 0x0F];
}
return new String(hexChars);
}
View dp dx convert.java
/**
* This method converts dp unit to equivalent pixels, depending on device density.
*
* @param dp A value in dp (density independent pixels) unit. Which we need to convert into pixels
* @param context Context to get resources and device specific display metrics
* @return A float value to represent px equivalent to dp depending on device density
*/
public static float convertDpToPixel(float dp, Context context){
Resources resources = context.getResources();
DisplayMetrics metrics = resources.getDisplayMetrics();
View humanReadableByteCount.java
public static String humanReadableByteCount(long bytes, boolean si) {
int unit = si ? 1000 : 1024;
if (bytes < unit) return bytes + " B";
int exp = (int) (Math.log(bytes) / Math.log(unit));
String pre = (si ? "kMGTPE" : "KMGTPE").charAt(exp-1) + (si ? "" : "i");
return String.format("%.1f %sB", bytes / Math.pow(unit, exp), pre);
}
//example outputs
SI BINARY
View TabLayoutUtil.java
public class TabLayoutUtil {
/**
* 通过反射修改TabLayout Indicator的宽度(仅在Android 4.2及以上生效)
*/
public static void setUpIndicatorWidth(TabLayout tabLayout, int marginLeft, int marginRight) {
Class<?> tabLayoutClass = tabLayout.getClass();
Field tabStrip = null;
try {
tabStrip = tabLayoutClass.getDeclaredField("mTabStrip");
You can’t perform that action at this time.