diff --git a/expandable-recyclerview/.gitignore b/expandable-recyclerview/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/expandable-recyclerview/.gitignore @@ -0,0 +1 @@ +/build diff --git a/expandable-recyclerview/build.gradle b/expandable-recyclerview/build.gradle new file mode 100644 index 0000000..2720554 --- /dev/null +++ b/expandable-recyclerview/build.gradle @@ -0,0 +1,51 @@ +apply plugin: 'com.android.library' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +afterEvaluate { + generateReleaseBuildConfig.enabled = false +} + +android { + compileSdkVersion 29 + buildToolsVersion "29.0.2" + + + defaultConfig { + minSdkVersion 23 + targetSdkVersion 29 + versionCode 1 + versionName "0.0.1-alpha01" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + consumerProguardFiles 'consumer-rules.pro' + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + +} + +dependencies { + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.1.0' + implementation 'androidx.core:core-ktx:1.1.0' + implementation "androidx.recyclerview:recyclerview:1.1.0" + implementation "com.github.adriankuta:tree-structure:1.1.0" + + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' +} + +ext { + PUBLISH_GROUP_ID = 'com.github.adriankuta' + PUBLISH_ARTIFACT_ID = 'expandable-recyclerView' + PUBLISH_VERSION = android.defaultConfig.versionName +} + +apply from: "${rootProject.projectDir}/scripts/publish-mavencentral.gradle" diff --git a/expandable-recyclerview/consumer-rules.pro b/expandable-recyclerview/consumer-rules.pro new file mode 100644 index 0000000..e69de29 diff --git a/expandable-recyclerview/proguard-rules.pro b/expandable-recyclerview/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/expandable-recyclerview/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/expandable-recyclerview/src/androidTest/java/com/github/adriankuta/expandable_recyclerview/ExampleInstrumentedTest.kt b/expandable-recyclerview/src/androidTest/java/com/github/adriankuta/expandable_recyclerview/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..77d99f3 --- /dev/null +++ b/expandable-recyclerview/src/androidTest/java/com/github/adriankuta/expandable_recyclerview/ExampleInstrumentedTest.kt @@ -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) + } +} diff --git a/expandable-recyclerview/src/main/AndroidManifest.xml b/expandable-recyclerview/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7a24aac --- /dev/null +++ b/expandable-recyclerview/src/main/AndroidManifest.xml @@ -0,0 +1,2 @@ + diff --git a/expandable-recyclerview/src/main/java/com/github/adriankuta/expandable_recyclerview/ExpandableGroup.kt b/expandable-recyclerview/src/main/java/com/github/adriankuta/expandable_recyclerview/ExpandableGroup.kt new file mode 100644 index 0000000..2868799 --- /dev/null +++ b/expandable-recyclerview/src/main/java/com/github/adriankuta/expandable_recyclerview/ExpandableGroup.kt @@ -0,0 +1,19 @@ +package com.github.adriankuta.expandable_recyclerview + +import com.github.adriankuta.datastructure.tree.TreeNode + +open class ExpandableGroup(value: T) : TreeNode(value) { + + private var _isExpanded = false + val isExpanded: Boolean + get() = _isExpanded + + + open fun expand() { + _isExpanded = true + } + + open fun collapse() { + _isExpanded = false + } +} \ No newline at end of file diff --git a/expandable-recyclerview/src/main/java/com/github/adriankuta/expandable_recyclerview/ExpandableRecyclerView.kt b/expandable-recyclerview/src/main/java/com/github/adriankuta/expandable_recyclerview/ExpandableRecyclerView.kt new file mode 100644 index 0000000..1d58455 --- /dev/null +++ b/expandable-recyclerview/src/main/java/com/github/adriankuta/expandable_recyclerview/ExpandableRecyclerView.kt @@ -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) { + + +} \ No newline at end of file diff --git a/expandable-recyclerview/src/main/java/com/github/adriankuta/expandable_recyclerview/MultilevelRecyclerViewAdapter.kt b/expandable-recyclerview/src/main/java/com/github/adriankuta/expandable_recyclerview/MultilevelRecyclerViewAdapter.kt new file mode 100644 index 0000000..db89541 --- /dev/null +++ b/expandable-recyclerview/src/main/java/com/github/adriankuta/expandable_recyclerview/MultilevelRecyclerViewAdapter.kt @@ -0,0 +1,26 @@ +package com.github.adriankuta.expandable_recyclerview + +import android.view.ViewGroup +import androidx.recyclerview.widget.RecyclerView + +abstract class MultilevelRecyclerViewAdapter: RecyclerView.Adapter() { + + abstract fun getExpandableGroups(): ExpandableGroup + + 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) + } +} \ No newline at end of file diff --git a/expandable-recyclerview/src/main/java/com/github/adriankuta/expandable_recyclerview/Temp.java b/expandable-recyclerview/src/main/java/com/github/adriankuta/expandable_recyclerview/Temp.java new file mode 100644 index 0000000..b37f623 --- /dev/null +++ b/expandable-recyclerview/src/main/java/com/github/adriankuta/expandable_recyclerview/Temp.java @@ -0,0 +1,9 @@ +package com.github.adriankuta.expandable_recyclerview; + +public class Temp { + + public static void main(String[] args) { + ExpandableGroup group = new ExpandableGroup<>(""); + + } +} diff --git a/expandable-recyclerview/src/main/res/values/strings.xml b/expandable-recyclerview/src/main/res/values/strings.xml new file mode 100644 index 0000000..ab1f7fe --- /dev/null +++ b/expandable-recyclerview/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + Expandable RecyclerView + diff --git a/expandable-recyclerview/src/test/java/com/github/adriankuta/expandable_recyclerview/ExampleUnitTest.kt b/expandable-recyclerview/src/test/java/com/github/adriankuta/expandable_recyclerview/ExampleUnitTest.kt new file mode 100644 index 0000000..a4b6b0f --- /dev/null +++ b/expandable-recyclerview/src/test/java/com/github/adriankuta/expandable_recyclerview/ExampleUnitTest.kt @@ -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) + } +}