Skip to content

Commit d9ef8df

Browse files
committed
Module for Kotlin extensions
1 parent c563e5d commit d9ef8df

File tree

14 files changed

+109
-57
lines changed

14 files changed

+109
-57
lines changed

.travis.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,8 @@ android:
77
components:
88
- platform-tools
99
- tools
10-
- build-tools-25.0.0
10+
- build-tools-25.0.2
1111
- android-25
1212
- extra-android-m2repository
1313

14-
before_script:
15-
- chmod +x gradlew
16-
1714
script: "./gradlew build"

README.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ dependencies {
1818
compile 'com.github.Commit451.AdapterLayout:adapterlayout:latest.release.here@aar'
1919
}
2020
```
21-
and for [FlowLayout](https://github.com/blazsolar/FlowLayout) support
21+
and for [FlowLayout](https://github.com/blazsolar/FlowLayout) support:
2222
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.wefika/flowlayout/badge.svg?style=flat)](https://maven-badges.herokuapp.com/maven-central/com.wefika/flowlayout)
2323
```gradle
2424
dependencies {
@@ -27,6 +27,12 @@ dependencies {
2727
compile 'com.github.Commit451.AdapterLayout:adapterflowlayout:latest.release.here@aar'
2828
}
2929
```
30+
and for Kotlin extensions support:
31+
```gradle
32+
dependencies {
33+
compile 'com.github.Commit451.AdapterLayout:adapterlayout-kotlin:latest.release.here@aar'
34+
}
35+
```
3036

3137
# Usage
3238
See the sample project for full usage.
@@ -44,17 +50,17 @@ cheeseAdapter.addAll(cheeses);
4450
```
4551
At this point, the data will be added to the `LinearLayout` so long as your `RecyclerView.Adapter` works correctly. `onCreateViewHolder` and `onBindViewHolder` will be called as needed.
4652

47-
# But... Why?
53+
## But... Why?
4854
This library is useful for displaying data sets that are repeating, but do not need to be recycled as they would be in a `RecyclerView`. This could be the case if you wanted to display a list of items within a `ScrollView`, or wanted to use a custom `ViewGroup` that did not extend `RecyclerView`.
4955

50-
# But Why RecyclerView Adapter?
56+
## But Why RecyclerView Adapter?
5157
Most developers should be using `RecyclerView` instead of `ListView` and should be familiar with creating a `RecyclerView.Adapter`. `RecyclerView.Adapter` also enforces the use of `ViewHolder`s which is better for performance. RecyclerView's adapter also allows for better responses to data structure changes via `notifyItemInserted`, `notifyItemRemoved` etc.
5258

53-
# Currently Created AdapterLayouts
59+
## Currently Created AdapterLayouts
5460
- AdapterLinearLayout
5561
- AdapterFlowLayout (separate dependency)
5662

57-
# Creating Your Own AdapterLayout
63+
## Creating Your Own AdapterLayout
5864
It is simple to create your own `ViewGroup` backed by a `RecyclerView.Adapter`. See the `AdapterFlowLayout` library and `AdapterLayoutDelegate` in the library for an example of how to create one.
5965

6066
# Limitations
@@ -63,7 +69,7 @@ It is simple to create your own `ViewGroup` backed by a `RecyclerView.Adapter`.
6369
License
6470
--------
6571

66-
Copyright 2016 Commit 451
72+
Copyright 2017 Commit 451
6773

6874
Licensed under the Apache License, Version 2.0 (the "License");
6975
you may not use this file except in compliance with the License.

adapterflowlayout/build.gradle

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
apply plugin: 'com.android.library'
22

33
android {
4-
compileSdkVersion 25
5-
buildToolsVersion "25.0.0"
4+
compileSdkVersion rootProject.ext.compileSdkVersion
5+
buildToolsVersion rootProject.ext.buildToolsVersion
66

77
defaultConfig {
8-
minSdkVersion 15
9-
targetSdkVersion 25
8+
minSdkVersion rootProject.ext.minSdkVersion
9+
targetSdkVersion rootProject.ext.targetSdkVersion
1010
versionCode 1
1111
versionName "1.0"
1212
}
@@ -23,7 +23,6 @@ android {
2323

2424
dependencies {
2525
compile fileTree(dir: 'libs', include: ['*.jar'])
26-
testCompile 'junit:junit:4.12'
2726
compile 'com.wefika:flowlayout:0.4.1'
2827
provided project(':adapterlayout')
2928
}

adapterflowlayout/src/androidTest/java/com/commit451/adapterflowlayout/ApplicationTest.java

Lines changed: 0 additions & 13 deletions
This file was deleted.

adapterflowlayout/src/test/java/com/commit451/adapterflowlayout/ExampleUnitTest.java

Lines changed: 0 additions & 15 deletions
This file was deleted.

adapterlayout-kotlin/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

adapterlayout-kotlin/build.gradle

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
apply plugin: 'com.android.library'
2+
apply plugin: 'kotlin-android'
3+
4+
android {
5+
compileSdkVersion rootProject.ext.compileSdkVersion
6+
buildToolsVersion rootProject.ext.buildToolsVersion
7+
8+
defaultConfig {
9+
minSdkVersion rootProject.ext.minSdkVersion
10+
targetSdkVersion rootProject.ext.targetSdkVersion
11+
versionCode 1
12+
versionName "1.0"
13+
14+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
15+
16+
}
17+
buildTypes {
18+
release {
19+
minifyEnabled false
20+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21+
}
22+
}
23+
sourceSets {
24+
main.java.srcDirs += 'src/main/kotlin'
25+
}
26+
}
27+
28+
dependencies {
29+
compile fileTree(dir: 'libs', include: ['*.jar'])
30+
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
31+
provided project(':adapterlayout')
32+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in /Users/johncarlson/Develop/Android/sdk/tools/proguard/proguard-android.txt
4+
# You can edit the include path and order by changing the proguardFiles
5+
# directive in build.gradle.
6+
#
7+
# For more details, see
8+
# http://developer.android.com/guide/developing/tools/proguard.html
9+
10+
# Add any project specific keep options here:
11+
12+
# If your project uses WebView with JS, uncomment the following
13+
# and specify the fully qualified class name to the JavaScript interface
14+
# class:
15+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16+
# public *;
17+
#}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="com.commit451.adapterlayout.kotlin">
3+
4+
<application />
5+
6+
</manifest>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.commit451.adapterlayout.kotlin
2+
3+
import android.support.v7.widget.RecyclerView
4+
import com.commit451.adapterlayout.AdapterLayout
5+
6+
fun RecyclerView.ViewHolder.getAdapterLayoutAdapterPosition(): Int {
7+
return AdapterLayout.getAdapterPosition(this)
8+
}
9+
10+
fun RecyclerView.ViewHolder.getAdapterLayoutLayoutPosition(): Int {
11+
return AdapterLayout.getLayoutPosition(this)
12+
}

0 commit comments

Comments
 (0)