Skip to content

Commit c8b0795

Browse files
author
Uglev Andrey
committed
static binders
1 parent 234b655 commit c8b0795

12 files changed

Lines changed: 59 additions & 24 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
*.iml
22
.gradle
33
/local.properties
4+
/.idea/compiler.xml
5+
/.idea/gradle.xml
6+
/.idea/misc.xml
47
/.idea/caches
58
/.idea/libraries
69
/.idea/modules.xml

.idea/compiler.xml

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ Recycli is a Kotlin library for Android RecyclerView that simplifies the creatio
4545
apply plugin: 'com.google.devtools.ksp'
4646
4747
dependencies {
48-
implementation 'com.detmir.recycli:adapters:2.1.0'
49-
compileOnly 'com.detmir.recycli:annotations:2.1.0'
50-
ksp 'com.detmir.recycli:processors:2.1.0'
48+
implementation 'com.detmir.recycli:adapters:2.2.0'
49+
compileOnly 'com.detmir.recycli:annotations:2.2.0'
50+
ksp 'com.detmir.recycli:processors:2.2.0'
5151
}
5252
5353
```

app/src/main/java/com/detmir/kkppt3/MainActivity.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,19 @@ import android.content.Intent
44
import android.os.Bundle
55
import android.widget.Button
66
import androidx.appcompat.app.AppCompatActivity
7+
import com.detmir.recycli.adapters.RecyclerConfig
78

89
class MainActivity : AppCompatActivity() {
910

1011

1112
override fun onCreate(savedInstanceState: Bundle?) {
1213
super.onCreate(savedInstanceState)
14+
15+
RecyclerConfig.adapterBinders = mutableListOf(
16+
com.detmir.ui.RecyclerBinderImpl::class.java,
17+
com.detmir.kkppt3.RecyclerBinderImpl::class.java
18+
)
19+
RecyclerConfig.allowAssetsScan = false
1320
setContentView(R.layout.activity_main)
1421
val case0000Button = findViewById<Button>(R.id.activity_main_0000)
1522
val case0100Button = findViewById<Button>(R.id.activity_main_0100)

recycli/gradle.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ POM_NAME=Recycli
22
POM_ARTIFACT_ID=adapters
33
POM_PACKAGING=aar
44
GROUP=com.detmir.recycli
5-
VERSION_NAME=2.1.0
5+
VERSION_NAME=2.2.0
66

77
POM_DESCRIPTION=Android library for RecycleView
88
POM_INCEPTION_YEAR=2021
@@ -22,3 +22,4 @@ POM_DEVELOPER_URL=https://github.com/detmir
2222

2323
kapt.use.worker.api=true
2424
kapt.incremental.apt=true
25+

recycli/src/main/java/com/detmir/recycli/adapters/RecyclerBaseAdapter.kt

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,35 @@ open class RecyclerBaseAdapter(
2727

2828
fun warmUpBinders(context: Context) {
2929
if (!warmedUp) {
30-
val kspBinders = mutableListOf<RecyclerBinder>()
31-
for (packCamel in listAssetFiles(context)) {
32-
val pack = packCamel.replace("_", ".")
33-
try {
34-
val clazz = Class.forName("$pack.RecyclerBinderImpl")
35-
val binder = clazz.newInstance() as RecyclerBinder
36-
kspBinders.add(binder)
37-
} catch (e: Throwable) {
38-
// log here
30+
val kspBindersClasses = mutableSetOf<Class<*>>()
31+
if (RecyclerConfig.allowAssetsScan) {
32+
33+
for (packCamel in listAssetFiles(context)) {
34+
val pack = packCamel.replace("_", ".")
35+
try {
36+
val binderName = "$pack.RecyclerBinderImpl"
37+
//kspBindersClassesNames.add()
38+
val clazz = Class.forName(binderName)
39+
kspBindersClasses.add(clazz)
40+
41+
} catch (e: Throwable) {
42+
// log here
43+
}
3944
}
4045
}
4146

47+
if (RecyclerConfig.allowStaticAdaptersScan) {
48+
RecyclerConfig.adapterBinders.forEach {
49+
kspBindersClasses.add(it)
50+
}
51+
}
52+
53+
val kspBinders = mutableListOf<RecyclerBinder>()
54+
kspBindersClasses.forEach { clazz ->
55+
val binder = clazz.newInstance() as RecyclerBinder
56+
kspBinders.add(binder)
57+
}
58+
4259
var i = 1
4360
for (recyclerBinder in kspBinders) {
4461
for (entr in recyclerBinder.stateToIndexMap) {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.detmir.recycli.adapters
2+
3+
object RecyclerConfig {
4+
var adapterBinders: MutableList<Class<*>> = mutableListOf()
5+
var allowAssetsScan = true
6+
var allowStaticAdaptersScan = true
7+
}

recycliannotation/gradle.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
POM_NAME=RecycliAnnotations
22
POM_ARTIFACT_ID=annotations
33
GROUP=com.detmir.recycli
4-
VERSION_NAME=2.1.0
4+
VERSION_NAME=2.2.0
55

66
POM_DESCRIPTION=Annotations librrary for Recycli
77
POM_INCEPTION_YEAR=2021
@@ -21,3 +21,4 @@ POM_DEVELOPER_URL=https://github.com/detmir
2121

2222
kapt.use.worker.api=true
2323
kapt.incremental.apt=true
24+

0 commit comments

Comments
 (0)