Giter Site home page Giter Site logo

easyutils's Introduction

icon

android开发常用工具类


目录

###Config### 配置类

  1. boolean isAppReleased应用是否已发布,默认为false
  2. boolean isDevLogDisplayOn是否输出日志信息,默认应用发布时关闭。
  3. boolean isDevToastDisplayOn是否显示开发期临时Toast,默认应用发布时关闭。

###Dimension ### 单位转换工具
使用方法:

  1. dp转px
    Dimension.dp2px(Context context, float value);
  2. px转dp
    Dimension.px2dp(Context context, float value);

###L ### 用于输出日志等信息,主要为了完成app发布后的log清除工作。

使用方法:
主要使用方法有三种(以error信息为例)

  1. 指定TAG输出。
    L.e(String TAG, String msg);
  2. 不指定TAG,传入当前类的实例,实际输出TAG为当前类的类名。 L.e(Object obj, String msg);
  3. 不传人任何TAG信息,输出TAG为调用该方法的类的类名。
    L.e(String msg);

    其中也包含Log中的其他用法,如:L.e(String tag, String msg, Throwable tr);,同时也包含另外两种传递Object和不传入任何作为TAG参数的传递方法。
    注:w(String msg, Throwable tr)w(String tag, Throwable tr)冲突,保留w(String tag, Throwable tr)。

    应用发布时将L.java里面的display赋值为false即可使应用不再打印日志信息。
    推荐在Config内配置isDevLogDisplayOnfalse禁用Log打印。

###NetWork ### 获取网络状态
使用方法:

  1. 网络是否连接
    NetWork.isConnected(Context context);
  2. 获取网络连接类型
    NetWork.getType(Context context);
    Type.WIFI 网络连接类型为wifi
    Type.G2 网络连接类型为2G网络
    Type.G3 网络连接类型为3G网络
    Type.G4 网络连接类型为4G网络
    Type.OTHER 网络连接类型为其他网络
    Type.NONE 网络未连接
  3. 是否为wifi网络
    NetWork.isWifi(Context context);
  4. 是否为4G网络
    NetWork.isG4(Context context);
  5. 是否为3G网络
    NetWork.isG3(Context context);
  6. 是否为2G网络
    NetWork.isG2(Context context);
  7. 是否开启GPS
    NetWork.isGpsEnabled(Context context);

###Screen ### 获取屏幕信息
使用方法:

  1. 获取像素密度
    Screen.getDensity(Context context);
  2. 获取像素宽度
    Screen.getWidthPixels(Context context);
  3. 获取像素高度
    Screen.getHeightPixels(Context context);
  4. 获取状态栏高度
    Screen.getStatusBarHeight(Activity activity);
  5. 获取标题栏高度
    Screen.getTitleBarHeight(Activity activity);
  6. 获取内容部分高度
    Screen.getContentHeight(Activity activity);

###T ### 用于显示Toast,主要为了完成app发布后的Toast清除工作。

使用方法:
T.show(Context context, String msg);


Copyright © www.funol.net

easyutils's People

Contributors

4332weizi avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.