2.8k words 3 mins.

# 题记 创造财富是致富的一种直接的方式。(Creating wealth is a way to get rich.)而财富,是你身上拥有,且别人需要的东西。 # 最佳途径 如果想变得富有,最好的方式是创立或者加盟初创科技公司,特别是攻克技术难题的公司。这是一种几百年来,屡试不爽可靠的致富方式。 #...
59 words 1 mins.

年轻的时候,总以为钱很重要。 长大以后,才发觉,那时还是太年轻。 生活不仅有眼前的苟且,还有诗和远方。 但也需要一路的盘缠。
9.5k words 9 mins.

# InputStream InputStream: 输入流的抽象,提供应用程从内存读取任意字节数(read 指针向后偏移),跳过,标记流位置(标记一个索引位置,reset 后,read 指针会重置为 mark 的值),流剩余字节数的 API。 FilterInputStream: 算是装饰者,包装或者聚合了 InputStream ,使用它作为基本的数据源。覆盖 InputStream 所有方法,简单的把方法调用转发给 InputStream 。 a public abstract class InputStream implements Closeable {...
559 words 1 mins.

# Return true at onTouchEvent of the child view during action down The subsequent move and up actions will be dispatched to the child view directly, but the parent views still have a chance to intercept the actions. Once the parent views intercept the touch event during move action by return true...
71 words 1 mins.

View 坐标系原点在 parent view 左上角,left, top, right, bottom 是 child view 左上角和右下角相对坐标轴的距离。
10k words 9 mins.

# 生命周期回调方法映射为事件,并派发给 LifeCycle androidx.fragment.app.FragmentActivity#onStart@Overrideprotected void onStart() { super.onStart(); // …… // NOTE: HC onStart goes here. mFragmentLifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_START);...
29k words 26 mins.

# remove & detach Fragment 差别 public void removeFragment(Fragment fragment) { if (DEBUG) Log.v(TAG, "remove: " + fragment + " nesting=" + fragment.mBackStackNesting); final boolean inactive = !fragment.isInBackStack(); if (!fragment.mDetached || inactive)...
29k words 26 mins.

# 总结 使用 Fragment 的 Activity 需要继承 FragmentActivity 这里有派发生命周期方法给 FragmentManager,再派发给旗下 Fragment。 加入 Fragment 时,需要判断 savedInstanceState == null ,避免重复创建实例。 add Fragment,初始时,其 Fragment 生命周期方法会被升级到 onStart 状态,随后与 FragmentManager 的状态同步,如果宿主 Activity 是 Resume 状态,则同步至 onResume 状态。 detach...
8.1k words 7 mins.

# ViewModel 源码剖析 # 示例代码 ViewModel 负责数据存储,借助 LiveData,实现异步获取数据,完成后,通知 UI 观察者,更新 UI public class MyViewModel extends ViewModel { private MutableLiveData<List<User>> users; public LiveData<List<User>> getUsers() { if (users == null) {...
1k words 1 mins.

Requirement:: 应用内有些 Activity 数据敏感,需要区别对待,这里需要识别首次进入红色 Activity 集合内,在红色 Activity 集合内跳转,和跳出红色 Activity 集合三种情况。【当红色 Activity 集合是应用内的 Activity 集合时,就相当于首次进入应用,应用内界面跳转和退出应用的判定】 算法描述: 定义一个保存 Activity Simple Name 的集合。 Activity onResume 时,将此 Activity Simple Name 加入集合。 当集合元素个数等于 1 时,为首次进入该应用打开的第一个...