-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better UI, add animations & dividers
- Loading branch information
Showing
5 changed files
with
63 additions
and
8 deletions.
There are no files selected for viewing
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
35 changes: 35 additions & 0 deletions
35
wukong/src/main/java/com/senorsen/wukong/ui/DividerItemDecoration.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.senorsen.wukong.ui | ||
|
||
import android.content.Context | ||
import android.graphics.Canvas | ||
import android.support.v7.widget.RecyclerView | ||
import android.graphics.drawable.Drawable | ||
import com.senorsen.wukong.R | ||
|
||
|
||
class DividerItemDecoration(context: Context, private val leftInset: Int = 0) : RecyclerView.ItemDecoration() { | ||
|
||
private val mDivider: Drawable | ||
|
||
init { | ||
mDivider = context.getResources().getDrawable(R.drawable.line_divider) | ||
} | ||
|
||
override fun onDrawOver(c: Canvas, parent: RecyclerView, state: RecyclerView.State) { | ||
val left = parent.paddingLeft + leftInset | ||
val right = parent.width - parent.paddingRight | ||
|
||
val childCount = parent.childCount | ||
for (i in 0 until childCount) { | ||
val child = parent.getChildAt(i) | ||
|
||
val params = child.layoutParams as RecyclerView.LayoutParams | ||
|
||
val top = child.bottom + params.bottomMargin | ||
val bottom = top + mDivider.intrinsicHeight | ||
|
||
mDivider.setBounds(left, top, right, bottom) | ||
mDivider.draw(c) | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shape="rectangle"> | ||
<size | ||
android:width="1dp" | ||
android:height="0.5px" /> | ||
|
||
<solid android:color="#ddd" /> | ||
|
||
</shape> |
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