diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt index 6f5abe839..09ee897f1 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt @@ -11,6 +11,8 @@ import android.view.Menu import android.view.View import android.view.ViewGroup import android.widget.RelativeLayout +import androidx.recyclerview.widget.ItemTouchHelper +import androidx.recyclerview.widget.RecyclerView import com.bumptech.glide.Glide import com.google.gson.Gson import com.simplemobiletools.commons.activities.BaseSimpleActivity @@ -18,6 +20,9 @@ import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter import com.simplemobiletools.commons.dialogs.* import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.helpers.* +import com.simplemobiletools.commons.interfaces.ItemMoveCallback +import com.simplemobiletools.commons.interfaces.ItemTouchHelperContract +import com.simplemobiletools.commons.interfaces.StartReorderDragListener import com.simplemobiletools.commons.models.FileDirItem import com.simplemobiletools.commons.views.FastScroller import com.simplemobiletools.commons.views.MyRecyclerView @@ -31,6 +36,7 @@ import com.simplemobiletools.gallery.pro.helpers.* import com.simplemobiletools.gallery.pro.interfaces.DirectoryOperationsListener import com.simplemobiletools.gallery.pro.models.AlbumCover import com.simplemobiletools.gallery.pro.models.Directory +import kotlinx.android.synthetic.main.directory_item_grid_square.view.* import kotlinx.android.synthetic.main.directory_item_grid_square.view.dir_check import kotlinx.android.synthetic.main.directory_item_grid_square.view.dir_location import kotlinx.android.synthetic.main.directory_item_grid_square.view.dir_lock @@ -38,11 +44,14 @@ import kotlinx.android.synthetic.main.directory_item_grid_square.view.dir_name import kotlinx.android.synthetic.main.directory_item_grid_square.view.dir_pin import kotlinx.android.synthetic.main.directory_item_grid_square.view.dir_thumbnail import kotlinx.android.synthetic.main.directory_item_list.view.* +import kotlinx.android.synthetic.main.directory_item_list.view.dir_drag_handle +import kotlinx.android.synthetic.main.directory_item_list.view.dir_holder +import kotlinx.android.synthetic.main.directory_item_list.view.photo_cnt import java.io.File class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList, val listener: DirectoryOperationsListener?, recyclerView: MyRecyclerView, val isPickIntent: Boolean, fastScroller: FastScroller? = null, itemClick: (Any) -> Unit) : - MyRecyclerViewAdapter(activity, recyclerView, fastScroller, itemClick) { + MyRecyclerViewAdapter(activity, recyclerView, fastScroller, itemClick), ItemTouchHelperContract { private val config = activity.config private val isListViewType = config.viewTypeFolders == VIEW_TYPE_LIST @@ -53,6 +62,8 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList() + private var isChangingOrder = false + private var startReorderDragListener: StartReorderDragListener private var showMediaCount = config.showFolderMediaCount private var folderStyle = config.folderStyle @@ -61,6 +72,15 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList renameDir() R.id.cab_pin -> pinFolders(true) R.id.cab_unpin -> pinFolders(false) + R.id.cab_change_order -> changeOrder() R.id.cab_empty_recycle_bin -> tryEmptyRecycleBin(true) R.id.cab_empty_disable_recycle_bin -> emptyAndDisableRecycleBin() R.id.cab_hide -> toggleFoldersVisibility(true) @@ -146,7 +167,13 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList - + + + + + - + + + + + + xmlns:app="http://schemas.android.com/apk/res-auto"> + app:showAsAction="ifRoom" /> + app:showAsAction="ifRoom" /> + app:showAsAction="ifRoom" /> + app:showAsAction="ifRoom" /> + + app:showAsAction="ifRoom" /> + app:showAsAction="ifRoom" /> + app:showAsAction="ifRoom" /> + app:showAsAction="never" /> + app:showAsAction="never" /> + app:showAsAction="never" /> + app:showAsAction="never" /> + app:showAsAction="never" /> + app:showAsAction="never" /> + app:showAsAction="never" /> + app:showAsAction="never" /> + android:title="@string/select_photo" /> + android:title="@string/use_default" /> + app:showAsAction="ifRoom" />