Skip to content

Instantly share code, notes, and snippets.

View jimbray's full-sized avatar

jimbray jimbray

View GitHub Profile
@jimbray
jimbray / findViewById_type
Last active March 4, 2016 01:26
用泛型findViewById
public <T extends View> T $(int id) {
return (T) super.findViewById(id);
}
public <T extends View> T $(View view, int id) {
return (T) view.findViewById(id);
}
@jimbray
jimbray / CommonViewHolder
Created March 4, 2016 09:12
通用的ListView Adapter
package com.zrd.waukeen.common;
import android.content.Context;
import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class CommonViewHolder {
@jimbray
jimbray / change release apk name
Created January 6, 2017 07:37
gradle 修改 release apk 名称
android {}外 定义 获取时间的函数
def release_time() {
return new Date().format("yyyy-MM-dd_HH-mm-ss")
}
更改apk 名称
//修改release apk名称
android.applicationVariants.all {
//质量压缩
private Bitmap compressImage(Bitmap image) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
image.compress(Bitmap.CompressFormat.JPEG, 100, baos);//质量压缩方法,这里100表示不压缩,把压缩后的数据存放到baos中
int options = 100;
while ( baos.toByteArray().length / 1024>100) { //循环判断如果压缩后图片是否大于100kb,大于继续压缩
baos.reset();//重置baos即清空baos
image.compress(Bitmap.CompressFormat.JPEG, options, baos);//这里压缩options%,把压缩后的数据存放到baos中
options -= 10;//每次都减少10
/**
* Created by jimbray on 2018/11/18.
* Email: jimbray16@gmail.com
*/
public class RosBridgeClientManager {
private static final String TAG = RosBridgeClientManager.class.getSimpleName();
private static RosBridgeClientManager instance;