summaryrefslogtreecommitdiffstats
path: root/src/android
diff options
context:
space:
mode:
authorCharles Lombardo <clombardo169@gmail.com>2023-03-08 22:14:24 +0100
committerbunnei <bunneidev@gmail.com>2023-06-03 09:05:39 +0200
commit096cdc57bb0e78beae485a3283bc1dcd26d17bad (patch)
tree9c1083c58c3d6b3fa62d40db7a3a9cf6730e741d /src/android
parentandroid: Inherit from Material 3 themes (diff)
downloadyuzu-096cdc57bb0e78beae485a3283bc1dcd26d17bad.tar
yuzu-096cdc57bb0e78beae485a3283bc1dcd26d17bad.tar.gz
yuzu-096cdc57bb0e78beae485a3283bc1dcd26d17bad.tar.bz2
yuzu-096cdc57bb0e78beae485a3283bc1dcd26d17bad.tar.lz
yuzu-096cdc57bb0e78beae485a3283bc1dcd26d17bad.tar.xz
yuzu-096cdc57bb0e78beae485a3283bc1dcd26d17bad.tar.zst
yuzu-096cdc57bb0e78beae485a3283bc1dcd26d17bad.zip
Diffstat (limited to 'src/android')
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/DividerItemDecoration.java130
1 files changed, 0 insertions, 130 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/DividerItemDecoration.java b/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/DividerItemDecoration.java
deleted file mode 100644
index f725382e6..000000000
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/DividerItemDecoration.java
+++ /dev/null
@@ -1,130 +0,0 @@
-package org.yuzu.yuzu_emu.ui;
-
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.graphics.Canvas;
-import android.graphics.Rect;
-import android.graphics.drawable.Drawable;
-import android.util.AttributeSet;
-import android.view.View;
-
-import androidx.annotation.NonNull;
-import androidx.recyclerview.widget.LinearLayoutManager;
-import androidx.recyclerview.widget.RecyclerView;
-
-/**
- * Implementation from:
- * https://gist.github.com/lapastillaroja/858caf1a82791b6c1a36
- */
-public class DividerItemDecoration extends RecyclerView.ItemDecoration {
-
- private Drawable mDivider;
- private boolean mShowFirstDivider = false;
- private boolean mShowLastDivider = false;
-
- public DividerItemDecoration(Context context, AttributeSet attrs) {
- final TypedArray a = context
- .obtainStyledAttributes(attrs, new int[]{android.R.attr.listDivider});
- mDivider = a.getDrawable(0);
- a.recycle();
- }
-
- public DividerItemDecoration(Context context, AttributeSet attrs, boolean showFirstDivider,
- boolean showLastDivider) {
- this(context, attrs);
- mShowFirstDivider = showFirstDivider;
- mShowLastDivider = showLastDivider;
- }
-
- public DividerItemDecoration(Drawable divider) {
- mDivider = divider;
- }
-
- public DividerItemDecoration(Drawable divider, boolean showFirstDivider,
- boolean showLastDivider) {
- this(divider);
- mShowFirstDivider = showFirstDivider;
- mShowLastDivider = showLastDivider;
- }
-
- @Override
- public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent,
- @NonNull RecyclerView.State state) {
- super.getItemOffsets(outRect, view, parent, state);
- if (mDivider == null) {
- return;
- }
- if (parent.getChildAdapterPosition(view) < 1) {
- return;
- }
-
- if (getOrientation(parent) == LinearLayoutManager.VERTICAL) {
- outRect.top = mDivider.getIntrinsicHeight();
- } else {
- outRect.left = mDivider.getIntrinsicWidth();
- }
- }
-
- @Override
- public void onDrawOver(@NonNull Canvas c, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
- if (mDivider == null) {
- super.onDrawOver(c, parent, state);
- return;
- }
-
- // Initialization needed to avoid compiler warning
- int left = 0, right = 0, top = 0, bottom = 0, size;
- int orientation = getOrientation(parent);
- int childCount = parent.getChildCount();
-
- if (orientation == LinearLayoutManager.VERTICAL) {
- size = mDivider.getIntrinsicHeight();
- left = parent.getPaddingLeft();
- right = parent.getWidth() - parent.getPaddingRight();
- } else { //horizontal
- size = mDivider.getIntrinsicWidth();
- top = parent.getPaddingTop();
- bottom = parent.getHeight() - parent.getPaddingBottom();
- }
-
- for (int i = mShowFirstDivider ? 0 : 1; i < childCount; i++) {
- View child = parent.getChildAt(i);
- RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
-
- if (orientation == LinearLayoutManager.VERTICAL) {
- top = child.getTop() - params.topMargin;
- bottom = top + size;
- } else { //horizontal
- left = child.getLeft() - params.leftMargin;
- right = left + size;
- }
- mDivider.setBounds(left, top, right, bottom);
- mDivider.draw(c);
- }
-
- // show last divider
- if (mShowLastDivider && childCount > 0) {
- View child = parent.getChildAt(childCount - 1);
- RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
- if (orientation == LinearLayoutManager.VERTICAL) {
- top = child.getBottom() + params.bottomMargin;
- bottom = top + size;
- } else { // horizontal
- left = child.getRight() + params.rightMargin;
- right = left + size;
- }
- mDivider.setBounds(left, top, right, bottom);
- mDivider.draw(c);
- }
- }
-
- private int getOrientation(RecyclerView parent) {
- if (parent.getLayoutManager() instanceof LinearLayoutManager) {
- LinearLayoutManager layoutManager = (LinearLayoutManager) parent.getLayoutManager();
- return layoutManager.getOrientation();
- } else {
- throw new IllegalStateException(
- "DividerItemDecoration can only be used with a LinearLayoutManager.");
- }
- }
-}