Skip to content

Instantly share code, notes, and snippets.

View MuratVarol's full-sized avatar
🏠
Working from home

Murat VAROL MuratVarol

🏠
Working from home
  • Oyak Securities
  • Istanbul
View GitHub Profile
open class BaseRecyclerAdapter<T>(
private var modelList: List<T>,
private val itemLayoutId: Int,
private val viewModel: ViewModel?
) : RecyclerView.Adapter<BaseViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseViewHolder {
val layoutInflater: LayoutInflater = LayoutInflater.from(parent.context)
val binding: ViewDataBinding =
DataBindingUtil.inflate(layoutInflater, itemLayoutId, parent, false)
abstract class BaseViewHolder(val itemBinding: ViewDataBinding) :
RecyclerView.ViewHolder(itemBinding.root) {
abstract fun bindData(position: Int)
}
import com.google.gson.JsonParseException
import com.sample.app.internal.util.Failure
import com.squareup.moshi.JsonDataException
import io.reactivex.Single
import io.reactivex.android.schedulers.AndroidSchedulers
/**
* Singleton class for handling API requests and responses