mirror of
https://github.com/AdrianKuta/Expandable-RecyclerView.git
synced 2025-07-02 07:17:59 +02:00
Expandable ReyclerView module
This commit is contained in:
@ -0,0 +1,24 @@
|
||||
package com.github.adriankuta.expandable_recyclerview
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
import org.junit.Assert.*
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* See [testing documentation](http://d.android.com/tools/testing).
|
||||
*/
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class ExampleInstrumentedTest {
|
||||
@Test
|
||||
fun useAppContext() {
|
||||
// Context of the app under test.
|
||||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
assertEquals("com.github.adriankuta.expandable_recyclerview.test", appContext.packageName)
|
||||
}
|
||||
}
|
2
expandable-recyclerview/src/main/AndroidManifest.xml
Normal file
2
expandable-recyclerview/src/main/AndroidManifest.xml
Normal file
@ -0,0 +1,2 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.github.adriankuta.expandable_recyclerview" />
|
@ -0,0 +1,19 @@
|
||||
package com.github.adriankuta.expandable_recyclerview
|
||||
|
||||
import com.github.adriankuta.datastructure.tree.TreeNode
|
||||
|
||||
open class ExpandableGroup<T>(value: T) : TreeNode<T>(value) {
|
||||
|
||||
private var _isExpanded = false
|
||||
val isExpanded: Boolean
|
||||
get() = _isExpanded
|
||||
|
||||
|
||||
open fun expand() {
|
||||
_isExpanded = true
|
||||
}
|
||||
|
||||
open fun collapse() {
|
||||
_isExpanded = false
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package com.github.adriankuta.expandable_recyclerview
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
|
||||
class ExpandableRecyclerView @JvmOverloads constructor(
|
||||
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
|
||||
) : RecyclerView(context, attrs, defStyleAttr) {
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package com.github.adriankuta.expandable_recyclerview
|
||||
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
|
||||
abstract class MultilevelRecyclerViewAdapter<T, VH: RecyclerView.ViewHolder>: RecyclerView.Adapter<VH>() {
|
||||
|
||||
abstract fun getExpandableGroups(): ExpandableGroup<T>
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): VH {
|
||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
getExpandableGroups().toList()
|
||||
return getExpandableGroups().nodeCount()
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: VH, position: Int) {
|
||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
override fun getItemViewType(position: Int): Int {
|
||||
return super.getItemViewType(position)
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package com.github.adriankuta.expandable_recyclerview;
|
||||
|
||||
public class Temp {
|
||||
|
||||
public static void main(String[] args) {
|
||||
ExpandableGroup<String> group = new ExpandableGroup<>("");
|
||||
|
||||
}
|
||||
}
|
3
expandable-recyclerview/src/main/res/values/strings.xml
Normal file
3
expandable-recyclerview/src/main/res/values/strings.xml
Normal file
@ -0,0 +1,3 @@
|
||||
<resources>
|
||||
<string name="app_name">Expandable RecyclerView</string>
|
||||
</resources>
|
@ -0,0 +1,17 @@
|
||||
package com.github.adriankuta.expandable_recyclerview
|
||||
|
||||
import org.junit.Test
|
||||
|
||||
import org.junit.Assert.*
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* See [testing documentation](http://d.android.com/tools/testing).
|
||||
*/
|
||||
class ExampleUnitTest {
|
||||
@Test
|
||||
fun addition_isCorrect() {
|
||||
assertEquals(4, 2 + 2)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user