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>(),
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()
}
}
}