基本内容

包结构

Android项目目录结构模板以及简单说明【简单版】
https://www.cnblogs.com/whycxb/p/9739148.html

常用插件

https://blog.csdn.net/jia635/article/details/78811892

使用 lambda

app build.gradle 添加

android {    compileOptions {        sourceCompatibility = '1.8'        targetCompatibility = '1.8'        sourceCompatibility JavaVersion.VERSION_1_8        targetCompatibility JavaVersion.VERSION_1_8    }}

log 封装

import android.util.Log;import com.laolang.shopone.helloj.BuildConfig;public class LogUtil {    static String className;//类名    static String methodName;//方法名    static int lineNumber;//行数    /**     * 判断是否可以调试     * @return     */    public static boolean isDebuggable() {        return BuildConfig.DEBUG;    }    private static String createLog(String log ) {        StringBuffer buffer = new StringBuffer();        buffer.append("================");        buffer.append(methodName);        buffer.append("(").append(className).append(":").append(lineNumber).append(")================:");        buffer.append(log);        return buffer.toString();    }    /**     * 获取文件名、方法名、所在行数     * @param sElements     */    private static void getMethodNames(StackTraceElement[] sElements){        className = sElements[1].getFileName();        methodName = sElements[1].getMethodName();        lineNumber = sElements[1].getLineNumber();    }    public static void e(String message){        if (!isDebuggable())            return;        getMethodNames(new Throwable().getStackTrace());        Log.e(className, createLog(message));    }    public static void i(String message){        if (!isDebuggable())            return;        getMethodNames(new Throwable().getStackTrace());        Log.i(className, createLog(message));    }    public static void d(String message){        if (!isDebuggable())            return;        getMethodNames(new Throwable().getStackTrace());        Log.d(className, createLog(message));    }    public static void v(String message){        if (!isDebuggable())            return;        getMethodNames(new Throwable().getStackTrace());        Log.v(className, createLog(message));    }    public static void w(String message){        if (!isDebuggable())            return;        getMethodNames(new Throwable().getStackTrace());        Log.w(className, createLog(message));    }}

效果

更多相关文章

  1. Android的文件系统结构
  2. Android(安卓)FragmentActivity Intent 跳转封装
  3. 在android中玩转wcf
  4. android 学习视频
  5. Android学习笔记1——建立android工程及其目录结构
  6. Android(安卓)Studio使用教程、工程目录结构、使用注意事项、常
  7. android体系结构
  8. Android入门教程(四)之------Android工程目录结构介绍
  9. Android(安卓)分析 Android(安卓)应用结构

随机推荐

  1. android下lcd显示的两个问题
  2. 解决 Linux/Ubuntu: adb shell insufficie
  3. Official Note of Android (important pa
  4. 不同Activity之间传递数据
  5. android蓝牙开发入门到精通3---服务端客
  6. android中的Sqlite数据库操作
  7. Android(安卓)修改默认按键不震动
  8. android spinner下拉选择框
  9. android 存储一些app配置信息
  10. android 使用md5加密