mirror of
				https://github.com/AdrianKuta/Expandable-RecyclerView.git
				synced 2025-10-31 08:53:41 +01:00 
			
		
		
		
	6: Enhance demo application (#9)
* 6: Use data model instead of String. Remove databinding. * 6: Use online lib dependency * 6: Remove CircleCI
This commit is contained in:
		| @@ -1,86 +0,0 @@ | |||||||
| version: 2.1 |  | ||||||
| jobs: |  | ||||||
|   build: |  | ||||||
|     working_directory: ~/code |  | ||||||
|     docker: |  | ||||||
|       - image: circleci/android:api-29 |  | ||||||
|     environment: |  | ||||||
|       JVM_OPTS: -Xmx3200m |  | ||||||
|     steps: |  | ||||||
|       - checkout |  | ||||||
|       - restore_cache: |  | ||||||
|           key: jars-{{ checksum "build.gradle" }}-{{ checksum  "app/build.gradle" }} |  | ||||||
|       - run: |  | ||||||
|           name: Download Dependencies |  | ||||||
|           command: ./gradlew androidDependencies |  | ||||||
|       - save_cache: |  | ||||||
|           paths: |  | ||||||
|             - ~/.gradle |  | ||||||
|           key: jars-{{ checksum "build.gradle" }}-{{ checksum  "app/build.gradle" }} |  | ||||||
|  |  | ||||||
|   tests: |  | ||||||
|     working_directory: ~/code |  | ||||||
|     docker: |  | ||||||
|       - image: circleci/android:api-29 |  | ||||||
|     environment: |  | ||||||
|       JVM_OPTS: -Xmx3200m |  | ||||||
|     steps: |  | ||||||
|       - checkout |  | ||||||
|       - restore_cache: |  | ||||||
|           key: jars-{{ checksum "build.gradle" }}-{{ checksum  "app/build.gradle" }} |  | ||||||
|       - store_artifacts: |  | ||||||
|           path: app/build/reports |  | ||||||
|           destination: reports |  | ||||||
|       - run: |  | ||||||
|           name: Run Lint Test |  | ||||||
|           command: ./gradlew lint |  | ||||||
|       - run: |  | ||||||
|           name: Run Tests |  | ||||||
|           command: ./gradlew lint test |  | ||||||
|       - store_artifacts: |  | ||||||
|           path: app/build/reports |  | ||||||
|           destination: reports |  | ||||||
|       - store_test_results: |  | ||||||
|           path: app/build/test-results |  | ||||||
|  |  | ||||||
|   deploy: |  | ||||||
|     working_directory: ~/code |  | ||||||
|     docker: |  | ||||||
|       - image: circleci/android:api-29 |  | ||||||
|     environment: |  | ||||||
|       JVM_OPTS: -Xmx3200m |  | ||||||
|     steps: |  | ||||||
|       - checkout |  | ||||||
|       - restore_cache: |  | ||||||
|           key: jars-{{ checksum "build.gradle" }}-{{ checksum  "app/build.gradle" }} |  | ||||||
|       - run: |  | ||||||
|           name: Build Library |  | ||||||
|           command: ./gradlew :expandable-recyclerview:assembleRelease |  | ||||||
|       - run: |  | ||||||
|           name: Export key |  | ||||||
|           command: | |  | ||||||
|             mkdir expandable-recyclerview/maven |  | ||||||
|             echo ${GPG_KEY_CONTENTS} | base64 -d --ignore-garbage > expandable-recyclerview/maven/secret.gpg |  | ||||||
|       - run: |  | ||||||
|           name: Staging |  | ||||||
|           command: ./gradlew :expandable-recyclerview:publishReleasePublicationToSonatypeRepository |  | ||||||
|       - run: |  | ||||||
|           name: Release Library |  | ||||||
|           command: ./gradlew closeAndReleaseRepository |  | ||||||
|  |  | ||||||
| workflows: |  | ||||||
|   version: 2.1 |  | ||||||
|   build-and-deploy: |  | ||||||
|     jobs: |  | ||||||
|       - build: |  | ||||||
|           filters:  # required since `deploy` has tag filters AND requires `build` |  | ||||||
|             tags: |  | ||||||
|               only: /.*/ |  | ||||||
|       - deploy: |  | ||||||
|           requires: |  | ||||||
|             - build |  | ||||||
|           filters: |  | ||||||
|             tags: |  | ||||||
|               only: /v[0-9]{1,3}\.[0-9]{1,3}\.?[0-9]{0,3}.*/ |  | ||||||
|             branches: |  | ||||||
|               ignore: /.*/ |  | ||||||
| @@ -23,9 +23,6 @@ android { | |||||||
|     buildFeatures { |     buildFeatures { | ||||||
|         viewBinding true |         viewBinding true | ||||||
|     } |     } | ||||||
|     dataBinding { |  | ||||||
|         enabled = true |  | ||||||
|     } |  | ||||||
| } | } | ||||||
|  |  | ||||||
| dependencies { | dependencies { | ||||||
| @@ -34,8 +31,7 @@ dependencies { | |||||||
|     implementation 'androidx.appcompat:appcompat:1.5.1' |     implementation 'androidx.appcompat:appcompat:1.5.1' | ||||||
|     implementation 'androidx.core:core-ktx:1.9.0' |     implementation 'androidx.core:core-ktx:1.9.0' | ||||||
|     implementation 'androidx.constraintlayout:constraintlayout:2.1.4' |     implementation 'androidx.constraintlayout:constraintlayout:2.1.4' | ||||||
|  |     implementation 'com.github.adriankuta:expandable-recyclerView:2.1.0' | ||||||
|     implementation project(path: ':expandable-recyclerview') |  | ||||||
|  |  | ||||||
|     testImplementation 'junit:junit:4.13.2' |     testImplementation 'junit:junit:4.13.2' | ||||||
|     androidTestImplementation 'androidx.test.ext:junit:1.1.4' |     androidTestImplementation 'androidx.test.ext:junit:1.1.4' | ||||||
|   | |||||||
| @@ -3,6 +3,7 @@ package com.github.adriankuta | |||||||
| import android.view.LayoutInflater | import android.view.LayoutInflater | ||||||
| import android.view.View | import android.view.View | ||||||
| import android.view.ViewGroup | import android.view.ViewGroup | ||||||
|  | import androidx.core.view.isGone | ||||||
| import androidx.recyclerview.widget.RecyclerView | import androidx.recyclerview.widget.RecyclerView | ||||||
| import com.github.adriankuta.databinding.ItemLevel1Binding | import com.github.adriankuta.databinding.ItemLevel1Binding | ||||||
| import com.github.adriankuta.databinding.ItemLevel2Binding | import com.github.adriankuta.databinding.ItemLevel2Binding | ||||||
| @@ -12,16 +13,16 @@ import com.github.adriankuta.expandable_recyclerview.ExpandableTreeNode | |||||||
| import com.github.adriankuta.expandable_recyclerview.expandableTree | import com.github.adriankuta.expandable_recyclerview.expandableTree | ||||||
|  |  | ||||||
| class ExpandableAdapter : | class ExpandableAdapter : | ||||||
|     ExpandableRecyclerViewAdapter<String, ExpandableAdapter.ExpandableViewHolder>() { |     ExpandableRecyclerViewAdapter<Region, ExpandableAdapter.ExpandableViewHolder>() { | ||||||
|  |  | ||||||
|     private var tree: ExpandableTreeNode<String>? = null |     private var tree: ExpandableTreeNode<Region>? = null | ||||||
|  |  | ||||||
|     fun setTree(tree: ExpandableTreeNode<String>) { |     fun setTree(tree: ExpandableTreeNode<Region>) { | ||||||
|         this.tree = tree |         this.tree = tree | ||||||
|         notifyDataSetChanged() |         notifyDataSetChanged() | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     override fun getTreeNodes(): ExpandableTreeNode<String> = tree ?: expandableTree("") |     override fun getTreeNodes(): ExpandableTreeNode<Region> = tree ?: expandableTree(Region("")) | ||||||
|  |  | ||||||
|     override fun onCreateViewHolder(parent: ViewGroup, nestLevel: Int): ExpandableViewHolder { |     override fun onCreateViewHolder(parent: ViewGroup, nestLevel: Int): ExpandableViewHolder { | ||||||
|         return when (nestLevel) { |         return when (nestLevel) { | ||||||
| @@ -34,7 +35,7 @@ class ExpandableAdapter : | |||||||
|  |  | ||||||
|     override fun onBindViewHolder( |     override fun onBindViewHolder( | ||||||
|         holder: ExpandableViewHolder, |         holder: ExpandableViewHolder, | ||||||
|         treeNode: ExpandableTreeNode<String>, |         treeNode: ExpandableTreeNode<Region>, | ||||||
|         nestLevel: Int |         nestLevel: Int | ||||||
|     ) { |     ) { | ||||||
|         holder.bind(treeNode) { |         holder.bind(treeNode) { | ||||||
| @@ -46,41 +47,65 @@ class ExpandableAdapter : | |||||||
|  |  | ||||||
|         class Level1(private val binding: ItemLevel1Binding) : ExpandableViewHolder(binding.root) { |         class Level1(private val binding: ItemLevel1Binding) : ExpandableViewHolder(binding.root) { | ||||||
|             override fun bind( |             override fun bind( | ||||||
|                 node: ExpandableTreeNode<String>, |                 node: ExpandableTreeNode<Region>, | ||||||
|                 onClickListener: ((ExpandableTreeNode<String>) -> Unit)? |                 onClickListener: ((ExpandableTreeNode<Region>) -> Unit)? | ||||||
|             ) { |             ) { | ||||||
|                 binding.node = node |                 binding.apply { | ||||||
|                 binding.root.setOnClickListener { onClickListener?.invoke(node) } |                     root.setOnClickListener { onClickListener?.invoke(node) } | ||||||
|                 binding.executePendingBindings() |                     textView.text = node.value.name | ||||||
|  |                     expandIcon.isGone = node.children.isEmpty() | ||||||
|  |                     expandIcon.setImageResource( | ||||||
|  |                         if (node.expanded) | ||||||
|  |                             R.drawable.ic_expand_less_black_24dp | ||||||
|  |                         else | ||||||
|  |                             R.drawable.ic_expand_more_black_24dp | ||||||
|  |                     ) | ||||||
|  |                 } | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         class Level2(private val binding: ItemLevel2Binding) : ExpandableViewHolder(binding.root) { |         class Level2(private val binding: ItemLevel2Binding) : ExpandableViewHolder(binding.root) { | ||||||
|             override fun bind( |             override fun bind( | ||||||
|                 node: ExpandableTreeNode<String>, |                 node: ExpandableTreeNode<Region>, | ||||||
|                 onClickListener: ((ExpandableTreeNode<String>) -> Unit)? |                 onClickListener: ((ExpandableTreeNode<Region>) -> Unit)? | ||||||
|             ) { |             ) { | ||||||
|                 binding.node = node |                 binding.apply { | ||||||
|                 binding.root.setOnClickListener { onClickListener?.invoke(node) } |                     root.setOnClickListener { onClickListener?.invoke(node) } | ||||||
|                 binding.executePendingBindings() |                     textView.text = node.value.name | ||||||
|  |                     expandIcon.isGone = node.children.isEmpty() | ||||||
|  |                     expandIcon.setImageResource( | ||||||
|  |                         if (node.expanded) | ||||||
|  |                             R.drawable.ic_expand_less_black_24dp | ||||||
|  |                         else | ||||||
|  |                             R.drawable.ic_expand_more_black_24dp | ||||||
|  |                     ) | ||||||
|  |                 } | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         class Level3(private val binding: ItemLevel3Binding) : ExpandableViewHolder(binding.root) { |         class Level3(private val binding: ItemLevel3Binding) : ExpandableViewHolder(binding.root) { | ||||||
|             override fun bind( |             override fun bind( | ||||||
|                 node: ExpandableTreeNode<String>, |                 node: ExpandableTreeNode<Region>, | ||||||
|                 onClickListener: ((ExpandableTreeNode<String>) -> Unit)? |                 onClickListener: ((ExpandableTreeNode<Region>) -> Unit)? | ||||||
|             ) { |             ) { | ||||||
|                 binding.node = node |                 binding.apply { | ||||||
|                 binding.root.setOnClickListener { onClickListener?.invoke(node) } |                     root.setOnClickListener { onClickListener?.invoke(node) } | ||||||
|                 binding.executePendingBindings() |                     textView.text = node.value.name | ||||||
|  |                     expandIcon.isGone = node.children.isEmpty() | ||||||
|  |                     expandIcon.setImageResource( | ||||||
|  |                         if (node.expanded) | ||||||
|  |                             R.drawable.ic_expand_less_black_24dp | ||||||
|  |                         else | ||||||
|  |                             R.drawable.ic_expand_more_black_24dp | ||||||
|  |                     ) | ||||||
|  |                 } | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |  | ||||||
|         abstract fun bind( |         abstract fun bind( | ||||||
|             node: ExpandableTreeNode<String>, |             node: ExpandableTreeNode<Region>, | ||||||
|             onClickListener: ((ExpandableTreeNode<String>) -> Unit)? = null |             onClickListener: ((ExpandableTreeNode<Region>) -> Unit)? = null | ||||||
|         ) |         ) | ||||||
|  |  | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -9,23 +9,24 @@ class MainActivity : AppCompatActivity() { | |||||||
|  |  | ||||||
|     private lateinit var binding: ActivityMainBinding |     private lateinit var binding: ActivityMainBinding | ||||||
|  |  | ||||||
|  |  | ||||||
|     override fun onCreate(savedInstanceState: Bundle?) { |     override fun onCreate(savedInstanceState: Bundle?) { | ||||||
|         super.onCreate(savedInstanceState) |         super.onCreate(savedInstanceState) | ||||||
|         binding = ActivityMainBinding.inflate(layoutInflater) |         binding = ActivityMainBinding.inflate(layoutInflater) | ||||||
|         setContentView(binding.root) |         setContentView(binding.root) | ||||||
|  |  | ||||||
|         val tree = expandableTree("World") { |         val tree = expandableTree(Region("World")) { | ||||||
|             child("North America") { |             child(Region("North America")) { | ||||||
|                 child("USA") |                 child(Region("USA")) | ||||||
|             } |             } | ||||||
|             child("Europe") { |             child(Region("Europe")) { | ||||||
|                 child("Poland") { |                 child(Region("Poland")) { | ||||||
|                     child("Warsaw") |                     child(Region("Warsaw")) | ||||||
|                 } |                 } | ||||||
|                 child("Germany") |                 child(Region("Germany")) | ||||||
|             } |             } | ||||||
|             child("Asia") { |             child(Region("Asia")) { | ||||||
|                 child("China") |                 child(Region("China")) | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										3
									
								
								app/src/main/java/com/github/adriankuta/Region.kt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								app/src/main/java/com/github/adriankuta/Region.kt
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,3 @@ | |||||||
|  | package com.github.adriankuta | ||||||
|  |  | ||||||
|  | data class Region(val name: String) | ||||||
| @@ -1,44 +1,31 @@ | |||||||
| <?xml version="1.0" encoding="utf-8"?> | <?xml version="1.0" encoding="utf-8"?> | ||||||
| <layout> | <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||||||
|  |     xmlns:app="http://schemas.android.com/apk/res-auto" | ||||||
|  |     xmlns:tools="http://schemas.android.com/tools" | ||||||
|  |     android:layout_width="match_parent" | ||||||
|  |     android:layout_height="wrap_content"> | ||||||
|  |  | ||||||
|     <data> |     <ImageView | ||||||
|  |         android:id="@+id/expand_icon" | ||||||
|  |         android:layout_width="24dp" | ||||||
|  |         android:layout_height="0dp" | ||||||
|  |         android:scaleType="centerInside" | ||||||
|  |         android:visibility="gone" | ||||||
|  |         app:layout_constraintBottom_toBottomOf="@id/textView" | ||||||
|  |         app:layout_constraintStart_toStartOf="parent" | ||||||
|  |         app:layout_constraintTop_toTopOf="@id/textView" | ||||||
|  |         tools:src="@drawable/ic_expand_less_black_24dp" | ||||||
|  |         tools:visibility="visible" /> | ||||||
|  |  | ||||||
|         <variable |     <TextView | ||||||
|             name="node" |         android:id="@+id/textView" | ||||||
|             type="com.github.adriankuta.expandable_recyclerview.ExpandableTreeNode<String>" /> |         android:layout_width="0dp" | ||||||
|  |  | ||||||
|         <import type="android.view.View" /> |  | ||||||
|     </data> |  | ||||||
|  |  | ||||||
|     <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" |  | ||||||
|         xmlns:app="http://schemas.android.com/apk/res-auto" |  | ||||||
|         xmlns:tools="http://schemas.android.com/tools" |  | ||||||
|         android:layout_width="match_parent" |  | ||||||
|         android:layout_height="wrap_content" |         android:layout_height="wrap_content" | ||||||
|         tools:viewBindingIgnore="true"> |         android:padding="8dp" | ||||||
|  |         android:text="@{node.value}" | ||||||
|         <ImageView |         app:layout_constraintBottom_toBottomOf="parent" | ||||||
|             android:id="@+id/expand_icon" |         app:layout_constraintEnd_toEndOf="parent" | ||||||
|             android:layout_width="24dp" |         app:layout_constraintStart_toEndOf="@id/expand_icon" | ||||||
|             android:layout_height="0dp" |         app:layout_constraintTop_toTopOf="parent" | ||||||
|             android:scaleType="centerInside" |         tools:text="@tools:sample/full_names" /> | ||||||
|             android:src="@{node.expanded ? @drawable/ic_expand_more_black_24dp : @drawable/ic_expand_less_black_24dp}" | </androidx.constraintlayout.widget.ConstraintLayout> | ||||||
|             android:visibility="@{node.children.empty ? View.GONE : View.VISIBLE}" |  | ||||||
|             app:layout_constraintBottom_toBottomOf="@id/textView" |  | ||||||
|             app:layout_constraintStart_toStartOf="parent" |  | ||||||
|             app:layout_constraintTop_toTopOf="@id/textView" |  | ||||||
|             tools:src="@drawable/ic_expand_less_black_24dp" /> |  | ||||||
|  |  | ||||||
|         <TextView |  | ||||||
|             android:id="@+id/textView" |  | ||||||
|             android:layout_width="0dp" |  | ||||||
|             android:layout_height="wrap_content" |  | ||||||
|             android:padding="8dp" |  | ||||||
|             android:text="@{node.value}" |  | ||||||
|             app:layout_constraintBottom_toBottomOf="parent" |  | ||||||
|             app:layout_constraintEnd_toEndOf="parent" |  | ||||||
|             app:layout_constraintStart_toEndOf="@id/expand_icon" |  | ||||||
|             app:layout_constraintTop_toTopOf="parent" |  | ||||||
|             tools:text="@tools:sample/full_names" /> |  | ||||||
|     </androidx.constraintlayout.widget.ConstraintLayout> |  | ||||||
| </layout> |  | ||||||
|   | |||||||
| @@ -1,46 +1,33 @@ | |||||||
| <?xml version="1.0" encoding="utf-8"?> | <?xml version="1.0" encoding="utf-8"?> | ||||||
| <layout> | <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||||||
|  |     xmlns:app="http://schemas.android.com/apk/res-auto" | ||||||
|  |     xmlns:tools="http://schemas.android.com/tools" | ||||||
|  |     android:layout_width="match_parent" | ||||||
|  |     android:layout_height="wrap_content"> | ||||||
|  |  | ||||||
|     <data> |     <ImageView | ||||||
|  |         android:id="@+id/expand_icon" | ||||||
|  |         android:layout_width="24dp" | ||||||
|  |         android:layout_height="0dp" | ||||||
|  |         android:layout_marginStart="24dp" | ||||||
|  |         android:scaleType="centerInside" | ||||||
|  |         android:visibility="gone" | ||||||
|  |         app:layout_constraintBottom_toBottomOf="@id/textView" | ||||||
|  |         app:layout_constraintStart_toStartOf="parent" | ||||||
|  |         app:layout_constraintTop_toTopOf="@id/textView" | ||||||
|  |         tools:src="@drawable/ic_expand_less_black_24dp" | ||||||
|  |         tools:visibility="visible" /> | ||||||
|  |  | ||||||
|         <variable |     <TextView | ||||||
|             name="node" |         android:id="@+id/textView" | ||||||
|             type="com.github.adriankuta.expandable_recyclerview.ExpandableTreeNode<String>" /> |         android:layout_width="0dp" | ||||||
|  |  | ||||||
|         <import type="android.view.View" /> |  | ||||||
|     </data> |  | ||||||
|  |  | ||||||
|     <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" |  | ||||||
|         xmlns:app="http://schemas.android.com/apk/res-auto" |  | ||||||
|         xmlns:tools="http://schemas.android.com/tools" |  | ||||||
|         android:layout_width="match_parent" |  | ||||||
|         android:layout_height="wrap_content" |         android:layout_height="wrap_content" | ||||||
|         tools:viewBindingIgnore="true"> |         android:padding="8dp" | ||||||
|  |         android:text="@{node.value}" | ||||||
|         <ImageView |         app:layout_constraintBottom_toBottomOf="parent" | ||||||
|             android:id="@+id/expand_icon" |         app:layout_constraintEnd_toEndOf="parent" | ||||||
|             android:layout_width="24dp" |         app:layout_constraintStart_toEndOf="@id/expand_icon" | ||||||
|             android:layout_height="0dp" |         app:layout_constraintTop_toTopOf="parent" | ||||||
|             android:layout_marginStart="24dp" |         app:layout_goneMarginStart="48dp" | ||||||
|             android:scaleType="centerInside" |         tools:text="@tools:sample/full_names" /> | ||||||
|             android:src="@{node.expanded ? @drawable/ic_expand_more_black_24dp : @drawable/ic_expand_less_black_24dp}" | </androidx.constraintlayout.widget.ConstraintLayout> | ||||||
|             android:visibility="@{node.children.empty ? View.GONE : View.VISIBLE}" |  | ||||||
|             app:layout_constraintBottom_toBottomOf="@id/textView" |  | ||||||
|             app:layout_constraintStart_toStartOf="parent" |  | ||||||
|             app:layout_constraintTop_toTopOf="@id/textView" |  | ||||||
|             tools:src="@drawable/ic_expand_less_black_24dp" /> |  | ||||||
|  |  | ||||||
|         <TextView |  | ||||||
|             android:id="@+id/textView" |  | ||||||
|             android:layout_width="0dp" |  | ||||||
|             android:layout_height="wrap_content" |  | ||||||
|             android:padding="8dp" |  | ||||||
|             android:text="@{node.value}" |  | ||||||
|             app:layout_constraintBottom_toBottomOf="parent" |  | ||||||
|             app:layout_constraintEnd_toEndOf="parent" |  | ||||||
|             app:layout_constraintStart_toEndOf="@id/expand_icon" |  | ||||||
|             app:layout_constraintTop_toTopOf="parent" |  | ||||||
|             app:layout_goneMarginStart="48dp" |  | ||||||
|             tools:text="@tools:sample/full_names" /> |  | ||||||
|     </androidx.constraintlayout.widget.ConstraintLayout> |  | ||||||
| </layout> |  | ||||||
|   | |||||||
| @@ -1,46 +1,33 @@ | |||||||
| <?xml version="1.0" encoding="utf-8"?> | <?xml version="1.0" encoding="utf-8"?> | ||||||
| <layout> | <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||||||
|  |     xmlns:app="http://schemas.android.com/apk/res-auto" | ||||||
|  |     xmlns:tools="http://schemas.android.com/tools" | ||||||
|  |     android:layout_width="match_parent" | ||||||
|  |     android:layout_height="wrap_content"> | ||||||
|  |  | ||||||
|     <data> |     <ImageView | ||||||
|  |         android:id="@+id/expand_icon" | ||||||
|  |         android:layout_width="24dp" | ||||||
|  |         android:layout_height="0dp" | ||||||
|  |         android:layout_marginStart="48dp" | ||||||
|  |         android:scaleType="centerInside" | ||||||
|  |         android:visibility="gone" | ||||||
|  |         app:layout_constraintBottom_toBottomOf="@id/textView" | ||||||
|  |         app:layout_constraintStart_toStartOf="parent" | ||||||
|  |         app:layout_constraintTop_toTopOf="@id/textView" | ||||||
|  |         tools:src="@drawable/ic_expand_less_black_24dp" | ||||||
|  |         tools:visibility="visible"/> | ||||||
|  |  | ||||||
|         <variable |     <TextView | ||||||
|             name="node" |         android:id="@+id/textView" | ||||||
|             type="com.github.adriankuta.expandable_recyclerview.ExpandableTreeNode<String>" /> |         android:layout_width="0dp" | ||||||
|  |  | ||||||
|         <import type="android.view.View" /> |  | ||||||
|     </data> |  | ||||||
|  |  | ||||||
|     <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" |  | ||||||
|         xmlns:app="http://schemas.android.com/apk/res-auto" |  | ||||||
|         xmlns:tools="http://schemas.android.com/tools" |  | ||||||
|         android:layout_width="match_parent" |  | ||||||
|         android:layout_height="wrap_content" |         android:layout_height="wrap_content" | ||||||
|         tools:viewBindingIgnore="true"> |         android:padding="8dp" | ||||||
|  |         android:text="@{node.value}" | ||||||
|         <ImageView |         app:layout_constraintBottom_toBottomOf="parent" | ||||||
|             android:id="@+id/expand_icon" |         app:layout_constraintEnd_toEndOf="parent" | ||||||
|             android:layout_width="24dp" |         app:layout_constraintStart_toEndOf="@id/expand_icon" | ||||||
|             android:layout_height="0dp" |         app:layout_constraintTop_toTopOf="parent" | ||||||
|             android:layout_marginStart="48dp" |         app:layout_goneMarginStart="96dp" | ||||||
|             android:scaleType="centerInside" |         tools:text="@tools:sample/full_names" /> | ||||||
|             android:src="@{node.expanded ? @drawable/ic_expand_more_black_24dp : @drawable/ic_expand_less_black_24dp}" | </androidx.constraintlayout.widget.ConstraintLayout> | ||||||
|             android:visibility="@{node.children.empty ? View.GONE : View.VISIBLE}" |  | ||||||
|             app:layout_constraintBottom_toBottomOf="@id/textView" |  | ||||||
|             app:layout_constraintStart_toStartOf="parent" |  | ||||||
|             app:layout_constraintTop_toTopOf="@id/textView" |  | ||||||
|             tools:src="@drawable/ic_expand_less_black_24dp" /> |  | ||||||
|  |  | ||||||
|         <TextView |  | ||||||
|             android:id="@+id/textView" |  | ||||||
|             android:layout_width="0dp" |  | ||||||
|             android:layout_height="wrap_content" |  | ||||||
|             android:padding="8dp" |  | ||||||
|             android:text="@{node.value}" |  | ||||||
|             app:layout_constraintBottom_toBottomOf="parent" |  | ||||||
|             app:layout_constraintEnd_toEndOf="parent" |  | ||||||
|             app:layout_constraintStart_toEndOf="@id/expand_icon" |  | ||||||
|             app:layout_constraintTop_toTopOf="parent" |  | ||||||
|             app:layout_goneMarginStart="96dp" |  | ||||||
|             tools:text="@tools:sample/full_names" /> |  | ||||||
|     </androidx.constraintlayout.widget.ConstraintLayout> |  | ||||||
| </layout> |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Adrian Kuta
						Adrian Kuta