Created
June 12, 2017 19:20
-
-
Save ha-yi/6b10b960e3b5e9dcaa83de74cda8ce91 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ListJiwaPresenter (context: Context, val recyclerView: RecyclerView?):BasePresenter<MutableList<Jiwa>>(context) { | |
override fun onSuccess(data: MutableList<Jiwa>?) { | |
recyclerView?.layoutManager = LinearLayoutManager(recyclerView?.context, LinearLayoutManager.VERTICAL, false) | |
recyclerView?.adapter = ListJiwaAdapter(data) | |
} | |
override fun onError(message: String?) { | |
Terpaksa error "Gagal mengambil data Jiwa" | |
} | |
class ListJiwaAdapter(val data:MutableList<Jiwa>?) : RecyclerView.Adapter<ListJiwaAdapter.JiwaHolder>() { | |
override fun onBindViewHolder(holder: JiwaHolder?, position: Int) { | |
holder?.setJiwa(data?.get(position)) | |
} | |
override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): JiwaHolder = | |
JiwaHolder(LayoutInflater.from(parent?.context).inflate(R.layout.list_jiwa_item, parent, false)) | |
override fun getItemCount(): Int = data?.size?:0 | |
class JiwaHolder(view:View):RecyclerView.ViewHolder(view) { | |
fun setJiwa(jiwa: Jiwa?) { | |
// initialize view | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment