kotlin

Kotlin Compilation Error : None of the following functions can be called with the arguments supplied

二次信任 提交于 2021-02-17 21:19:12
问题 I have a class whose constructor takes 2 int parameters (null values are allowed). Following is the compilation error. None of the following functions can be called with the arguments supplied: public final operator fun plus(other: Byte): Int defined in kotlin.Int public final operator fun plus(other: Double): Double defined in kotlin.Int public final operator fun plus(other: Float): Float defined in kotlin.Int public final operator fun plus(other: Int): Int defined in kotlin.Int public final

Using Kotlin Coroutines to replace LocalBroadcastManager for Firebase messaging

£可爱£侵袭症+ 提交于 2021-02-17 19:12:53
问题 When using Firebase Cloud Messaging on Android, it is often desirable to notify the current Activity of an incoming push notification. One of the recommended ways to do this has been to use LocalBroadcastManager to send an Intent from the FirebaseMessagingService implementation to the Activity (StackOverflow example answer). However, as of version 1.1.0-alpha01 (2018-12-17), LocalBroadcastManager is deprecated: LocalBroadcastManager is an application-wide event bus and embraces layer

Can't use setBackgroundResource() when using Thread.sleep on click

99封情书 提交于 2021-02-17 06:37:05
问题 I can successfully change color by using: TextView1.setOnClickListener{ TextView1.setBackgroundResource(R.color.red); } But if I use TextView1.setOnClickListener{ TextView1.setBackgroundResource(R.color.red); Thread.sleep(1_000) TextView1.setBackgroundResource(R.color.white); } color doesn't change at all. Why is that? 回答1: This is due to the fact that calling Thread.sleep() just causes your thread to hang, in this particular example, it causes the GUI (graphical user interface) thread to

How to add Kotlin PSI source files to IDEA Plugin project configuration

浪子不回头ぞ 提交于 2021-02-17 03:44:44
问题 I am trying to add support for kotlin for one of the IDEA plugins. So far, I found this page and understood that I need to work with kotlin PSI files, such as KtClass and others. When I was setting up my project I added idea source files to sdk(by cloning this repo), to make it easier to debug + see documentation. However it seems that these idea source files doesn't include kotlin source files, such as mentioned KtClass and others, which I use in my project. Currently I see only decompiled

How to disable menu item of bottom navigation view?

﹥>﹥吖頭↗ 提交于 2021-02-17 02:07:42
问题 How can I disable a material design bottom navigation menu item? I can set .isClickable = false but this doesn't show the menu item as disabled, similar to a button. I can't do .isEnabled , the API won't allow it. <com.google.android.material.bottomnavigation.BottomNavigationView android:id="@+id/menu_item_1" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="bottom" android:background="@color/colorDark" app:menu="@menu/bottom_navigation_menu">

How to disable menu item of bottom navigation view?

為{幸葍}努か 提交于 2021-02-17 02:07:30
问题 How can I disable a material design bottom navigation menu item? I can set .isClickable = false but this doesn't show the menu item as disabled, similar to a button. I can't do .isEnabled , the API won't allow it. <com.google.android.material.bottomnavigation.BottomNavigationView android:id="@+id/menu_item_1" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="bottom" android:background="@color/colorDark" app:menu="@menu/bottom_navigation_menu">

Kotlin: how to return running service instance in binder?

a 夏天 提交于 2021-02-16 16:10:57
问题 I have working Java code for Service and trying to convert it to Kotlin . class MyService : Service() { companion object MyBinder : Binder() { fun getService() : MyService? { return MyService::class.objectInstance } } // service implementation } The problem is that in activities getService() always returns null. I am sure the service is started before, I see it in logcat. I suggest this auto generated line from Java code should be different but I cannot find the solution: return MyService:

Kotlin: how to return running service instance in binder?

半世苍凉 提交于 2021-02-16 16:09:27
问题 I have working Java code for Service and trying to convert it to Kotlin . class MyService : Service() { companion object MyBinder : Binder() { fun getService() : MyService? { return MyService::class.objectInstance } } // service implementation } The problem is that in activities getService() always returns null. I am sure the service is started before, I see it in logcat. I suggest this auto generated line from Java code should be different but I cannot find the solution: return MyService:

Kotlin: how to return running service instance in binder?

主宰稳场 提交于 2021-02-16 16:08:38
问题 I have working Java code for Service and trying to convert it to Kotlin . class MyService : Service() { companion object MyBinder : Binder() { fun getService() : MyService? { return MyService::class.objectInstance } } // service implementation } The problem is that in activities getService() always returns null. I am sure the service is started before, I see it in logcat. I suggest this auto generated line from Java code should be different but I cannot find the solution: return MyService:

Does Android Jetpack require the use of the Kotlin language?

雨燕双飞 提交于 2021-02-16 10:01:58
问题 I can't seem to find a clear answer to this in Google, and all the documentation and samples I've seen for Jetpack seem to refer to and use Kotlin. But do you HAVE to use Kotlin in order to use Jetpack? Or can Jetpack be used with traditional Java programs? I was looking at Kotlin but it adds almost a MB to your app size. And seeing as my entire app is only about 200KB currently, I don't think Kotlin is worth increasing the size of my app by 500%! 回答1: Jetpack is a collection of libraries