Skip to content

Commit

Permalink
Merge pull request #442 from chimbori/remove-android-kotlin-extensions
Browse files Browse the repository at this point in the history
Remove deprecated `android-kotlin-extensions` & `jCenter()`, upgrade Gradle from 7.0.2 to 7.3
  • Loading branch information
Zhuinden authored Oct 3, 2023
2 parents 3a64d39 + 3d54381 commit 85889f2
Show file tree
Hide file tree
Showing 47 changed files with 254 additions and 1,330 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Run Tests

on:
push:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: Checkout Submodules
uses: actions/checkout@v3

- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1

- name: Run Lint
run: ./gradlew lint --console plain

- name: Run Unit Tests
run: ./gradlew test --console plain
10 changes: 5 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
*.iml
*.jks
.DS_Store
.externalNativeBuild
.gradle
/local.properties
.idea/*
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/.idea/workspace.xml
/build
/captures
.externalNativeBuild
*.jks
/local.properties
64 changes: 2 additions & 62 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,35 +97,6 @@ You can implement the `Group` interface directly if you want. However, in most

Groupie abstracts away the complexity of multiple item view types. Each Item declares a view layout id, and gets a callback to `bind` the inflated layout. That's all you need; you can add your new item directly to a `GroupieAdapter` and call it a day.

### Item with Kotlin-Android-Extensions:

**Note: `kotlin-android-extensions` is deprecated since Kotlin 1.4.20. Therefore, `groupie-kotlin-android-extensions` is also deprecated, and `viewbinding` should be preferred.**

Groupie includes a module for Kotlin and Kotlin Android extensions. [Setup here.](#kotlin)

```gradle
implementation "com.github.lisawray.groupie:groupie:$groupie_version"
implementation "com.github.lisawray.groupie:groupie-kotlin-android-extensions:$groupie_version"
```

The `Item` class gives you simple callbacks to bind your model object to the generated fields.

```kotlin
import com.xwray.groupie.kotlinandroidextensions.Item
import com.xwray.groupie.kotlinandroidextensions.GroupieViewHolder
import kotlinx.android.synthetic.main.song.*

class SongItem(private val song: Song) : Item() {

override fun getLayout() = R.layout.song

override fun bind(viewHolder: GroupieViewHolder, position: Int) {
viewHolder.title.text = song.title
viewHolder.artist.text = song.artist
}
}
```

### Item with data binding:

The `Item` class gives you simple callbacks to bind your model object to the generated binding. Because of data binding, there's no need to write a view holder.
Expand Down Expand Up @@ -220,37 +191,6 @@ In your app `build.gradle` file, include:
implementation 'com.github.lisawray.groupie:groupie:$groupie_version'
```

### Using with Kotlin-Android-Extensions (deprecated)

If you are still relying on the deprecated `kotlin-android-extensions` module, then also apply the following:

```
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
....
// IMPORTANT! Enables kotlin synthetic view properties.
// See: https://github.com/Kotlin/KEEP/blob/master/proposals/android-extensions-entity-caching.md
androidExtensions {
experimental = true
}
}
dependencies {
implementation 'com.github.lisawray.groupie:groupie:$groupie_version'
implementation 'com.github.lisawray.groupie:groupie-kotlin-android-extensions:$groupie_version'
}
```

Remember to include
```kotlin
import kotlinx.android.synthetic.main.my_item_layout.*
```
in the corresponding Item class for generated view references.

## View binding

Add to your app module's `build.gradle`:
Expand Down Expand Up @@ -332,8 +272,8 @@ Bindings are only generated for layouts wrapped with <layout/> tags, so there's
You can add a `<data>` section to directly bind a model or ViewModel, but you don't have to. The generated view bindings alone are a huge time saver.

### Kotlin AND data binding / view binding?
Sure, why not? Follow all the instructions from *both* sections above. You only need to include the `groupie-databinding` or `groupie-viewbinding` dependency, and omit the references to `android-extensions`. You'll make `BindableItem`s instead of importing and using Kotlin extensions.

Sure, why not? Follow all the instructions from *both* sections above.
You only need to include the `groupie-databinding` or `groupie-viewbinding` dependency.

# Contributing
Contributions you say? Yes please!
Expand Down
5 changes: 0 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ def testReportsDir = "${rootProject.buildDir}/test-reports"
def testResultsDir = "${rootProject.buildDir}/test-results"

buildscript {

ext.kotlin_version = '1.6.21'
ext.android_plugin_version = '7.0.4'
ext.sdkVersion = 31
Expand All @@ -19,22 +18,18 @@ buildscript {
repositories {
google()
mavenCentral()
jcenter()
maven { url "https://jitpack.io" }
}
dependencies {
classpath "com.android.tools.build:gradle:$android_plugin_version"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.dokka:dokka-android-gradle-plugin:0.9.18"


// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects { project ->

repositories {
google()
mavenCentral()
Expand Down
1 change: 0 additions & 1 deletion example/.gitignore

This file was deleted.

34 changes: 0 additions & 34 deletions example/build.gradle

This file was deleted.

21 changes: 0 additions & 21 deletions example/src/main/AndroidManifest.xml

This file was deleted.

51 changes: 0 additions & 51 deletions example/src/main/java/com/xwray/groupie/example/ColumnGroup.kt

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 85889f2

Please sign in to comment.