diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml new file mode 100644 index 00000000..646221a0 --- /dev/null +++ b/.github/workflows/run-tests.yml @@ -0,0 +1,28 @@ +name: Run Tests + +on: + push: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Set up JDK + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + + - name: Checkout Submodules + uses: actions/checkout@v3 + + - name: Validate Gradle Wrapper + uses: gradle/wrapper-validation-action@v1 + + - name: Run Lint + run: ./gradlew lint --console plain + + - name: Run Unit Tests + run: ./gradlew test --console plain diff --git a/.gitignore b/.gitignore index 59b4767c..3f283870 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,11 @@ *.iml +*.jks +.DS_Store +.externalNativeBuild .gradle -/local.properties .idea/* -/.idea/workspace.xml /.idea/libraries -.DS_Store +/.idea/workspace.xml /build /captures -.externalNativeBuild -*.jks +/local.properties diff --git a/README.md b/README.md index 422f3b70..f6412edf 100644 --- a/README.md +++ b/README.md @@ -97,35 +97,6 @@ You can implement the `Group` interface directly if you want. However, in most Groupie abstracts away the complexity of multiple item view types. Each Item declares a view layout id, and gets a callback to `bind` the inflated layout. That's all you need; you can add your new item directly to a `GroupieAdapter` and call it a day. -### Item with Kotlin-Android-Extensions: - -**Note: `kotlin-android-extensions` is deprecated since Kotlin 1.4.20. Therefore, `groupie-kotlin-android-extensions` is also deprecated, and `viewbinding` should be preferred.** - -Groupie includes a module for Kotlin and Kotlin Android extensions. [Setup here.](#kotlin) - -```gradle -implementation "com.github.lisawray.groupie:groupie:$groupie_version" -implementation "com.github.lisawray.groupie:groupie-kotlin-android-extensions:$groupie_version" -``` - -The `Item` class gives you simple callbacks to bind your model object to the generated fields. - -```kotlin -import com.xwray.groupie.kotlinandroidextensions.Item -import com.xwray.groupie.kotlinandroidextensions.GroupieViewHolder -import kotlinx.android.synthetic.main.song.* - -class SongItem(private val song: Song) : Item() { - - override fun getLayout() = R.layout.song - - override fun bind(viewHolder: GroupieViewHolder, position: Int) { - viewHolder.title.text = song.title - viewHolder.artist.text = song.artist - } -} -``` - ### Item with data binding: The `Item` class gives you simple callbacks to bind your model object to the generated binding. Because of data binding, there's no need to write a view holder. @@ -220,37 +191,6 @@ In your app `build.gradle` file, include: implementation 'com.github.lisawray.groupie:groupie:$groupie_version' ``` -### Using with Kotlin-Android-Extensions (deprecated) - -If you are still relying on the deprecated `kotlin-android-extensions` module, then also apply the following: - -``` -apply plugin: 'kotlin-android' -apply plugin: 'kotlin-android-extensions' - -android { - .... - - // IMPORTANT! Enables kotlin synthetic view properties. - // See: https://github.com/Kotlin/KEEP/blob/master/proposals/android-extensions-entity-caching.md - androidExtensions { - experimental = true - } - -} - -dependencies { - implementation 'com.github.lisawray.groupie:groupie:$groupie_version' - implementation 'com.github.lisawray.groupie:groupie-kotlin-android-extensions:$groupie_version' -} -``` - -Remember to include -```kotlin -import kotlinx.android.synthetic.main.my_item_layout.* -``` -in the corresponding Item class for generated view references. - ## View binding Add to your app module's `build.gradle`: @@ -332,8 +272,8 @@ Bindings are only generated for layouts wrapped with tags, so there's You can add a `` section to directly bind a model or ViewModel, but you don't have to. The generated view bindings alone are a huge time saver. ### Kotlin AND data binding / view binding? -Sure, why not? Follow all the instructions from *both* sections above. You only need to include the `groupie-databinding` or `groupie-viewbinding` dependency, and omit the references to `android-extensions`. You'll make `BindableItem`s instead of importing and using Kotlin extensions. - +Sure, why not? Follow all the instructions from *both* sections above. +You only need to include the `groupie-databinding` or `groupie-viewbinding` dependency. # Contributing Contributions you say? Yes please! diff --git a/build.gradle b/build.gradle index 74e9af72..f5eb5a3b 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,6 @@ def testReportsDir = "${rootProject.buildDir}/test-reports" def testResultsDir = "${rootProject.buildDir}/test-results" buildscript { - ext.kotlin_version = '1.6.21' ext.android_plugin_version = '7.0.4' ext.sdkVersion = 31 @@ -19,22 +18,18 @@ buildscript { repositories { google() mavenCentral() - jcenter() maven { url "https://jitpack.io" } } dependencies { classpath "com.android.tools.build:gradle:$android_plugin_version" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.dokka:dokka-android-gradle-plugin:0.9.18" - - // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { project -> - repositories { google() mavenCentral() diff --git a/example/.gitignore b/example/.gitignore deleted file mode 100644 index 796b96d1..00000000 --- a/example/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build diff --git a/example/build.gradle b/example/build.gradle deleted file mode 100644 index 0aafff37..00000000 --- a/example/build.gradle +++ /dev/null @@ -1,34 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'kotlin-android-extensions' - -androidExtensions { - experimental = true -} - -android { - compileSdkVersion rootProject.sdkVersion - - defaultConfig { - applicationId "com.xwray.groupie.example" - minSdkVersion rootProject.minimumSdkVersion - targetSdkVersion rootProject.sdkVersion - versionCode 1 - versionName "1.0" - vectorDrawables.useSupportLibrary true - } - buildTypes { - release { - minifyEnabled false - } - } - lintOptions { - abortOnError false - } -} - -dependencies { - implementation project(':example-shared') - implementation project(':library') - implementation project(':library-kotlin-android-extensions') -} \ No newline at end of file diff --git a/example/src/main/AndroidManifest.xml b/example/src/main/AndroidManifest.xml deleted file mode 100644 index ac10c07e..00000000 --- a/example/src/main/AndroidManifest.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - diff --git a/example/src/main/java/com/xwray/groupie/example/ColumnGroup.kt b/example/src/main/java/com/xwray/groupie/example/ColumnGroup.kt deleted file mode 100644 index 74743da3..00000000 --- a/example/src/main/java/com/xwray/groupie/example/ColumnGroup.kt +++ /dev/null @@ -1,51 +0,0 @@ -package com.xwray.groupie.example - -import com.xwray.groupie.Group -import com.xwray.groupie.GroupDataObserver -import com.xwray.groupie.Item -import java.util.* - -/** - * A simple, non-editable, non-nested group of Items which displays a list as vertical columns. - */ -class ColumnGroup(items: List>) : Group { - - private val items = ArrayList>() - - init { - for (i in items.indices) { - // Rearrange items so that the adapter appears to arrange them in vertical columns - var index: Int - if (i % 2 == 0) { - index = i / 2 - } else { - index = (i - 1) / 2 + (items.size / 2f).toInt() - // If columns are uneven, we'll put an extra one at the end of the first column, - // meaning the second column's indices will all be increased by 1 - if (items.size % 2 == 1) index++ - } - val trackItem = items[index] - this.items.add(trackItem) - } - } - - override fun registerGroupDataObserver(groupDataObserver: GroupDataObserver) { - // no need to do anything here - } - - override fun unregisterGroupDataObserver(groupDataObserver: GroupDataObserver) { - // no need to do anything here - } - - override fun getItem(position: Int): Item<*> { - return items[position] - } - - override fun getPosition(item: Item<*>): Int { - return items.indexOf(item) - } - - override fun getItemCount(): Int { - return items.size - } -} diff --git a/example/src/main/java/com/xwray/groupie/example/ExpandableHeaderItem.kt b/example/src/main/java/com/xwray/groupie/example/ExpandableHeaderItem.kt deleted file mode 100644 index e4276ea5..00000000 --- a/example/src/main/java/com/xwray/groupie/example/ExpandableHeaderItem.kt +++ /dev/null @@ -1,57 +0,0 @@ -package com.xwray.groupie.example - -import android.graphics.drawable.Animatable -import androidx.annotation.StringRes -import android.view.View -import android.widget.ImageView -import com.xwray.groupie.ExpandableGroup -import com.xwray.groupie.ExpandableItem -import com.xwray.groupie.Item -import com.xwray.groupie.example.item.HeaderItem -import com.xwray.groupie.kotlinandroidextensions.GroupieViewHolder -import kotlinx.android.synthetic.main.item_header.* - -class ExpandableHeaderItem( - @StringRes titleStringResId: Int, - @StringRes subtitleResId: Int -) : HeaderItem(titleStringResId, subtitleResId), ExpandableItem { - var clickListener: ((ExpandableHeaderItem) -> Unit)? = null - - private lateinit var expandableGroup: ExpandableGroup - - private val actualClickListener = View.OnClickListener { - clickListener?.invoke(this) - } - - private val iconClickListener = View.OnClickListener { icon -> - expandableGroup.onToggleExpanded() - (icon as ImageView).apply { - visibility = View.VISIBLE - setImageResource(when { - expandableGroup.isExpanded -> R.drawable.collapse_animated - else -> R.drawable.expand_animated - }) - (drawable as Animatable).start() - } - } - - override fun bind(viewHolder: GroupieViewHolder, position: Int) { - super.bind(viewHolder, position) - - // Initial icon state -- not animated. - viewHolder.icon.apply { - visibility = View.VISIBLE - setImageResource(when { - expandableGroup.isExpanded -> R.drawable.collapse - else -> R.drawable.expand - }) - setOnClickListener(iconClickListener) - } - - viewHolder.itemView.setOnClickListener(actualClickListener) - } - - override fun setExpandableGroup(onToggleListener: ExpandableGroup) { - this.expandableGroup = onToggleListener - } -} diff --git a/example/src/main/java/com/xwray/groupie/example/HeaderItemDecoration.kt b/example/src/main/java/com/xwray/groupie/example/HeaderItemDecoration.kt deleted file mode 100644 index 982a5900..00000000 --- a/example/src/main/java/com/xwray/groupie/example/HeaderItemDecoration.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.xwray.groupie.example - -import androidx.annotation.ColorInt - -class HeaderItemDecoration(@ColorInt background: Int, sidePaddingPixels: Int) - : com.xwray.groupie.example.core.decoration.HeaderItemDecoration( - background, sidePaddingPixels, R.layout.item_header) diff --git a/example/src/main/java/com/xwray/groupie/example/InsetItemDecoration.kt b/example/src/main/java/com/xwray/groupie/example/InsetItemDecoration.kt deleted file mode 100644 index a80f81c2..00000000 --- a/example/src/main/java/com/xwray/groupie/example/InsetItemDecoration.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.xwray.groupie.example - -import androidx.annotation.ColorInt -import androidx.annotation.Dimension - -class InsetItemDecoration(@ColorInt backgroundColor: Int, @Dimension padding: Int) : - com.xwray.groupie.example.core.decoration.InsetItemDecoration(backgroundColor, padding, INSET_TYPE_KEY, INSET) diff --git a/example/src/main/java/com/xwray/groupie/example/MainActivity.kt b/example/src/main/java/com/xwray/groupie/example/MainActivity.kt deleted file mode 100644 index ee700126..00000000 --- a/example/src/main/java/com/xwray/groupie/example/MainActivity.kt +++ /dev/null @@ -1,320 +0,0 @@ -package com.xwray.groupie.example - -import android.content.Intent -import android.content.SharedPreferences -import android.os.Bundle -import android.os.Handler -import android.text.TextUtils -import android.view.Menu -import android.view.MenuItem -import android.view.View -import android.widget.Toast -import androidx.appcompat.app.AppCompatActivity -import androidx.core.content.ContextCompat -import androidx.recyclerview.widget.GridLayoutManager -import androidx.recyclerview.widget.ItemTouchHelper -import androidx.recyclerview.widget.RecyclerView -import com.xwray.groupie.ExpandableGroup -import com.xwray.groupie.Group -import com.xwray.groupie.GroupieAdapter -import com.xwray.groupie.OnItemClickListener -import com.xwray.groupie.OnItemLongClickListener -import com.xwray.groupie.Section -import com.xwray.groupie.example.core.InfiniteScrollListener -import com.xwray.groupie.example.core.Prefs -import com.xwray.groupie.example.core.SettingsActivity -import com.xwray.groupie.example.core.decoration.CarouselItemDecoration -import com.xwray.groupie.example.core.decoration.DebugItemDecoration -import com.xwray.groupie.example.core.decoration.SwipeTouchCallback -import com.xwray.groupie.example.item.* -import com.xwray.groupie.groupiex.plusAssign -import kotlinx.android.synthetic.main.activity_main.* - -const val INSET_TYPE_KEY = "inset_type" -const val INSET = "inset" - -class MainActivity : AppCompatActivity() { - - private val groupAdapter = GroupieAdapter() - private lateinit var groupLayoutManager: GridLayoutManager - private val prefs by lazy { Prefs.get(this) } - private val handler = Handler() - - private val gray: Int by lazy { ContextCompat.getColor(this, R.color.background) } - private val betweenPadding: Int by lazy { resources.getDimensionPixelSize(R.dimen.padding_small) } - private val rainbow200: IntArray by lazy { resources.getIntArray(R.array.rainbow_200) } - private val rainbow500: IntArray by lazy { resources.getIntArray(R.array.rainbow_500) } - - private val infiniteLoadingSection = Section(HeaderItem(R.string.infinite_loading)) - private val swipeSection = Section(HeaderItem(R.string.swipe_to_delete)) - private val dragSection = Section(HeaderItem(R.string.drag_to_reorder)) - - // Normally there's no need to hold onto a reference to this list, but for demonstration - // purposes, we'll shuffle this list and post an update periodically - private val updatableItems: ArrayList by lazy { - ArrayList().apply { - for (i in 1..12) { - add(UpdatableItem(rainbow200[i], i)) - } - } - } - - override fun onCreateOptionsMenu(menu: Menu?): Boolean { - menuInflater.inflate(R.menu.menu, menu) - return true - } - - override fun onOptionsItemSelected(item: MenuItem): Boolean { - if (item.itemId == R.id.refresh) { - recreateAdapter() - return true - } - return super.onOptionsItemSelected(item) - } - - // Hold a reference to the updating group, so we can, well, update it - private var updatingGroup = Section() - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) - - groupAdapter.apply { - setOnItemClickListener(onItemClickListener) - setOnItemLongClickListener(onItemLongClickListener) - spanCount = 12 - } - - recreateAdapter() - - groupLayoutManager = GridLayoutManager(this, groupAdapter.spanCount).apply { - spanSizeLookup = groupAdapter.spanSizeLookup - } - - recyclerView.apply { - layoutManager = groupLayoutManager - addItemDecoration(HeaderItemDecoration(gray, betweenPadding)) - addItemDecoration(InsetItemDecoration(gray, betweenPadding)) - addItemDecoration(DebugItemDecoration(context)) - adapter = groupAdapter - addOnScrollListener(object : InfiniteScrollListener(groupLayoutManager) { - override fun onLoadMore(currentPage: Int) { - val color = rainbow200[currentPage % rainbow200.size] - for (i in 0..4) { - infiniteLoadingSection.add(CardItem(color)) - } - } - }) - } - - ItemTouchHelper(touchCallback).attachToRecyclerView(recyclerView) - - fab.setOnClickListener { startActivity(Intent(this@MainActivity, SettingsActivity::class.java)) } - - prefs.registerListener(onSharedPrefChangeListener) - } - - private fun recreateAdapter() { - groupAdapter.clear() - - val groups = createGroups() - - if (prefs.useAsync) { - groupAdapter.updateAsync(groups) - } else { - groupAdapter.update(groups) - } - } - - private fun createGroups(): List = mutableListOf().apply { - // Full bleed item - this += Section(HeaderItem(R.string.full_bleed_item)).apply { - add(FullBleedCardItem(R.color.purple_200)) - } - - // Update in place group - this += Section().apply { - val updatingHeader = HeaderItem( - R.string.updating_group, - R.string.updating_group_subtitle, - R.drawable.shuffle, - onShuffleClicked) - setHeader(updatingHeader) - - updatingGroup.update(updatableItems) - add(updatingGroup) - } - - // Expandable group - val expandableHeaderItem = ExpandableHeaderItem(R.string.expanding_group, R.string.expanding_group_subtitle) - this += ExpandableGroup(expandableHeaderItem).apply { - for (i in 0..1) { - add(CardItem(rainbow200[1])) - } - } - - // Reordering a Section of Expandable Groups - val section = Section(HeaderItem(R.string.reorderable_section)) - val swappableExpandableGroup = mutableListOf() - var colorIndex = 0 - for (i in 0..2) { - val header = ExpandableHeaderItem(R.string.reorderable_item_title, R.string.reorderable_item_subtitle) - val group = ExpandableGroup(header).apply { - val numChildren= i * 2 // groups will continue to grow by 2 - for (j in 0..numChildren) { - add(CardItem(rainbow200[colorIndex])) - if (colorIndex + 1 >= rainbow200.size) { - colorIndex = 0 - } else { - colorIndex += 1 - } - } - } - header.clickListener = { - swappableExpandableGroup.remove(group) - swappableExpandableGroup.add(group) - - section.update(swappableExpandableGroup) - } - swappableExpandableGroup.add(group) - } - section.addAll(swappableExpandableGroup) - this += section - - // Columns - fun makeColumnGroup(): ColumnGroup { - val columnItems = ArrayList() - for (i in 1..5) { - // First five items are red -- they'll end up in a vertical column - columnItems += ColumnItem(rainbow200[0], i) - } - for (i in 6..10) { - // Next five items are pink - columnItems += ColumnItem(rainbow200[1], i) - } - return ColumnGroup(columnItems) - } - - this += Section(HeaderItem(R.string.vertical_columns)).apply { - add(makeColumnGroup()) - } - - // Group showing even spacing with multiple columns - this += Section(HeaderItem(R.string.multiple_columns)).apply { - for (i in 0..11) { - add(SmallCardItem(rainbow200[5])) - } - } - - // Swipe to delete (with add button in header) - swipeSection.clear() - for (i in 0..2) { - swipeSection += SwipeToDeleteItem(rainbow200[i]) - } - this += swipeSection - - dragSection.clear() - for (i in 0..4) { - dragSection += DraggableItem(rainbow500[i]) - } - this += dragSection - - // Horizontal carousel - fun makeCarouselItem(): CarouselItem { - val carouselDecoration = CarouselItemDecoration(gray, betweenPadding) - val carouselAdapter = GroupieAdapter() - for (i in 0..29) { - carouselAdapter += CarouselCardItem(rainbow200[7]) - } - return CarouselItem(carouselDecoration, carouselAdapter) - } - - this += Section(HeaderItem(R.string.carousel, R.string.carousel_subtitle)).apply { - add(makeCarouselItem()) - } - - // Update with payload - this += Section(HeaderItem(R.string.update_with_payload, R.string.update_with_payload_subtitle)).apply { - rainbow500.indices.forEach { i -> - add(HeartCardItem(rainbow200[i], i.toLong()) { item, favorite -> - // Pretend to make a network request - handler.postDelayed({ - // Network request was successful! - item.setFavorite(favorite) - item.notifyChanged(FAVORITE) - }, 1000) - }) - } - } - - // Infinite loading section - this += infiniteLoadingSection - } - - private val onItemClickListener = OnItemClickListener { item, _ -> - if (item is CardItem && !TextUtils.isEmpty(item.text)) { - Toast.makeText(this@MainActivity, item.text, Toast.LENGTH_SHORT).show() - } - } - - private val onItemLongClickListener = OnItemLongClickListener { item, _ -> - if (item is CardItem && !item.text.isNullOrBlank()) { - Toast.makeText(this@MainActivity, "Long clicked: " + item.text, Toast.LENGTH_SHORT).show() - return@OnItemLongClickListener true - } - false - } - - private val onShuffleClicked = View.OnClickListener { - ArrayList(updatableItems).apply { - shuffle() - updatingGroup.update(this) - } - - // You can also do this by forcing a change with payload - recyclerView.post { recyclerView.invalidateItemDecorations() } - } - - override fun onDestroy() { - prefs.unregisterListener(onSharedPrefChangeListener) - super.onDestroy() - } - - private val touchCallback: SwipeTouchCallback by lazy { - object : SwipeTouchCallback() { - override fun onMove(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder, - target: RecyclerView.ViewHolder): Boolean { - val item = groupAdapter.getItem(viewHolder.bindingAdapterPosition) - val targetItem = groupAdapter.getItem(target.bindingAdapterPosition) - - val dragItems = dragSection.groups - var targetIndex = dragItems.indexOf(targetItem) - dragItems.remove(item) - - // if item gets moved out of the boundary - if (targetIndex == -1) { - targetIndex = if (target.bindingAdapterPosition < viewHolder.bindingAdapterPosition) { - 0 - } else { - dragItems.size - 1 - } - } - - dragItems.add(targetIndex, item) - dragSection.update(dragItems) - return true - } - - override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) { - val item = groupAdapter.getItem(viewHolder.bindingAdapterPosition) - // Change notification to the adapter happens automatically when the section is - // changed. - swipeSection.remove(item) - } - } - } - - private val onSharedPrefChangeListener = SharedPreferences.OnSharedPreferenceChangeListener { _, _ -> - recreateAdapter() - } -} diff --git a/example/src/main/java/com/xwray/groupie/example/item/CardItem.kt b/example/src/main/java/com/xwray/groupie/example/item/CardItem.kt deleted file mode 100644 index dc95e788..00000000 --- a/example/src/main/java/com/xwray/groupie/example/item/CardItem.kt +++ /dev/null @@ -1,23 +0,0 @@ -package com.xwray.groupie.example.item - -import androidx.annotation.ColorInt -import com.xwray.groupie.example.INSET -import com.xwray.groupie.example.INSET_TYPE_KEY -import com.xwray.groupie.example.R -import com.xwray.groupie.kotlinandroidextensions.Item -import com.xwray.groupie.kotlinandroidextensions.GroupieViewHolder -import kotlinx.android.synthetic.main.item_card.* - -open class CardItem (@ColorInt private val colorInt: Int, val text: CharSequence? = "") : Item() { - - init { - extras[INSET_TYPE_KEY] = INSET - } - - override fun getLayout() = R.layout.item_card - - override fun bind(viewHolder: GroupieViewHolder, position: Int) { - viewHolder.root.setBackgroundColor(colorInt) - viewHolder.text.text = text - } -} diff --git a/example/src/main/java/com/xwray/groupie/example/item/CarouselCardItem.kt b/example/src/main/java/com/xwray/groupie/example/item/CarouselCardItem.kt deleted file mode 100644 index cb7baaf7..00000000 --- a/example/src/main/java/com/xwray/groupie/example/item/CarouselCardItem.kt +++ /dev/null @@ -1,18 +0,0 @@ -package com.xwray.groupie.example.item - -import androidx.annotation.ColorInt -import com.xwray.groupie.Item -import com.xwray.groupie.GroupieViewHolder -import com.xwray.groupie.example.R - -/** - * A card item with a fixed width so it can be used with a horizontal layout manager. - */ -class CarouselCardItem(@ColorInt private val colorInt: Int) : Item() { - - override fun getLayout() = R.layout.item_square_card - - override fun bind(viewHolder: GroupieViewHolder, position: Int) { - viewHolder.root.setBackgroundColor(colorInt) - } -} diff --git a/example/src/main/java/com/xwray/groupie/example/item/CarouselItem.kt b/example/src/main/java/com/xwray/groupie/example/item/CarouselItem.kt deleted file mode 100644 index d255be8f..00000000 --- a/example/src/main/java/com/xwray/groupie/example/item/CarouselItem.kt +++ /dev/null @@ -1,33 +0,0 @@ -package com.xwray.groupie.example.item - -import androidx.recyclerview.widget.LinearLayoutManager -import androidx.recyclerview.widget.RecyclerView -import com.xwray.groupie.GroupieAdapter -import com.xwray.groupie.example.R -import com.xwray.groupie.kotlinandroidextensions.Item -import com.xwray.groupie.kotlinandroidextensions.GroupieViewHolder -import kotlinx.android.synthetic.main.item_carousel.* - -/** - * A horizontally scrolling RecyclerView, for use in a vertically scrolling RecyclerView. - */ -class CarouselItem(private val carouselDecoration: RecyclerView.ItemDecoration, - private val carouselAdapter: GroupieAdapter) : Item() { - - override fun getLayout(): Int { - return R.layout.item_carousel - } - - override fun bind(viewHolder: GroupieViewHolder, position: Int) { - viewHolder.recyclerView.apply { - layoutManager = LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false) - adapter = carouselAdapter - - // We don't know if the layout we're passed has been bound before so - // we need to ensure we don't register the item decoration multiple times, - // by trying to remove it first. (Nothing happens if it's not registered.) - removeItemDecoration(carouselDecoration) - addItemDecoration(carouselDecoration) - } - } -} diff --git a/example/src/main/java/com/xwray/groupie/example/item/ColumnItem.kt b/example/src/main/java/com/xwray/groupie/example/item/ColumnItem.kt deleted file mode 100644 index b720bd4e..00000000 --- a/example/src/main/java/com/xwray/groupie/example/item/ColumnItem.kt +++ /dev/null @@ -1,15 +0,0 @@ -package com.xwray.groupie.example.item - -import androidx.annotation.ColorInt -import com.xwray.groupie.example.INSET -import com.xwray.groupie.example.INSET_TYPE_KEY - -class ColumnItem(@ColorInt colorInt: Int, index: Int) : CardItem(colorInt, index.toString()) { - - init { - extras[INSET_TYPE_KEY] = INSET - } - - override fun getSpanSize(spanCount: Int, position: Int) = spanCount / 2 - -} diff --git a/example/src/main/java/com/xwray/groupie/example/item/DraggableItem.kt b/example/src/main/java/com/xwray/groupie/example/item/DraggableItem.kt deleted file mode 100644 index bcebd39f..00000000 --- a/example/src/main/java/com/xwray/groupie/example/item/DraggableItem.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.xwray.groupie.example.item - -import androidx.annotation.ColorInt -import androidx.recyclerview.widget.ItemTouchHelper - -class DraggableItem(@ColorInt colorInt: Int) : CardItem(colorInt) { - - override fun getDragDirs(): Int { - return ItemTouchHelper.UP or ItemTouchHelper.DOWN - } -} diff --git a/example/src/main/java/com/xwray/groupie/example/item/FullBleedCardItem.kt b/example/src/main/java/com/xwray/groupie/example/item/FullBleedCardItem.kt deleted file mode 100644 index 24314f49..00000000 --- a/example/src/main/java/com/xwray/groupie/example/item/FullBleedCardItem.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.xwray.groupie.example.item - -import androidx.annotation.ColorRes -import com.xwray.groupie.example.INSET_TYPE_KEY - -class FullBleedCardItem(@ColorRes colorInt: Int) : CardItem(colorInt) { - - init { - extras.remove(INSET_TYPE_KEY) - } -} diff --git a/example/src/main/java/com/xwray/groupie/example/item/HeaderItem.kt b/example/src/main/java/com/xwray/groupie/example/item/HeaderItem.kt deleted file mode 100644 index 9bb69217..00000000 --- a/example/src/main/java/com/xwray/groupie/example/item/HeaderItem.kt +++ /dev/null @@ -1,41 +0,0 @@ -package com.xwray.groupie.example.item - -import androidx.annotation.DrawableRes -import androidx.annotation.StringRes -import android.view.View -import com.xwray.groupie.example.R -import com.xwray.groupie.kotlinandroidextensions.Item -import com.xwray.groupie.kotlinandroidextensions.GroupieViewHolder -import kotlinx.android.synthetic.main.item_header.* - -open class HeaderItem( - @StringRes private val titleStringResId: Int, - @StringRes private val subtitleResId: Int? = null, - @DrawableRes private val iconResId: Int? = null, - private val onIconClickListener: View.OnClickListener? = null) : Item() { - - override fun getLayout(): Int { - return R.layout.item_header - } - - override fun bind(viewHolder: GroupieViewHolder, position: Int) { - viewHolder.title.setText(titleStringResId) - - viewHolder.subtitle.apply { - visibility = View.GONE - subtitleResId?.let { - visibility = View.VISIBLE - setText(it) - } - } - - viewHolder.icon.apply { - visibility = View.GONE - iconResId?.let { - visibility = View.VISIBLE - setImageResource(it) - setOnClickListener(onIconClickListener) - } - } - } -} diff --git a/example/src/main/java/com/xwray/groupie/example/item/HeartCardItem.kt b/example/src/main/java/com/xwray/groupie/example/item/HeartCardItem.kt deleted file mode 100644 index 212365f3..00000000 --- a/example/src/main/java/com/xwray/groupie/example/item/HeartCardItem.kt +++ /dev/null @@ -1,75 +0,0 @@ -package com.xwray.groupie.example.item - -import android.graphics.drawable.Animatable -import androidx.annotation.ColorInt -import com.xwray.groupie.example.INSET -import com.xwray.groupie.example.INSET_TYPE_KEY -import com.xwray.groupie.example.R -import com.xwray.groupie.kotlinandroidextensions.Item -import com.xwray.groupie.kotlinandroidextensions.GroupieViewHolder -import kotlinx.android.synthetic.main.item_heart_card.* - -const val FAVORITE = "FAVORITE" - -class HeartCardItem( - @ColorInt private val colorInt: Int, - id: Long, - private val onFavoriteListener: (item: HeartCardItem, favorite: Boolean) -> Unit -) : Item(id) { - - private var checked = false - private var inProgress = false - private var holder: com.xwray.groupie.GroupieViewHolder? = null - - init { - extras[INSET_TYPE_KEY] = INSET - } - - override fun getLayout() = R.layout.item_heart_card - - private fun bindHeart(holder: GroupieViewHolder) { - if (inProgress) { - animateProgress(holder) - } else { - (holder.favorite.drawable as? Animatable)?.stop() - holder.favorite.setImageResource(R.drawable.favorite_state_list) - } - holder.favorite.isChecked = checked - } - - private fun animateProgress(holder: GroupieViewHolder) { - holder.favorite.apply { - setImageResource(R.drawable.avd_favorite_progress) - (drawable as Animatable).start() - } - } - - fun setFavorite(favorite: Boolean) { - inProgress = false - checked = favorite - } - - override fun isClickable() = false - - override fun bind(holder: GroupieViewHolder, position: Int) { - holder.root.setBackgroundColor(colorInt) - bindHeart(holder) - holder.text.text = (id + 1).toString() - - holder.favorite.setOnClickListener { - if (!inProgress) { - inProgress = true - animateProgress(holder) - onFavoriteListener(this@HeartCardItem, !checked) - } - } - } - - override fun bind(holder: GroupieViewHolder, position: Int, payloads: List) { - if (payloads.contains(FAVORITE)) { - bindHeart(holder) - } else { - bind(holder, position) - } - } -} diff --git a/example/src/main/java/com/xwray/groupie/example/item/SmallCardItem.kt b/example/src/main/java/com/xwray/groupie/example/item/SmallCardItem.kt deleted file mode 100644 index 153164a8..00000000 --- a/example/src/main/java/com/xwray/groupie/example/item/SmallCardItem.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.xwray.groupie.example.item - -import androidx.annotation.ColorInt - -open class SmallCardItem(@ColorInt private val colorInt: Int, text: CharSequence? = "") : CardItem(colorInt, text) { - - override fun getSpanSize(spanCount: Int, position: Int) = spanCount / 3 - -} diff --git a/example/src/main/java/com/xwray/groupie/example/item/SwipeToDeleteItem.kt b/example/src/main/java/com/xwray/groupie/example/item/SwipeToDeleteItem.kt deleted file mode 100644 index f5592ec7..00000000 --- a/example/src/main/java/com/xwray/groupie/example/item/SwipeToDeleteItem.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.xwray.groupie.example.item - -import androidx.annotation.ColorInt -import androidx.recyclerview.widget.ItemTouchHelper - -class SwipeToDeleteItem(@ColorInt colorInt: Int) : CardItem(colorInt) { - - override fun getSwipeDirs(): Int { - return ItemTouchHelper.LEFT or ItemTouchHelper.RIGHT - } -} diff --git a/example/src/main/java/com/xwray/groupie/example/item/UpdatableItem.kt b/example/src/main/java/com/xwray/groupie/example/item/UpdatableItem.kt deleted file mode 100644 index 31baac02..00000000 --- a/example/src/main/java/com/xwray/groupie/example/item/UpdatableItem.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.xwray.groupie.example.item - -import androidx.annotation.ColorInt - -data class UpdatableItem(@ColorInt private val colorInt: Int, private val index: Int) : SmallCardItem(colorInt, index.toString()) { - - override fun getId() = index.toLong() - -} diff --git a/example/src/main/res/drawable/ic_baseline_refresh_24.xml b/example/src/main/res/drawable/ic_baseline_refresh_24.xml deleted file mode 100644 index 0f49bab2..00000000 --- a/example/src/main/res/drawable/ic_baseline_refresh_24.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/example/src/main/res/layout/activity_main.xml b/example/src/main/res/layout/activity_main.xml deleted file mode 100644 index dc6a1ee8..00000000 --- a/example/src/main/res/layout/activity_main.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - diff --git a/example/src/main/res/layout/item_card.xml b/example/src/main/res/layout/item_card.xml deleted file mode 100644 index 17bc7a82..00000000 --- a/example/src/main/res/layout/item_card.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - diff --git a/example/src/main/res/layout/item_carousel.xml b/example/src/main/res/layout/item_carousel.xml deleted file mode 100644 index df1df932..00000000 --- a/example/src/main/res/layout/item_carousel.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - diff --git a/example/src/main/res/layout/item_expandable_header.xml b/example/src/main/res/layout/item_expandable_header.xml deleted file mode 100644 index cca29225..00000000 --- a/example/src/main/res/layout/item_expandable_header.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - diff --git a/example/src/main/res/layout/item_header.xml b/example/src/main/res/layout/item_header.xml deleted file mode 100644 index 691bd9b6..00000000 --- a/example/src/main/res/layout/item_header.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - - - diff --git a/example/src/main/res/layout/item_heart_card.xml b/example/src/main/res/layout/item_heart_card.xml deleted file mode 100644 index 09702c31..00000000 --- a/example/src/main/res/layout/item_heart_card.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - diff --git a/example/src/main/res/layout/item_square_card.xml b/example/src/main/res/layout/item_square_card.xml deleted file mode 100644 index 4968eab3..00000000 --- a/example/src/main/res/layout/item_square_card.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - diff --git a/example/src/main/res/menu/menu.xml b/example/src/main/res/menu/menu.xml deleted file mode 100644 index 13291688..00000000 --- a/example/src/main/res/menu/menu.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 13372aef..7454180f 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ff46025f..e750102e 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Tue May 03 11:55:29 CEST 2022 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip distributionPath=wrapper/dists -zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 9d82f789..1b6c7873 100755 --- a/gradlew +++ b/gradlew @@ -1,74 +1,129 @@ -#!/usr/bin/env bash +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum -warn ( ) { +warn () { echo "$*" -} +} >&2 -die ( ) { +die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -77,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" + JAVACMD=java which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the @@ -85,76 +140,95 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=$((i+1)) + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules -function splitJvmOpts() { - JVM_OPTS=("$@") -} -eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS -JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" - -exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index aec99730..ac1b06f9 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,3 +1,19 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @@ -8,20 +24,23 @@ @rem Set local scope for the variables with windows NT shell if "%OS%"=="Windows_NT" setlocal -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - set DIRNAME=%~dp0 if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if "%ERRORLEVEL%" == "0" goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -35,7 +54,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -45,34 +64,14 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windowz variants - -if not "%OS%" == "Windows_NT" goto win9xME_args -if "%@eval[2+2]" == "4" goto 4NT_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* -goto execute - -:4NT_args -@rem Get arguments from the 4NT Shell from JP Software -set CMD_LINE_ARGS=%$ - :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell diff --git a/library-kotlin-android-extensions/.gitignore b/library-kotlin-android-extensions/.gitignore deleted file mode 100644 index 796b96d1..00000000 --- a/library-kotlin-android-extensions/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build diff --git a/library-kotlin-android-extensions/build.gradle b/library-kotlin-android-extensions/build.gradle deleted file mode 100644 index b3d3c765..00000000 --- a/library-kotlin-android-extensions/build.gradle +++ /dev/null @@ -1,118 +0,0 @@ -apply plugin: 'com.android.library' -apply plugin: 'kotlin-android' -apply plugin: 'kotlin-android-extensions' -apply plugin: 'maven-publish' - - -archivesBaseName = 'groupie-kotlin-android-extensions' - -androidExtensions { - experimental = true -} - -android { - compileSdkVersion rootProject.sdkVersion - - - defaultConfig { - minSdkVersion rootProject.minimumSdkVersion - targetSdkVersion rootProject.sdkVersion - versionCode 1 - versionName "1.0" - - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - - } - - signingConfigs { - release { - } - } - buildTypes { - release { - signingConfig signingConfigs.release - minifyEnabled false - } - } - -} - -dependencies { - implementation project(':library') - implementation "androidx.recyclerview:recyclerview:1.2.1" -} - -tasks.withType(Javadoc).all { - enabled = false -} - - -group = "com.github.lisawray.groupie" -version = "2.10.1" - -task javadoc(type: Javadoc) { - configurations.implementation.canBeResolved(true) - configurations.api.canBeResolved(true) - - failOnError false - - source = android.sourceSets.main.java.srcDirs - classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) - //destinationDir = file("../javadoc/") - classpath += configurations.api -} - -task sourcesJar(type: Jar) { - from android.sourceSets.main.java.srcDirs - archiveClassifier = "sources" -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} - -artifacts { - archives sourcesJar - archives javadocJar -} - -// Because the components are created only during the afterEvaluate phase, you must -// configure your publications using the afterEvaluate() lifecycle method. -afterEvaluate { - publishing { - publications { - // Creates a Maven publication called "release". - release(MavenPublication) { - // Applies the component for the release build variant. - from components.release - artifact(sourcesJar) - - // You can then customize attributes of the publication as shown below. - groupId = 'com.github.lisawray.groupie' - artifactId = 'groupie-kotlin-android-extensions' - version = '2.10.1' - - pom.withXml { - def dependenciesNode = (asNode().get("dependencies") as groovy.util.NodeList).get(0) as groovy.util.Node - def configurationNames = ["implementation", "api"] - - configurationNames.forEach { configurationName -> - configurations[configurationName].allDependencies.forEach { - if (it.group != null && it.version != "unspecified") { - def dependencyNode = dependenciesNode.appendNode("dependency") - dependencyNode.appendNode("groupId", it.group) - dependencyNode.appendNode("artifactId", it.name) - dependencyNode.appendNode("version", it.version) - // dependencyNode.appendNode("scope", configurationName) - } - } - } - } - } - } - } -} - - - diff --git a/library-kotlin-android-extensions/gradle.properties b/library-kotlin-android-extensions/gradle.properties deleted file mode 100644 index 01d04106..00000000 --- a/library-kotlin-android-extensions/gradle.properties +++ /dev/null @@ -1,6 +0,0 @@ -POM_NAME=groupie-kotlin-android-extensions -POM_DESCRIPTION=Library to help with complex RecyclerViews -POM_BINTRAY_NAME=groupie-kotlin-android-extensions -POM_ARTIFACT_ID=groupie-kotlin-android-extensions -POM_PACKAGING=aar -POM_VERSION=2.10.1 \ No newline at end of file diff --git a/library-kotlin-android-extensions/src/main/AndroidManifest.xml b/library-kotlin-android-extensions/src/main/AndroidManifest.xml deleted file mode 100644 index 6109fbed..00000000 --- a/library-kotlin-android-extensions/src/main/AndroidManifest.xml +++ /dev/null @@ -1,2 +0,0 @@ - diff --git a/library-kotlin-android-extensions/src/main/java/com/xwray/groupie/groupiex/GroupAdapterExt.kt b/library-kotlin-android-extensions/src/main/java/com/xwray/groupie/groupiex/GroupAdapterExt.kt deleted file mode 100644 index 70ba54fd..00000000 --- a/library-kotlin-android-extensions/src/main/java/com/xwray/groupie/groupiex/GroupAdapterExt.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.xwray.groupie.groupiex - -import com.xwray.groupie.Group -import com.xwray.groupie.GroupAdapter -import com.xwray.groupie.GroupieViewHolder - -// TODO(zhuinden): move this into its own artifact later: `groupiex` (or rather, `groupie-ktx`) -operator fun GroupAdapter.plusAssign(element: Group) = this.add(element) -operator fun GroupAdapter.plusAssign(groups: Collection) = this.addAll(groups) -operator fun GroupAdapter.minusAssign(element: Group) = this.remove(element) -operator fun GroupAdapter.minusAssign(groups: Collection) = this.removeAll(groups) \ No newline at end of file diff --git a/library-kotlin-android-extensions/src/main/java/com/xwray/groupie/groupiex/SectionExt.kt b/library-kotlin-android-extensions/src/main/java/com/xwray/groupie/groupiex/SectionExt.kt deleted file mode 100644 index 44e234f4..00000000 --- a/library-kotlin-android-extensions/src/main/java/com/xwray/groupie/groupiex/SectionExt.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.xwray.groupie.groupiex - -import com.xwray.groupie.Group -import com.xwray.groupie.Section - -// TODO(zhuinden): move this into its own artifact later: `groupiex` (or rather, `groupie-ktx`) -operator fun Section.plusAssign(element: Group) = this.add(element) -operator fun Section.plusAssign(groups: Collection) = this.addAll(groups) -operator fun Section.minusAssign(element: Group) = this.remove(element) -operator fun Section.minusAssign(groups: Collection) = this.removeAll(groups) \ No newline at end of file diff --git a/library-kotlin-android-extensions/src/main/java/com/xwray/groupie/kotlinandroidextensions/GroupieViewHolder.kt b/library-kotlin-android-extensions/src/main/java/com/xwray/groupie/kotlinandroidextensions/GroupieViewHolder.kt deleted file mode 100644 index f5f9fb35..00000000 --- a/library-kotlin-android-extensions/src/main/java/com/xwray/groupie/kotlinandroidextensions/GroupieViewHolder.kt +++ /dev/null @@ -1,13 +0,0 @@ -package com.xwray.groupie.kotlinandroidextensions - -import android.view.View -import com.xwray.groupie.GroupieViewHolder -import kotlinx.android.extensions.CacheImplementation -import kotlinx.android.extensions.ContainerOptions -import kotlinx.android.extensions.LayoutContainer - -// Need to specify ContainerOptions in order for caching to work. -// See: https://youtrack.jetbrains.com/oauth?state=%2Fissue%2FKT-28617 -@Deprecated(message = "Kotlin-Android-Extensions is deprecated since 1.4.20, therefore so is the `kotlin-android-extensions` integration in Groupie. Use `groupie-viewbinding` instead.") -@ContainerOptions(cache = CacheImplementation.HASH_MAP) -class GroupieViewHolder(override val containerView: View) : GroupieViewHolder(containerView), LayoutContainer \ No newline at end of file diff --git a/library-kotlin-android-extensions/src/main/java/com/xwray/groupie/kotlinandroidextensions/Item.kt b/library-kotlin-android-extensions/src/main/java/com/xwray/groupie/kotlinandroidextensions/Item.kt deleted file mode 100644 index af8d3e40..00000000 --- a/library-kotlin-android-extensions/src/main/java/com/xwray/groupie/kotlinandroidextensions/Item.kt +++ /dev/null @@ -1,15 +0,0 @@ -package com.xwray.groupie.kotlinandroidextensions - -import android.view.View -import com.xwray.groupie.Item - -@Deprecated(message = "Kotlin-Android-Extensions is deprecated since 1.4.21, therefore so is the kotlin-android-extensions module in Groupie. Use `groupie-viewbinding` instead.") -abstract class Item : Item { - - constructor() : super() - constructor(id: Long) : super(id) - - override fun createViewHolder(itemView: View): GroupieViewHolder { - return GroupieViewHolder(itemView) - } -} \ No newline at end of file diff --git a/library/build.gradle b/library/build.gradle index b5f48e06..9e30b3f2 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -82,7 +82,7 @@ afterEvaluate { version = '2.10.1' pom.withXml { - def dependenciesNode = (asNode().get("dependencies") as groovy.util.NodeList).get(0) as groovy.util.Node + def dependenciesNode = (asNode().get("dependencies") as NodeList).get(0) as Node def configurationNames = ["implementation", "api"] configurationNames.forEach { configurationName -> @@ -101,4 +101,3 @@ afterEvaluate { } } } - diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index 9485eabe..00000000 --- a/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -include ':example-databinding', ':library-databinding', ':library', ':example', ':example-shared', ':library-kotlin-android-extensions', 'example-viewbinding', ':library-viewbinding' diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 00000000..f7bf2f3d --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,8 @@ +include( + ":example-shared", + ":example-viewbinding", + ":library", + ":library-databinding", + ":library-viewbinding", + ":example-databinding", +)