aboutsummaryrefslogtreecommitdiff
path: root/sample/src/main/kotlin/ca
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2018-09-09 11:59:24 -0400
committerGitHub <noreply@github.com>2018-09-09 11:59:24 -0400
commitd540934915da26ab2cec4c897e973be35e0bfe24 (patch)
tree6f114d080c168381266a0d5d3a40b685e28b8e9a /sample/src/main/kotlin/ca
parent718a51ed00a0a5c3dc7a655e617308e82da65d1a (diff)
downloadkau-d540934915da26ab2cec4c897e973be35e0bfe24.tar.gz
kau-d540934915da26ab2cec4c897e973be35e0bfe24.tar.bz2
kau-d540934915da26ab2cec4c897e973be35e0bfe24.zip
Clean up kotterknife (#161)
* Remove bindview implementations internally * Remove more bindView calls * Make config private in ElasticRecyclerActivity * Fix recyclerview * Update adapter * Improve swipe destroy and add direction to swipe finish
Diffstat (limited to 'sample/src/main/kotlin/ca')
-rw-r--r--sample/src/main/kotlin/ca/allanwang/kau/sample/AdapterActivity.kt11
-rw-r--r--sample/src/main/kotlin/ca/allanwang/kau/sample/PermissionCheckbox.kt5
-rw-r--r--sample/src/main/kotlin/ca/allanwang/kau/sample/SwipeActivity.kt29
3 files changed, 15 insertions, 30 deletions
diff --git a/sample/src/main/kotlin/ca/allanwang/kau/sample/AdapterActivity.kt b/sample/src/main/kotlin/ca/allanwang/kau/sample/AdapterActivity.kt
index 874e73b..ada60ca 100644
--- a/sample/src/main/kotlin/ca/allanwang/kau/sample/AdapterActivity.kt
+++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/AdapterActivity.kt
@@ -1,11 +1,12 @@
package ca.allanwang.kau.sample
import android.os.Bundle
+import ca.allanwang.kau.adapters.fastAdapter
import ca.allanwang.kau.iitems.CardIItem
import ca.allanwang.kau.ui.activities.ElasticRecyclerActivity
import ca.allanwang.kau.utils.toast
import com.mikepenz.fastadapter.IItem
-import com.mikepenz.fastadapter.commons.adapters.FastItemAdapter
+import com.mikepenz.fastadapter.adapters.ItemAdapter
import com.mikepenz.google_material_typeface_library.GoogleMaterial
/**
@@ -13,10 +14,9 @@ import com.mikepenz.google_material_typeface_library.GoogleMaterial
*/
class AdapterActivity : ElasticRecyclerActivity() {
- val adapter = FastItemAdapter<IItem<*, *>>()
-
override fun onCreate(savedInstanceState: Bundle?, configs: Configs): Boolean {
- recycler.adapter = adapter
+ val adapter = ItemAdapter<IItem<*, *>>()
+ recycler.adapter = fastAdapter(adapter)
adapter.add(listOf(
CardIItem {
titleRes = R.string.kau_text_copied
@@ -43,8 +43,7 @@ class AdapterActivity : ElasticRecyclerActivity() {
titleRes = R.string.kau_text_copied
button = "Test"
buttonClick = { toast("HI") }
- }
- ))
+ }))
setOutsideTapListener { finishAfterTransition() }
return true
}
diff --git a/sample/src/main/kotlin/ca/allanwang/kau/sample/PermissionCheckbox.kt b/sample/src/main/kotlin/ca/allanwang/kau/sample/PermissionCheckbox.kt
index 3dba332..beb1a29 100644
--- a/sample/src/main/kotlin/ca/allanwang/kau/sample/PermissionCheckbox.kt
+++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/PermissionCheckbox.kt
@@ -5,7 +5,6 @@ import android.view.View
import android.widget.CheckBox
import android.widget.TextView
import ca.allanwang.kau.iitems.KauIItem
-import ca.allanwang.kau.utils.bindView
import ca.allanwang.kau.utils.hasPermission
/**
@@ -23,7 +22,7 @@ class PermissionCheckbox(val permission: String) : KauIItem<PermissionCheckbox,
}
class ViewHolder(v: View) : RecyclerView.ViewHolder(v) {
- val text: TextView by bindView(R.id.perm_text)
- val checkbox: CheckBox by bindView(R.id.perm_checkbox)
+ val text: TextView = v.findViewById(R.id.perm_text)
+ val checkbox: CheckBox = v.findViewById(R.id.perm_checkbox)
}
} \ No newline at end of file
diff --git a/sample/src/main/kotlin/ca/allanwang/kau/sample/SwipeActivity.kt b/sample/src/main/kotlin/ca/allanwang/kau/sample/SwipeActivity.kt
index bc2d4a4..4197b6d 100644
--- a/sample/src/main/kotlin/ca/allanwang/kau/sample/SwipeActivity.kt
+++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/SwipeActivity.kt
@@ -2,12 +2,10 @@ package ca.allanwang.kau.sample
import android.app.Activity
import android.os.Bundle
-import android.support.v7.widget.Toolbar
-import android.view.ViewGroup
-import android.widget.Button
import ca.allanwang.kau.internal.KauBaseActivity
import ca.allanwang.kau.swipe.*
import ca.allanwang.kau.utils.*
+import kotlinx.android.synthetic.main.activity_swipe.*
/**
* Created by Allan Wang on 2017-08-05.
@@ -22,37 +20,26 @@ fun Activity.startActivityWithEdge(flag: Int) {
class SwipeActivity : KauBaseActivity() {
- val toolbar: Toolbar by bindView(R.id.swipe_toolbar)
- val container: ViewGroup by bindView(R.id.swipe_container)
- val directions: List<Button> by bindViews(R.id.swipe_from_left, R.id.swipe_from_right, R.id.swipe_from_top, R.id.swipe_from_bottom)
-
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_swipe)
- directions.forEach {
- val swipeEdge = when (it.id) {
- R.id.swipe_from_left -> SWIPE_EDGE_LEFT
- R.id.swipe_from_right -> SWIPE_EDGE_RIGHT
- R.id.swipe_from_top -> SWIPE_EDGE_TOP
- R.id.swipe_from_bottom -> SWIPE_EDGE_BOTTOM
- else -> -1
- }
- it.setOnClickListener { startActivityWithEdge(swipeEdge) }
- }
+ listOf(swipe_from_left, swipe_from_right, swipe_from_top, swipe_from_bottom)
+ .zip(listOf(SWIPE_EDGE_LEFT, SWIPE_EDGE_RIGHT, SWIPE_EDGE_TOP, SWIPE_EDGE_BOTTOM))
+ .forEach { (button, edge) -> button.setOnClickListener { startActivityWithEdge(edge) } }
val flag = intent.getIntExtra(SWIPE_EDGE, -1)
- toolbar.title = when (flag) {
+ swipe_toolbar.title = when (flag) {
SWIPE_EDGE_LEFT -> "Left Edge Swipe"
SWIPE_EDGE_RIGHT -> "Right Edge Swipe"
SWIPE_EDGE_TOP -> "Top Edge Swipe"
SWIPE_EDGE_BOTTOM -> "Bottom Edge Swipe"
else -> "Invalid Edge Swipe"
}
- setSupportActionBar(toolbar)
+ setSupportActionBar(swipe_toolbar)
val headerColor = rndColor.darken(0.6f)
- toolbar.setBackgroundColor(headerColor)
+ swipe_toolbar.setBackgroundColor(headerColor)
statusBarColor = headerColor
val bg = headerColor.darken(0.2f)
- container.setBackgroundColor(bg)
+ swipe_container.setBackgroundColor(bg)
navigationBarColor = bg
kauSwipeOnCreate {
edgeFlag = flag