For #8422: Add spacing between migration items
parent
4a06a228f3
commit
25d5b0d31c
|
@ -5,10 +5,12 @@
|
||||||
package org.mozilla.fenix.migration
|
package org.mozilla.fenix.migration
|
||||||
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.graphics.Rect
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import androidx.annotation.DimenRes
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.recyclerview.widget.DiffUtil
|
import androidx.recyclerview.widget.DiffUtil
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
@ -52,6 +54,8 @@ class MigrationProgressActivity : AbstractMigrationProgressActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
migration_status_list.apply {
|
migration_status_list.apply {
|
||||||
|
val margin = resources.getDimensionPixelSize(R.dimen.migration_margin)
|
||||||
|
addItemDecoration(MigrationStatusItemDecoration(margin))
|
||||||
layoutManager = LinearLayoutManager(this@MigrationProgressActivity)
|
layoutManager = LinearLayoutManager(this@MigrationProgressActivity)
|
||||||
adapter = statusAdapter
|
adapter = statusAdapter
|
||||||
}
|
}
|
||||||
|
@ -158,3 +162,23 @@ internal class MigrationStatusAdapter :
|
||||||
oldItem.status == newItem.status
|
oldItem.status == newItem.status
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal class MigrationStatusItemDecoration(
|
||||||
|
@DimenRes private val spacing: Int
|
||||||
|
) : RecyclerView.ItemDecoration() {
|
||||||
|
|
||||||
|
override fun getItemOffsets(
|
||||||
|
outRect: Rect,
|
||||||
|
view: View,
|
||||||
|
parent: RecyclerView,
|
||||||
|
state: RecyclerView.State
|
||||||
|
) {
|
||||||
|
val position = parent.getChildViewHolder(view).adapterPosition
|
||||||
|
val itemCount = state.itemCount
|
||||||
|
|
||||||
|
outRect.left = spacing
|
||||||
|
outRect.right = spacing
|
||||||
|
outRect.top = spacing
|
||||||
|
outRect.bottom = if (position == itemCount - 1) spacing else 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue