aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/view/CardView.java22
-rw-r--r--app/src/main/java/github/daneren2005/dsub/view/GridSpacingDecoration.java33
-rw-r--r--app/src/main/res/layout/album_cell_item.xml3
-rw-r--r--app/src/main/res/layout/basic_cell_item.xml3
-rw-r--r--app/src/main/res/values/dimens.xml1
5 files changed, 43 insertions, 19 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/view/CardView.java b/app/src/main/java/github/daneren2005/dsub/view/CardView.java
index ba6b66a4..973e63fa 100644
--- a/app/src/main/java/github/daneren2005/dsub/view/CardView.java
+++ b/app/src/main/java/github/daneren2005/dsub/view/CardView.java
@@ -2,12 +2,12 @@ package github.daneren2005.dsub.view;
import android.annotation.TargetApi;
import android.content.Context;
-import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Path;
import android.graphics.RectF;
import android.os.Build;
import android.util.AttributeSet;
+import android.util.Log;
import android.widget.FrameLayout;
import github.daneren2005.dsub.R;
@@ -15,27 +15,23 @@ import github.daneren2005.dsub.R;
public class CardView extends FrameLayout{
public CardView(Context context) {
super(context);
- this.setClipChildren(true);
- this.setBackgroundResource(R.drawable.card_rounded_corners);
+ init(context);
}
public CardView(Context context, AttributeSet attrs) {
super(context, attrs);
- this.setClipChildren(true);
- this.setBackgroundResource(R.drawable.card_rounded_corners);
+ init(context);
}
public CardView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
- this.setClipChildren(true);
- this.setBackgroundResource(R.drawable.card_rounded_corners);
+ init(context);
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public CardView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
- this.setClipChildren(true);
- this.setBackgroundResource(R.drawable.card_rounded_corners);
+ init(context);
}
@Override
@@ -47,4 +43,12 @@ public class CardView extends FrameLayout{
canvas.clipPath(clipPath);
super.onDraw(canvas);
}
+
+ private void init(Context context) {
+ setClipChildren(true);
+ setBackgroundResource(R.drawable.card_rounded_corners);
+ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ setElevation(10.0f);
+ }
+ }
}
diff --git a/app/src/main/java/github/daneren2005/dsub/view/GridSpacingDecoration.java b/app/src/main/java/github/daneren2005/dsub/view/GridSpacingDecoration.java
index c6d3dbb1..a33746c4 100644
--- a/app/src/main/java/github/daneren2005/dsub/view/GridSpacingDecoration.java
+++ b/app/src/main/java/github/daneren2005/dsub/view/GridSpacingDecoration.java
@@ -21,6 +21,11 @@ import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.util.TypedValue;
import android.view.View;
+import android.view.ViewGroup;
+import android.widget.FrameLayout;
+import android.widget.LinearLayout;
+
+import static android.widget.LinearLayout.*;
public class GridSpacingDecoration extends RecyclerView.ItemDecoration {
private static final String TAG = GridSpacingDecoration.class.getSimpleName();
@@ -56,25 +61,37 @@ public class GridSpacingDecoration extends RecyclerView.ItemDecoration {
/* INVALID SPAN */
if (spanCount < 1 || spanSize > 1) return;
- outRect.top = halfSpacing;
- outRect.bottom = halfSpacing;
- outRect.left = halfSpacing;
- outRect.right = halfSpacing;
+ int margins = 0;
+ if(view instanceof UpdateView) {
+ View firstChild = ((ViewGroup) view).getChildAt(0);
+ ViewGroup.LayoutParams layoutParams = firstChild.getLayoutParams();
+ if (layoutParams instanceof LinearLayout.LayoutParams) {
+ margins = ((LinearLayout.LayoutParams) layoutParams).bottomMargin;
+ } else if (layoutParams instanceof FrameLayout.LayoutParams) {
+ margins = ((FrameLayout.LayoutParams) layoutParams).bottomMargin;
+ }
+ }
+ int doubleMargins = margins * 2;
+
+ outRect.top = halfSpacing - margins;
+ outRect.bottom = halfSpacing - margins;
+ outRect.left = halfSpacing - margins;
+ outRect.right = halfSpacing - margins;
if (isTopEdge(childIndex, spanCount)) {
- outRect.top = spacing;
+ outRect.top = spacing - doubleMargins;
}
if (isLeftEdge(spanIndex, spanCount)) {
- outRect.left = spacing;
+ outRect.left = spacing - doubleMargins;
}
if (isRightEdge(spanIndex, spanCount)) {
- outRect.right = spacing;
+ outRect.right = spacing - doubleMargins;
}
if (isBottomEdge(childIndex, childCount, spanCount)) {
- outRect.bottom = spacing;
+ outRect.bottom = spacing - doubleMargins;
}
}
diff --git a/app/src/main/res/layout/album_cell_item.xml b/app/src/main/res/layout/album_cell_item.xml
index b352a5f1..524727a0 100644
--- a/app/src/main/res/layout/album_cell_item.xml
+++ b/app/src/main/res/layout/album_cell_item.xml
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<github.daneren2005.dsub.view.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:layout_height="match_parent"
+ android:layout_margin="2dp">
<LinearLayout
android:orientation="vertical"
diff --git a/app/src/main/res/layout/basic_cell_item.xml b/app/src/main/res/layout/basic_cell_item.xml
index 55734b1e..fcfb6da5 100644
--- a/app/src/main/res/layout/basic_cell_item.xml
+++ b/app/src/main/res/layout/basic_cell_item.xml
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<github.daneren2005.dsub.view.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:layout_height="match_parent"
+ android:layout_margin="2dp">
<LinearLayout
android:orientation="vertical"
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
index 3a0e053a..3431de0c 100644
--- a/app/src/main/res/values/dimens.xml
+++ b/app/src/main/res/values/dimens.xml
@@ -8,4 +8,5 @@
<dimen name="Star.Small">20dp</dimen>
<dimen name="Card.Radius">4dp</dimen>
<dimen name="Card.TextLeftPadding">8dp</dimen>
+ <dimen name="Card.MarginsForShadow">2dp</dimen>
</resources> \ No newline at end of file