kotlin

RecyclerView还在写Adapter?永远抛弃吧(一)

微笑、不失礼 提交于 2021-01-07 18:45:12
RecyclerView还在写Adapter?永远抛弃吧(一) RecyclerView的用法是什么样子的我就不说了,做安卓的同学都知道,需要写adapter,然后在adapter中写布局文件,虽然有第三方的框架可以大大减少代码量,但是还是存在一些问题。我在想RecyclerView能不能像TextView那样直接setText("xxx")一样使用呢?答案是肯定的,今天给大家介绍一款框架名叫CHGAdapter的Android版本。这里主要介绍Android的kotlin版。 话不多说,现在开始介绍具体使用方法。 显示简单的列表 首先创建一个模型:MenuItemModel 因为我们这里要实现类似TextView那种setText的方式来使用RecyclerView,因此我们需要告诉RecyclerView的内容有两点 1.数据对象使用哪一个布局文件。2.数据对象使用哪一个ViewHolder。那么我们需要模型实现接口 com.chg.adapter.Model open class SongModel : Model { var iconName:Int = 0 var name:String? = null var songer:String? = null constructor(iconName: Int, name: String?, songer: String?)

Android(Kotlin版本)MVC框架的实例以及代码

拥有回忆 提交于 2021-01-07 14:44:07
Android(Kotlin版本)MVC框架的实例以及代码   本文地址: https://blog.csdn.net/qq_40785165/article/details/112135944 ,转载需附上此地址   代码也许是枯燥的,但是创造永远能让人心血澎湃,这大概就是热情吧!   大家好,我是小黑,一个还没秃头的程序员~~~   近日较忙,但是也不能忘记了写文章的初心,就是为了记录自己一段时间内的学习以及改变,今日内容为Android开发中MVC的框架设计,由于最近在学习kotlin,所以本文章将使用kotlin作为开发语言,先来看看效果图   Demo中的功能很简单,就是个模拟登录的过程,以及登录成功后调用数据接口开发列表,由于想把MVC架构与数据请求一起写了,又想节约篇幅,所以登录模块的代码就不贴出来了,这里只展示列表的设计代码,想要其他代码的同学可以到 Demo的github地址 手动下载,话不多说,下面开始正文。   MVC框架由一下三个部分组成:Model|(模型层)、View(视图层)、Controller(控制层) 1.Model:负责请求接口,进行数据处理,将结果通过回调告知Controller层并进行视图更新。 2.View:视图设计,在这里一般指layout中的xml视图代码 3.Controller:控制层,通常指Activity/Fragment

你的青春,值得献给小型创业公司吗?

我的未来我决定 提交于 2021-01-07 08:58:49
01、 2014 年的时候,我从“上有天堂下有苏杭”的苏州回到了九朝古都洛阳。之所以用“回”这个字,我想你也猜到了原因:我的籍贯是河南省洛阳市。 回来的时候挺胆战心惊的,因为洛阳的软件行业很萧条。举个不恰当的例子,就好像一名当打之年的 NBA 球星因为某些原因来到了 CBA。 我那时候也想选一个相对大点的公司,但选来选去, 不是人家看不上我,就是我看不上那点工资 。当然了,我最终选的这家小型创业公司工资也不高,勉强维持生计吧。 我那时候才 24,正值程序人生当中的黄金年龄。但已经回来了,再出去漂也不合适,于是我就这样劝自己: 既来之则安之,踏踏实实干吧,是金子哪都能发光。 相比在大公司里做一颗螺丝钉,不如在小公司里做“瘸子里面的将军”。 假如公司创业成功,搞不好很快就能走上财富自由之路。 好歹算是还乡了,虽然没有衣锦。能陪在家人身边,多好啊! 02、 工作了一年半的时间后,工资涨到了从苏州离开时的水准(在洛阳可能算是中等偏上的水平)。但随后,事情的走向开始不容乐观,同事越来越少,少到最后只剩下老板和我两个人。这样的情况从 2015 年持续到现在,也没有任何好转的迹象——我们俩都在死撑,等待最后那根压死骆驼的稻草。 上周末和几个之前的同事聚餐,半年多没见面了,一见到我就关切地问:“还在之前的公司上班吗?” “嗯,还在。”我只能苦笑着说。 “你老板挺能撑的,之前听你说卖了一套房子了

你的青春,值得献给小型创业公司吗?

北慕城南 提交于 2021-01-07 08:41:33
01、 2014 年的时候,我从“上有天堂下有苏杭”的苏州回到了九朝古都洛阳。之所以用“回”这个字, 我 想你也猜到了原因:我的籍贯是河南省洛阳市。 回来的时候挺胆战心惊的,因为洛阳的软件行业很萧条。举个不恰当的例子,就好像一名当打之年的 NBA 球星因为某些原因来到了 CBA。 我那时候也想选一个相对大点的公司,但选来选去, 不是人家看不上我,就是我看不上那点工资 。当然了,我最终选的这家小型创业公司工资也不高,勉强维持生计吧。 我那时候才 24,正值程序人生当中的黄金年龄。但已经回来了,再出去漂也不合适,于是我就这样劝自己: 既来之则安之,踏踏实实干吧,是金子哪都能发光。 相比在大公司里做一颗螺丝钉,不如在小公司里做“瘸子里面的将军”。 假如公司创业成功,搞不好很快就能走上财富自由之路。 好歹算是还乡了,虽然没有衣锦。能陪在家人身边,多好啊! 02、 工作了一年半的时间后,工资涨到了从苏州离开时的水准(在洛阳可能算是中等偏上的水平)。但随后,事情的走向开始不容乐观,同事越来越少,少到最后只剩下老板和我两个人。这样的情况从 2015 年持续到现在,也没有任何好转的迹象——我们俩都在死撑,等待最后那根压死骆驼的稻草。 上周末和几个之前的同事聚餐,半年多没见面了,一见到我就关切地问:“还在之前的公司上班吗?” “嗯,还在。”我只能苦笑着说。 “你老板挺能撑的,之前听你说卖了一套房子了

how to upload image in latest retrofit version using Kotlin with the right RequestBody.create method?

倖福魔咒の 提交于 2021-01-07 06:59:38
问题 I have tried to read the solution in here or in here , but I am confused when I implement it on my own code I am using this on my gradle implementation 'com.squareup.retrofit2:retrofit:2.5.0' implementation 'com.squareup.retrofit2:converter-gson:2.5.0' implementation 'com.squareup.okhttp3:logging-interceptor:4.4.0' I am trying to upload an image using this code in retorift interface UploadMediaAPI { @Multipart @POST("uploadImage") fun uploadImage( @Part image: MultipartBody.Part ): Call

how to upload image in latest retrofit version using Kotlin with the right RequestBody.create method?

江枫思渺然 提交于 2021-01-07 06:59:06
问题 I have tried to read the solution in here or in here , but I am confused when I implement it on my own code I am using this on my gradle implementation 'com.squareup.retrofit2:retrofit:2.5.0' implementation 'com.squareup.retrofit2:converter-gson:2.5.0' implementation 'com.squareup.okhttp3:logging-interceptor:4.4.0' I am trying to upload an image using this code in retorift interface UploadMediaAPI { @Multipart @POST("uploadImage") fun uploadImage( @Part image: MultipartBody.Part ): Call

How can I build a nested list using builder pattern?

a 夏天 提交于 2021-01-07 06:50:29
问题 I am trying to make a query builder for GraphQL syntax, by using a builder pattern. I already did it for the filtering part: I want to programatically make a way to say what data I want to get back from the query. (NOTE: before the title part of the query was hardcoded into the QueryBuilder. So for that I made a class called Entity which has a list of itself as an attribute. class Entity( private val entity: EntityType, private val entities: MutableList<Entity> = mutableListOf() ) { override

Minimized video call and shared view with Zoom SDK

感情迁移 提交于 2021-01-07 06:37:53
问题 I'm trying to integrate Zoom SDK meetings in an Android app. I've struggled for a while now with using the custom meeting ui and learning how to use Zoom's video view called MobileRTCVideoView . Here's the interface I would like to create: What I've tried: Studied Zoom's sample apps on Github. Studied Zoom's documentation for customized meeting ui. Asked on the developer forum. Read related threads on the developer forum. However, I still don't understand how to implement it, and would very

Ble: Send advertise data to iOS from Android

。_饼干妹妹 提交于 2021-01-07 06:35:57
问题 I have to send some advertise data via ble to an iOS central app. On Android peripheral side, when i create advertise i do: var byteArrayData = dataToSend.toByteArray(Charsets.UTF_8) var data = AdvertiseData.Builder().apply { addServiceData( ParcelUuid(MY_SERVICE_UUID), byteArrayData ) } bleAdvertiser.startAdvertising(mySettings.build(), data.build(), myAdvertiseCallback) but it seems that iOS is not able to read custom service data. So, there's a way to sent some small data (few bytes) via

Ble: Send advertise data to iOS from Android

淺唱寂寞╮ 提交于 2021-01-07 06:34:31
问题 I have to send some advertise data via ble to an iOS central app. On Android peripheral side, when i create advertise i do: var byteArrayData = dataToSend.toByteArray(Charsets.UTF_8) var data = AdvertiseData.Builder().apply { addServiceData( ParcelUuid(MY_SERVICE_UUID), byteArrayData ) } bleAdvertiser.startAdvertising(mySettings.build(), data.build(), myAdvertiseCallback) but it seems that iOS is not able to read custom service data. So, there's a way to sent some small data (few bytes) via