Compare commits

...

9 Commits

Author SHA1 Message Date
Denis Karmyshakov fb79dc971a Gradle update (#52) 2017-11-20 19:20:18 +03:00
Arseniy Borisov eef6932a4a Update by payload fixed (#51) 2017-11-13 12:10:06 +03:00
Denis Karmyshakov 10fcb22358 Merge pull request #48 from TouchInstinct/versions_in_constants
Versions in constants
2017-10-04 13:12:32 +03:00
Denis Karmyshakov f20db0317e Versions in constants 2017-10-04 13:10:49 +03:00
Denis Karmyshakov deff9f7cdd Versions in constants 2017-10-04 13:05:39 +03:00
Ilia Kurtov 9dcf3fb6b2 Merge pull request #43 from TouchInstinct/lib_version
rxjava version
2017-09-15 16:19:22 +03:00
gorodeckii 00b13c3acb rxjava version 2017-09-15 15:18:05 +03:00
Gavriil 74e70be245 RxJava version update (#42) 2017-09-11 18:51:05 +03:00
Arseniy Borisov c7edf3c84d idea formatter (#41) 2017-09-04 17:36:48 +03:00
6 changed files with 56 additions and 41 deletions

View File

@ -1,9 +1,7 @@
apply plugin: 'com.android.library' apply plugin: 'com.android.library'
apply plugin: 'me.tatarka.retrolambda'
android { android {
compileSdkVersion 25 compileSdkVersion compileSdk
buildToolsVersion '25.0.3'
compileOptions { compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_1_8
@ -16,7 +14,7 @@ android {
} }
dependencies { dependencies {
provided 'com.android.support:support-annotations:25.4.0' compileOnly "com.android.support:support-annotations:$supportLibraryVersion"
provided 'io.reactivex:rxandroid:1.2.1' compileOnly "io.reactivex:rxandroid:$rxAndroidVersion"
provided 'io.reactivex:rxjava:1.3.0' compileOnly "io.reactivex:rxjava:$rxJavaVersion"
} }

View File

@ -83,7 +83,6 @@ public class DiffUtil {
* Calculates the list of update operations that can covert one list into the other one. * Calculates the list of update operations that can covert one list into the other one.
* *
* @param cb The callback that acts as a gateway to the backing list data * @param cb The callback that acts as a gateway to the backing list data
*
* @return A DiffResult that contains the information about the edit sequence to convert the * @return A DiffResult that contains the information about the edit sequence to convert the
* old list into the new list. * old list into the new list.
*/ */
@ -100,7 +99,6 @@ public class DiffUtil {
* *
* @param cb The callback that acts as a gateway to the backing list data * @param cb The callback that acts as a gateway to the backing list data
* @param detectMoves True if DiffUtil should try to detect moved items, false otherwise. * @param detectMoves True if DiffUtil should try to detect moved items, false otherwise.
*
* @return A DiffResult that contains the information about the edit sequence to convert the * @return A DiffResult that contains the information about the edit sequence to convert the
* old list into the new list. * old list into the new list.
*/ */
@ -329,7 +327,6 @@ public class DiffUtil {
* *
* @param oldItemPosition The position of the item in the old list * @param oldItemPosition The position of the item in the old list
* @param newItemPosition The position of the item in the new list * @param newItemPosition The position of the item in the new list
*
* @return A payload object that represents the change between the two items. * @return A payload object that represents the change between the two items.
*/ */
@Nullable @Nullable
@ -560,7 +557,6 @@ public class DiffUtil {
* @param y The y position in the matrix (position in the new list) * @param y The y position in the matrix (position in the new list)
* @param snakeIndex The current snake index * @param snakeIndex The current snake index
* @param removal True if we are looking for a removal, false otherwise * @param removal True if we are looking for a removal, false otherwise
*
* @return True if such item is found. * @return True if such item is found.
*/ */
private boolean findMatchingItem(final int x, final int y, final int snakeIndex, private boolean findMatchingItem(final int x, final int y, final int snakeIndex,

View File

@ -58,6 +58,8 @@ public class ObservableList<TItem> extends ObservableCollection<TItem> implement
private SameItemsPredicate<TItem> sameItemsPredicate; private SameItemsPredicate<TItem> sameItemsPredicate;
@Nullable @Nullable
private ChangePayloadProducer<TItem> changePayloadProducer; private ChangePayloadProducer<TItem> changePayloadProducer;
@Nullable
private ObservableList<TItem> diffUtilsSource;
public ObservableList() { public ObservableList() {
super(); super();
@ -227,9 +229,19 @@ public class ObservableList<TItem> extends ObservableCollection<TItem> implement
synchronized (this) { synchronized (this) {
final List<TItem> oldList = new ArrayList<>(items); final List<TItem> oldList = new ArrayList<>(items);
final List<TItem> newList = new ArrayList<>(newItems); final List<TItem> newList = new ArrayList<>(newItems);
final CollectionsChangesCalculator<TItem> calculator = sameItemsPredicate != null final CollectionsChangesCalculator<TItem> calculator;
? new DiffCollectionsChangesCalculator<>(oldList, newList, detectMoves, sameItemsPredicate, changePayloadProducer) if (diffUtilsSource != null) {
: new DefaultCollectionsChangesCalculator<>(oldList, newList, false); if (diffUtilsSource.sameItemsPredicate != null) {
calculator = new DiffCollectionsChangesCalculator<>(oldList, newList,
diffUtilsSource.detectMoves, diffUtilsSource.sameItemsPredicate, diffUtilsSource.changePayloadProducer);
} else {
calculator = new DefaultCollectionsChangesCalculator<>(oldList, newList, false);
}
} else if (sameItemsPredicate != null) {
calculator = new DiffCollectionsChangesCalculator<>(oldList, newList, detectMoves, sameItemsPredicate, changePayloadProducer);
} else {
calculator = new DefaultCollectionsChangesCalculator<>(oldList, newList, false);
}
items.clear(); items.clear();
items.addAll(newItems); items.addAll(newItems);
notifyAboutChanges(calculator.calculateInsertedItems(), calculator.calculateRemovedItems(), calculator.calculateChanges()); notifyAboutChanges(calculator.calculateInsertedItems(), calculator.calculateRemovedItems(), calculator.calculateChanges());
@ -271,7 +283,16 @@ public class ObservableList<TItem> extends ObservableCollection<TItem> implement
* @return true if diff utils is enabled. * @return true if diff utils is enabled.
*/ */
public boolean diffUtilsIsEnabled() { public boolean diffUtilsIsEnabled() {
return sameItemsPredicate != null; return diffUtilsSource != null ? diffUtilsSource.diffUtilsIsEnabled() : sameItemsPredicate != null;
}
/**
* Sets observableCollection as a source of diff utils parameters;
*
* @param diffUtilsSource Source of diff utils parameters.
*/
public void setDiffUtilsSource(@Nullable final ObservableList<TItem> diffUtilsSource) {
this.diffUtilsSource = diffUtilsSource;
} }
/** /**