fix codestyle

This commit is contained in:
Konrad Pozniak 2021-06-28 22:04:34 +02:00
commit 2cc53d6772
7 changed files with 423 additions and 358 deletions

View file

@ -93,7 +93,7 @@ class ScheduledTootActivity : BaseActivity(), ScheduledTootActionListener, Injec
}
if (loadState.refresh is LoadState.NotLoading) {
binding.progressBar.hide()
if(adapter.itemCount == 0) {
if (adapter.itemCount == 0) {
binding.errorMessageView.setup(R.drawable.elephant_friend_empty, R.string.no_scheduled_status)
binding.errorMessageView.show()
} else {
@ -117,16 +117,19 @@ class ScheduledTootActivity : BaseActivity(), ScheduledTootActionListener, Injec
}
override fun edit(item: ScheduledStatus) {
val intent = ComposeActivity.startIntent(this, ComposeActivity.ComposeOptions(
scheduledTootId = item.id,
tootText = item.params.text,
contentWarning = item.params.spoilerText,
mediaAttachments = item.mediaAttachments,
inReplyToId = item.params.inReplyToId,
visibility = item.params.visibility,
scheduledAt = item.scheduledAt,
sensitive = item.params.sensitive
))
val intent = ComposeActivity.startIntent(
this,
ComposeActivity.ComposeOptions(
scheduledTootId = item.id,
tootText = item.params.text,
contentWarning = item.params.spoilerText,
mediaAttachments = item.mediaAttachments,
inReplyToId = item.params.inReplyToId,
visibility = item.params.visibility,
scheduledAt = item.scheduledAt,
sensitive = item.params.sensitive
)
)
startActivity(intent)
}

View file

@ -30,18 +30,17 @@ interface ScheduledTootActionListener {
}
class ScheduledTootAdapter(
val listener: ScheduledTootActionListener
val listener: ScheduledTootActionListener
) : PagingDataAdapter<ScheduledStatus, BindingHolder<ItemScheduledTootBinding>>(
object: DiffUtil.ItemCallback<ScheduledStatus>(){
override fun areItemsTheSame(oldItem: ScheduledStatus, newItem: ScheduledStatus): Boolean {
return oldItem.id == newItem.id
}
override fun areContentsTheSame(oldItem: ScheduledStatus, newItem: ScheduledStatus): Boolean {
return oldItem == newItem
}
object : DiffUtil.ItemCallback<ScheduledStatus>() {
override fun areItemsTheSame(oldItem: ScheduledStatus, newItem: ScheduledStatus): Boolean {
return oldItem.id == newItem.id
}
override fun areContentsTheSame(oldItem: ScheduledStatus, newItem: ScheduledStatus): Boolean {
return oldItem == newItem
}
}
) {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BindingHolder<ItemScheduledTootBinding> {
@ -50,7 +49,7 @@ class ScheduledTootAdapter(
}
override fun onBindViewHolder(holder: BindingHolder<ItemScheduledTootBinding>, position: Int) {
getItem(position)?.let{ item ->
getItem(position)?.let { item ->
holder.binding.edit.isEnabled = true
holder.binding.delete.isEnabled = true
holder.binding.text.text = item.params.text

View file

@ -24,7 +24,7 @@ import kotlinx.coroutines.rx3.await
class ScheduledTootPagingSourceFactory(
private val mastodonApi: MastodonApi
): () -> ScheduledTootPagingSource {
) : () -> ScheduledTootPagingSource {
private val scheduledTootsCache = mutableListOf<ScheduledStatus>()
@ -45,7 +45,7 @@ class ScheduledTootPagingSourceFactory(
class ScheduledTootPagingSource(
private val mastodonApi: MastodonApi,
private val scheduledTootsCache: MutableList<ScheduledStatus>
): PagingSource<String, ScheduledStatus>() {
) : PagingSource<String, ScheduledStatus>() {
override fun getRefreshKey(state: PagingState<String, ScheduledStatus>): String? {
return null