From c079bbb6999291a89d7c6a9a6fbe7457b5789e1f Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 20 Jun 2017 22:30:22 +0200 Subject: [PATCH] use MyScalableRecyclerView from Commons --- app/build.gradle | 2 +- .../filemanager/fragments/ItemsFragment.kt | 22 +++++++++---------- app/src/main/res/layout/items_fragment.xml | 2 +- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 5f20c3b6..84eec3b8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -32,7 +32,7 @@ android { } dependencies { - compile 'com.simplemobiletools:commons:2.21.4' + compile 'com.simplemobiletools:commons:2.21.7' 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/fragments/ItemsFragment.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/fragments/ItemsFragment.kt index bf5e4ee3..a8c5e6bc 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/fragments/ItemsFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/fragments/ItemsFragment.kt @@ -5,6 +5,7 @@ import android.content.Intent import android.net.Uri import android.os.Bundle import android.os.Parcelable +import android.support.v4.app.Fragment import android.support.v7.widget.LinearLayoutManager import android.view.LayoutInflater import android.view.View @@ -13,7 +14,6 @@ import android.webkit.MimeTypeMap import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.models.FileDirItem import com.simplemobiletools.commons.views.RecyclerViewDivider -import com.simplemobiletools.filemanager.Config import com.simplemobiletools.filemanager.PATH import com.simplemobiletools.filemanager.R import com.simplemobiletools.filemanager.SCROLL_STATE @@ -26,15 +26,14 @@ import kotlinx.android.synthetic.main.items_fragment.view.* import java.io.File import java.util.* -class ItemsFragment : android.support.v4.app.Fragment(), ItemsAdapter.ItemOperationsListener { +class ItemsFragment : Fragment(), ItemsAdapter.ItemOperationsListener { private var mListener: ItemInteractionListener? = null private var mStoredTextColor = 0 + private var mShowHidden = false + private var mItems = ArrayList() - lateinit var mItems: ArrayList - lateinit var mConfig: Config lateinit var fragmentView: View - private var mShowHidden = false var mPath = "" override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View { @@ -44,9 +43,7 @@ class ItemsFragment : android.support.v4.app.Fragment(), ItemsAdapter.ItemOperat override fun onViewCreated(view: View?, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - mConfig = context.config - mShowHidden = mConfig.showHidden - mItems = ArrayList() + mShowHidden = context.config.showHidden fillItems() items_swipe_refresh.setOnRefreshListener({ fillItems() }) @@ -55,15 +52,16 @@ class ItemsFragment : android.support.v4.app.Fragment(), ItemsAdapter.ItemOperat override fun onResume() { super.onResume() - if (mShowHidden != mConfig.showHidden) { + val config = context.config + if (mShowHidden != config.showHidden) { mShowHidden = !mShowHidden fillItems() } context.updateTextColors(items_holder) - if (mStoredTextColor != context.config.textColor) { + if (mStoredTextColor != config.textColor) { mItems = ArrayList() fillItems() - mStoredTextColor = context.config.textColor + mStoredTextColor = config.textColor } } @@ -76,7 +74,7 @@ class ItemsFragment : android.support.v4.app.Fragment(), ItemsAdapter.ItemOperat mPath = arguments.getString(PATH) getItems(mPath) { val newItems = it - FileDirItem.sorting = mConfig.getFolderSorting(mPath) + FileDirItem.sorting = context.config.getFolderSorting(mPath) newItems.sort() fragmentView.apply { diff --git a/app/src/main/res/layout/items_fragment.xml b/app/src/main/res/layout/items_fragment.xml index e1027a6c..dd072003 100644 --- a/app/src/main/res/layout/items_fragment.xml +++ b/app/src/main/res/layout/items_fragment.xml @@ -16,7 +16,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> -