Giter Site home page Giter Site logo

headed-lazy-grid's Introduction

headed-lazy-grid

Jetpack Compose LazyGrid with sticky headers implementation

Version compatibility:

  • 0.3.0 compatible with Jetpack Compose 1.2.1
  • 0.6.0 compatible with Jetpack Compose 1.3.1
  • 0.7.0 compatible with Jetpack Compose 1.4.0-alpha03
  • 0.7.2 compatible with Jetpack Compose 1.4.3
  • 0.8.0 compatible with Jetpack Compose 1.5.0-beta01
  • 0.8.1 compatible with Jetpack Compose 1.5.0-beta03
  • 0.8.2 compatible with Jetpack Compose 1.5.0
  • 0.9.0 compatible with Jetpack Compose 1.6.0-alpha03
  • 0.9.1 compatible with Jetpack Compose 1.6.0-alpha07
  • 0.9.2 compatible with Jetpack Compose 1.6.3 (internal implementation was updated)

headed-lazy-grid's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

headed-lazy-grid's Issues

Crash in LazyGridSpanLayoutProvider

Not sure how to reproduce. This is from a Crashlytics report. Looks like it's caused if the bucket size is 0. Maybe check if index is out of bounds and return a default LineConfiguration.

Fatal Exception: java.lang.ArrayIndexOutOfBoundsException: length=10; index=-1
at java.util.ArrayList.get(ArrayList.java:439)
at ua.hospes.lazygrid.LazyGridSpanLayoutProvider.getLineConfiguration(LazyGridSpanLayoutProvider.kt:79)
at ua.hospes.lazygrid.LazyGridKt$rememberLazyGridMeasurePolicy$1$1$1.invoke(LazyGrid.kt:266)
at ua.hospes.lazygrid.LazyGridKt$rememberLazyGridMeasurePolicy$1$1$1.invoke(LazyGrid.kt:265)
at ua.hospes.lazygrid.LazyGridState.notifyPrefetch(LazyGridState.java:336)
at ua.hospes.lazygrid.LazyGridState.onScroll$lazy_grid_release(LazyGridState.java:284)
at ua.hospes.lazygrid.LazyGridState$scrollableState$1.invoke(LazyGridState.kt:142)
at ua.hospes.lazygrid.LazyGridState$scrollableState$1.invoke(LazyGridState.kt:142)
at androidx.compose.foundation.gestures.DefaultScrollableState$scrollScope$1.scrollBy(ScrollableState.kt:166)
at androidx.compose.foundation.gestures.ScrollingLogic$dispatchScroll$performScroll$1.invoke-MK-Hz9U(Scrollable.kt:425)
at androidx.compose.foundation.gestures.ScrollingLogic$dispatchScroll$performScroll$1.invoke(Scrollable.kt:417)
at androidx.compose.foundation.AndroidEdgeEffectOverscrollEffect.applyToScroll-Rhakbz0(AndroidOverscroll.kt:180)
at androidx.compose.foundation.gestures.ScrollingLogic.dispatchScroll-3eAAhYA(Scrollable.kt:438)
at androidx.compose.foundation.gestures.ScrollingLogic$doFlingAnimation$2$outerScopeScroll$1.invoke-MK-Hz9U(Scrollable.kt:490)
at androidx.compose.foundation.gestures.ScrollingLogic$doFlingAnimation$2$outerScopeScroll$1.invoke(Scrollable.kt:489)
at androidx.compose.foundation.gestures.ScrollingLogic$doFlingAnimation$2$scope$1.scrollBy(Scrollable.kt:494)
at androidx.compose.foundation.gestures.DefaultFlingBehavior$performFling$2$1.invoke(Scrollable.kt:605)
at androidx.compose.foundation.gestures.DefaultFlingBehavior$performFling$2$1.invoke(Scrollable.kt:603)
at androidx.compose.animation.core.SuspendAnimationKt.doAnimationFrame(SuspendAnimation.kt:361)
at androidx.compose.animation.core.SuspendAnimationKt.doAnimationFrameWithScale(SuspendAnimation.kt:339)
at androidx.compose.animation.core.SuspendAnimationKt.access$doAnimationFrameWithScale(SuspendAnimation.kt:1)
at androidx.compose.animation.core.SuspendAnimationKt$animate$9.invoke(SuspendAnimation.kt:279)
at androidx.compose.animation.core.SuspendAnimationKt$animate$9.invoke(SuspendAnimation.kt:278)
at androidx.compose.animation.core.SuspendAnimationKt$callWithFrameNanos$2.invoke(SuspendAnimation.kt:304)
at androidx.compose.animation.core.SuspendAnimationKt$callWithFrameNanos$2.invoke(SuspendAnimation.kt:303)
at androidx.compose.runtime.BroadcastFrameClock$FrameAwaiter.resume(BroadcastFrameClock.java:42)
at androidx.compose.runtime.BroadcastFrameClock.sendFrame(BroadcastFrameClock.kt:71)
at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$1.invoke(Recomposer.kt:543)
at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$1.invoke(Recomposer.kt:536)
at androidx.compose.ui.platform.AndroidUiFrameClock$withFrameNanos$2$callback$1.doFrame(AndroidUiFrameClock.android.kt:41)
at androidx.compose.ui.platform.AndroidUiDispatcher.performFrameDispatch(AndroidUiDispatcher.java:109)
at androidx.compose.ui.platform.AndroidUiDispatcher.access$performFrameDispatch(AndroidUiDispatcher.java:41)
at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.doFrame(AndroidUiDispatcher.android.kt:69)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1299)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1309)
at android.view.Choreographer.doCallbacks(Choreographer.java:923)
at android.view.Choreographer.doFrame(Choreographer.java:847)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1283)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.app.ActivityThread.main(ActivityThread.java:8757)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)

Items before first sticky header causes ArrayIndexOutOfBoundsException

When a few items are added before the first sticky header or if 2 sticky headers are very close to each other with only 2-3 rows between them, reverse direction scroll causes a crash with ArrayIndexOutOfBoundsException

Reproduce the issue by adding this code before the first stickyHeader in MainActivity

LazyVerticalGrid(...) {

    // Items before header
    items(items = arrayListOf(testItems[0], testItems[1])) {
        Item(
            item = it,
            modifier = Modifier.fillMaxWidth(),
        )
     }

    // First Header
    stickyHeader {
        ...
    }

    // Rest of the code
    ...

}

Alternatively, you can check this fork

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.