turing-tech / MaterialScrollBar

An Android library that brings the Material Design 5.1 sidebar to pre-5.1 devices.
Apache License 2.0
778 stars 126 forks source link

addIndicator and Kotlin #46

Closed carmas123 closed 7 years ago

carmas123 commented 8 years ago

Hi, if you try to use MaterialScrollBar with Kotlin and try to call method addIndicator(indicator, false) or other DragScrollBar methods you got an error:

java.lang.IllegalAccessError: Illegal class access: 'com.example.app.BaseListFragment' attempting to access 'com.turingtechnologies.materialscrollbar.Indicator'

Schinizer commented 8 years ago

A workaround is to wrap those calls using a java class.

public class MaterialScrollBarHack
{
    // Hack to make widget work
    public static void Helper(Context context, RecyclerView recyclerView)
    {
        DragScrollBar materialScrollBar = new DragScrollBar(context, recyclerView, true);
        materialScrollBar.setHandleColour(ContextCompat.getColor(context, R.color.colorPrimary));
        materialScrollBar.addIndicator(new CustomIndicator(context), true);
    }
}

// Call this in Kotlin
MaterialScrollBarHack.Helper(context, recyclerView)