Skip to content

Instantly share code, notes, and snippets.

@CodeK1988
CodeK1988 / DialogFragment
Last active September 9, 2019 02:02
DialogFragment相关记录
1.dialogfragment 返回事件处理
继承 DialogInterface.OnKeyListener
override fun onKey(dialog: DialogInterface?, keyCode: Int, event: KeyEvent?): Boolean {
return keyCode == KeyEvent.KEYCODE_BACK //自行修改 我的是禁用返回键
}
donot forget
dialog.setOnKeyListener(this)
@CodeK1988
CodeK1988 / 优化您的构建速度
Last active August 15, 2019 01:56
android studio
thanks
https://developer.android.com/studio/build/optimize-your-build?hl=zh-cn
https://developer.android.com/studio/releases/gradle-plugin
@CodeK1988
CodeK1988 / AppBarLayout NestedScrollView 以及顶部视频调节亮度进度等事件处理
Created August 14, 2019 10:07
AppBarLayout NestedScrollView 以及顶部视频调节亮度进度等事件处理
thanks:
[Manage touch events in a ViewGroup](https://developer.android.com/training/gestures/viewgroup)
https://medium.com/@suragch/how-touch-events-are-delivered-in-android-eee3b607b038
焦点问题遇到的比较少 特此记录一下 加深理解和记忆
@CodeK1988
CodeK1988 / VerticalOnlyNestedScrollView
Created August 14, 2019 09:04
VerticalOnlyNestedScrollView
/**
* thanks https://stackoverflow.com/questions/36093384/stop-nestedscrollview-inside-viewpager-to-process-horizontal-scrolls
*/
public class VerticalOnlyNestedScrollView extends NestedScrollView {
public VerticalOnlyNestedScrollView(Context context) {
super(context);
}
@CodeK1988
CodeK1988 / xiaomi takephoto Gallery Intent.ACTION_GET_CONTENT
Created August 12, 2019 03:30
xiaomi takephoto Gallery Intent.ACTION_GET_CONTENT not working
@CodeK1988
CodeK1988 / RecyclerView notes
Last active August 5, 2019 10:27
RecyclerView相关笔记
1.NestedScrollView RecyclerView recyclerView always scroll top
add
recyclerView.isFocusableInTouchMode = false
recyclerView.requestFocus()
its working!
2.addItemDecoration
if (recyclerView.itemDecorationCount > 0) {
val itemDecorationAt = recyclerView.getItemDecorationAt(0)
if (itemDecorationAt == null) {
@CodeK1988
CodeK1988 / Bitmap too large to be uploaded into a texture
Last active July 31, 2019 04:50
图片满屏宽高比1:5 长图 小米机上报错 Bitmap too large to be uploaded into a texture
Bitmap too large to be uploaded into a texture (1080x4153, max=4096x4096)
thanks:
https://medium.com/digio-australia/custom-image-manipulation-crop-and-translate-at-load-time-with-glide-on-android-cb556f5a5aae
https://github.com/mantel-digio/GlideCropper/blob/master/app/src/main/java/au/com/digio/glidecropper/widget/CroppedImageView.kt
https://developer.android.com/topic/performance/graphics/load-bitmap
吐槽:
csdn 上的技术博文大大大大大部分质量真是差劲 一点验证意识都没有。
@CodeK1988
CodeK1988 / Using AppBarLayout.Behavior.DragCallback to control scroll of collapsing toolbar layout
Last active July 30, 2019 02:43
Using AppBarLayout.Behavior.DragCallback to control scroll of collapsing toolbar layout
private void disAppBarScroll() {
try {
CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) apl_module.getLayoutParams();
AppBarLayout.Behavior behavior = (AppBarLayout.Behavior) layoutParams.getBehavior();
if (behavior != null) {
behavior.setDragCallback(new AppBarLayout.Behavior.DragCallback() {
@Override
public boolean canDrag(@NonNull AppBarLayout appBarLayout) {
return false;
}
@CodeK1988
CodeK1988 / Kotlin custom constructor ways
Created July 23, 2019 02:59
kotlin handsome code 集合
thanks:
https://medium.com/@rygel/stop-repeating-yourself-and-create-custom-views-on-android-with-kotlin-f5b3fc581c0e
https://medium.com/@elye.project/building-custom-component-with-kotlin-fc082678b080
https://medium.com/@mmlodawski/https-medium-com-mmlodawski-do-not-always-trust-jvmoverloads-5251f1ad2cfe
1.
constructor(context: Context) : super(context) {
init(context)
}
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
hdpi 72x72
mdpi 48x48
xhdpi 96x96
xxhdpi 144x144
xxxhdpi 192x192
android中的dp在渲染前会将dp转为px,计算公式:
px = density * dp;
density = dpi / 160;