Code Monkey home page Code Monkey logo

corelib's Introduction

What is it?

CoreLib是一个工具核心库。

  • 网络库,直接JSON的对象化Request和Response。
  • 大文件下载
  • 文件IO工具类
  • Log系统,支持动态Log开关,Log会保存在本地。
  • 自定义线程池。
  • SingleInstance管理。

Sample工程:

https://github.com/MichaelSun/CorelibSample

集成方式

AndroidMenifest.xml加入一下权限:

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.INTERNET" />

corelib是lib工程,直接导入。

初始化代码加入App,需要在所有的初始化之前:

public class MyApplication extends Application {

    @Override public void onCreate() {        
        /**
        * true: open Log
        * flase: close Log
        * /
        CoreConfig.init(getApplicationContext(), false);
    }
    ...
}

网络

使用标注方式定义API的java bean request,所有的返回数据都会直接解析成Object Response,目前支持JSON。 所有的网络分成RequestResponse,所有的API Request继承自RequestBase,所有的API Response继承自ResponseBase

Log系统

使用CoreConfig.init(getApplicationContext(), true)启动log之后,Log会存储在*/scard/.your_package_name/debug_log.txt*。

如果要在Logcat中过滤Log,使用*adb -d shell DebugLog:d :s

使用方式:

CoreConfig.LOG(msg);
CoreConfig.LOG(tag, msg);
CoreConfig.LOG(msg, Throwable);

Proguard配置

-keep class com.michael.corelib.** {*;}

-keep class * extends com.michael.corelib.internet.core.RequestBase { *; }
-keep class * extends com.michael.corelib.internet.core.ResponseBase { *; }

corelib's People

Contributors

michaelsun avatar wy284086 avatar mandygao 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.