我正在使用ModalBottomSheet并且必须State hoisting使用它的祖先组件。
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
Demo4Theme {
// A surface container using the 'background' color from the theme
Surface(modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background) {
ArticleScreen()
}
}
}
}
}
@Stable
class ArticleState(
val orderModalState: SageSheetState,
val filterModalState: DrawerState
)
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun rememberSageSheetState(
state: SageSheetState = SageSheetState(
coroutineScope = rememberCoroutineScope(), sheetState = rememberSheetState()
)): SageSheetState {
return remember { state }
}
@OptIn(ExperimentalMaterial3Api::class)
@Composable …Run Code Online (Sandbox Code Playgroud) 我是参考文档引入了依赖
implementation "androidx.datastore:datastore:1.0.0"
Run Code Online (Sandbox Code Playgroud)
然后定义架构app/src/main/proto/.proto
syntax = "proto3";
option java_package = "com.freedom.android.config.work";
option java_multiple_files = true;
message WorkItemVO {
bool enabled = 1;
string title = 2;
string repeat_interval = 3;
string repeat_interval_timeUnit = 4;
string last_update_time = 5;
string last_update_result = 6;
}
Run Code Online (Sandbox Code Playgroud)
之后app build,却build/generated/source/proto/没有生成WorkItemVOclass文件。
你能告诉我我错过了什么吗?
kotlin关键字对象创建的单例类会被JVM回收吗?
object MySingleton
Run Code Online (Sandbox Code Playgroud)
如果MySingleton从未使用过,那么在应用程序运行时它是否会继续占用内存?