From 43146b5afff461add8992fe2c1ecf431f9e595fd Mon Sep 17 00:00:00 2001 From: davidoskky Date: Sun, 9 Mar 2025 12:42:44 +0100 Subject: [PATCH] Fix Ktlint warnings --- .../android/adapters/SourcesListAdapter.kt | 47 +++++++++++++------ 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/SourcesListAdapter.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/SourcesListAdapter.kt index aca1943..03c4b7e 100644 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/SourcesListAdapter.kt +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/adapters/SourcesListAdapter.kt @@ -32,13 +32,19 @@ class SourcesListAdapter( ) : RecyclerView.Adapter(), DIAware { 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) return ViewHolder(binding) } - override fun onBindViewHolder(holder: ViewHolder, position: Int) { + override fun onBindViewHolder( + holder: ViewHolder, + position: Int, + ) { holder.bind(items[position], position) } @@ -48,14 +54,17 @@ class SourcesListAdapter( override fun getItemCount(): Int = items.size - - inner class ViewHolder(val binding: SourceListItemBinding) : RecyclerView.ViewHolder(binding.root) { - + inner class ViewHolder( + val binding: SourceListItemBinding, + ) : RecyclerView.ViewHolder(binding.root) { private val context: Context = app.applicationContext private val repository: Repository by instance() private val appSettingsService: AppSettingsService by instance() - fun bind(source: SelfossModel.SourceDetail, position: Int) { + fun bind( + source: SelfossModel.SourceDetail, + position: Int, + ) { binding.apply { sourceTitle.text = source.title.getHtmlDecoded() if (source.getIcon(repository.baseUrl).isEmpty()) { @@ -78,8 +87,12 @@ class SourcesListAdapter( } } - private fun showDeleteConfirmationDialog(source: SelfossModel.SourceDetail, position: Int) { - AlertDialog.Builder(app) + private fun showDeleteConfirmationDialog( + source: SelfossModel.SourceDetail, + position: Int, + ) { + AlertDialog + .Builder(app) .setTitle(app.getString(R.string.confirm_delete_title)) .setMessage(app.getString(R.string.confirm_delete_message, source.title)) .setPositiveButton(android.R.string.ok) { _, _ -> deleteSource(source, position) } @@ -87,7 +100,10 @@ class SourcesListAdapter( .show() } - private fun deleteSource(source: SelfossModel.SourceDetail, position: Int) { + private fun deleteSource( + source: SelfossModel.SourceDetail, + position: Int, + ) { CoroutineScope(Dispatchers.IO).launch { val successfullyDeletedSource = repository.deleteSource(source.id, source.title) launch(Dispatchers.Main) { @@ -96,11 +112,12 @@ class SourcesListAdapter( notifyItemRemoved(position) notifyItemRangeChanged(position, itemCount) } else { - Toast.makeText( - app, - R.string.can_delete_source, - Toast.LENGTH_SHORT, - ).show() + Toast + .makeText( + app, + R.string.can_delete_source, + Toast.LENGTH_SHORT, + ).show() } } }