Skip to content

Commit

Permalink
version 1.1.0 - updated dependencies (androidx & other), removed subm…
Browse files Browse the repository at this point in the history
…itItems method
  • Loading branch information
Tomasz Bieńkowski committed Jul 14, 2020
1 parent 43e08f8 commit 61797f9
Show file tree
Hide file tree
Showing 25 changed files with 114 additions and 74 deletions.
1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 28
compileSdkVersion 29
defaultConfig {
def versionMajor = 1
def versionMinor = 0
def versionMinor = 1
def versionPatch = 0

versionCode versionMajor * 1000000 + versionMinor * 1000 + versionPatch
Expand All @@ -15,9 +15,9 @@ android {
applicationId "it.bienkowski.recyclerdelegates.demo"

minSdkVersion 14
targetSdkVersion 28
targetSdkVersion 29

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
Expand All @@ -31,12 +31,12 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(":recyclerdelegates")
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'androidx.appcompat:appcompat:1.2.0-rc01'
implementation 'com.google.android.material:material:1.2.0-beta01'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'

testImplementation 'junit:junit:4.12'
testImplementation 'junit:junit:4.13'

androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package it.bienkowski.recyclerdelegates.demo

import android.support.test.InstrumentationRegistry
import android.support.test.runner.AndroidJUnit4
import androidx.test.runner.AndroidJUnit4
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith
Expand All @@ -16,7 +15,7 @@ class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getTargetContext()
assertEquals("it.bienkowski.recyclerdelegates", appContext.packageName)
val appContext = androidx.test.InstrumentationRegistry.getTargetContext()
assertEquals("it.bienkowski.recyclerdelegates.demo", appContext.packageName)
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package it.bienkowski.recyclerdelegates.demo

import android.os.Bundle
import android.support.design.widget.FloatingActionButton
import android.support.v7.app.AlertDialog
import android.support.v7.app.AppCompatActivity
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
import android.view.Menu
import android.view.MenuItem
import android.view.View
import android.widget.EditText
import android.widget.ImageButton
import android.widget.TextView
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.floatingactionbutton.FloatingActionButton
import it.bienkowski.recyclerdelegates.DelegatingRecyclerAdapter

import it.bienkowski.recyclerdelegates.delegates.BaseRecyclerDelegate
Expand Down Expand Up @@ -108,7 +108,7 @@ class ToDoSampleActivity : AppCompatActivity(), TodoItemDelegate.Listeners {
fab.setOnClickListener { addTodoItem() }

// On start we show EmptyItem, modifyItems calls are passed through DiffUtil
adapter.submitItems(EmptyItem())
adapter.submitList(listOf(EmptyItem()))
}

// Menu to add "delete completed menu"
Expand Down Expand Up @@ -136,9 +136,9 @@ class ToDoSampleActivity : AppCompatActivity(), TodoItemDelegate.Listeners {

AlertDialog.Builder(this)
.setView(editText)
.setPositiveButton("SAVE", { _, _ ->
.setPositiveButton("SAVE") { _, _ ->
callback(editText.text.toString())
})
}
.show()
}

Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/layout/activity_demo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="it.bienkowski.recyclerdelegates.ToDoSampleActivity">
tools:context="it.bienkowski.recyclerdelegates.demo.ToDoSampleActivity">

<android.support.v7.widget.RecyclerView
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler"
android:layout_width="0dp"
android:layout_height="0dp"
Expand All @@ -15,7 +15,7 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<android.support.design.widget.FloatingActionButton
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/item_empty.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:padding="16dp"
android:text="No tasks"
android:gravity="center"
android:textColor="#333"
android:textSize="24sp"
app:layout_constraintBottom_toBottomOf="parent"
Expand Down
9 changes: 4 additions & 5 deletions app/src/main/res/layout/item_todo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp"
>
android:paddingRight="16dp">

<ImageButton
android:id="@+id/checkbox"
Expand All @@ -17,15 +16,15 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:src="@drawable/ic_check_box_black_24dp"
tools:ignore="ContentDescription" />
tools:ignore="ContentDescription"
tools:src="@drawable/ic_check_box_black_24dp" />

<TextView
android:id="@+id/text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.3.61'
ext.kotlin_version = '1.3.72'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.android.tools.build:gradle:4.0.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
}
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
android.useAndroidX=true
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-all.zip
18 changes: 9 additions & 9 deletions recyclerdelegates/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ apply plugin: 'com.github.dcendents.android-maven'
group = 'com.github.tbienko'

android {
compileSdkVersion 28
compileSdkVersion 29

defaultConfig {
def versionMajor = 1
def versionMinor = 0
def versionMinor = 1
def versionPatch = 0

versionCode versionMajor * 1000000 + versionMinor * 1000 + versionPatch
versionName "${versionMajor}.${versionMinor}.${versionPatch}"

//noinspection MinSdkTooLow
minSdkVersion 7
targetSdkVersion 28
targetSdkVersion 29

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
Expand All @@ -33,13 +33,13 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

api 'com.android.support:recyclerview-v7:28.0.0'
api 'androidx.recyclerview:recyclerview:1.1.0'

testImplementation 'junit:junit:4.12'
testImplementation 'io.mockk:mockk:1.7.15'
testImplementation 'junit:junit:4.13'
testImplementation 'io.mockk:mockk:1.10.0'

androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package it.bienkowski.recyclerdelegates;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;

import androidx.test.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package it.bienkowski.recyclerdelegates

import android.support.v7.util.DiffUtil
import androidx.recyclerview.widget.DiffUtil


/**
* [DiffUtil.Callback] implementation comparing items using
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package it.bienkowski.recyclerdelegates

import android.support.v7.util.DiffUtil
import android.support.v7.widget.RecyclerView

import android.view.ViewGroup
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.RecyclerView

/**
* [RecyclerView.Adapter] which delegate operations to [RecyclerDelegateManager]
Expand All @@ -11,21 +12,17 @@ class DelegatingRecyclerAdapter<I : Any>(
private val manager: RecyclerDelegateManager<I>
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {

private var mutableItems: List<I> = listOf()

val items : List<I>
get() = mutableItems
private var internalItems: List<I> = listOf()

val items: List<I>
get() = internalItems

fun submitList(newItems: List<I>) {
val oldItems = mutableItems
mutableItems = newItems
DiffUtil.calculateDiff(DelegatingDiffUtilCallback(manager, oldItems, newItems)).dispatchUpdatesTo(this)
val diff = DiffUtil.calculateDiff(DelegatingDiffUtilCallback(manager, internalItems, newItems))
internalItems = newItems
diff.dispatchUpdatesTo(this)
}

@Deprecated("use submitList instead")
fun submitItems(vararg items: I) = submitList(items.toList())

override fun getItemCount(): Int = items.size

override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package it.bienkowski.recyclerdelegates

import android.support.v7.util.DiffUtil
import android.support.v7.widget.RecyclerView
import android.view.ViewGroup
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.RecyclerView

/**
* Delegated methods from [RecyclerView.Adapter], called from [RecyclerDelegateManager] implementation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package it.bienkowski.recyclerdelegates

import android.support.v7.util.DiffUtil
import android.support.v7.widget.RecyclerView
import android.view.ViewGroup
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.RecyclerView

/**
* Bridge between [RecyclerView.Adapter] and [RecyclerDelegate], in general it contains
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package it.bienkowski.recyclerdelegates.delegates

import android.support.annotation.LayoutRes
import android.support.v7.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.annotation.LayoutRes
import androidx.recyclerview.widget.RecyclerView
import it.bienkowski.recyclerdelegates.RecyclerDelegate

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package it.bienkowski.recyclerdelegates.delegates

import android.support.v7.widget.RecyclerView
import android.view.View
import androidx.recyclerview.widget.RecyclerView

/**
* Minimalistic view holder implementation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package it.bienkowski.recyclerdelegates.delegates

import android.support.annotation.LayoutRes
import android.view.View
import androidx.annotation.LayoutRes

/**
* Simple delegate which may be used to display static layouts
Expand Down
Loading

0 comments on commit 61797f9

Please sign in to comment.