Search in sources :

Example 1 with LoggConfiguration

use of com.logg.config.LoggConfiguration in project Logg by RockyQu.

the class PrinterManager method init.

@Override
public void init() {
    LoggConfiguration configuration = new LoggConfiguration.Buidler().setDebug(true).build();
    this.init(configuration);
}
Also used : LoggConfiguration(com.logg.config.LoggConfiguration)

Example 2 with LoggConfiguration

use of com.logg.config.LoggConfiguration in project Logg by RockyQu.

the class Utils method objectToString.

/**
 * Object to String
 *
 * @param object
 * @param childLevel
 * @return
 */
private static String objectToString(Object object, int childLevel) {
    if (object == null) {
        return LoggConstant.NULL;
    }
    if (childLevel > LoggConstant.MAX_LEVEL) {
        return object.toString();
    }
    // 自定义解析类判断
    LoggConfiguration loggConfig = PrinterManager.getInstance().getConfiguration();
    if (loggConfig != null) {
        for (Parser parser : loggConfig.getParsers()) {
            if (parser.parseClassType().isAssignableFrom(object.getClass())) {
                return parser.parseString(object);
            }
        }
    }
    // 是否是数组
    if (Utils.isArray(object)) {
        return Utils.parseArray(object);
    }
    if (object.toString().startsWith(object.getClass().getName() + "@")) {
        StringBuilder builder = new StringBuilder();
        iterateClassFields(object.getClass(), builder, object, false, childLevel);
        Class superClass = object.getClass().getSuperclass();
        while (!superClass.equals(Object.class)) {
            iterateClassFields(superClass, builder, object, true, childLevel);
            superClass = superClass.getSuperclass();
        }
        return builder.toString();
    }
    return object.toString();
}
Also used : LoggConfiguration(com.logg.config.LoggConfiguration) Parser(com.logg.parser.Parser)

Example 3 with LoggConfiguration

use of com.logg.config.LoggConfiguration in project MVPFrames by RockyQu.

the class AppConfiguration method injectAppLifecycle.

@Override
public void injectAppLifecycle(Context context, List<ApplicationLifecycles> lifecycleManager) {
    // AppDelegateManager.Lifecycle的所有方法都会在基类Application对应的生命周期中被调用,所以在对应的方法中可以扩展一些自己需要的逻辑
    lifecycleManager.add(new ApplicationLifecycles() {

        @Override
        public void onCreate(Application application) {
            LoggConfiguration configuration = new LoggConfiguration.Buidler().setDebug(BuildConfig.DEBUG_FLAG).build();
            Logg.init(configuration);
            // LeakCanary内存泄露检查
            ((App) application).getAppComponent().extras().put(RefWatcher.class.getName(), BuildConfig.DEBUG_FLAG ? LeakCanary.install(application) : RefWatcher.DISABLED);
        }

        @Override
        public void onTerminate(Application application) {
        }
    });
    lifecycleManager.add(new ApplicationLifecycles() {

        // 渠道名称,必须与Mainfests渠道配置name相同
        final String CHANNEL = "Channel";

        @Override
        public void onCreate(Application application) {
            // 项目在SDCard下创建的目录
            if (!ProjectUtils.init(AppUtils.getAppChannel(application, CHANNEL))) {
            // 失败
            }
        }

        @Override
        public void onTerminate(Application application) {
        }
    });
    lifecycleManager.add(new ApplicationLifecycles() {

        @Override
        public void onCreate(Application application) {
            // 读取当前登录用户信息
            String value = PreferencesUtils.getString(application, LoginActivity.class.getName(), null);
            if (value != null) {
                User user = GsonUtils.getEntity(value, User.class);
                ((App) application).getAppComponent().extras().put(LoginActivity.class.getName(), user);
            }
        }

        @Override
        public void onTerminate(Application application) {
        }
    });
    lifecycleManager.add(new ApplicationLifecycles() {

        @Override
        public void onCreate(Application application) {
            DownloaderConfiguration configuration = DownloaderConfiguration.builder().application(application).debug(BuildConfig.DEBUG_FLAG).build();
            Downloader.getInstance().init(configuration);
        }

        @Override
        public void onTerminate(Application application) {
        }
    });
}
Also used : LoggConfiguration(com.logg.config.LoggConfiguration) User(com.frame.mvp.entity.User) ApplicationLifecycles(com.tool.common.base.delegate.ApplicationLifecycles) Application(android.app.Application) DownloaderConfiguration(com.tool.common.http.download.config.DownloaderConfiguration)

Aggregations

LoggConfiguration (com.logg.config.LoggConfiguration)3 Application (android.app.Application)1 User (com.frame.mvp.entity.User)1 Parser (com.logg.parser.Parser)1 ApplicationLifecycles (com.tool.common.base.delegate.ApplicationLifecycles)1 DownloaderConfiguration (com.tool.common.http.download.config.DownloaderConfiguration)1