From 2f4119faac8eaee98217175a23c9e9dec7dadb96 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 19 Mar 2017 11:50:57 +0100 Subject: [PATCH] adding file sorting --- app/build.gradle | 2 +- .../filemanager/activities/MainActivity.kt | 6 ++++- .../filemanager/fragments/ItemsFragment.kt | 27 ++++++++++--------- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 17363997..4ac0fcb3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -32,7 +32,7 @@ android { } dependencies { - compile 'com.simplemobiletools:commons:2.13.5' + compile 'com.simplemobiletools:commons:2.13.6' compile 'com.bignerdranch.android:recyclerview-multiselect:0.2' compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" } diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/activities/MainActivity.kt index 6fd7d4cf..99279415 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/activities/MainActivity.kt @@ -140,7 +140,11 @@ class MainActivity : SimpleActivity(), ItemsFragment.ItemInteractionListener, Br private fun showSortingDialog() { ChangeSortingDialog(this, currentPath) { - + if (latestFragment != null) { + latestFragment!!.fillItems() + } else { + openPath(currentPath) + } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/fragments/ItemsFragment.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/fragments/ItemsFragment.kt index c43e9178..eea9451a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/fragments/ItemsFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/fragments/ItemsFragment.kt @@ -72,25 +72,26 @@ class ItemsFragment : android.support.v4.app.Fragment(), ItemsAdapter.ItemOperat mStoredTextColor = context.config.textColor } - private fun fillItems() { + fun fillItems() { mPath = arguments.getString(PATH) getItems(mPath) { val newItems = it - Collections.sort(newItems) + FileDirItem.sorting = mConfig.getFolderSorting(mPath) + newItems.sort() fragmentView.apply { - items_swipe_refresh.isRefreshing = false - if (newItems.hashCode() == mItems.hashCode()) { - return@getItems - } - - mItems = newItems - - val adapter = ItemsAdapter(activity as SimpleActivity, mItems, this@ItemsFragment) { - itemClicked(it) - } - activity.runOnUiThread { + items_swipe_refresh.isRefreshing = false + if (newItems.hashCode() == mItems.hashCode()) { + return@runOnUiThread + } + + mItems = newItems + + val adapter = ItemsAdapter(activity as SimpleActivity, mItems, this@ItemsFragment) { + itemClicked(it) + } + val currAdapter = items_list.adapter if (currAdapter == null) { items_list.apply {