EventBus
-
先
EventBus.getDefault()
生成一个EventBus()单例,并初始化EventBus所需数据 -
注册,注销EventBus
a.EventBus.getDefault().register(this)
注册EventBus
b.EventBus.getDefault().unregister(this)
注销EventBus
c.subscriber.getClass()
获取每个注册的Class 放入 subscriptionsByEventType -
EventBus.getDefault().post("hello")
调用post(Object event)方法,post方法执行:- 放入队列
用ThreadLocal<PostingThreadState>
创建currentPostingThreadState
,
PostingThreadState postingState = currentPostingThreadState.get(); List<Object> eventQueue = postingState.eventQueue; eventQueue.add(event);
把event装入eventQueue队列 - 获取event的类型
获取event的event放入eventTypes
获取event的Class和event的类型(Object、String、Comparable、com.hande.common.event.Events$ClearMessageInList等类型)
放入
Map<Class<?>, List<Class<?>>> eventTypesCache
- 遍历eventTypes 得到 eventType 再遍历 subscriptions
subscription.subscriberMethod.method.invoke(subscription.subscriber, event)
发送事件- EmoticonPickerView 接收到事件
threadMode = ThreadMode.MAIN
就是主线程处理事件
- 放入队列
ThirdPart
腾讯X5webview:
tbs_sdk_thirdapp_v4.3.0.3_43903_sharewithdownloadwithfile_withoutGame_obfs_20200402_121309.jar
折叠屏
已删除今日头条屏幕适配方案
implementation 'me.jessyan:autosize:1.1.2'
<meta-data
android:name="design_width_in_dp"
android:value="375" />
<meta-data
android:name="design_height_in_dp"
android:value="667" />
华为折叠屏适配方案:
1.在每个activity里加:
android:configChanges="screenSize|smallestScreenSize|screenLayout"
2.在 manifest 文件的 < application > 节点中增加 < meta-data > 数据:
<meta-data
android:name="android.min_aspect"
android:value="1.0" />
国际化多语言
- 获取本地国家
Locale.getDefault().getLanguage()
- 获取本地区域(如:香港 HK、台湾 TW)
Locale.getDefault().getCountry()