This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
android {}外 定义 获取时间的函数 | |
def release_time() { | |
return new Date().format("yyyy-MM-dd_HH-mm-ss") | |
} | |
更改apk 名称 | |
//修改release apk名称 | |
android.applicationVariants.all { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 判断是否是 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)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer); | |
drawerToggle = setupDrawerToggle(); | |
mDrawerLayout.setDrawerListener(drawerToggle); | |
private ActionBarDrawerToggle setupDrawerToggle() { | |
return new ActionBarDrawerToggle(this, mDrawerLayout, mToolbar, | |
R.string.app_name, R.string.app_name); | |
} | |
@Override |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//质量压缩 | |
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static Object reflect2(Object obj) { | |
if (obj == null) | |
return null; | |
Field[] fields = obj.getClass().getDeclaredFields(); | |
for (int j = 0; j < fields.length; j++) { | |
fields[j].setAccessible(true); | |
// 字段名 | |
System.out.print(fields[j].getName() + ","); | |
// 字段值 | |
if (fields[j].getType().getName().equals( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static String getCurVersionName(Context context) { | |
String versionName = null; | |
try { | |
PackageInfo pInfo = context.getPackageManager().getPackageInfo( | |
context.getPackageName(), 0); | |
versionName = pInfo.versionName; | |
} catch (NameNotFoundException e) { | |
versionName = "没有版本号"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 根据value寻找key | |
* @param map | |
* @param value | |
* @return | |
*/ | |
public static String getMapKeyByValue(HashMap<String, String> map, Object value) { | |
Set<String> kset = map.keySet(); | |
for(String ks : kset){ | |
if(value.equals(map.get(ks))) { |
NewerOlder