node for each
39 | def deps = configurations.compile.allDependencies + configurations.implementation.allDependencies
40 | deps.each {
41 | dependencies.add("implementation", it)
42 | }
43 |
44 | }
45 | }
46 | }
--------------------------------------------------------------------------------
/library-databinding/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/library-databinding/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'maven-publish'
3 |
4 | archivesBaseName = 'groupie-databinding'
5 |
6 | android {
7 | compileSdkVersion rootProject.sdkVersion
8 |
9 | defaultConfig {
10 | minSdkVersion rootProject.minimumSdkVersion
11 | targetSdkVersion rootProject.sdkVersion
12 | versionCode 20
13 | versionName "1.0"
14 | }
15 | signingConfigs {
16 | release {
17 | }
18 | }
19 | buildTypes {
20 | release {
21 | signingConfig signingConfigs.release
22 | minifyEnabled false
23 | }
24 | }
25 |
26 | lintOptions {
27 | abortOnError false
28 | }
29 | }
30 |
31 | dependencies {
32 | implementation project(':library')
33 | implementation "androidx.recyclerview:recyclerview:1.2.1"
34 | compileOnly("androidx.databinding:databinding-runtime:$databinding_version") {
35 | transitive = false
36 | }
37 | compileOnly("androidx.databinding:databinding-common:$databinding_version") {
38 | transitive = false
39 | }
40 | compileOnly("androidx.databinding:viewbinding:$databinding_version") {
41 | transitive = false
42 | }
43 | implementation("androidx.annotation:annotation:1.3.0")
44 | }
45 |
46 |
47 | group = "com.github.lisawray.groupie"
48 | version = "2.10.1"
49 |
50 | task javadoc(type: Javadoc) {
51 | configurations.implementation.canBeResolved(true)
52 | configurations.api.canBeResolved(true)
53 |
54 | failOnError false
55 |
56 | source = android.sourceSets.main.java.srcDirs
57 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
58 | //destinationDir = file("../javadoc/")
59 | classpath += configurations.api
60 | }
61 |
62 | task sourcesJar(type: Jar) {
63 | from android.sourceSets.main.java.srcDirs
64 | archiveClassifier = "sources"
65 | }
66 |
67 | task javadocJar(type: Jar, dependsOn: javadoc) {
68 | classifier = 'javadoc'
69 | from javadoc.destinationDir
70 | }
71 |
72 | artifacts {
73 | archives sourcesJar
74 | archives javadocJar
75 | }
76 |
77 | // Because the components are created only during the afterEvaluate phase, you must
78 | // configure your publications using the afterEvaluate() lifecycle method.
79 | afterEvaluate {
80 | publishing {
81 | publications {
82 | // Creates a Maven publication called "release".
83 | release(MavenPublication) {
84 | // Applies the component for the release build variant.
85 | from components.release
86 | artifact(sourcesJar)
87 |
88 | // You can then customize attributes of the publication as shown below.
89 | groupId = 'com.github.lisawray.groupie'
90 | artifactId = 'groupie-databinding'
91 | version = '2.10.1'
92 |
93 | pom.withXml {
94 | def dependenciesNode = (asNode().get("dependencies") as groovy.util.NodeList).get(0) as groovy.util.Node
95 | def configurationNames = ["implementation", "api"]
96 |
97 | configurationNames.forEach { configurationName ->
98 | configurations[configurationName].allDependencies.forEach {
99 | if (it.group != null && it.version != "unspecified") {
100 | def dependencyNode = dependenciesNode.appendNode("dependency")
101 | dependencyNode.appendNode("groupId", it.group)
102 | dependencyNode.appendNode("artifactId", it.name)
103 | dependencyNode.appendNode("version", it.version)
104 | // dependencyNode.appendNode("scope", configurationName)
105 | }
106 | }
107 | }
108 | }
109 | }
110 | }
111 | }
112 | }
113 |
114 |
115 |
116 |
--------------------------------------------------------------------------------
/library-databinding/gradle.properties:
--------------------------------------------------------------------------------
1 | POM_NAME=groupie-databinding
2 | POM_DESCRIPTION=Library to help with complex RecyclerViews
3 | POM_BINTRAY_NAME=groupie-databinding
4 | POM_ARTIFACT_ID=groupie-databinding
5 | POM_PACKAGING=aar
6 | POM_VERSION=2.10.1
--------------------------------------------------------------------------------
/library-databinding/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/library-databinding/src/main/java/com/xwray/groupie/databinding/BindableItem.java:
--------------------------------------------------------------------------------
1 | package com.xwray.groupie.databinding;
2 |
3 | import androidx.databinding.DataBindingUtil;
4 | import androidx.databinding.ViewDataBinding;
5 | import androidx.annotation.CallSuper;
6 | import androidx.annotation.NonNull;
7 | import android.view.View;
8 |
9 | import com.xwray.groupie.Item;
10 | import com.xwray.groupie.OnItemClickListener;
11 | import com.xwray.groupie.OnItemLongClickListener;
12 |
13 | import java.util.List;
14 |
15 | /**
16 | * The base unit of content for a GroupAdapter.
17 | *
18 | * Because an Item is a Group of size one, you don't need to use Groups directly if you don't want;
19 | * simply mix and match Items and add directly to the adapter.
20 | *
21 | * If you want to use Groups, because Item extends Group, you can mix and match adding Items and
22 | * other Groups directly to the adapter.
23 | *
24 | * @param The ViewDataBinding subclass associated with this Item.
25 | */
26 | public abstract class BindableItem extends Item> {
27 |
28 | public BindableItem() {
29 | super();
30 | }
31 |
32 | protected BindableItem(long id) {
33 | super(id);
34 | }
35 |
36 | @NonNull
37 | @Override
38 | public GroupieViewHolder createViewHolder(@NonNull View itemView) {
39 | T viewDataBinding = DataBindingUtil.bind(itemView);
40 | return new GroupieViewHolder<>(viewDataBinding);
41 | }
42 |
43 | /**
44 | * Perform any actions required to set up the view for display.
45 | *
46 | * @param viewHolder The viewHolder to bind
47 | * @param position The adapter position
48 | * @param payloads Any payloads (this list may be empty)
49 | * @param onItemClickListener An optional adapter-level click listener
50 | * @param onItemLongClickListener An optional adapter-level long click listener
51 | */
52 | @CallSuper
53 | @Override
54 | public void bind(@NonNull GroupieViewHolder viewHolder, int position, @NonNull List