rewriting the Included Folders to recyclerview too
This commit is contained in:
parent
d596829fd6
commit
69bc80fa4e
5 changed files with 36 additions and 61 deletions
|
@ -7,26 +7,27 @@ import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
|||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
|
||||
import com.simplemobiletools.gallery.R
|
||||
import com.simplemobiletools.gallery.adapters.ExcludedFoldersAdapter
|
||||
import com.simplemobiletools.gallery.adapters.ManageFoldersAdapter
|
||||
import com.simplemobiletools.gallery.extensions.config
|
||||
import kotlinx.android.synthetic.main.activity_excluded_folders.*
|
||||
import kotlinx.android.synthetic.main.activity_manage_folders.*
|
||||
|
||||
class ExcludedFoldersActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_excluded_folders)
|
||||
setContentView(R.layout.activity_manage_folders)
|
||||
updateExcludedFolders()
|
||||
}
|
||||
|
||||
private fun updateExcludedFolders() {
|
||||
val folders = ArrayList<String>()
|
||||
config.excludedFolders.mapTo(folders, { it })
|
||||
manage_excluded_folders_placeholder.beVisibleIf(folders.isEmpty())
|
||||
manage_excluded_folders_placeholder.setTextColor(config.textColor)
|
||||
manage_folders_placeholder.text = getString(R.string.excluded_activity_placeholder)
|
||||
manage_folders_placeholder.beVisibleIf(folders.isEmpty())
|
||||
manage_folders_placeholder.setTextColor(config.textColor)
|
||||
|
||||
val adapter = ExcludedFoldersAdapter(this, folders, this, manage_exclude_folders_list) {}
|
||||
val adapter = ManageFoldersAdapter(this, folders, true, this, manage_folders_list) {}
|
||||
adapter.setupDragListener(true)
|
||||
manage_exclude_folders_list.adapter = adapter
|
||||
manage_folders_list.adapter = adapter
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
||||
|
|
|
@ -6,32 +6,29 @@ import android.view.MenuItem
|
|||
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
||||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||
import com.simplemobiletools.commons.extensions.scanPath
|
||||
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
|
||||
import com.simplemobiletools.gallery.R
|
||||
import com.simplemobiletools.gallery.adapters.ManageFoldersAdapter
|
||||
import com.simplemobiletools.gallery.extensions.config
|
||||
import kotlinx.android.synthetic.main.activity_included_folders.*
|
||||
import kotlinx.android.synthetic.main.item_manage_folder.view.*
|
||||
import kotlinx.android.synthetic.main.activity_manage_folders.*
|
||||
|
||||
class IncludedFoldersActivity : SimpleActivity() {
|
||||
class IncludedFoldersActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_included_folders)
|
||||
setContentView(R.layout.activity_manage_folders)
|
||||
updateIncludedFolders()
|
||||
}
|
||||
|
||||
private fun updateIncludedFolders() {
|
||||
included_folders_holder.removeAllViews()
|
||||
val folders = config.includedFolders
|
||||
included_folders_placeholder.beVisibleIf(folders.isEmpty())
|
||||
included_folders_placeholder.setTextColor(config.textColor)
|
||||
val folders = ArrayList<String>()
|
||||
config.includedFolders.mapTo(folders, { it })
|
||||
manage_folders_placeholder.text = getString(R.string.included_activity_placeholder)
|
||||
manage_folders_placeholder.beVisibleIf(folders.isEmpty())
|
||||
manage_folders_placeholder.setTextColor(config.textColor)
|
||||
|
||||
for (folder in folders) {
|
||||
layoutInflater.inflate(R.layout.item_manage_folder, null, false).apply {
|
||||
manage_folder_title.apply {
|
||||
text = folder
|
||||
setTextColor(config.textColor)
|
||||
}
|
||||
}
|
||||
}
|
||||
val adapter = ManageFoldersAdapter(this, folders, false, this, manage_folders_list) {}
|
||||
adapter.setupDragListener(true)
|
||||
manage_folders_list.adapter = adapter
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
||||
|
@ -47,6 +44,10 @@ class IncludedFoldersActivity : SimpleActivity() {
|
|||
return true
|
||||
}
|
||||
|
||||
override fun refreshItems() {
|
||||
updateIncludedFolders()
|
||||
}
|
||||
|
||||
private fun addIncludedFolder() {
|
||||
FilePickerDialog(this, pickFile = false, showHidden = config.shouldShowHidden) {
|
||||
config.addIncludedFolder(it)
|
||||
|
|
|
@ -14,8 +14,8 @@ import com.simplemobiletools.gallery.extensions.config
|
|||
import kotlinx.android.synthetic.main.item_manage_folder.view.*
|
||||
import java.util.*
|
||||
|
||||
class ExcludedFoldersAdapter(activity: BaseSimpleActivity, var folders: ArrayList<String>, val listener: RefreshRecyclerViewListener?, recyclerView: MyRecyclerView,
|
||||
itemClick: (Any) -> Unit) : MyRecyclerViewAdapter(activity, recyclerView, itemClick) {
|
||||
class ManageFoldersAdapter(activity: BaseSimpleActivity, var folders: ArrayList<String>, val isShowingExcludedFolders: Boolean, val listener: RefreshRecyclerViewListener?,
|
||||
recyclerView: MyRecyclerView, itemClick: (Any) -> Unit) : MyRecyclerViewAdapter(activity, recyclerView, itemClick) {
|
||||
|
||||
private val config = activity.config
|
||||
|
||||
|
@ -74,7 +74,11 @@ class ExcludedFoldersAdapter(activity: BaseSimpleActivity, var folders: ArrayLis
|
|||
removeFolders.add(folder)
|
||||
notifyItemRemoved(it)
|
||||
itemViews.put(it, null)
|
||||
config.removeExcludedFolder(folder)
|
||||
if (isShowingExcludedFolders) {
|
||||
config.removeExcludedFolder(folder)
|
||||
} else {
|
||||
config.removeIncludedFolder(folder)
|
||||
}
|
||||
}
|
||||
|
||||
folders.removeAll(removeFolders)
|
|
@ -1,30 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/included_folders_scrollview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/include_folders_wrapper"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/included_folders_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/included_folders_placeholder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal"
|
||||
android:paddingLeft="@dimen/big_margin"
|
||||
android:paddingRight="@dimen/big_margin"
|
||||
android:paddingTop="@dimen/activity_margin"
|
||||
android:text="@string/included_activity_placeholder"
|
||||
android:visibility="gone"/>
|
||||
</RelativeLayout>
|
||||
</ScrollView>
|
|
@ -1,21 +1,20 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/manage_exclude_folders_wrapper"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/manage_folders_wrapper"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyRecyclerView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/manage_exclude_folders_list"
|
||||
android:id="@+id/manage_folders_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
app:layoutManager="android.support.v7.widget.LinearLayoutManager"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/manage_excluded_folders_placeholder"
|
||||
android:id="@+id/manage_folders_placeholder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal"
|
Loading…
Reference in a new issue