Fix Ktlint warnings
Some checks failed
Check PR code / Lint (pull_request) Successful in 3m6s
Check PR code / build (pull_request) Failing after 8m33s

This commit is contained in:
davidoskky 2025-03-09 12:42:44 +01:00
parent ba4b27651b
commit 43146b5aff

View File

@ -32,13 +32,19 @@ class SourcesListAdapter(
) : RecyclerView.Adapter<SourcesListAdapter.ViewHolder>(), ) : RecyclerView.Adapter<SourcesListAdapter.ViewHolder>(),
DIAware { DIAware {
override val di: DI by closestDI(app) override val di: DI by closestDI(app)
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { override fun onCreateViewHolder(
parent: ViewGroup,
viewType: Int,
): ViewHolder {
val binding = SourceListItemBinding.inflate(LayoutInflater.from(parent.context), parent, false) val binding = SourceListItemBinding.inflate(LayoutInflater.from(parent.context), parent, false)
return ViewHolder(binding) return ViewHolder(binding)
} }
override fun onBindViewHolder(holder: ViewHolder, position: Int) { override fun onBindViewHolder(
holder: ViewHolder,
position: Int,
) {
holder.bind(items[position], position) holder.bind(items[position], position)
} }
@ -48,14 +54,17 @@ class SourcesListAdapter(
override fun getItemCount(): Int = items.size override fun getItemCount(): Int = items.size
inner class ViewHolder(
inner class ViewHolder(val binding: SourceListItemBinding) : RecyclerView.ViewHolder(binding.root) { val binding: SourceListItemBinding,
) : RecyclerView.ViewHolder(binding.root) {
private val context: Context = app.applicationContext private val context: Context = app.applicationContext
private val repository: Repository by instance() private val repository: Repository by instance()
private val appSettingsService: AppSettingsService by instance() private val appSettingsService: AppSettingsService by instance()
fun bind(source: SelfossModel.SourceDetail, position: Int) { fun bind(
source: SelfossModel.SourceDetail,
position: Int,
) {
binding.apply { binding.apply {
sourceTitle.text = source.title.getHtmlDecoded() sourceTitle.text = source.title.getHtmlDecoded()
if (source.getIcon(repository.baseUrl).isEmpty()) { if (source.getIcon(repository.baseUrl).isEmpty()) {
@ -78,8 +87,12 @@ class SourcesListAdapter(
} }
} }
private fun showDeleteConfirmationDialog(source: SelfossModel.SourceDetail, position: Int) { private fun showDeleteConfirmationDialog(
AlertDialog.Builder(app) source: SelfossModel.SourceDetail,
position: Int,
) {
AlertDialog
.Builder(app)
.setTitle(app.getString(R.string.confirm_delete_title)) .setTitle(app.getString(R.string.confirm_delete_title))
.setMessage(app.getString(R.string.confirm_delete_message, source.title)) .setMessage(app.getString(R.string.confirm_delete_message, source.title))
.setPositiveButton(android.R.string.ok) { _, _ -> deleteSource(source, position) } .setPositiveButton(android.R.string.ok) { _, _ -> deleteSource(source, position) }
@ -87,7 +100,10 @@ class SourcesListAdapter(
.show() .show()
} }
private fun deleteSource(source: SelfossModel.SourceDetail, position: Int) { private fun deleteSource(
source: SelfossModel.SourceDetail,
position: Int,
) {
CoroutineScope(Dispatchers.IO).launch { CoroutineScope(Dispatchers.IO).launch {
val successfullyDeletedSource = repository.deleteSource(source.id, source.title) val successfullyDeletedSource = repository.deleteSource(source.id, source.title)
launch(Dispatchers.Main) { launch(Dispatchers.Main) {
@ -96,11 +112,12 @@ class SourcesListAdapter(
notifyItemRemoved(position) notifyItemRemoved(position)
notifyItemRangeChanged(position, itemCount) notifyItemRangeChanged(position, itemCount)
} else { } else {
Toast.makeText( Toast
app, .makeText(
R.string.can_delete_source, app,
Toast.LENGTH_SHORT, R.string.can_delete_source,
).show() Toast.LENGTH_SHORT,
).show()
} }
} }
} }