Code Monkey home page Code Monkey logo

wild-scroll's Introduction

DEPRECATED

wild-scroll

Android RecyclerView Fast Scroller + Section bar

alt tag alt tag alt tag

Download

Grab via Maven:

<dependency>
  <groupId>com.appspell.wild-scroll</groupId>
  <artifactId>wild-scroll</artifactId>
  <version>0.90</version>
  <type>pom</type>
</dependency>

or Gradle:

implementation 'com.appspell.wild-scroll:wild-scroll:0.90'

Minimal working example

In your layout file:

<com.appspell.wildscroll.view.WildScrollRecyclerView
        android:id="@+id/list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:listitem="@layout/item_sample_list" />

In your code (Actvity/Fragment):

val recyclerView = view.findViewById<RecyclerView>(R.id.list)
with(recyclerView) {
   layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false)
   adapter = SampleAdapter()
   (adapter as SampleAdapter).items = DataSource(resources).companies
}

One important thing that your need to implement SectionFastScroll for your RecyclerView.Adapter

class SampleAdapter : RecyclerView.Adapter<ViewHolder>(), SectionFastScroll {
   override fun getSectionName(position: Int): String = items[position].section 
}

Set all available attributes in XML

<com.appspell.wildscroll.view.WildScrollRecyclerView
        android:id="@+id/list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:wildScroll_textColor="@color/textSecondary"
        app:wildScroll_textSize="@dimen/textRegular"
        app:wildScroll_highlightColor="@color/colorSecondary"
        app:wildScroll_highlightTextSize="@dimen/textHighlighted"
        app:wildScroll_sectionBarBackgroundColor="@color/divider"
        app:wildScroll_sectionBarPaddingLeft="@dimen/padding"
        app:wildScroll_sectionBarPaddingRight="@dimen/padding"
        app:wildScroll_sectionBarCollapseDigital="true"
        app:wildScroll_sectionBarGravity="right"
        app:wildScroll_sectionBarEnable="true"
        app:wildScroll_popupEnable="true"
        app:wildScroll_popupBackgroundColor="@color/colorSecondary"
        app:wildScroll_popupPadding="@dimen/padding"
        app:wildScroll_popupTextColor="@color/colorSecondaryLight"
        app:wildScroll_popupTextSize="@dimen/textPopup"
        tools:listitem="@layout/item_sample_list" />

Configure in code

        val recyclerView = view.findViewById<WildScrollRecyclerView>(R.id.list)
        with(recyclerView) {
            layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false)
            adapter = SampleSecondAdapter()
            (adapter as SampleSecondAdapter).items = DataSource(resources).companies

            textColor = R.color.colorSecondaryDark
            textSize = R.dimen.textRegular
            textTypeFace = Typeface.SANS_SERIF

            highlightColor = R.color.colorSecondary
            highlightTextSize = R.dimen.fastscroll_section_highlight_text_size
            highlightTextFace = Typeface.DEFAULT_BOLD

            sectionBarPaddingLeft = R.dimen.padding
            sectionBarPaddingRight = R.dimen.padding
            sectionBarCollapseDigital = false
            sectionBarGravity = LEFT

            sectionPopup = SectionLetterPopup(context,
                    textColorRes = R.color.colorSecondaryLight,
                    textSizeDimen = R.dimen.textPopup,
                    textTypeFace = Typeface.DEFAULT_BOLD,
                    backgroundResource = R.drawable.background_popup,
                    paddingRes = R.dimen.padding)
        }

Section popups

You can set your custom popup or use one of included into the library ones.

SectionLetterPopup - This popup shows section name and can use custom background (backgroundResource).

SectionCirclePopup - Extends SectionLetterPopup but use predefined round background.

StubSectionPopup - It's just a stub. This popup can't be rendered.

If you want to implement your own section popup you should use interface com.appspell.wildscroll.sections.popup.SectionPopup.

XML attributes

Section bar

wildScroll_sectionBarEnable - show or hide section bar

wildScroll_sectionBarGravity - section bar positon. (currently available: left and right)

wildScroll_textColor - section text color

wildScroll_textSize - section text size

wildScroll_highlightColor - color for selected section

wildScroll_highlightTextSize - text size for selected section

wildScroll_sectionBarBackgroundColor - background color for section bar

wildScroll_sectionBarPaddingLeft - left padding for section bar

wildScroll_sectionBarPaddingRight - right padding for section bar

wildScroll_sectionBarCollapseDigital - merge all of numeric sections into one (1..10 -> #)

Popup

wildScroll_popupEnable - show or hide section popup

wildScroll_popupBackgroundDrawable - popup background

wildScroll_popupBackgroundColor - color for preselected background drawable (like tint)

wildScroll_popupPadding - paddings for popup

wildScroll_popupTextColor - section text color

wildScroll_popupTextSize - section text size

wild-scroll's People

Contributors

appspell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

wild-scroll's Issues

Getting Run Time Error!

java.lang.NoClassDefFoundError: Failed resolution of: Lkotlinx/coroutines/experimental/BuildersKt;

java.lang.IllegalStateException

This issue is on some devices

java.lang.IllegalStateException: sections.keyAt(index) must not be null
at com.appspell.wildscroll.b.f.c(Sections.kt:140)
at com.appspell.wildscroll.b.f.b(Sections.kt:78)
at com.appspell.wildscroll.b.a.a.a(FastScroll.kt:57)
at com.appspell.wildscroll.b.c.a(SectionBarView.kt:166)
at com.appspell.wildscroll.view.WildScrollRecyclerView.onTouchEvent(WildScrollRecyclerView.kt:215)
at android.view.View.dispatchTouchEvent(View.java:13472)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3216)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2888)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3222)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2904)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3222)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2904)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3222)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2904)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3222)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2904)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3222)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2904)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3222)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2904)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3222)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2904)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3222)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2904)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3222)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2904)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3222)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2904)
at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:731)
at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1869)
at android.app.Activity.dispatchTouchEvent(Activity.java:3487)
at android.support.v7.view.i.dispatchTouchEvent(WindowCallbackWrapper.java:69)
at android.support.v7.view.i.dispatchTouchEvent(WindowCallbackWrapper.java:69)
at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:689)
at android.view.View.dispatchPointerEvent(View.java:13720)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:6125)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:5903)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5352)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:5405)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:5371)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:5530)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:5379)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:5587)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5352)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:5405)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:5371)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:5379)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5352)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:8412)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:8345)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:8298)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:8527)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:198)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:326)
at android.os.Looper.loop(Looper.java:181)
at android.app.ActivityThread.main(ActivityThread.java:7073)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)

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.