fqxyi 发布的文章

LifeCycle源码解读

对于LifeCycle的简单使用可以看上一篇文章:LiveData+ViewModel+Repository搭建MVVM

这篇文章主要是为了阅读源码,尽量深入阅读,能力还是一般,见谅:

LifeCycle的作用

解决onCreate等生命周期方法,由于各种原因,后期越来越臃肿的问题。

关键类阐述

LifecycleRegistryOwner/LifecycleOwner

在Activity等组件生命周期发生变化的时候,发出相应的Event给LifecycleRegistry。

LifecycleRegistry

控制state的转换、接受分发Event事件。

LifecycleObserver

通过注解绑定Event和自定义的函数,实现对生命周期的监听并处理。

Event

@SuppressWarnings("WeakerAccess")
public enum Event {
    /**
     * Constant for onCreate event of the {@link LifecycleOwner}.
     */
    ON_CREATE,
    /**
     * Constant for onStart event of the {@link LifecycleOwner}.
     */
    ON_START,
    /**
     * Constant for onResume event of the {@link LifecycleOwner}.
     */
    ON_RESUME,
    /**
     * Constant for onPause event of the {@link LifecycleOwner}.
     */
    ON_PAUSE,
    /**
     * Constant for onStop event of the {@link LifecycleOwner}.
     */
    ON_STOP,
    /**
     * Constant for onDestroy event of the {@link LifecycleOwner}.
     */
    ON_DESTROY,
    /**
     * An {@link Event Event} constant that can be used to match all events.
     */
    ON_ANY
}

- 阅读剩余部分 -

LiveData+ViewModel+Repository搭建MVVM

什么是LiveData

LiveData is an observable data holder class. Unlike a regular observable, LiveData is lifecycle-aware, meaning it respects the lifecycle of other app components, such as activities, fragments, or services. This awareness ensures LiveData only updates app component observers that are in an active lifecycle state.
Source:https://developer.android.com/topic/libraries/architecture/livedata.html

什么是ViewModel

The ViewModel class is designed to store and manage UI-related data in a lifecycle conscious way. The ViewModel class allows data to survive configuration changes such as screen rotations.
Source:https://developer.android.com/topic/libraries/architecture/viewmodel

ViewModel的生命周期

ViewModel的生命周期

- 阅读剩余部分 -

Linux安装Android SDK

步骤

  1. 官网下载Command line tools only
  2. 解压后执行./tools/android update sdk
  3. 再执行./tools/bin/sdkmanager "build-tools;26.0.2",用于安装build-tools
  4. 执行./tools/bin/sdkmanager "platform-tools",用于安装platform-tools
  5. 执行./tools/bin/sdkmanager "platforms;android-26",用于安装platforms
  6. 最后,更多sdkmanager命令请查看官方文档,例如:执行./tools/bin/sdkmanager --update --sdk_root=指定sdk安装目录路径,用于指定sdk安装目录

Linux安装Jenkins教程

步骤

下载war后将文件复制到 Tomcat 中的 webapps 目录,通过地址 http://localhost:8080/jenkins 打开 Jenkins 的 web 页。

初始管理员密码位置:/root/.jenkins/secrets/initialAdminPassword

FAQ

Jenkenis报错:该jenkins实例似乎已离线

解决方法:
安装插件那个页面,就是提示你offline的那个页面,不要动。然后打开一个新的tab,输入网址http://localhost:8080/jenkins/pluginManager/advanced。 这里面最底下有个【升级站点】,把其中的链接改成http的就好了(http://updates.jenkins.io/update-center.json)。 然后在服务列表中关闭jenkins,再启动(war包形式安装的话,这样做:service tomcat restart),这样就能正常联网了。