adding file sorting

This commit is contained in:
tibbi 2017-03-19 11:50:57 +01:00
parent 12d234d0d5
commit 2f4119faac
3 changed files with 20 additions and 15 deletions

View File

@ -32,7 +32,7 @@ android {
} }
dependencies { dependencies {
compile 'com.simplemobiletools:commons:2.13.5' compile 'com.simplemobiletools:commons:2.13.6'
compile 'com.bignerdranch.android:recyclerview-multiselect:0.2' compile 'com.bignerdranch.android:recyclerview-multiselect:0.2'
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
} }

View File

@ -140,7 +140,11 @@ class MainActivity : SimpleActivity(), ItemsFragment.ItemInteractionListener, Br
private fun showSortingDialog() { private fun showSortingDialog() {
ChangeSortingDialog(this, currentPath) { ChangeSortingDialog(this, currentPath) {
if (latestFragment != null) {
latestFragment!!.fillItems()
} else {
openPath(currentPath)
}
} }
} }

View File

@ -72,16 +72,18 @@ class ItemsFragment : android.support.v4.app.Fragment(), ItemsAdapter.ItemOperat
mStoredTextColor = context.config.textColor mStoredTextColor = context.config.textColor
} }
private fun fillItems() { fun fillItems() {
mPath = arguments.getString(PATH) mPath = arguments.getString(PATH)
getItems(mPath) { getItems(mPath) {
val newItems = it val newItems = it
Collections.sort(newItems) FileDirItem.sorting = mConfig.getFolderSorting(mPath)
newItems.sort()
fragmentView.apply { fragmentView.apply {
activity.runOnUiThread {
items_swipe_refresh.isRefreshing = false items_swipe_refresh.isRefreshing = false
if (newItems.hashCode() == mItems.hashCode()) { if (newItems.hashCode() == mItems.hashCode()) {
return@getItems return@runOnUiThread
} }
mItems = newItems mItems = newItems
@ -90,7 +92,6 @@ class ItemsFragment : android.support.v4.app.Fragment(), ItemsAdapter.ItemOperat
itemClicked(it) itemClicked(it)
} }
activity.runOnUiThread {
val currAdapter = items_list.adapter val currAdapter = items_list.adapter
if (currAdapter == null) { if (currAdapter == null) {
items_list.apply { items_list.apply {