ToastUtils
public class ToastUtils {
private static Toast mToast;
public static void showToast(String tips){
if (mToast == null) {
mToast = Toast.makeText(BaseApplication.getContext(), tips, Toast.LENGTH_SHORT);
}else {
mToast.show();
}
}
}
SizeUtils
public class SizeUtils {
public static int dip2px(Context context, float dpValue) {
float scale = context.getResources().getDisplayMetrics().density;
return (int) (dpValue * scale + 0.5f);
}
public static int px2dip(Context context, float pxValue) {
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (pxValue / scale + 0.5f);
}
}
LogUtils
public class LogUtils {
private static int currentLev = 5;
private static final int DEBUG_LEV = 4;
private static final int INFO_LEV = 3;
private static final int WARNING_LEV = 2;
private static final int ERROR_LEV = 1;
public static void d(Object clazz,String log) {
if(currentLev >= DEBUG_LEV) {
Log.d(clazz.getClass().getSimpleName(),log);
}
}
public static void i(Object clazz,String log) {
if(currentLev >= INFO_LEV) {
Log.i(clazz.getClass().getSimpleName(),log);
}
}
public static void w(Object clazz,String log) {
if(currentLev >= WARNING_LEV) {
Log.w(clazz.getClass().getSimpleName(),log);
}
}
public static void e(Object clazz,String log) {
if(currentLev >= ERROR_LEV) {
Log.e(clazz.getClass().getSimpleName(),log);
}
}
}
RetrofitManager
public class RetrofitManager {
public static final RetrofitManager mRetrofitManager = new RetrofitManager();
private final Retrofit mRetrofit;
public static RetrofitManager getInstance() {
return mRetrofitManager;
}
public RetrofitManager() {
this.mRetrofit = new Retrofit.Builder()
.baseUrl(Constant.BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.build();
}
public Retrofit getRetrofit(){
return mRetrofit;
}
}
|