-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix upload list comparator to make it respect the comparator contract #4245
Fix upload list comparator to make it respect the comparator contract #4245
Conversation
5f52998
to
6541907
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While being here, I'm sure we can apply Scout's Rule #1
- leave the place cleaner than we found it. ;)
Also, if possible, could we write the test in Kotlin? The goal is to accelerate and encourage it's adoption, as Kotlin is de facto primary development language for Android now.
src/main/java/com/owncloud/android/ui/adapter/UploadListAdapter.java
Outdated
Show resolved
Hide resolved
src/test/java/com/owncloud/android/ui/adapter/UploadListAdapterTest.java
Outdated
Show resolved
Hide resolved
src/test/java/com/owncloud/android/ui/adapter/UploadListAdapterTest.java
Outdated
Show resolved
Hide resolved
965bcad
to
afd4315
Compare
Codecov Report
@@ Coverage Diff @@
## master #4245 +/- ##
============================================
+ Coverage 15.99% 16.05% +0.05%
Complexity 1 1
============================================
Files 340 341 +1
Lines 31155 31158 +3
Branches 4424 4421 -3
============================================
+ Hits 4983 5002 +19
+ Misses 25313 25295 -18
- Partials 859 861 +2
|
IT test failed: https://www.kaminsky.me/nc-dev/android-integrationTests/10057 |
88e6465
to
f19f5f9
Compare
IT test failed: https://www.kaminsky.me/nc-dev/android-integrationTests/10059 |
src/main/java/com/owncloud/android/ui/adapter/UploadListAdapter.java
Outdated
Show resolved
Hide resolved
src/test/java/com/owncloud/android/ui/adapter/UploadListAdapterTest.kt
Outdated
Show resolved
Hide resolved
src/main/java/com/owncloud/android/ui/adapter/UploadListAdapter.java
Outdated
Show resolved
Hide resolved
src/test/java/com/owncloud/android/ui/adapter/UploadListAdapterTest.kt
Outdated
Show resolved
Hide resolved
src/test/java/com/owncloud/android/ui/adapter/UploadListAdapterTest.kt
Outdated
Show resolved
Hide resolved
Yes this is possible that nobody hit that path on an old phone. The app will compile without trouble, but it will fail at runtime.
@tobiasKaminsky I believe the app is tested on API 14. Is it possible that test is not covering this path?
…On July 25, 2019 9:38:18 PM UTC, Daniele Fognini ***@***.***> wrote:
fogninid commented on this pull request.
> @@ -681,6 +682,72 @@ private void openFileWithDefault(String
localPath) {
CURRENT, FINISHED, FAILED
}
+ /**
+ * sort uploads by (status, uploadingNow, updateTime, uploadId).
+ *
+ * Lower language level version of:
+ *
+ * Comparator.nullsFirst(
+ * Comparator.comparing(OCUpload::getFixedUploadStatus)
+ *
.thenComparing(Comparator.comparing(OCUpload::isFixedUploadingNow).reversed())
+ *
.thenComparing(Comparator.comparing(OCUpload::getFixedUploadEndTimeStamp).reversed())
+ * .thenComparing(OCUpload::getFixedUploadId))
+ *
+ */
+ @VisibleForTesting
+ static Comparator<OCUpload> uploadListComparator = new
Comparator<OCUpload>() {
My question why is it working now!
It was changed in master 6 months ago:
cb71348#diff-24801376b7c7edeb4e3089df542a4de8R676
I assume that nobody is actually using such old devices anymore or
caring to update them.
I will change it to use the older version, but you should probably
consider to drop support or at least try to compile with such old sdk
versions.
--
You are receiving this because you commented.
Reply to this email directly or view it on GitHub:
#4245 (comment)
|
6f8aeb3
to
54529f9
Compare
54529f9
to
00aacf1
Compare
Signed-off-by: Daniele Fognini <dfogni@gmail.com>
00aacf1
to
51ff5c3
Compare
APK file: https://www.kaminsky.me/nc-dev/android-artifacts/10214.apk |
Codacy281Lint
SpotBugs (new)
SpotBugs (master)
|
@nextcloud-android-bot well done for deleting the unresolved conversation /s I added the |
Ok, let's go with the old impl and not spend more time massaging it into unreachable perfection. Thanks. Awesome work with valuable analysis as a byproduct. |
Thanks for your awesome work! |
b36067d Merge pull request #4294 from AlexNi245/#2216-activity-data-divers-design 9624019 activity header has now the same font size as a activity element fa11565 fixed issue Avoid reassigning parameters such as 'itemPosition' 5a3db5e replace do while loop in getHeaderPositionForItem with while loop 1dd2a5a change naming of Canvas c to Canvas canvas f4e964e change class name of ActivityListItemDecoration to StickyHeaderItemDecoration, which is more generic 52a7ffe add license text 6ffa9d0 remove duplicate entry of setContentView cdd5d38 add getHeaderPositionForItem unit test 0ac5a8b add static import for com.owncloud.android.lib.resources.activities.model.Activity; 4ea9667 unit test for isHeader(int pos) b61f9e0 format ActivityListAdapter 9012f43 set visibility from ActivityViewHeaderHolder back to protected 7a30070 remove unnecessary TAG field and replace nested if statement with && to fix codeacy-bot issues a26a895 apply changes to java doc c41dd38 optimize imports b4764f7 remove unnecessary files 792a6b9 finish implementation of sticky header implementation. This feature was created according to the this implementation : https://stackoverflow.com/questions/32949971/how-can-i-make-sticky-headers-in-recyclerview-without-external-lib 13e7aff increase height of header element and set backgroundcolor to white a184345 first implementation of sticky header logic. cd3d8dc start to implement sticky header behavior 259e106 Merge pull request #4355 from nextcloud/drawer caf1842 drawer: show only server address cb7d4a3 revert to old image (#4356) 7e44fec revert to old image f7c4eec Merge pull request #4345 from nextcloud/push a3fda5a no need to use owncloudClient 9a023c6 Check if app is excluded from battery optimization (#3589) 527c5db Use conscrypt (#4314) 6014e90 use conscrypt 5373660 Provide a banal 'paste' postmessage implementation. (#4189) 68cebf8 revert DeviceModule back to Kotlin 969ce78 Drone: update FindBugs results to reflect reduced error/warning count [skip ci] f26095f Merge pull request #4245 from fogninid/fixUploadListComparator e72a789 show on special vendors "disable power check" in auto upload menu - tint button - change logic when to show battery warning c8173c3 Use reloading on photo view (#2250) c38dcf3 Delete temp file on receive external files (#4349) c155edf Merge pull request #4347 from nextcloud/blacklistThumbnail a03ff84 daily dev 20190820
the current comparator implementation is correct only if there is only one "isUpdating" file in the array.
This can happen for example as a result of #4244, or if concurrent uploads will be impelmented.
Change the implementation to make it follow the simpler Comparator.thenComparing pattern