Skip to content
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: reverse listing of saved badges #570

Merged
merged 4 commits into from
Dec 26, 2019
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ class StorageUtils(val context: Context) {

externalStorageDir?.let {
val files = File(externalStorageDir).listFiles() ?: return list
files.sortWith(Comparator<File> { a, b ->
when {
a.lastModified() - b.lastModified() > 0 -> 1
a.lastModified() - b.lastModified() < 0 -> -1
else -> 0
}
Copy link
Member

@iamareebjamal iamareebjamal Dec 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return a.lastModified() - b.lastModified()

})
for (i in files.indices) {
if (getFileExtension(files[i].name) == badgeExt) {
val json = files[i].readText()
Expand All @@ -59,7 +66,7 @@ class StorageUtils(val context: Context) {
}
}
}
return list
return list.asReversed()
}

private fun getFileExtension(name: String): String {
Expand Down