Skip to content

Commit

Permalink
Merge branch 'release/v0.0.12'
Browse files Browse the repository at this point in the history
  • Loading branch information
sangcomz committed Dec 15, 2017
2 parents 60ce4ed + 52592bf commit 6afa4d7
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 27 deletions.
4 changes: 2 additions & 2 deletions app/src/main/res/layout/recycler_row.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp">
android:layout_height="wrap_content">

<TextView
android:id="@+id/full_name_tv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
tools:text="asdf" />

</android.support.v7.widget.CardView>
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
buildscript {

ext {
support_version = '27.0.1'
kotlin_version = '1.1.60'
support_version = '27.0.2'
kotlin_version = '1.2.0'
constraint_version = '1.0.2'
}

Expand Down
8 changes: 5 additions & 3 deletions stickytimelineview/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ apply plugin: 'com.github.dcendents.android-maven'

group='com.github.sangcomz'

repositories {
mavenCentral()
}


android {
compileSdkVersion gradle.compileSdk
buildToolsVersion gradle.buildTools
Expand Down Expand Up @@ -35,6 +40,3 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation "com.android.support.constraint:constraint-layout:$constraint_version"
}
repositories {
mavenCentral()
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,30 +44,39 @@ class RecyclerSectionItemDecoration(context: Context,

val pos = parent.getChildAdapterPosition(view)

if (getIsSection(pos)) {
outRect.top = headerOffset
if (getIsSection(pos)) outRect.top = headerOffset
else {
outRect.top = defaultOffset / 2
}
}


val leftMargin = defaultOffset * 6
val rightMargin = defaultOffset * 2

outRect.bottom = defaultOffset / 2
outRect.left = leftMargin
outRect.right = rightMargin

}

override fun onDraw(c: Canvas?, parent: RecyclerView?, state: RecyclerView.State?) {
super.onDraw(c, parent, state)
c?.let {
parent?.let {
val leftMargin = defaultOffset * 6
val rightMargin = defaultOffset * 2
val topMargin = defaultOffset
(0 until parent.childCount)
.map { parent.getChildAt(it) }
.forEach {
val params = it.layoutParams
if (params is RecyclerView.LayoutParams && params.leftMargin != leftMargin) {
params.setMargins(leftMargin, 0, rightMargin, topMargin)
it.layoutParams = params
}
}
}
}
// c?.let {
// parent?.let {
// val leftMargin = defaultOffset * 6
// val rightMargin = defaultOffset * 2
// val topMargin = defaultOffset
// (0 until parent.childCount)
// .map { parent.getChildAt(it) }
// .forEach {
// val params = it.layoutParams
// if (params is RecyclerView.LayoutParams && params.leftMargin != leftMargin) {
// params.setMargins(leftMargin, 0, rightMargin, topMargin)
// it.layoutParams = params
// }
// }
// }
// }
}

override fun onDrawOver(c: Canvas, parent: RecyclerView, state: RecyclerView.State?) {
Expand All @@ -80,6 +89,7 @@ class RecyclerSectionItemDecoration(context: Context,

val childInContact = getChildInContact(parent, headerOffset * 2)
val contractPosition = parent.getChildAdapterPosition(childInContact)

if (getIsSection(contractPosition)) {
childInContact?.let {
val topChild = parent.getChildAt(0) ?: return
Expand Down Expand Up @@ -113,7 +123,6 @@ class RecyclerSectionItemDecoration(context: Context,

}
}

}
}

Expand Down

0 comments on commit 6afa4d7

Please sign in to comment.