remove redundant SAM constructors

This commit is contained in:
Konrad Pozniak 2020-08-18 20:42:06 +02:00
parent f608912165
commit c037f42b61
4 changed files with 11 additions and 14 deletions

View File

@ -25,7 +25,6 @@ import android.content.Intent
import android.os.Bundle
import androidx.activity.viewModels
import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.lifecycle.Observer
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import at.connyduck.pixelcat.R
@ -105,14 +104,14 @@ class ComposeActivity : BaseActivity(), OnImageActionClickListener {
viewModel.imageLiveData.observe(
this,
Observer {
{
adapter.submitList(it)
}
)
viewModel.visibility.observe(
this,
Observer {
{
val visibilityString = when (it) {
VISIBILITY.PUBLIC -> R.string.compose_visibility_public
VISIBILITY.UNLISTED -> R.string.compose_visibility_unlisted

View File

@ -22,7 +22,6 @@ package at.connyduck.pixelcat.components.profile
import android.os.Bundle
import android.view.View
import androidx.fragment.app.viewModels
import androidx.lifecycle.Observer
import androidx.lifecycle.lifecycleScope
import androidx.paging.ExperimentalPagingApi
import androidx.recyclerview.widget.GridLayoutManager
@ -113,7 +112,7 @@ class ProfileFragment : DaggerFragment(R.layout.fragment_profile) {
viewModel.profile.observe(
viewLifecycleOwner,
Observer {
{
when (it) {
is Success -> onAccountChanged(it.data)
is Error -> showError()
@ -122,7 +121,7 @@ class ProfileFragment : DaggerFragment(R.layout.fragment_profile) {
)
viewModel.relationship.observe(
viewLifecycleOwner,
Observer {
{
when (it) {
is Success -> onRelationshipChanged(it.data)
is Error -> showError()

View File

@ -74,12 +74,12 @@ class TimelineListAdapter(
(holder.binding.postImages.adapter as TimelineImageAdapter).images = status.attachments
val maxImageRatio = status.attachments.map {
if (it.meta?.small?.width == null || it.meta.small.height == null) {
1f
} else {
it.meta.small.height.toFloat() / it.meta.small.width.toFloat()
}
}.maxOrNull()?.coerceAtMost(1f) ?: 1f
if (it.meta?.small?.width == null || it.meta.small.height == null) {
1f
} else {
it.meta.small.height.toFloat() / it.meta.small.width.toFloat()
}
}.maxOrNull()?.coerceAtMost(1f) ?: 1f
holder.binding.postImages.layoutParams.height = (displayWidth * maxImageRatio).toInt()

View File

@ -7,7 +7,6 @@ import androidx.fragment.app.Fragment
import androidx.lifecycle.DefaultLifecycleObserver
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.Observer
import androidx.viewbinding.ViewBinding
import kotlin.properties.ReadOnlyProperty
import kotlin.reflect.KProperty
@ -33,7 +32,7 @@ class FragmentViewBindingDelegate<T : ViewBinding>(
override fun onCreate(owner: LifecycleOwner) {
fragment.viewLifecycleOwnerLiveData.observe(
fragment,
Observer { t ->
{ t ->
t?.lifecycle?.addObserver(object : DefaultLifecycleObserver {
override fun onDestroy(owner: LifecycleOwner) {
binding = null