Skip to content

Instantly share code, notes, and snippets.

View jimbray's full-sized avatar

jimbray jimbray

View GitHub Profile
@jimbray
jimbray / isTablet
Last active March 3, 2016 08:52
判断设备是否是 Tablet,适配Tablet设备的时候特别有用。
/**
* 判断是否是 Tablet
*
* @param activity Activity
* @return true, if is tablet device
*/
public static boolean isTablet(Activity activity) {
DisplayMetrics dm = new DisplayMetrics();
activity.getWindowManager().getDefaultDisplay().getMetrics(dm);
double diagonalPixels = Math.sqrt(Math.pow(dm.widthPixels, 2) + Math.pow(dm.heightPixels, 2));
@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 {
/**
* 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;