Skip to content

Commit bd8f8d0

Browse files
fix(FavoriteFragment): adjust button margin and improve clearView formatting
1 parent 4efd1e7 commit bd8f8d0

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

app/src/main/java/com/github/codeworkscreativehub/mlauncher/ui/FavoriteFragment.kt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,10 @@ class FavoriteFragment : BaseFragment() {
125125
}
126126

127127

128-
override fun clearView(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder) {
128+
override fun clearView(
129+
recyclerView: RecyclerView,
130+
viewHolder: RecyclerView.ViewHolder
131+
) {
129132
// Reset the background color after dragging is finished
130133
super.clearView(recyclerView, viewHolder)
131134
viewHolder.itemView.setBackgroundColor(
@@ -186,6 +189,13 @@ class FavoriteFragment : BaseFragment() {
186189
}
187190

188191
private fun setupAddRemoveButtons() {
192+
val margin = resources.getDimensionPixelSize(R.dimen.bottom_margin_gesture_nav)
193+
binding.addRemoveAppButton.apply {
194+
val params = layoutParams as ViewGroup.MarginLayoutParams
195+
params.bottomMargin = margin
196+
layoutParams = params
197+
}
198+
189199
binding.addAppButton.apply {
190200
setOnClickListener {
191201
addHomeAppSlot()
@@ -266,7 +276,7 @@ class FavoriteFragment : BaseFragment() {
266276

267277
private fun removeFavoriteAtPosition(position: Int) {
268278
val currentNum = prefs.homeAppsNum
269-
if (position < 0 || position >= currentNum) return
279+
if (position !in 0..<currentNum) return
270280

271281
// Shift all subsequent favorites left by one
272282
for (i in position until currentNum - 1) {

app/src/main/res/layout/fragment_favorite.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,10 @@
3636

3737
<!-- Add/Remove buttons -->
3838
<LinearLayout
39+
android:id="@+id/addRemoveAppButton"
3940
android:layout_width="match_parent"
4041
android:layout_height="wrap_content"
41-
android:layout_marginTop="24dp"
42+
android:layout_marginTop="14dp"
4243
android:gravity="center"
4344
android:orientation="horizontal"
4445
android:spacing="16dp">

0 commit comments

Comments
 (0)