Skip to content

Commit

Permalink
release v1.1.0
Browse files Browse the repository at this point in the history
This release contains support for LazyGrids.
Also, some dependencies were updated.
  • Loading branch information
gregkorossy committed Feb 29, 2024
1 parent 5351afc commit 9dcad2b
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 15 deletions.
30 changes: 25 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
# LazyList hijacker
# LazyList and LazyGrid hijacker

![GitHub](https://img.shields.io/github/license/gregkorossy/lazylist-state-hijack)
![Maven Central](https://img.shields.io/maven-central/v/me.gingerninja.lazylist/hijacker)
![GitHub Repo stars](https://img.shields.io/github/stars/gregkorossy/lazylist-state-hijack)

`LazyColumn` is a very useful component of the compose ecosystem. It's the somewhat equivalent of `RecyclerView` from the view / XML world. However, it has a huge problem when it comes to changing the order of the list items, which [was reported a few years ago](https://issuetracker.google.com/issues/209652366) first and it's yet to be fixed. This library is supposed to provide a quickfix for this until the official implementation gets fixed.

**The solution works with any `LazyList` implementation, such as `LazyColumn` and `LazyRow`.**
**The solution works with any `LazyList` implementation, such as `LazyColumn` and `LazyRow`, as well as `LazyGrid`.**

## Install

Add the following dependency to your module `build.gradle.kts` file:

```kotlin
implementation("me.gingerninja.lazylist:hijacker:1.0.0")
implementation("me.gingerninja.lazylist:hijacker:1.1.0")
```

If you are using Gradle instead of Kotlin DSL, add it to your module `build.gradle` file:
```gradle
implementation "me.gingerninja.lazylist:hijacker:1.0.0"
implementation "me.gingerninja.lazylist:hijacker:1.1.0"
```

## Usage
Expand All @@ -33,6 +33,13 @@ or if you don't want to auto-enable it just yet (for whatever reason):
val hijacker = rememberLazyListStateHijacker(listState = listState, enabled = false)
```

It also works with `LazyGrid`:
```kotlin
val hijacker = rememberLazyGridStateHijacker(gridState = gridState)
// or if you don't want to auto-enable it just yet (for whatever reason):
// val hijacker = rememberLazyGridStateHijacker(gridState = gridState, enabled = false)
```

The returned instance can be controlled by its `enabled` flag:

```kotlin
Expand Down Expand Up @@ -62,6 +69,7 @@ LazyColumn(

The library contains the ProGuard rules necessary for it to work with reflection, but in case you need them separately, here they are:

### Lists
```
-keepclassmembers class androidx.compose.foundation.lazy.LazyListState {
private androidx.compose.foundation.lazy.LazyListScrollPosition scrollPosition;
Expand All @@ -73,8 +81,20 @@ The library contains the ProGuard rules necessary for it to work with reflection
}
```

### Grids
```
-keepclassmembers class androidx.compose.foundation.lazy.grid.LazyGridState {
private androidx.compose.foundation.lazy.grid.LazyGridScrollPosition scrollPosition;
}
-keepclassmembers class androidx.compose.foundation.lazy.grid.LazyGridScrollPosition {
private androidx.compose.runtime.MutableIntState index$delegate;
private java.lang.Object lastKnownFirstItemKey;
}
```

## Compatibility

This lib was tested against the latest versions of the `compose-foundation` artifact, namely `1.5.3` and `1.6.0-alpha07`, but should work with earlier versions as well.
This lib was tested against the latest versions of the `compose-foundation` artifact, namely `1.5.3` and `1.6.2`, but should work with earlier versions as well.

> This library works only on the JVM as it relies on Java Reflection.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ android {
applicationId = "me.gingerninja.lazylist.sample"
minSdk = 21
targetSdk = 34
versionCode = 1
versionName = "1.0"
versionCode = 2
versionName = "1.1.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down
11 changes: 5 additions & 6 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
[versions]
agp = "8.3.0-alpha06"
agp = "8.3.0-rc02"
kotlin = "1.9.10"
core-ktx = "1.12.0"
junit = "4.13.2"
androidx-test-ext-junit = "1.1.5"
espresso-core = "3.5.1"
lifecycle-runtime-ktx = "2.6.2"
activity-compose = "1.7.2"
appcompat = "1.6.1"
compose = "1.6.0-alpha07"
compose-material3 = "1.2.0-alpha09"
lifecycle-runtime-ktx = "2.7.0"
activity-compose = "1.8.2"
compose = "1.6.2"
compose-material3 = "1.2.0"

[libraries]
core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "core-ktx" }
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Thu Oct 05 04:50:17 CEST 2023
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-rc-2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion library/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
}

group = "me.gingerninja.lazylist"
version = "1.0.0"
version = "1.1.0"

android {
namespace = "me.gingerninja.lazylist.hijacker"
Expand Down

0 comments on commit 9dcad2b

Please sign in to comment.