Skip to content

Instantly share code, notes, and snippets.

@easternHong
easternHong / ImageProcessing.java
Created December 29, 2014 10:23
YUV420_to_RGB;decodeYUV420SPtoLuma;rgbToBitmap;lumaToGreyscale;
package com.jwetherell.motion_detection.image;
import java.io.ByteArrayOutputStream;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.Matrix;
/**
@easternHong
easternHong / build.gradle
Last active August 29, 2020 07:59
android studio gradle checkstyle findbugs pmd lint
//go to https://github.com/easternHong/vb-android-app-quality
//get the config file and put them into app/config/..
apply plugin: 'pmd'
apply plugin: 'findbugs'
apply plugin: 'checkstyle'
task findbugs(type: FindBugs) {
description 'Run findbugs'
group 'verification'
classes = fileTree('build/intermediates/classes/debug/')
@easternHong
easternHong / StringUtils.java
Last active March 2, 2018 09:41
ByteArrayToHexString HexStringToByteArray
/**
* Utility method to convert a byte array to a hexadecimal string.
*
* @param bytes Bytes to convert
* @return String, containing hexadecimal representation.
*/
public static String ByteArrayToHexString(byte[] bytes) {
final char[] hexArray = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
char[] hexChars = new char[bytes.length * 2]; // Each byte has two hex characters (nibbles)
int v;
@easternHong
easternHong / .pac
Created November 14, 2017 07:50
OmegaProfile_Auto_Switch
var FindProxyForURL = function(init, profiles) {
return function(url, host) {
"use strict";
var result = init, scheme = url.substr(0, url.indexOf(":"));
do {
result = profiles[result];
if (typeof result === "function") result = result(url, host, scheme);
} while (typeof result !== "string" || result.charCodeAt(0) === 43);
return result;
};
@easternHong
easternHong / .pac
Created November 14, 2017 07:50
OmegaProfile_Auto_Switch
var FindProxyForURL = function(init, profiles) {
return function(url, host) {
"use strict";
var result = init, scheme = url.substr(0, url.indexOf(":"));
do {
result = profiles[result];
if (typeof result === "function") result = result(url, host, scheme);
} while (typeof result !== "string" || result.charCodeAt(0) === 43);
return result;
};
@Message
public static class MsgHeader {
public MsgHeader() {
msgId = -1;
}
@Index(0)
public int msgId;
public byte[] toBytes() {
@easternHong
easternHong / ClassUtils.java
Created February 22, 2016 06:34
无需反射,获取一个类的实例...
/**
* <p>Operates on classes without using reflection.</p>
* <p/>
* <p>This class handles invalid {@code null} inputs as best it can.
* Each method documents its behaviour in more detail.</p>
* <p/>
* <p>The notion of a {@code canonical name} includes the human
* readable name for the type, for example {@code int[]}. The
* non-canonical method variants work with the JVM names, such as
* {@code [I}. </p>
@easternHong
easternHong / build脚本
Created June 24, 2015 06:25
ubuntu shell
#!/bin/bash
cd /home/hunt/AndroidStudioProjects/EFamily/EFamily
branch=''
printf "please input branch :"
read branch
git co ${branch}
#echo ${branch}
time=`date +"%02m%d%H"`
build=`date +"%m%d%H"`
@easternHong
easternHong / onLayout.java
Created December 8, 2015 14:29
android view layout children
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
int row, col, left, top;
for (int i=0; i < getChildCount(); i++) {
row = i / mColumnCount;
col = i % mColumnCount;
View child = getChildAt(i);
left = col * child.getMeasuredWidth();
top = row * child.getMeasuredHeight();
@easternHong
easternHong / measure.java
Last active December 8, 2015 13:52
Android View Measure
//https://github.com/devunwired/custom-view-examples/tree/master/app/src/main/java/com/example/customview/widget
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
setMeasuredDimension(measure(widthMeasureSpec, true), measure(heightMeasureSpec, false));
}
private int measure(int measureSpec, boolean isWidth) {
int result;
int mode = MeasureSpec.getMode(measureSpec);
int size = MeasureSpec.getSize(measureSpec);