Compare commits

..

No commits in common. "ac4c4b94419914ecdf86f613cbfd514f6a5abbbe" and "02d734eee88cbda6dbd7ece20309928250b814a3" have entirely different histories.

2 changed files with 12 additions and 9 deletions

View File

@ -63,6 +63,13 @@ class SourcesActivity : AppCompatActivity(), DIAware {
) )
binding.recyclerView.adapter = mAdapter binding.recyclerView.adapter = mAdapter
mAdapter.notifyDataSetChanged() mAdapter.notifyDataSetChanged()
if (items.isEmpty()) {
Toast.makeText(
this@SourcesActivity,
R.string.nothing_here,
Toast.LENGTH_SHORT
).show()
}
} else { } else {
Toast.makeText( Toast.makeText(
this@SourcesActivity, this@SourcesActivity,

View File

@ -61,13 +61,9 @@ class SourcesListAdapter(
binding.sourceTitle.text = itm.title.getHtmlDecoded() binding.sourceTitle.text = itm.title.getHtmlDecoded()
} }
override fun getItemId(position: Int) = position.toLong()
override fun getItemViewType(position: Int) = position
override fun getItemCount(): Int = items.size override fun getItemCount(): Int = items.size
inner class ViewHolder(private val mView: ConstraintLayout) : RecyclerView.ViewHolder(mView) { inner class ViewHolder(internal val mView: ConstraintLayout) : RecyclerView.ViewHolder(mView) {
init { init {
handleClickListeners() handleClickListeners()
@ -78,13 +74,13 @@ class SourcesListAdapter(
val deleteBtn: Button = mView.findViewById(R.id.deleteBtn) val deleteBtn: Button = mView.findViewById(R.id.deleteBtn)
deleteBtn.setOnClickListener { deleteBtn.setOnClickListener {
val (id) = items[bindingAdapterPosition] val (id) = items[adapterPosition]
CoroutineScope(Dispatchers.IO).launch { CoroutineScope(Dispatchers.IO).launch {
val successfullyDeletedSource = repository.deleteSource(id) val successfullyDeletedSource = repository.deleteSource(id)
if (successfullyDeletedSource) { if (successfullyDeletedSource) {
items.removeAt(bindingAdapterPosition) items.removeAt(adapterPosition)
notifyItemRemoved(bindingAdapterPosition) notifyItemRemoved(adapterPosition)
notifyItemRangeChanged(bindingAdapterPosition, itemCount) notifyItemRangeChanged(adapterPosition, itemCount)
} else { } else {
Toast.makeText( Toast.makeText(
app, app,