小编Ali*_*ine的帖子

SignInWithGoogle API 没有响应

我正在尝试将 Google Sign in API 与我的应用程序集成。这是大学项目的一部分。我关注了以下网站:https://proandroiddev.com/google-signin-compose-a9afa67b7519

但是,当我尝试时,它根本不起作用。我已经设置了一切,甚至在 Google Cloud API 和服务、OAuth 2.0 客户端 ID 中也是如此。

@HiltViewModel
class UserSessionViewModel @Inject constructor(
    application: Application,
) : ViewModel() {

    private val _user: MutableStateFlow<User?> = MutableStateFlow(null)
    val user: StateFlow<User?> = _user

    companion object {}
    init {
        verifySignedInUser(application.applicationContext)
    }

    fun signIn(email: String, name: String){
        viewModelScope.launch {
            _user.value = User(
                email = email,
                displayName = name
            )
        }
    }

    fun signOut(){}

    private fun verifySignedInUser(applicationContext: Context){
        val gsa = GoogleSignIn.getLastSignedInAccount(applicationContext)
        if(gsa != null){
            _user.value = User( …
Run Code Online (Sandbox Code Playgroud)

android

6
推荐指数
1
解决办法
387
查看次数

C++20 的 [[likely]] 或 [[unlikely]] 属性的用途是什么

我阅读了有关 C++ 20 的更多内容,最近注意到了[[likely]]or[[unlikely]]属性。这似乎是一个有趣的概念,在以前的 C++ 版本中没有发现。根据官方 CPP 参考资料:

允许编译器针对以下情况进行优化:包含该语句的执行路径比不包含此类语句的任何替代执行路径的可能性更大或更小。

这到底意味着什么?

这篇博文反对使用它们,因为它看起来更像是不成熟的优化形式和一些其他细节。https://blog.aaronballman.com/2020/08/dont-use-the-likely-or-unlikely-attributes/

c++ c++20

6
推荐指数
1
解决办法
3519
查看次数

java.lang.IllegalArgumentException:与请求 NavDeepLinkRequest 匹配的导航目的地

错误:

java.lang.IllegalArgumentException: Navigation destination that matches request NavDeepLinkRequest{ uri=android-app://androidx.navigation/book_screen } cannot be found
Run Code Online (Sandbox Code Playgroud)

导航根主机:

animatedCompose("${Graph.BOOK}/{id}",
arguments = listOf(
    navArgument("id"){
        type = NavType.LongType
        defaultValue = -1
    }
)
    ){
    val id = it.arguments?.getInt("id") ?: -1
    val actionText = if(id != -1) "Save" else "Add"
    val title = if(id != -1) "Edit Book" else "Add New Book"
    BookScreen(navHostController, title=title, actionText=actionText)
}
Run Code Online (Sandbox Code Playgroud)

从另一个屏幕内:

 Scaffold(
        floatingActionButton = {
            FloatingActionButton(onClick = {
                rootNavHostController.navigate(Graph.BOOK)
            }) {
                Icon(Icons.Filled.Add,null)
            }
        }
Run Code Online (Sandbox Code Playgroud)

我认为,您可以将{id}可选参数作为参数。但是,不确定为什么现在不起作用。

android android-jetpack-compose

5
推荐指数
1
解决办法
3633
查看次数

在 fmt lib C++ 中显示 unicode 字符

我想显示\xe2\x88\x9e具有 Unicode 的无穷大符号U+221E。我目前正在使用fmt库,它应该有很多支持并且是跨平台的。

\n
fmt::print("", fmt::styled("\xe2\x88\x9e >", fmt::emphasis::bold | fg(fmt::color::aquamarine)));\n
Run Code Online (Sandbox Code Playgroud)\n

我得到以下输出:

\n
? >\n
Run Code Online (Sandbox Code Playgroud)\n

我也尝试过设置:setlocale(LC_ALL, "en_US.UTF-8");没有帮助。我使用的是 Windows 11 x64。

\n

警告:

\n
warning C4566: character represented by universal-character-name \'\\u221E\' cannot be represented in the current code page (1252)\n
Run Code Online (Sandbox Code Playgroud)\n

MS Visual Studio 2022 IDE。

\n

我应该在项目属性中更改字符集吗?当前设置为:使用 Unicode 字符集,第二个选项是:使用多字节字符集

\n

c++ unicode fmt

5
推荐指数
1
解决办法
857
查看次数

输入“,”无法测试两个列表

inter :: [Integer] -> [Integer] -> [Integer]\ninter s1 s2 = [s | s <- s2, s `elem` s1]\n\ninter [5, 6, 3, 1], [5, 2, 1, 3]\n\nmain = return()\n
Run Code Online (Sandbox Code Playgroud)\n

我不确定如何测试上述实现,我试图在这里传递两个不同的列表。

\n

我不断得到:

\n
GHCi, version 8.10.6: https://www.haskell.org/ghc/  :? for help\nLoaded GHCi configuration from /home/runner/University-Labs/.ghci\n[1 of 1] Compiling Main             ( Main.hs, interpreted )\n\nMain.hs:4:19: error: parse error on input \xe2\x80\x98,\xe2\x80\x99\n  |\n4 | inter [5, 6, 3, 1], [5, 2, 1, 3]\n  |                   ^\nFailed, no modules loaded.\n\xee\xba\xa7 \n<interactive>:1:1: error:\n    \xe2\x80\xa2 Variable not in …
Run Code Online (Sandbox Code Playgroud)

haskell

3
推荐指数
1
解决办法
122
查看次数

出现歧义的“产品”

代码:

\n
product :: (Eq p, Num p) => p -> p\nproduct 1 = 1\nproduct n = n * product (n-1)\n
Run Code Online (Sandbox Code Playgroud)\n

用法:

\n
main = print (product(8))\n
Run Code Online (Sandbox Code Playgroud)\n

错误:

\n
GHCi, version 8.10.6: https://www.haskell.org/ghc/  :? for help\nLoaded GHCi configuration from /home/runner/University-Labs/.ghci\n[1 of 1] Compiling Main             ( Main.hs, interpreted )\n\nMain.hs:3:17: error:\n    Ambiguous occurrence \xe2\x80\x98product\xe2\x80\x99\n    It could refer to\n       either \xe2\x80\x98Prelude.product\xe2\x80\x99,\n              imported from \xe2\x80\x98Prelude\xe2\x80\x99 at Main.hs:1:1\n              (and originally defined in \xe2\x80\x98Data.Foldable\xe2\x80\x99)\n           or \xe2\x80\x98Main.product\xe2\x80\x99, defined at Main.hs:2:1\n  |\n3 | product n = …
Run Code Online (Sandbox Code Playgroud)

haskell

3
推荐指数
1
解决办法
178
查看次数

Round corners for Dropdown menu compose android

Before, I posted here, I Googled a lot. I found the following: MaterialTheme(shapes = MaterialTheme.shapes.copy(medium = RoundedCornerShape(16.dp))){} from the following SO post: Jetpack compose DropdownMenu With rounded Corners

EDIT: I am using Material Design v3.


  MaterialTheme(shapes = MaterialTheme.shapes.copy(medium = RoundedCornerShape(16.dp))) {
            IconButton(
                            onClick = { showMenu = !showMenu }) {
                            Icon(imageVector = Icons.Outlined.MoreVert, contentDescription = "")
                            DropdownMenu(
                                expanded = showMenu,
                                onDismissRequest = { showMenu = false },
                                modifier = Modifier.background(MaterialTheme.colorScheme.background).padding(4.dp)
                            ) {
                                DropdownMenuItem(text = { Text("Refresh", fontSize = 16.sp) }, …
Run Code Online (Sandbox Code Playgroud)

android android-jetpack-compose android-jetpack-compose-material3 android-compose-dropdownmenu

2
推荐指数
1
解决办法
1363
查看次数

在 Compose 中锁定方向

我试图锁定应用程序入口屏幕的屏幕方向,然后将实际应用程序及其功能反转回正常状态。

val systemUiController = rememberSystemUiController()
val context = LocalContext.current
Run Code Online (Sandbox Code Playgroud)

我观看了本教程,https://www.youtube.com/watch?v =U5G25kcaNu0,它使用了这一行:

this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTAIT)
Run Code Online (Sandbox Code Playgroud)

但是,这是由活动控制的。我想知道是否可以按屏幕视图执行此操作。

android

1
推荐指数
1
解决办法
1931
查看次数

尝试使用 package,require 未在 ES 模块范围中定义,您可以使用 import 代替

我刚刚安装:npm i node-id3,来自:https ://www.npmjs.com/package/node-id3 。讽刺的是,我无法使用这个包。我正在Node.js v18.14.0上运行。

根据链接:

const NodeID3 = require('node-id3')
NodeID3.read(file, function(err, tags) {})
Run Code Online (Sandbox Code Playgroud)

这导致了这样的情况:

const NodeID3 = require('node-id3')
                ^

ReferenceError: require is not defined in ES module scope, you can use import instead
This file is being treated as an ES module because it has a '.js' file extension and 'C:\Users\root\Documents\GitHub\Database\package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
Run Code Online (Sandbox Code Playgroud)

javascript node.js

1
推荐指数
1
解决办法
1112
查看次数