Merge pull request #35 from TouchInstinct/idea_formatting
idea formatting
This commit is contained in:
commit
5e9bfc701c
|
|
@ -18,5 +18,5 @@ android {
|
||||||
dependencies {
|
dependencies {
|
||||||
provided 'com.android.support:support-annotations:25.4.0'
|
provided 'com.android.support:support-annotations:25.4.0'
|
||||||
provided 'io.reactivex.rxjava2:rxandroid:2.0.1'
|
provided 'io.reactivex.rxjava2:rxandroid:2.0.1'
|
||||||
provided 'io.reactivex.rxjava2:rxjava:2.1.1'
|
provided 'io.reactivex.rxjava2:rxjava:2.1.2'
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,13 +50,13 @@ import java.util.List;
|
||||||
* and the cost of your comparison methods. Below are some average run times for reference:
|
* and the cost of your comparison methods. Below are some average run times for reference:
|
||||||
* (The areSame list is composed of random UUID Strings and the tests are run on Nexus 5X with M)
|
* (The areSame list is composed of random UUID Strings and the tests are run on Nexus 5X with M)
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>100 items and 10 modifications: avg: 0.39 ms, median: 0.35 ms
|
* <li>100 items and 10 modifications: avg: 0.39 ms, median: 0.35 ms
|
||||||
* <li>100 items and 100 modifications: 3.82 ms, median: 3.75 ms
|
* <li>100 items and 100 modifications: 3.82 ms, median: 3.75 ms
|
||||||
* <li>100 items and 100 modifications without moves: 2.09 ms, median: 2.06 ms
|
* <li>100 items and 100 modifications without moves: 2.09 ms, median: 2.06 ms
|
||||||
* <li>1000 items and 50 modifications: avg: 4.67 ms, median: 4.59 ms
|
* <li>1000 items and 50 modifications: avg: 4.67 ms, median: 4.59 ms
|
||||||
* <li>1000 items and 50 modifications without moves: avg: 3.59 ms, median: 3.50 ms
|
* <li>1000 items and 50 modifications without moves: avg: 3.59 ms, median: 3.50 ms
|
||||||
* <li>1000 items and 200 modifications: 27.07 ms, median: 26.92 ms
|
* <li>1000 items and 200 modifications: 27.07 ms, median: 26.92 ms
|
||||||
* <li>1000 items and 200 modifications without moves: 13.54 ms, median: 13.36 ms
|
* <li>1000 items and 200 modifications without moves: 13.54 ms, median: 13.36 ms
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* <p>Due to implementation constraints, the max size of the list can be 2^26.
|
* <p>Due to implementation constraints, the max size of the list can be 2^26.
|
||||||
|
|
@ -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.
|
||||||
*/
|
*/
|
||||||
|
|
@ -98,9 +97,8 @@ public class DiffUtil {
|
||||||
* positions), you can disable move detection which takes <code>O(N^2)</code> time where
|
* positions), you can disable move detection which takes <code>O(N^2)</code> time where
|
||||||
* N is the number of added, moved, removed items.
|
* N is the number of added, moved, removed items.
|
||||||
*
|
*
|
||||||
* @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.
|
||||||
*/
|
*/
|
||||||
|
|
@ -185,7 +183,7 @@ public class DiffUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Snake diffPartial(Callback cb, int startOld, int endOld,
|
private static Snake diffPartial(Callback cb, int startOld, int endOld,
|
||||||
int startNew, int endNew, int[] forward, int[] backward, int kOffset) {
|
int startNew, int endNew, int[] forward, int[] backward, int kOffset) {
|
||||||
final int oldSize = endOld - startOld;
|
final int oldSize = endOld - startOld;
|
||||||
final int newSize = endNew - startNew;
|
final int newSize = endNew - startNew;
|
||||||
|
|
||||||
|
|
@ -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
|
||||||
|
|
@ -453,14 +450,14 @@ public class DiffUtil {
|
||||||
private final boolean mDetectMoves;
|
private final boolean mDetectMoves;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param callback The callback that was used to calculate the diff
|
* @param callback The callback that was used to calculate the diff
|
||||||
* @param snakes The list of Myers' snakes
|
* @param snakes The list of Myers' snakes
|
||||||
* @param oldItemStatuses An int[] that can be re-purposed to keep metadata
|
* @param oldItemStatuses An int[] that can be re-purposed to keep metadata
|
||||||
* @param newItemStatuses An int[] that can be re-purposed to keep metadata
|
* @param newItemStatuses An int[] that can be re-purposed to keep metadata
|
||||||
* @param detectMoves True if this DiffResult will try to detect moved items
|
* @param detectMoves True if this DiffResult will try to detect moved items
|
||||||
*/
|
*/
|
||||||
DiffResult(Callback callback, List<Snake> snakes, int[] oldItemStatuses,
|
DiffResult(Callback callback, List<Snake> snakes, int[] oldItemStatuses,
|
||||||
int[] newItemStatuses, boolean detectMoves) {
|
int[] newItemStatuses, boolean detectMoves) {
|
||||||
mSnakes = snakes;
|
mSnakes = snakes;
|
||||||
mOldItemStatuses = oldItemStatuses;
|
mOldItemStatuses = oldItemStatuses;
|
||||||
mNewItemStatuses = newItemStatuses;
|
mNewItemStatuses = newItemStatuses;
|
||||||
|
|
@ -556,15 +553,14 @@ public class DiffUtil {
|
||||||
* Finds a matching item that is before the given coordinates in the matrix
|
* Finds a matching item that is before the given coordinates in the matrix
|
||||||
* (before : left and above).
|
* (before : left and above).
|
||||||
*
|
*
|
||||||
* @param x The x position in the matrix (position in the old list)
|
* @param x The x position in the matrix (position in the old list)
|
||||||
* @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,
|
||||||
final boolean removal) {
|
final boolean removal) {
|
||||||
final int myItemPos;
|
final int myItemPos;
|
||||||
int curX;
|
int curX;
|
||||||
int curY;
|
int curY;
|
||||||
|
|
@ -664,7 +660,7 @@ public class DiffUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static PostponedUpdate removePostponedUpdate(List<PostponedUpdate> updates,
|
private static PostponedUpdate removePostponedUpdate(List<PostponedUpdate> updates,
|
||||||
int pos, boolean removal) {
|
int pos, boolean removal) {
|
||||||
for (int i = updates.size() - 1; i >= 0; i--) {
|
for (int i = updates.size() - 1; i >= 0; i--) {
|
||||||
final PostponedUpdate update = updates.get(i);
|
final PostponedUpdate update = updates.get(i);
|
||||||
if (update.posInOwnerList == pos && update.removal == removal) {
|
if (update.posInOwnerList == pos && update.removal == removal) {
|
||||||
|
|
@ -680,7 +676,7 @@ public class DiffUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void dispatchAdditions(List<PostponedUpdate> postponedUpdates,
|
private void dispatchAdditions(List<PostponedUpdate> postponedUpdates,
|
||||||
ListUpdateCallback updateCallback, int start, int count, int globalIndex) {
|
ListUpdateCallback updateCallback, int start, int count, int globalIndex) {
|
||||||
if (!mDetectMoves) {
|
if (!mDetectMoves) {
|
||||||
updateCallback.onInserted(start, count);
|
updateCallback.onInserted(start, count);
|
||||||
return;
|
return;
|
||||||
|
|
@ -720,7 +716,7 @@ public class DiffUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void dispatchRemovals(List<PostponedUpdate> postponedUpdates,
|
private void dispatchRemovals(List<PostponedUpdate> postponedUpdates,
|
||||||
ListUpdateCallback updateCallback, int start, int count, int globalIndex) {
|
ListUpdateCallback updateCallback, int start, int count, int globalIndex) {
|
||||||
if (!mDetectMoves) {
|
if (!mDetectMoves) {
|
||||||
updateCallback.onRemoved(start, count);
|
updateCallback.onRemoved(start, count);
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -98,8 +98,8 @@ public abstract class ObservableCollection<TItem> {
|
||||||
* Method to notify that collection have changed.
|
* Method to notify that collection have changed.
|
||||||
*
|
*
|
||||||
* @param insertedItems Collection of inserted items;
|
* @param insertedItems Collection of inserted items;
|
||||||
* @param removedItems Collection of removed items;
|
* @param removedItems Collection of removed items;
|
||||||
* @param changes Changes of collection.
|
* @param changes Changes of collection.
|
||||||
*/
|
*/
|
||||||
protected void notifyAboutChanges(@NonNull final List<TItem> insertedItems,
|
protected void notifyAboutChanges(@NonNull final List<TItem> insertedItems,
|
||||||
@NonNull final List<TItem> removedItems,
|
@NonNull final List<TItem> removedItems,
|
||||||
|
|
|
||||||
|
|
@ -246,8 +246,8 @@ public class ObservableList<TItem> extends ObservableCollection<TItem> implement
|
||||||
/**
|
/**
|
||||||
* Enable diff utils algorithm in collection changes.
|
* Enable diff utils algorithm in collection changes.
|
||||||
*
|
*
|
||||||
* @param detectMoves The flag that determines whether the {@link Change.Moved} changes will be generated or not;
|
* @param detectMoves The flag that determines whether the {@link Change.Moved} changes will be generated or not;
|
||||||
* @param sameItemsPredicate Predicate for the determination of the same elements;
|
* @param sameItemsPredicate Predicate for the determination of the same elements;
|
||||||
* @param changePayloadProducer Function that calculate change payload when items the same but contents are different.
|
* @param changePayloadProducer Function that calculate change payload when items the same but contents are different.
|
||||||
*/
|
*/
|
||||||
public void enableDiffUtils(final boolean detectMoves,
|
public void enableDiffUtils(final boolean detectMoves,
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ public interface Converter<TObject, TStoreObject> {
|
||||||
*
|
*
|
||||||
* @param objectType Type of object;
|
* @param objectType Type of object;
|
||||||
* @param storeObjectType Type of store object allowed to store;
|
* @param storeObjectType Type of store object allowed to store;
|
||||||
* @param object Object to be converted to store object;
|
* @param object Object to be converted to store object;
|
||||||
* @return Object that is allowed to store into specific {@link Store};
|
* @return Object that is allowed to store into specific {@link Store};
|
||||||
* @throws ConversionException Exception during conversion. Usually it indicates illegal state.
|
* @throws ConversionException Exception during conversion. Usually it indicates illegal state.
|
||||||
*/
|
*/
|
||||||
|
|
@ -51,7 +51,7 @@ public interface Converter<TObject, TStoreObject> {
|
||||||
*
|
*
|
||||||
* @param objectType Type of object;
|
* @param objectType Type of object;
|
||||||
* @param storeObjectType Type of store object allowed to store;
|
* @param storeObjectType Type of store object allowed to store;
|
||||||
* @param storeObject Object from specific {@link Store};
|
* @param storeObject Object from specific {@link Store};
|
||||||
* @return Object converted from store object;
|
* @return Object converted from store object;
|
||||||
* @throws ConversionException Exception during conversion. Usually it indicates illegal state.
|
* @throws ConversionException Exception during conversion. Usually it indicates illegal state.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ import ru.touchin.roboswag.core.utils.ObjectUtils;
|
||||||
* Both arguments are not null.
|
* Both arguments are not null.
|
||||||
* Note that if you want to save this pair in state, you need make TFirst and TSecond Serializable too.
|
* Note that if you want to save this pair in state, you need make TFirst and TSecond Serializable too.
|
||||||
*
|
*
|
||||||
* @param <TFirst> type of the first nonnull argument.
|
* @param <TFirst> type of the first nonnull argument.
|
||||||
* @param <TSecond> type of the second nonnull argument.
|
* @param <TSecond> type of the second nonnull argument.
|
||||||
*/
|
*/
|
||||||
public class NonNullPair<TFirst, TSecond> implements Serializable {
|
public class NonNullPair<TFirst, TSecond> implements Serializable {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue