Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Commit

Permalink
For #8422: Add spacing between migration items
Browse files Browse the repository at this point in the history
  • Loading branch information
jonalmeida authored and ekager committed Apr 16, 2020
1 parent 4a06a22 commit 25d5b0d
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
package org.mozilla.fenix.migration

import android.content.Intent
import android.graphics.Rect
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.annotation.DimenRes
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.LinearLayoutManager
Expand Down Expand Up @@ -52,6 +54,8 @@ class MigrationProgressActivity : AbstractMigrationProgressActivity() {
}

migration_status_list.apply {
val margin = resources.getDimensionPixelSize(R.dimen.migration_margin)
addItemDecoration(MigrationStatusItemDecoration(margin))
layoutManager = LinearLayoutManager(this@MigrationProgressActivity)
adapter = statusAdapter
}
Expand Down Expand Up @@ -158,3 +162,23 @@ internal class MigrationStatusAdapter :
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
}
}

0 comments on commit 25d5b0d

Please sign in to comment.