- 严禁使用 lateinit 和 !!
- kotlin 函数类型的 toString 方法极慢 避免使用 (test on 1.5.20)
- 不要轻易忽略 IDE 给出的警告: Unchecked cast, JVM 运行时的类型擦除很有可能导致不符合预期, 发现这个问题的起因是发现一个泛型函数的泛型类型加 reified 的时候没有 Unchecked cast 警告, 但是没加的时候有, 经过查看字节码发现没加的时候由于类型擦除会直接 cast 变成 Object 类型
This file contains 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
public interface Opcodes { | |
int NOP = 0; // visitInsn 代表什么都不做 | |
int ACONST_NULL = 1; // - 把null推到栈顶 | |
/* | |
* ICONST系列只能把 -1 ~ 5 推到栈顶,其它int类型,需要使用PUSH系列命令 | |
*/ | |
int ICONST_M1 = 2; // - 把 -1 推到栈顶 | |
int ICONST_0 = 3; // - 把 int 0 推到栈顶 | |
int ICONST_1 = 4; // - 把 int 1 推到栈顶 |
This file contains 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
import kotlin.reflect.KProperty | |
/** | |
* this will be used: | |
* 1. before getValue return. | |
* 2. before setValue to change the value. | |
*/ | |
typealias ValueIntercepter<ValType> = (originValue: ValType) -> ValType | |
fun <ValType : Any?> exVar( |
This file contains 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
import android.app.Application | |
import android.content.Context | |
import android.net.ConnectivityManager | |
import android.net.Network | |
import android.net.NetworkCapabilities | |
import android.net.NetworkRequest | |
import android.os.Handler | |
import android.os.Looper | |
import android.util.SparseArray | |
import androidx.annotation.IntDef |
原文: String.format()详细用法 (juejin.cn)
转换符 | 详细说明 | 示例 |
---|---|---|
%s | 字符串类型 | “喜欢请收藏” |
%c | 字符类型 | ‘m’ |
%b | 布尔类型 | true |
%d | 整数类型(十进制) | 88 |
%x | 整数类型(十六进制) | FF |
%o | 整数类型(八进制) | 77 |
This file contains 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
import android.content.Intent | |
import android.graphics.Bitmap | |
import android.net.Uri | |
import android.util.SparseArray | |
import androidx.activity.ComponentActivity | |
import androidx.activity.result.ActivityResult | |
import androidx.activity.result.ActivityResultCaller | |
import androidx.activity.result.ActivityResultLauncher | |
import androidx.activity.result.contract.ActivityResultContracts | |
import androidx.core.os.bundleOf |
loge:
java.lang.NoSuchMethodError: No direct method <init>(Ljava/lang/String;Ljava/lang/String;IIIIIILjava/util/Map;ILkotlin/jvm/internal/DefaultConstructorMarker;)V in class Lcom/zsqw123/mediastore/read/ImageRead; or its super classes (declaration of 'com.zsqw123.mediastore.read.ImageRead' appears in /data/app/com.zsqw123.mediastore-2/base.apk:classes2.dex)
code:
class ImageRead(var name: String = "")