Utility extensions, properties and useful methods to boost your programming with Kotlin.
Add the following repository to your pom.xml
:
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add the following dependencies to your pom.xml
:
<dependencies>
<dependency>
<groupId>com.github.carleslc</groupId>
<artifactId>kotlin-extensions</artifactId>
<version>0.7.6</version>
</dependency>
</dependencies>
If you need more powerful extensions and tools check the optional libraries section.
Add the following repository to your build.gradle
:
repositories {
maven { url 'https://jitpack.io' }
}
Add the following dependency to your build.gradle
:
dependencies {
compile 'com.github.carleslc:kotlin-extensions:0.7.6'
}
If you need more powerful extensions and tools check the optional libraries section.
git clone https://github.com/Carleslc/kotlin-extensions.git
cd kotlin-extensions
mvn clean install
. This also adds this project to your local Maven repository.If you wish, you can use these steps to add the dependency using Maven or Gradle without accessing to the jitpack.io
remote repository.
Otherwise you will need to add the kotlin-extensions-0.7.6.jar
from generated target
folder as external dependency of your project.
If you need more powerful extensions and tools check the optional libraries section.
In order to use any of the extensions or methods of KotlinExtensions you only need to import them.
import me.carleslc.kotlin.extensions.standard.times
import me.carleslc.kotlin.extensions.standard.*
import me.carleslc.kotlin.extensions.arrays.*
Extensions for arrays, a syntactic-sugar way to create literal arrays like A[1, 2, 3]
instead typical arrayOf(1, 2, 3)
and methods to work with 2D arrays and matrices (2D arrays with fixed columns size) easier.
import me.carleslc.kotlin.extensions.bytes.*
Extensions for memory size conversions (from bits to pebibytes and petabytes).
Inspired from ktunits library.
import me.carleslc.kotlin.extensions.collections.*
Extensions for collections, sintactic-sugar for list and set literals with L[values]
or S[values]
and other global methods to create collections.
import me.carleslc.kotlin.extensions.conversions.*
Extensions for conversions between basic types.
import me.carleslc.kotlin.extensions.html.*
Extensions to generate HTML in a more readable way.
import me.carleslc.kotlin.extensions.map.*
Extensions for maps and sintactic-sugar for Map literals with M[pairs]
.
import me.carleslc.kotlin.extensions.number.*
Extensions for numbers and math operations.
import me.carleslc.kotlin.extensions.strings.*
Extensions for strings.
pluralize
and singularize
methods are extracted from kotlin-pluralizer.
import me.carleslc.kotlin.extensions.time.*
Extensions for timing, format and manage time or dates easily.
Inspired from kxdate and khronos libraries.
import me.carleslc.kotlin.extensions.tuples.*
Extensions for pairs and triples.
import me.carleslc.kotlin.extensions.preconditions.*
Extensions to ensure preconditions easily.
import me.carleslc.kotlin.extensions.standard.*
General purpose extensions and global methods that do not match any other package category (e.g. looping with 10 times { code }
or 10 * { code }
).
Do you want to contribute to this project? Great!
Simply fork and do a pull request. Then if it makes sense I will merge it creating a new version of this project.
Follow this rules when doing a pull request in order to be accepted:
⌘ + Option + L
in Mac with IntelliJ IDE to reformat your code.@file:Suppress("NOTHING_TO_INLINE")
to suppress warnings at top of your file.This library adds functional stuff to boost your programming with Kotlin. It is a perfect library to use together with KotlinExtensions.We've already included arrow.core
, arrow.data
and arrow.syntax
in KotlinExtensions.
This library from Google includes a lot of useful classes and methods to extend the language. It is written in Java but it can be used from Kotlin with no problem.
It is already included with version 23.3-android
in KotlinExtensions, available for Android use.
If you need extensions and useful tools for Android this library is a must for your Android development.
Extensions Kotlin语言拥有不通过继承基类和使用类似与装饰器模式的设计模式而去为一个类去增加一个新的功能的能力。 这种能力称为Extensions。Kotlin支持extension functions 和 extension properties。 Extension Functions 去申明一个extension function。我们需要将被被添加申明的类别前置作为接受类型(
背景说明 kotlin-android-extensions 是用于提供视图绑定功能,用于减少 findViewById代码的编写,只许在Activity中引入类似import kotlinx.android.synthetic.main.activity_main.* //导入这个的包,即可直接以viewid去得到view控件。本来是一个很好的插件,但是该插件被开发团队所废弃,取而代之的是使用V
kotlin-android-extensions是kotlin为Android专门提供的扩展插件,虽然现在其提供的功能不多,但是光是替代findViewById功能,就已经值得使用了。至于以后官方是否会提供更多的功能,让Android开发更快速便捷,就只能拭目以待了 module:app -> build.gradle 添加以下代码 apply plugin: ‘kotlin-android-e
问题一 、Kotlin plugin should be enabled before ‘kotlin-android-extensions‘ 在java项目中添加kotlin的类之后,根据提示进行各种配置和下载,一顿操作后出现了Kotlin plugin should be enabled before 'kotlin-android-extensions’ 处理办法:build.gradle文
一、动画效果添加对象 kotlin-android-extensions 插件 实现了 视图绑定 功能 , 开发过程中 , 可以不用调用如下形式 : ① 传统方法 : findViewById(R.id.textView) ② 注解绑定 : @BindView(R.id.textView)lateinit var textView:TextView ③ 视图绑定 : ActivityMainBin
Kotlin扩展插件 kotlin-android-extensions 在学习第一行代码第三版的时候, 发现书中有提到 kotlin-android-extensions这个插件,可以直接使用布局中的控件id来操作view控件, 不用再findViewById。但是很可惜,在as升级到4.0之后便被抛弃了。 今天在看教程的时候发现还有办法可以实现,也来分享给大家。 需要在根目录下的build
背景 apply plugin: ‘kotlin-android-extensions’ 该插件已经被废弃掉了 所以在移除该插件之后,相关的代码如: import kotlinx.android.synthetic.main 也废弃掉了无用了。 解决: 使用view binding的方式 在gradle中添加: buildFeatures{ viewBinding true
用AS比较早的,并且接触kotlin比较久的小伙伴应该知道 kotlin-android-extensions 插件。当然了也许你不会太在意它,毕竟在AS 3.6 之前它是自动加载的,只管用就好了,非常非常方便。 最近新血来潮更新了AS大版本终于上4+了,说实话雪狐和小蜜蜂都不好看,还是喜欢3.5的流线条味道(好吧我就是懒)。更新完第一件事就是拿一个老工程体验,我想到
The ‘kotlin-android-extensions’ Gradle plugin is deprecated 最近跑编译的时候,经常有个警告 The 'kotlin-android-extensions' Gradle plugin is deprecated. Please use this migration guide (https://goo.gle/kotlin-androi
如果你在创建kotlin项目中没有自动引入kotlin-android-extensions那么是不可以使用 Parcelize注解的. 不过现在创建的kotlin项目一般都不会自动引入了.因为直接使用id去读取控件是会有额外的开销.所以官方已经不推荐这种写法了. 回归正题,如果你没有引入这个kotlin-android-extensions,你还要去使用Parcelize注解,那么就需要引入另一
在主build.gradle 的 plugins 添加 可直接使用控制id 赋值 、操作 plugins { id 'kotlin-android-extensions' } textView.text="hello world" class MainActivity : AppCompatActivity() { override fun onCreate(savedInst
kotlin-android-extensions插件也被废弃了?扶我起来_郭霖的专栏-CSDN博客_kotlin-android-extensions废弃
下面是我试图用配置autowire的kotlin bean 最后,这是一个常规java bean,它确实用填充,但是当它得到时,我看到这些属性是空的/null
另一个Kotlin团队研发的可以让开发更简单的插件是Kotlin Android Extensions。当前仅仅包括了view的绑定。这个插件自动创建了很多的属性来让我们直接访问XML中的view。这种方式不需要你在开始使用之前明确地从布局中去找到这些views。 这些属性的名字就是来自对应view的id,所以我们取id的时候要十分小心,因为它们将会是我们类中非常重要的一部分。这些属性的类型也是来
如果你还记得,现在项目已经准备好去使用Kotlin Android Extensions。当我们创建这个项目,我们就已经在build.gradle中增加了这个依赖: buldscript{ repositories { jcenter() } dependencies { classpath "org.jetbrains.kotlin:kot
从https://api.spacexdata.com/v3获取日期启动此日期的格式为:2006-03-25T10:30:00+12:00。我想将其转换为“DD,mm,YYYY”,但总是得到错误:“java.time.format.DateTimeParseException:Text'2006-03-25T10:30:00+12:00'could not be parsed,unparsed T
Kotlin/Native The development of Kotlin/Native was moved to https://github.com/JetBrains/kotlin.Because of that, this repository was archived. Instead of creating new issues in this repository or comm
GraphQL Kotlin GraphQL Kotlin is a collection of libraries, built on top of graphql-java, that simplify running GraphQL clients and servers in Kotlin. Visit our documentation site for more details. ��