kotlin

Spinner value using retrofit and viewmodel

守給你的承諾、 提交于 2020-12-18 07:55:22
问题 Im trying to implement editting cart in my project..for that i have used spinner i posted two methods with using viewmodel and one is without using viewmodel without using viewmodel works fine the problem left with using viewmodel without using viewmodel works fine <-- it posts correct value in call ,setting properly value in spinner when i reviisit cart with using viewmodel <-- if i set spinner as 3 it shows sucess but when i revisit i see 8 in spinner and also postman i see 8 in response

顺利拿到OPPO公司Android架构师offer,花三分钟看完这篇文章你就懂了!已开源

送分小仙女□ 提交于 2020-12-17 23:12:14
目录 前言 Kotlin协程,现在已经成为了面试甚至是工作中一个非常火的东西。 本人在刚开始了解Kotlin协程的时候,断断续续看了网上不少文章,用长篇大论把Kotlin协程描述的非常玄乎,但是看完后还是依然云里雾里,所以决定来写一篇关于协程的文章,希望能够帮助大家能够更快的上手Kotlin协程 JNI 简介 JNI (Java Native Interface英文缩写),译为Java本地接口。是Java众多开发技术中的一门技术,意在利用本地代码,为Java程序提供更高效、更灵活的拓展。尽管Java一贯以其良好的跨平台性而著称,但真正的跨平台非C/C++莫属,因为当前世上90%的系统都是基于C/C++编写的。同时,Java的跨平台是以牺牲效率换来对多种平台的兼容性,因而JNI就是这种跨平台的主流实现方式之一。 总之,JNI是一门技术,是Java 与C/C++ 沟通的一门技术。首先,来回顾下Android的系统架构图。 我们来简单介绍下每一层的作用。 Linux层 Linux 内核 由于Android 系统是基础Linux 内核构建的,所以Linux是Android系统的基础。事实上,Android 的硬件驱动、进程管理、内存管理、网络管理都是在这一层。 硬件抽象层 硬件抽象层(Hardware Abstraction Layer缩写),硬件抽象层主要为上层提供标准显示界面

Android EventBus的基本用法(kotlin版)

别等时光非礼了梦想. 提交于 2020-12-16 12:10:15
EventBus https://github.com/greenrobot/EventBus EventBus是一种用于Android的事件发布-订阅总线。它简化了应用程序内各个组件之间进行通信的复杂度,尤其是碎片之间进行通信的问题,可以避免由于使用广播通信而带来的诸多不便。 接收方 class MainActivity : AppCompatActivity ( ) { override fun onCreate ( savedInstanceState : Bundle ? ) { super . onCreate ( savedInstanceState ) setContentView ( R . layout . activity_main ) EventBus . getDefault ( ) . register ( this ) //注册,重复注册会导致崩溃 MainActivity2 . start ( this ) } override fun onDestroy ( ) { super . onDestroy ( ) EventBus . getDefault ( ) . unregister ( this ) //解绑 } //接收消息 @Subscribe ( threadMode = ThreadMode . MAIN ) fun

Disable service restart on button click

让人想犯罪 __ 提交于 2020-12-16 02:30:20
问题 I start a foreground service that downloads a file when users click on a button. What happens now is when I click again on the button, the thread inside service starts second time and I see in a notification that progress is updated for both threads (jumps presentae between threads). How can I prevent starting the second thread in case the first one is running, how can I prevent startService() or onStartCommand() is being called if the service is still running? class ForegroundService :

Disable service restart on button click

六眼飞鱼酱① 提交于 2020-12-16 02:22:48
问题 I start a foreground service that downloads a file when users click on a button. What happens now is when I click again on the button, the thread inside service starts second time and I see in a notification that progress is updated for both threads (jumps presentae between threads). How can I prevent starting the second thread in case the first one is running, how can I prevent startService() or onStartCommand() is being called if the service is still running? class ForegroundService :

Motionlayout: WARNING could not find view id -1

青春壹個敷衍的年華 提交于 2020-12-15 19:33:14
问题 My problem is, that I constantly get the warning W/MotionLayout: WARNING could not find view id -1 . Because of this, my MotionLayout is really laggy and nearly jumps from the expanded state to the collapsed state . After waiting a couple of seconds, the animation starts getting better (no jumping / laggs anymore), but the warning remains. Base XML <layout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas

Motionlayout: WARNING could not find view id -1

佐手、 提交于 2020-12-15 19:32:14
问题 My problem is, that I constantly get the warning W/MotionLayout: WARNING could not find view id -1 . Because of this, my MotionLayout is really laggy and nearly jumps from the expanded state to the collapsed state . After waiting a couple of seconds, the animation starts getting better (no jumping / laggs anymore), but the warning remains. Base XML <layout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas

Transfer image to other activity in kotlin

半世苍凉 提交于 2020-12-15 07:19:36
问题 I am making an application like instagram which will allow the user to upload their pic and if they need any editing then they can press editing button and they can edit. How can I transfer the same photo which the user chose to the editing activity in kotlin? And also after editing how can I covert the whole ConstraintLayout to image and transfer it back to the upload activity. 回答1: You can save the image to internal storage from activity one, then send the image name to the second activity

ViewPager2 must not be null in NavigationDrawer and SwipeViewTabs

会有一股神秘感。 提交于 2020-12-15 06:48:50
问题 I am trying to link my Navigation Drawer with SwipeView Tabs, the problem is that the logcat tells me that my Viewpager must not be null, I have tried to solve this problem in many ways but could not. PageAdaper.kt class ViewPagerAdapter(fragmanetActivity: TabFragment): FragmentStateAdapter(fragmanetActivity) { override fun getItemCount(): Int = 3 override fun createFragment(position: Int): Fragment { when (position) { 0 -> return FirstFragment() 1 -> return SecondFragment() 2 -> return

ViewPager2 must not be null in NavigationDrawer and SwipeViewTabs

半腔热情 提交于 2020-12-15 06:48:05
问题 I am trying to link my Navigation Drawer with SwipeView Tabs, the problem is that the logcat tells me that my Viewpager must not be null, I have tried to solve this problem in many ways but could not. PageAdaper.kt class ViewPagerAdapter(fragmanetActivity: TabFragment): FragmentStateAdapter(fragmanetActivity) { override fun getItemCount(): Int = 3 override fun createFragment(position: Int): Fragment { when (position) { 0 -> return FirstFragment() 1 -> return SecondFragment() 2 -> return