-
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.
Merge pull request #2 from iFanie/feature-overridable-pre-addition-pr…
…ocessing Added overridable pre addition processing
- Loading branch information
Showing
12 changed files
with
270 additions
and
25 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
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
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
115 changes: 115 additions & 0 deletions
115
app/src/main/java/com/izikode/izilib/accordionrecyclerdemo/viewholder/EmptyPinkViewHolder.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,115 @@ | ||
package com.izikode.izilib.accordionrecyclerdemo.viewholder | ||
|
||
import android.support.constraint.ConstraintLayout | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.TextView | ||
import com.izikode.izilib.accordionrecycler.AccordionRecyclerPosition | ||
import com.izikode.izilib.accordionrecyclerdemo.R | ||
import com.izikode.izilib.accordionrecyclerdemo.data.ColorData | ||
import com.izikode.izilib.accordionrecyclerdemo.data.PinkData | ||
|
||
class EmptyPinkViewHolder(parent: ViewGroup) : ColorViewHolder<EmptyPinkViewHolder.EmptyPinkData>(parent, R.layout.view_holder_empty_pink) { | ||
|
||
private val container by lazy { itemView.findViewById<ConstraintLayout>(R.id.pink_container) } | ||
private val text by lazy { itemView.findViewById<TextView>(R.id.pink_text) } | ||
private val topShadow by lazy { itemView.findViewById<View>(R.id.pink_topShadow) } | ||
private val bottomShadow by lazy { itemView.findViewById<View>(R.id.pink_bottomShadow) } | ||
private val divider by lazy { itemView.findViewById<View>(R.id.pink_divider) } | ||
|
||
var onClick: ((position: Int, enclosedSum: Int) -> Unit)? = null | ||
|
||
override var data: EmptyPinkData? = null | ||
set(value) { | ||
text.text = value?.text | ||
field = value | ||
} | ||
|
||
var enclosedSum: Int = 0 | ||
|
||
fun update(data: EmptyPinkData?, overallPosition: AccordionRecyclerPosition, enclosedPosition: AccordionRecyclerPosition, sumOfTotalEnclosedItems: Int) { | ||
this.data = data | ||
this.enclosedSum = sumOfTotalEnclosedItems | ||
|
||
container.setBackgroundResource( | ||
when (overallPosition) { | ||
|
||
AccordionRecyclerPosition.BOTTOM -> R.drawable.empty_pink_background_bottom | ||
|
||
else -> R.drawable.empty_pink_background_middle | ||
|
||
} | ||
) | ||
|
||
when { | ||
|
||
enclosedPosition == AccordionRecyclerPosition.SINGLE && sumOfTotalEnclosedItems == 0 -> { | ||
topShadow.visibility = View.VISIBLE | ||
bottomShadow.visibility = View.VISIBLE | ||
divider.visibility = View.INVISIBLE | ||
} | ||
|
||
enclosedPosition == AccordionRecyclerPosition.SINGLE -> { | ||
topShadow.visibility = View.VISIBLE | ||
bottomShadow.visibility = View.INVISIBLE | ||
divider.visibility = View.INVISIBLE | ||
} | ||
|
||
enclosedPosition == AccordionRecyclerPosition.TOP && sumOfTotalEnclosedItems == 0 -> { | ||
topShadow.visibility = View.VISIBLE | ||
bottomShadow.visibility = View.INVISIBLE | ||
divider.visibility = View.VISIBLE | ||
} | ||
|
||
enclosedPosition == AccordionRecyclerPosition.TOP -> { | ||
topShadow.visibility = View.VISIBLE | ||
bottomShadow.visibility = View.INVISIBLE | ||
divider.visibility = View.INVISIBLE | ||
} | ||
|
||
enclosedPosition == AccordionRecyclerPosition.BOTTOM && sumOfTotalEnclosedItems == 0 -> { | ||
topShadow.visibility = View.INVISIBLE | ||
bottomShadow.visibility = View.VISIBLE | ||
divider.visibility = View.INVISIBLE | ||
} | ||
|
||
enclosedPosition == AccordionRecyclerPosition.BOTTOM -> { | ||
topShadow.visibility = View.INVISIBLE | ||
bottomShadow.visibility = View.INVISIBLE | ||
divider.visibility = View.INVISIBLE | ||
} | ||
|
||
enclosedPosition == AccordionRecyclerPosition.MIDDLE && sumOfTotalEnclosedItems == 0 -> { | ||
topShadow.visibility = View.INVISIBLE | ||
bottomShadow.visibility = View.INVISIBLE | ||
divider.visibility = View.VISIBLE | ||
} | ||
|
||
else -> { | ||
topShadow.visibility = View.INVISIBLE | ||
bottomShadow.visibility = View.INVISIBLE | ||
divider.visibility = View.INVISIBLE | ||
} | ||
|
||
} | ||
} | ||
|
||
init { | ||
container.setOnClickListener { | ||
onClick?.invoke(layoutPosition, enclosedSum) | ||
} | ||
} | ||
|
||
companion object { | ||
|
||
const val VIEW_TYPE = 31 | ||
|
||
} | ||
|
||
class EmptyPinkData : ColorData(VIEW_TYPE, null) { | ||
|
||
override var text: String = "Nothing to see here" | ||
|
||
} | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
app/src/main/res/drawable/empty_pink_background_bottom.xml
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,16 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<item android:top="-2dp"> | ||
|
||
<shape android:shape="rectangle"> | ||
|
||
<stroke android:color="@android:color/black" | ||
android:width="1dp" /> | ||
|
||
<corners android:bottomLeftRadius="8dp" | ||
android:bottomRightRadius="8dp" /> | ||
|
||
<solid android:color="#ffcce6" /> | ||
</shape> | ||
</item> | ||
</layer-list> |
14 changes: 14 additions & 0 deletions
14
app/src/main/res/drawable/empty_pink_background_middle.xml
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,14 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<item android:top="-2dp" | ||
android:bottom="-2dp"> | ||
|
||
<shape android:shape="rectangle"> | ||
|
||
<stroke android:color="@android:color/black" | ||
android:width="1dp" /> | ||
|
||
<solid android:color="#ffcce6" /> | ||
</shape> | ||
</item> | ||
</layer-list> |
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,16 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<item android:bottom="-2dp"> | ||
|
||
<shape android:shape="rectangle"> | ||
|
||
<stroke android:color="@android:color/black" | ||
android:width="1dp" /> | ||
|
||
<corners android:topLeftRadius="8dp" | ||
android:topRightRadius="8dp" /> | ||
|
||
<solid android:color="#ffcce6" /> | ||
</shape> | ||
</item> | ||
</layer-list> |
Oops, something went wrong.