I am trying to write the code below written in Kotlin, in Java. I am not able to create the DefaultElementsAdapter as I am unable to get the syntax right.
HtmlRecycler.Builder(this@MainActivity)
.setSource(networkSource)
.setAdapter(DefaultElementsAdapter(this@MainActivity) { element, i, view ->
}})
.setRecyclerView(recyclerView)
.setLoadingCallback(object : HtmlRecycler.LoadCallback {
override fun onLoadingStart() {
progressBar.visibility = View.VISIBLE
}
override fun onLoaded(document: Document?) {
progressBar.visibility = View.GONE
}
})
.build()
I am unable to get this right Java Code
DefaultElementsAdapter adapter = new DefaultElementsAdapter(this,
/****How to create the kotlin adapter here****/
);
HtmlRecycler.Builder builder = new HtmlRecycler.Builder(this);
builder.setSource(new StringSource(item.contentDescription))
.setRecyclerView(recyclerView)
.setAdapter(adapter)
.build();
The Kotlin class is something like this
public final class DefaultElementsAdapter public constructor(context: android.content.Context, onClick: (m7mdra.com.htmlrecycler.elements.Element, kotlin.Int, android.view.View) -> kotlin.Unit) : m7mdra.com.htmlrecycler.adapter.ElementsAdapter {
private final val context: android.content.Context /* compiled code */
private final val onClick: (m7mdra.com.htmlrecycler.elements.Element, kotlin.Int, android.view.View) -> kotlin.Unit /* compiled code */
public open fun onBindElement(holder: androidx.recyclerview.widget.RecyclerView.ViewHolder, position: kotlin.Int): kotlin.Unit { /* compiled code */ }
public open fun onCreateElement(parent: android.view.ViewGroup, elementType: m7mdra.com.htmlrecycler.elements.ElementType): androidx.recyclerview.widget.RecyclerView.ViewHolder { /* compiled code */ }
}
I am trying to use the library https://github.com/m7mdra/HtmlRecycler