This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
场景:dialogfragment(tabLayout+viewpager) + 两个Afragment | |
解决方案一: | |
class SafeMutableLiveData<T> : MutableLiveData<T>() { | |
private var weakLifecycleOwner: WeakReference<LifecycleOwner>? = null | |
override fun observe(owner: LifecycleOwner, observer: Observer<in T>) { | |
weakLifecycleOwner?.get()?.let { | |
removeObservers(it) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dialogfragment使用记录 | |
https://gist.github.com/yizuochengchi/2ad1e5e0127a3d42dd7c569da132c292 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1.MaterialButton | |
常规使用 | |
android:insetTop="0dp" | |
android:insetBottom="0dp" | |
android:textAppearance="?android:attr/textAppearance" | |
selector enable false | |
app:backgroundTint="@color/login_selector_button" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
换了家公司 新公司用的是windows系统 入职第一天搭建环境 | |
1.安装jdk1.8发现orale需要注册账号才可以下载 fuck!之前印象中好像没有 | |
无奈从论坛下载 | |
2.新建项目报错 Received status code 400 from server: Bad Request | |
懵逼了半天 解决办法 删除.gradle目录下 gradle.properties 最后4行设置的代理 | |
感谢 https://www.jianshu.com/p/e0ba79c83183 | |
window坑真多啊 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1.正常使用大家都知道 fromJson等 | |
2.将json字符串中某个字段转换成实体类代码如下 | |
if (data.has("pop")) { | |
val jsonElement = Gson().fromJson<JsonElement>(json, JsonElement::class.java) | |
val pop = jsonElement.asJsonObject.getAsJsonObject("data").getAsJsonObject("pop") | |
val bean = Gson().fromJson<Bean>(pop, Bean::class.java) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
thanks | |
1.https://stackoverflow.com/questions/56878906/remove-viewpager2-overscroll-animatoin | |
viewPager2.apply { | |
orientation = ViewPager2.ORIENTATION_HORIZONTAL | |
(getChildAt(0) as RecyclerView).overScrollMode = RecyclerView.OVER_SCROLL_NEVER | |
} | |
android:overScrollMode="never" is not working |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1.tabTextAppearance | |
<style name="YourTextAppearance" parent="TextAppearance.AppCompat.Button"> | |
<item name="android:textSize">20sp</item> | |
... | |
</style> | |
<com.google.android.material.tabs.TabLayout | |
android:id="@+id/tabLayout" | |
android:layout_width="match_parent" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 播放raw下的本地文件 | |
*/ | |
fun initPlayer(context: Context, rawRes: Int): SimpleExoPlayer { | |
val dataSpec = DataSpec(RawResourceDataSource.buildRawResourceUri(rawRes)) | |
val dataSource = RawResourceDataSource(context) | |
dataSource.open(dataSpec) | |
val bandwidthMeter = DefaultBandwidthMeter() | |
val extractorsFactory = DefaultExtractorsFactory() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
早上做地铁 在应用商店打开app 看到oppo应用商店的安全评测分平均分 92 | |
其中启动60 启动时间4s且有白屏 | |
应用启动这块一直想优化 但一直没顾得上 | |
查文档: | |
https://developer.android.com/topic/performance/vitals/launch-time | |
理论认知: | |
应用的启动方式 | |
冷启动:当启动应用时,后台没有该应用的进程,这时系统会首先会创建一个新的进程分配给该应用,这种启动方式就是冷启动。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
旧项目中使用Volley | |
移植入Okhttp Retrofit 如何同步cookie | |
1.之前的思路: | |
Volley 底层替换 | |
class OkHttpStack( | |
private val okHttpClient: OkHttpClient | |
) : BaseHttpStack() { |
NewerOlder