-
Notifications
You must be signed in to change notification settings - Fork 892
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix the toolbar y position in landscape
This fixes an issue where, in landscape translation mode, if the toolbar is visible when a long press occurs, the y would be incorrect. Also make the root a FrameLayout instead of a RelativeLayout. Refs #2993.
- Loading branch information
Showing
4 changed files
with
58 additions
and
17 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
app/src/main/java/com/quran/labs/androidquran/ui/translation/SpacerDecoration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.quran.labs.androidquran.ui.translation | ||
|
||
import android.graphics.Rect | ||
import android.view.View | ||
import androidx.recyclerview.widget.RecyclerView | ||
|
||
class SpacerDecoration( | ||
private var top: Int, | ||
private var bottom: Int | ||
) : RecyclerView.ItemDecoration() { | ||
|
||
fun setOffsets(top: Int, bottom: Int): Boolean { | ||
return if (this.top != top || this.bottom != bottom) { | ||
this.top = top | ||
this.bottom = bottom | ||
true | ||
} else { | ||
false | ||
} | ||
} | ||
|
||
override fun getItemOffsets( | ||
outRect: Rect, | ||
view: View, | ||
parent: RecyclerView, | ||
state: RecyclerView.State | ||
) { | ||
val adapter = parent.adapter ?: return | ||
when (parent.getChildAdapterPosition(view)) { | ||
0 -> outRect.top = top | ||
adapter.itemCount - 1 -> outRect.bottom = bottom | ||
else -> outRect.set(0, 0, 0, 0) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters