OpenSooq / Pluto

Pluto is an Easy, lightweight and high performance slider view library for Android. You have the flexibility to customize it to any view since it based RecyclerView.
https://engineering.opensooq.com
109 stars 16 forks source link

Crash in setCustomIndicator #19

Closed msuyudia closed 4 years ago

msuyudia commented 4 years ago

I have an issue always crash in line setCustomIndicator. My items in list is not null, i'm already debugged it and that list have an items. I don't know why property helper in your library not initiate it. and its not a pass parameter from setCustomIndicator. Can you help me solve this?

This my view :

    <com.opensooq.pluto.PlutoView
        android:id="@+id/iv_banner_detail_vote_election"
        android:layout_width="match_parent"
        android:layout_height="222dp"
        app:indicator_visibility="true"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"/>

    <com.opensooq.pluto.PlutoIndicator
        android:id="@+id/custom_indicator_detail_vote_election"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="16dp"
        android:layout_marginBottom="16dp"
        app:unselected_color="@color/colorPrimaryDark"
        app:selected_color="@color/colorPrimary"
        app:selected_width="12dp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintBottom_toBottomOf="@id/iv_banner_detail_vote_election"/>

This is my adapter :

class BannerSliderAdapter(items: MutableList<Uri?>) :
    PlutoAdapter<Uri?, BannerSliderAdapter.ViewHolder>(items) {

    override fun getViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        return ViewHolder(parent, R.layout.item_banner_slider)
    }

    class ViewHolder(parent: ViewGroup, itemLayoutId: Int) :
        PlutoViewHolder<Uri?>(parent, itemLayoutId) {

        private var ivBanner: ImageView = getView(R.id.iv_banner)

        override fun set(item: Uri?, position: Int) {
            Picasso.with(context).load(item).into(ivBanner)
        }

    }
}

This is where i'm initialize to call PlutoView and PlutoIndicator :

    private fun showBanner() {
        val adapter = BannerSliderAdapter(vote?.listPhoto ?: mutableListOf())
        iv_banner_detail_vote_election.setCustomIndicator(custom_indicator_detail_vote_election)
        iv_banner_detail_vote_election.create(adapter, 4000, lifecycle)
    }

And this is error log by crash :

DetailVoteElectionActivity: kotlin.UninitializedPropertyAccessException: lateinit property helper has not been initialized
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2817)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2895)
        at android.app.ActivityThread.-wrap11(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1616)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:176)
        at android.app.ActivityThread.main(ActivityThread.java:6651)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:824)
     Caused by: kotlin.UninitializedPropertyAccessException: lateinit property helper has not been initialized
        at com.opensooq.pluto.PlutoView.setCustomIndicator(PlutoView.kt:157)
        at com.ksmandroid.gravoteadmin.ui.detailvoteelection.DetailVoteElectionActivity.showBanner(DetailVoteElectionActivity.kt:89)
        at com.ksmandroid.gravoteadmin.ui.detailvoteelection.DetailVoteElectionActivity.onCreate(DetailVoteElectionActivity.kt:78)