mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-30 08:18:00 +01:00
update MyScalableRecyclerView to the new MyRecyclerView
This commit is contained in:
parent
93c0247f9d
commit
ee883d3acc
30 changed files with 205 additions and 354 deletions
|
@ -47,10 +47,9 @@ ext {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile 'com.simplemobiletools:commons:2.38.9'
|
compile 'com.simplemobiletools:commons:2.39.7'
|
||||||
compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.7.2'
|
compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.7.2'
|
||||||
compile 'com.theartofdev.edmodo:android-image-cropper:2.4.0'
|
compile 'com.theartofdev.edmodo:android-image-cropper:2.4.0'
|
||||||
compile 'com.bignerdranch.android:recyclerview-multiselect:0.2'
|
|
||||||
compile 'com.android.support:multidex:1.0.2'
|
compile 'com.android.support:multidex:1.0.2'
|
||||||
compile 'com.google.code.gson:gson:2.8.2'
|
compile 'com.google.code.gson:gson:2.8.2'
|
||||||
compile 'it.sephiroth.android.exif:library:1.0.1'
|
compile 'it.sephiroth.android.exif:library:1.0.1'
|
||||||
|
|
|
@ -4,7 +4,6 @@ import android.app.Activity
|
||||||
import android.content.ClipData
|
import android.content.ClipData
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Build
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.provider.MediaStore
|
import android.provider.MediaStore
|
||||||
|
@ -23,7 +22,7 @@ import com.simplemobiletools.commons.helpers.SORT_BY_DATE_MODIFIED
|
||||||
import com.simplemobiletools.commons.helpers.SORT_BY_DATE_TAKEN
|
import com.simplemobiletools.commons.helpers.SORT_BY_DATE_TAKEN
|
||||||
import com.simplemobiletools.commons.models.RadioItem
|
import com.simplemobiletools.commons.models.RadioItem
|
||||||
import com.simplemobiletools.commons.models.Release
|
import com.simplemobiletools.commons.models.Release
|
||||||
import com.simplemobiletools.commons.views.MyScalableRecyclerView
|
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||||
import com.simplemobiletools.gallery.BuildConfig
|
import com.simplemobiletools.gallery.BuildConfig
|
||||||
import com.simplemobiletools.gallery.R
|
import com.simplemobiletools.gallery.R
|
||||||
import com.simplemobiletools.gallery.adapters.DirectoryAdapter
|
import com.simplemobiletools.gallery.adapters.DirectoryAdapter
|
||||||
|
@ -64,6 +63,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
||||||
private var mLatestMediaId = 0L
|
private var mLatestMediaId = 0L
|
||||||
private var mLastMediaHandler = Handler()
|
private var mLastMediaHandler = Handler()
|
||||||
private var mCurrAsyncTask: GetDirectoriesAsynctask? = null
|
private var mCurrAsyncTask: GetDirectoriesAsynctask? = null
|
||||||
|
private var mZoomListener: MyRecyclerView.MyZoomListener? = null
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
@ -178,7 +178,6 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
||||||
directories_refresh_layout.isRefreshing = false
|
directories_refresh_layout.isRefreshing = false
|
||||||
mIsGettingDirs = false
|
mIsGettingDirs = false
|
||||||
storeStateVariables()
|
storeStateVariables()
|
||||||
directories_grid.listener = null
|
|
||||||
mLastMediaHandler.removeCallbacksAndMessages(null)
|
mLastMediaHandler.removeCallbacksAndMessages(null)
|
||||||
|
|
||||||
if (!mDirs.isEmpty()) {
|
if (!mDirs.isEmpty()) {
|
||||||
|
@ -341,6 +340,8 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
||||||
} else {
|
} else {
|
||||||
setupListLayoutManager()
|
setupListLayoutManager()
|
||||||
}
|
}
|
||||||
|
getDirectoryAdapter()?.setupZoomListener(mZoomListener)
|
||||||
|
getDirectoryAdapter()?.setupDragListener(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupGridLayoutManager() {
|
private fun setupGridLayoutManager() {
|
||||||
|
@ -353,42 +354,30 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
||||||
directories_refresh_layout.layoutParams = FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
directories_refresh_layout.layoutParams = FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
||||||
}
|
}
|
||||||
|
|
||||||
directories_grid.isDragSelectionEnabled = true
|
|
||||||
directories_grid.isZoomingEnabled = true
|
|
||||||
layoutManager.spanCount = config.dirColumnCnt
|
layoutManager.spanCount = config.dirColumnCnt
|
||||||
directories_grid.listener = object : MyScalableRecyclerView.MyScalableRecyclerViewListener {
|
mZoomListener = object : MyRecyclerView.MyZoomListener {
|
||||||
override fun zoomIn() {
|
override fun zoomIn() {
|
||||||
if (layoutManager.spanCount > 1) {
|
if (layoutManager.spanCount > 1) {
|
||||||
reduceColumnCount()
|
reduceColumnCount()
|
||||||
getRecyclerAdapter().actMode?.finish()
|
getRecyclerAdapter().finishActMode()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun zoomOut() {
|
override fun zoomOut() {
|
||||||
if (layoutManager.spanCount < MAX_COLUMN_COUNT) {
|
if (layoutManager.spanCount < MAX_COLUMN_COUNT) {
|
||||||
increaseColumnCount()
|
increaseColumnCount()
|
||||||
getRecyclerAdapter().actMode?.finish()
|
getRecyclerAdapter().finishActMode()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun selectItem(position: Int) {
|
|
||||||
getRecyclerAdapter().selectItem(position)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun selectRange(initialSelection: Int, lastDraggedIndex: Int, minReached: Int, maxReached: Int) {
|
|
||||||
getRecyclerAdapter().selectRange(initialSelection, lastDraggedIndex, minReached, maxReached)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupListLayoutManager() {
|
private fun setupListLayoutManager() {
|
||||||
directories_grid.isDragSelectionEnabled = true
|
|
||||||
directories_grid.isZoomingEnabled = false
|
|
||||||
|
|
||||||
val layoutManager = directories_grid.layoutManager as GridLayoutManager
|
val layoutManager = directories_grid.layoutManager as GridLayoutManager
|
||||||
layoutManager.spanCount = 1
|
layoutManager.spanCount = 1
|
||||||
layoutManager.orientation = GridLayoutManager.VERTICAL
|
layoutManager.orientation = GridLayoutManager.VERTICAL
|
||||||
directories_refresh_layout.layoutParams = FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
directories_refresh_layout.layoutParams = FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
||||||
|
mZoomListener = null
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createNewFolder() {
|
private fun createNewFolder() {
|
||||||
|
@ -560,8 +549,8 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
||||||
private fun setupAdapter() {
|
private fun setupAdapter() {
|
||||||
val currAdapter = directories_grid.adapter
|
val currAdapter = directories_grid.adapter
|
||||||
if (currAdapter == null) {
|
if (currAdapter == null) {
|
||||||
directories_grid.adapter = DirectoryAdapter(this, mDirs, this, isPickIntent(intent) || isGetAnyContentIntent(intent)) {
|
directories_grid.adapter = DirectoryAdapter(this, mDirs, this, directories_grid, isPickIntent(intent) || isGetAnyContentIntent(intent)) {
|
||||||
itemClicked(it.path)
|
itemClicked((it as Directory).path)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
(currAdapter as DirectoryAdapter).updateDirs(mDirs)
|
(currAdapter as DirectoryAdapter).updateDirs(mDirs)
|
||||||
|
@ -587,7 +576,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkLastMediaChanged() {
|
private fun checkLastMediaChanged() {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && isDestroyed)
|
if (isActivityDestroyed())
|
||||||
return
|
return
|
||||||
|
|
||||||
mLastMediaHandler.removeCallbacksAndMessages(null)
|
mLastMediaHandler.removeCallbacksAndMessages(null)
|
||||||
|
@ -610,10 +599,6 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
||||||
getDirectories()
|
getDirectories()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun itemLongClicked(position: Int) {
|
|
||||||
directories_grid.setDragSelectActive(position)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun recheckPinnedFolders() {
|
override fun recheckPinnedFolders() {
|
||||||
gotDirectories(movePinnedDirectoriesToFront(mDirs), true)
|
gotDirectories(movePinnedDirectoriesToFront(mDirs), true)
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@ import android.app.WallpaperManager
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Build
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.support.v7.widget.GridLayoutManager
|
import android.support.v7.widget.GridLayoutManager
|
||||||
|
@ -24,7 +23,6 @@ import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_STORAGE
|
import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_STORAGE
|
||||||
import com.simplemobiletools.commons.helpers.REQUEST_EDIT_IMAGE
|
import com.simplemobiletools.commons.helpers.REQUEST_EDIT_IMAGE
|
||||||
import com.simplemobiletools.commons.models.RadioItem
|
import com.simplemobiletools.commons.models.RadioItem
|
||||||
import com.simplemobiletools.commons.views.MyScalableRecyclerView
|
|
||||||
import com.simplemobiletools.gallery.R
|
import com.simplemobiletools.gallery.R
|
||||||
import com.simplemobiletools.gallery.adapters.MediaAdapter
|
import com.simplemobiletools.gallery.adapters.MediaAdapter
|
||||||
import com.simplemobiletools.gallery.asynctasks.GetMediaAsynctask
|
import com.simplemobiletools.gallery.asynctasks.GetMediaAsynctask
|
||||||
|
@ -120,7 +118,6 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
||||||
mIsGettingMedia = false
|
mIsGettingMedia = false
|
||||||
media_refresh_layout.isRefreshing = false
|
media_refresh_layout.isRefreshing = false
|
||||||
storeStateVariables()
|
storeStateVariables()
|
||||||
media_grid.listener = null
|
|
||||||
mLastMediaHandler.removeCallbacksAndMessages(null)
|
mLastMediaHandler.removeCallbacksAndMessages(null)
|
||||||
|
|
||||||
if (!mMedia.isEmpty()) {
|
if (!mMedia.isEmpty()) {
|
||||||
|
@ -204,7 +201,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkLastMediaChanged() {
|
private fun checkLastMediaChanged() {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && isDestroyed)
|
if (isActivityDestroyed())
|
||||||
return
|
return
|
||||||
|
|
||||||
mLastMediaHandler.removeCallbacksAndMessages(null)
|
mLastMediaHandler.removeCallbacksAndMessages(null)
|
||||||
|
@ -414,7 +411,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
||||||
media_refresh_layout.layoutParams = FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
media_refresh_layout.layoutParams = FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
||||||
}
|
}
|
||||||
|
|
||||||
media_grid.isDragSelectionEnabled = true
|
/*media_grid.isDragSelectionEnabled = true
|
||||||
media_grid.isZoomingEnabled = true
|
media_grid.isZoomingEnabled = true
|
||||||
layoutManager.spanCount = config.mediaColumnCnt
|
layoutManager.spanCount = config.mediaColumnCnt
|
||||||
media_grid.listener = object : MyScalableRecyclerView.MyScalableRecyclerViewListener {
|
media_grid.listener = object : MyScalableRecyclerView.MyScalableRecyclerViewListener {
|
||||||
|
@ -439,12 +436,12 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
||||||
override fun selectRange(initialSelection: Int, lastDraggedIndex: Int, minReached: Int, maxReached: Int) {
|
override fun selectRange(initialSelection: Int, lastDraggedIndex: Int, minReached: Int, maxReached: Int) {
|
||||||
getRecyclerAdapter().selectRange(initialSelection, lastDraggedIndex, minReached, maxReached)
|
getRecyclerAdapter().selectRange(initialSelection, lastDraggedIndex, minReached, maxReached)
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupListLayoutManager() {
|
private fun setupListLayoutManager() {
|
||||||
media_grid.isDragSelectionEnabled = true
|
//media_grid.isDragSelectionEnabled = true
|
||||||
media_grid.isZoomingEnabled = false
|
//media_grid.isZoomingEnabled = false
|
||||||
|
|
||||||
val layoutManager = media_grid.layoutManager as GridLayoutManager
|
val layoutManager = media_grid.layoutManager as GridLayoutManager
|
||||||
layoutManager.spanCount = 1
|
layoutManager.spanCount = 1
|
||||||
|
|
|
@ -5,10 +5,10 @@ import android.app.WallpaperManager
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Build
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
|
import com.simplemobiletools.commons.extensions.isActivityDestroyed
|
||||||
import com.simplemobiletools.commons.extensions.toast
|
import com.simplemobiletools.commons.extensions.toast
|
||||||
import com.simplemobiletools.gallery.R
|
import com.simplemobiletools.gallery.R
|
||||||
import com.theartofdev.edmodo.cropper.CropImageView
|
import com.theartofdev.edmodo.cropper.CropImageView
|
||||||
|
@ -86,7 +86,7 @@ class SetWallpaperActivity : SimpleActivity(), CropImageView.OnCropImageComplete
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCropImageComplete(view: CropImageView?, result: CropImageView.CropResult) {
|
override fun onCropImageComplete(view: CropImageView?, result: CropImageView.CropResult) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && isDestroyed)
|
if (isActivityDestroyed())
|
||||||
return
|
return
|
||||||
|
|
||||||
if (result.error == null) {
|
if (result.error == null) {
|
||||||
|
|
|
@ -1,36 +1,5 @@
|
||||||
package com.simplemobiletools.gallery.activities
|
package com.simplemobiletools.gallery.activities
|
||||||
|
|
||||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
import com.simplemobiletools.commons.extensions.getFilenameFromPath
|
|
||||||
import com.simplemobiletools.commons.extensions.toast
|
|
||||||
import com.simplemobiletools.gallery.R
|
|
||||||
import com.simplemobiletools.gallery.dialogs.PickDirectoryDialog
|
|
||||||
import com.simplemobiletools.gallery.extensions.config
|
|
||||||
import com.simplemobiletools.gallery.models.Directory
|
|
||||||
import java.io.File
|
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
open class SimpleActivity : BaseSimpleActivity() {
|
open class SimpleActivity : BaseSimpleActivity()
|
||||||
fun tryCopyMoveFilesTo(files: ArrayList<File>, isCopyOperation: Boolean, callback: () -> Unit) {
|
|
||||||
if (files.isEmpty()) {
|
|
||||||
toast(R.string.unknown_error_occurred)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
val source = if (files[0].isFile) files[0].parent else files[0].absolutePath
|
|
||||||
PickDirectoryDialog(this, source) {
|
|
||||||
copyMoveFilesTo(files, source.trimEnd('/'), it, isCopyOperation, true, callback)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun addTempFolderIfNeeded(dirs: ArrayList<Directory>): ArrayList<Directory> {
|
|
||||||
val directories = ArrayList<Directory>()
|
|
||||||
val tempFolderPath = config.tempFolderPath
|
|
||||||
if (tempFolderPath.isNotEmpty()) {
|
|
||||||
val newFolder = Directory(tempFolderPath, "", tempFolderPath.getFilenameFromPath(), 0, 0, 0, 0L)
|
|
||||||
directories.add(newFolder)
|
|
||||||
}
|
|
||||||
directories.addAll(dirs)
|
|
||||||
return directories
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -186,7 +186,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
title = mPath.getFilenameFromPath()
|
title = mPath.getFilenameFromPath()
|
||||||
|
|
||||||
view_pager.onGlobalLayout {
|
view_pager.onGlobalLayout {
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1 || !isDestroyed) {
|
if (!isActivityDestroyed()) {
|
||||||
if (mMedia.isNotEmpty()) {
|
if (mMedia.isNotEmpty()) {
|
||||||
gotMedia(mMedia)
|
gotMedia(mMedia)
|
||||||
}
|
}
|
||||||
|
@ -304,7 +304,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
|
|
||||||
private fun updatePagerItems(media: MutableList<Medium>) {
|
private fun updatePagerItems(media: MutableList<Medium>) {
|
||||||
val pagerAdapter = MyPagerAdapter(this, supportFragmentManager, media)
|
val pagerAdapter = MyPagerAdapter(this, supportFragmentManager, media)
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1 || !isDestroyed) {
|
if (!isActivityDestroyed()) {
|
||||||
view_pager.apply {
|
view_pager.apply {
|
||||||
adapter = pagerAdapter
|
adapter = pagerAdapter
|
||||||
currentItem = mPos
|
currentItem = mPos
|
||||||
|
@ -322,7 +322,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
private fun startSlideshow() {
|
private fun startSlideshow() {
|
||||||
if (getMediaForSlideshow()) {
|
if (getMediaForSlideshow()) {
|
||||||
view_pager.onGlobalLayout {
|
view_pager.onGlobalLayout {
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1 || !isDestroyed) {
|
if (!isActivityDestroyed()) {
|
||||||
hideSystemUI()
|
hideSystemUI()
|
||||||
mSlideshowInterval = config.slideshowInterval
|
mSlideshowInterval = config.slideshowInterval
|
||||||
mSlideshowMoveBackwards = config.slideshowMoveBackwards
|
mSlideshowMoveBackwards = config.slideshowMoveBackwards
|
||||||
|
@ -402,7 +402,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
if (mIsSlideshowActive) {
|
if (mIsSlideshowActive) {
|
||||||
if (getCurrentMedium()!!.isImage() || getCurrentMedium()!!.isGif()) {
|
if (getCurrentMedium()!!.isImage() || getCurrentMedium()!!.isGif()) {
|
||||||
mSlideshowHandler.postDelayed({
|
mSlideshowHandler.postDelayed({
|
||||||
if (mIsSlideshowActive && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && !isDestroyed) {
|
if (mIsSlideshowActive && !isActivityDestroyed()) {
|
||||||
swipeToNextMedium()
|
swipeToNextMedium()
|
||||||
}
|
}
|
||||||
}, mSlideshowInterval * 1000L)
|
}, mSlideshowInterval * 1000L)
|
||||||
|
|
|
@ -1,23 +1,20 @@
|
||||||
package com.simplemobiletools.gallery.adapters
|
package com.simplemobiletools.gallery.adapters
|
||||||
|
|
||||||
import android.graphics.PorterDuff
|
import android.graphics.PorterDuff
|
||||||
import android.os.Build
|
|
||||||
import android.support.v7.view.ActionMode
|
|
||||||
import android.support.v7.widget.RecyclerView
|
|
||||||
import android.util.SparseArray
|
import android.util.SparseArray
|
||||||
import android.view.*
|
import android.view.Menu
|
||||||
import com.bignerdranch.android.multiselector.ModalMultiSelectorCallback
|
import android.view.View
|
||||||
import com.bignerdranch.android.multiselector.MultiSelector
|
import android.view.ViewGroup
|
||||||
import com.bignerdranch.android.multiselector.SwappingHolder
|
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
|
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
|
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
||||||
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
||||||
import com.simplemobiletools.commons.dialogs.PropertiesDialog
|
import com.simplemobiletools.commons.dialogs.PropertiesDialog
|
||||||
import com.simplemobiletools.commons.dialogs.RenameItemDialog
|
import com.simplemobiletools.commons.dialogs.RenameItemDialog
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.interfaces.MyAdapterListener
|
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||||
import com.simplemobiletools.gallery.R
|
import com.simplemobiletools.gallery.R
|
||||||
import com.simplemobiletools.gallery.activities.SimpleActivity
|
|
||||||
import com.simplemobiletools.gallery.dialogs.ExcludeFolderDialog
|
import com.simplemobiletools.gallery.dialogs.ExcludeFolderDialog
|
||||||
import com.simplemobiletools.gallery.dialogs.PickMediumDialog
|
import com.simplemobiletools.gallery.dialogs.PickMediumDialog
|
||||||
import com.simplemobiletools.gallery.extensions.*
|
import com.simplemobiletools.gallery.extensions.*
|
||||||
|
@ -28,60 +25,51 @@ import kotlinx.android.synthetic.main.directory_item_list.view.*
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Directory>, val listener: DirOperationsListener?, val isPickIntent: Boolean,
|
class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: MutableList<Directory>, val listener: DirOperationsListener?, recyclerView: MyRecyclerView,
|
||||||
val itemClick: (Directory) -> Unit) : RecyclerView.Adapter<DirectoryAdapter.ViewHolder>() {
|
val isPickIntent: Boolean, itemClick: (Any) -> Unit) : MyRecyclerViewAdapter(activity, recyclerView, itemClick) {
|
||||||
|
|
||||||
private val config = activity.config
|
private val config = activity.config
|
||||||
var actMode: ActionMode? = null
|
|
||||||
var primaryColor = config.primaryColor
|
|
||||||
|
|
||||||
private val multiSelector = MultiSelector()
|
|
||||||
private val isListViewType = config.viewTypeFolders == VIEW_TYPE_LIST
|
private val isListViewType = config.viewTypeFolders == VIEW_TYPE_LIST
|
||||||
private var itemViews = SparseArray<View>()
|
|
||||||
private val selectedPositions = HashSet<Int>()
|
|
||||||
private var textColor = config.textColor
|
|
||||||
private var pinnedFolders = config.pinnedFolders
|
private var pinnedFolders = config.pinnedFolders
|
||||||
private var scrollHorizontally = config.scrollHorizontally
|
private var scrollHorizontally = config.scrollHorizontally
|
||||||
private var showMediaCount = config.showMediaCount
|
private var showMediaCount = config.showMediaCount
|
||||||
private var animateGifs = config.animateGifs
|
private var animateGifs = config.animateGifs
|
||||||
private var cropThumbnails = config.cropThumbnails
|
private var cropThumbnails = config.cropThumbnails
|
||||||
|
|
||||||
fun toggleItemSelection(select: Boolean, pos: Int) {
|
init {
|
||||||
if (select) {
|
selectableItemCount = dirs.count()
|
||||||
if (itemViews[pos] != null) {
|
|
||||||
itemViews[pos].dir_check?.background?.applyColorFilter(primaryColor)
|
|
||||||
selectedPositions.add(pos)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
selectedPositions.remove(pos)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
itemViews[pos]?.dir_check?.beVisibleIf(select)
|
override fun getActionMenuId() = R.menu.cab_directories
|
||||||
|
|
||||||
if (selectedPositions.isEmpty()) {
|
override fun prepareItemSelection(view: View) {
|
||||||
actMode?.finish()
|
view.dir_check?.background?.applyColorFilter(primaryColor)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updateTitle(selectedPositions.size)
|
override fun markItemSelection(select: Boolean, view: View?) {
|
||||||
|
view?.dir_check?.beVisibleIf(select)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateTitle(cnt: Int) {
|
override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): ViewHolder {
|
||||||
actMode?.title = "$cnt / ${dirs.size}"
|
val layoutType = if (isListViewType) R.layout.directory_item_list else R.layout.directory_item_grid
|
||||||
actMode?.invalidate()
|
val view = activity.layoutInflater.inflate(layoutType, parent, false)
|
||||||
|
return createViewHolder(view)
|
||||||
}
|
}
|
||||||
|
|
||||||
private val adapterListener = object : MyAdapterListener {
|
override fun onBindViewHolder(holder: MyRecyclerViewAdapter.ViewHolder, position: Int) {
|
||||||
override fun toggleItemSelectionAdapter(select: Boolean, position: Int) {
|
val dir = dirs[position]
|
||||||
toggleItemSelection(select, position)
|
val view = holder.bindView(dir, isPickIntent) {
|
||||||
|
setupView(it, dir)
|
||||||
|
}
|
||||||
|
itemViews.put(position, view)
|
||||||
|
toggleItemSelection(selectedPositions.contains(position), position)
|
||||||
|
holder.itemView.tag = holder
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getSelectedPositions(): HashSet<Int> = selectedPositions
|
override fun getItemCount() = dirs.size
|
||||||
}
|
|
||||||
|
|
||||||
private val multiSelectorMode = object : ModalMultiSelectorCallback(multiSelector) {
|
override fun actionItemPressed(id: Int) {
|
||||||
override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean {
|
when (id) {
|
||||||
when (item.itemId) {
|
|
||||||
R.id.cab_properties -> showProperties()
|
R.id.cab_properties -> showProperties()
|
||||||
R.id.cab_rename -> renameDir()
|
R.id.cab_rename -> renameDir()
|
||||||
R.id.cab_pin -> pinFolders(true)
|
R.id.cab_pin -> pinFolders(true)
|
||||||
|
@ -95,38 +83,18 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
|
||||||
R.id.cab_delete -> askConfirmDelete()
|
R.id.cab_delete -> askConfirmDelete()
|
||||||
R.id.cab_select_photo -> changeAlbumCover(false)
|
R.id.cab_select_photo -> changeAlbumCover(false)
|
||||||
R.id.cab_use_default -> changeAlbumCover(true)
|
R.id.cab_use_default -> changeAlbumCover(true)
|
||||||
else -> return false
|
|
||||||
}
|
}
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateActionMode(actionMode: ActionMode?, menu: Menu): Boolean {
|
override fun prepareActionMode(menu: Menu) {
|
||||||
super.onCreateActionMode(actionMode, menu)
|
|
||||||
actMode = actionMode
|
|
||||||
activity.menuInflater.inflate(R.menu.cab_directories, menu)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onPrepareActionMode(actionMode: ActionMode?, menu: Menu): Boolean {
|
|
||||||
menu.findItem(R.id.cab_rename).isVisible = selectedPositions.size == 1
|
menu.findItem(R.id.cab_rename).isVisible = selectedPositions.size == 1
|
||||||
menu.findItem(R.id.cab_change_cover_image).isVisible = selectedPositions.size == 1
|
menu.findItem(R.id.cab_change_cover_image).isVisible = selectedPositions.size == 1
|
||||||
|
|
||||||
checkHideBtnVisibility(menu)
|
checkHideBtnVisibility(menu)
|
||||||
checkPinBtnVisibility(menu)
|
checkPinBtnVisibility(menu)
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyActionMode(actionMode: ActionMode?) {
|
private fun checkHideBtnVisibility(menu: Menu) {
|
||||||
super.onDestroyActionMode(actionMode)
|
|
||||||
selectedPositions.forEach {
|
|
||||||
itemViews[it]?.dir_check?.beGone()
|
|
||||||
}
|
|
||||||
selectedPositions.clear()
|
|
||||||
actMode = null
|
|
||||||
}
|
|
||||||
|
|
||||||
fun checkHideBtnVisibility(menu: Menu) {
|
|
||||||
var hiddenCnt = 0
|
var hiddenCnt = 0
|
||||||
var unhiddenCnt = 0
|
var unhiddenCnt = 0
|
||||||
selectedPositions.mapNotNull { dirs.getOrNull(it)?.path }.forEach {
|
selectedPositions.mapNotNull { dirs.getOrNull(it)?.path }.forEach {
|
||||||
|
@ -141,7 +109,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
|
||||||
menu.findItem(R.id.cab_unhide).isVisible = hiddenCnt > 0
|
menu.findItem(R.id.cab_unhide).isVisible = hiddenCnt > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
fun checkPinBtnVisibility(menu: Menu) {
|
private fun checkPinBtnVisibility(menu: Menu) {
|
||||||
val pinnedFolders = config.pinnedFolders
|
val pinnedFolders = config.pinnedFolders
|
||||||
var pinnedCnt = 0
|
var pinnedCnt = 0
|
||||||
var unpinnedCnt = 0
|
var unpinnedCnt = 0
|
||||||
|
@ -156,7 +124,6 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
|
||||||
menu.findItem(R.id.cab_pin).isVisible = unpinnedCnt > 0
|
menu.findItem(R.id.cab_pin).isVisible = unpinnedCnt > 0
|
||||||
menu.findItem(R.id.cab_unpin).isVisible = pinnedCnt > 0
|
menu.findItem(R.id.cab_unpin).isVisible = pinnedCnt > 0
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private fun showProperties() {
|
private fun showProperties() {
|
||||||
if (selectedPositions.size <= 1) {
|
if (selectedPositions.size <= 1) {
|
||||||
|
@ -179,7 +146,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
|
||||||
RenameItemDialog(activity, dir.absolutePath) {
|
RenameItemDialog(activity, dir.absolutePath) {
|
||||||
activity.runOnUiThread {
|
activity.runOnUiThread {
|
||||||
listener?.refreshItems()
|
listener?.refreshItems()
|
||||||
actMode?.finish()
|
finishActMode()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -212,14 +179,14 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
|
||||||
private fun tryExcludeFolder() {
|
private fun tryExcludeFolder() {
|
||||||
ExcludeFolderDialog(activity, getSelectedPaths().toList()) {
|
ExcludeFolderDialog(activity, getSelectedPaths().toList()) {
|
||||||
listener?.refreshItems()
|
listener?.refreshItems()
|
||||||
actMode?.finish()
|
finishActMode()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun noMediaHandled() {
|
private fun noMediaHandled() {
|
||||||
activity.runOnUiThread {
|
activity.runOnUiThread {
|
||||||
listener?.refreshItems()
|
listener?.refreshItems()
|
||||||
actMode?.finish()
|
finishActMode()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,7 +200,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
|
||||||
pinnedFolders = config.pinnedFolders
|
pinnedFolders = config.pinnedFolders
|
||||||
listener?.recheckPinnedFolders()
|
listener?.recheckPinnedFolders()
|
||||||
notifyDataSetChanged()
|
notifyDataSetChanged()
|
||||||
actMode?.finish()
|
finishActMode()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun copyMoveTo(isCopyOperation: Boolean) {
|
private fun copyMoveTo(isCopyOperation: Boolean) {
|
||||||
|
@ -249,19 +216,10 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
|
||||||
activity.tryCopyMoveFilesTo(files, isCopyOperation) {
|
activity.tryCopyMoveFilesTo(files, isCopyOperation) {
|
||||||
config.tempFolderPath = ""
|
config.tempFolderPath = ""
|
||||||
listener?.refreshItems()
|
listener?.refreshItems()
|
||||||
actMode?.finish()
|
finishActMode()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun selectAll() {
|
|
||||||
val cnt = dirs.size
|
|
||||||
for (i in 0 until cnt) {
|
|
||||||
selectedPositions.add(i)
|
|
||||||
notifyItemChanged(i)
|
|
||||||
}
|
|
||||||
updateTitle(cnt)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun askConfirmDelete() {
|
private fun askConfirmDelete() {
|
||||||
ConfirmationDialog(activity) {
|
ConfirmationDialog(activity) {
|
||||||
deleteFiles()
|
deleteFiles()
|
||||||
|
@ -303,7 +261,8 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
|
||||||
.forEachIndexed { curIndex, i -> newItems.put(curIndex, itemViews[i]) }
|
.forEachIndexed { curIndex, i -> newItems.put(curIndex, itemViews[i]) }
|
||||||
|
|
||||||
itemViews = newItems
|
itemViews = newItems
|
||||||
actMode?.finish()
|
selectableItemCount = dirs.size
|
||||||
|
finishActMode()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,7 +297,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
|
||||||
|
|
||||||
private fun storeCovers(albumCovers: ArrayList<AlbumCover>) {
|
private fun storeCovers(albumCovers: ArrayList<AlbumCover>) {
|
||||||
activity.config.albumCovers = Gson().toJson(albumCovers)
|
activity.config.albumCovers = Gson().toJson(albumCovers)
|
||||||
actMode?.finish()
|
finishActMode()
|
||||||
listener?.refreshItems()
|
listener?.refreshItems()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -348,30 +307,18 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
|
||||||
return paths
|
return paths
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): ViewHolder {
|
|
||||||
val layoutType = if (isListViewType) R.layout.directory_item_list else R.layout.directory_item_grid
|
|
||||||
val view = LayoutInflater.from(parent?.context).inflate(layoutType, parent, false)
|
|
||||||
return ViewHolder(view, adapterListener, activity, multiSelectorMode, multiSelector, listener, isPickIntent, itemClick)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
|
||||||
val dir = dirs[position]
|
|
||||||
itemViews.put(position, holder.bindView(dir, pinnedFolders.contains(dir.path), scrollHorizontally, isListViewType, textColor, showMediaCount, animateGifs, cropThumbnails))
|
|
||||||
toggleItemSelection(selectedPositions.contains(position), position)
|
|
||||||
holder.itemView.tag = holder
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onViewRecycled(holder: ViewHolder?) {
|
override fun onViewRecycled(holder: ViewHolder?) {
|
||||||
super.onViewRecycled(holder)
|
super.onViewRecycled(holder)
|
||||||
holder?.stopLoad()
|
if (!activity.isActivityDestroyed()) {
|
||||||
|
Glide.with(activity).clear(holder?.itemView?.dir_thumbnail)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getItemCount() = dirs.size
|
|
||||||
|
|
||||||
fun updateDirs(newDirs: ArrayList<Directory>) {
|
fun updateDirs(newDirs: ArrayList<Directory>) {
|
||||||
dirs = newDirs
|
dirs = newDirs
|
||||||
|
selectableItemCount = dirs.size
|
||||||
notifyDataSetChanged()
|
notifyDataSetChanged()
|
||||||
actMode?.finish()
|
finishActMode()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateAnimateGifs(animateGifs: Boolean) {
|
fun updateAnimateGifs(animateGifs: Boolean) {
|
||||||
|
@ -394,101 +341,23 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
|
||||||
notifyDataSetChanged()
|
notifyDataSetChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateTextColor(textColor: Int) {
|
private fun setupView(view: View, directory: Directory) {
|
||||||
this.textColor = textColor
|
view.apply {
|
||||||
notifyDataSetChanged()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun selectItem(pos: Int) {
|
|
||||||
toggleItemSelection(true, pos)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun selectRange(from: Int, to: Int, min: Int, max: Int) {
|
|
||||||
if (from == to) {
|
|
||||||
(min..max).filter { it != from }
|
|
||||||
.forEach { toggleItemSelection(false, it) }
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (to < from) {
|
|
||||||
for (i in to..from)
|
|
||||||
toggleItemSelection(true, i)
|
|
||||||
|
|
||||||
if (min > -1 && min < to) {
|
|
||||||
(min until to).filter { it != from }
|
|
||||||
.forEach { toggleItemSelection(false, it) }
|
|
||||||
}
|
|
||||||
if (max > -1) {
|
|
||||||
for (i in from + 1..max)
|
|
||||||
toggleItemSelection(false, i)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (i in from..to)
|
|
||||||
toggleItemSelection(true, i)
|
|
||||||
|
|
||||||
if (max > -1 && max > to) {
|
|
||||||
(to + 1..max).filter { it != from }
|
|
||||||
.forEach { toggleItemSelection(false, it) }
|
|
||||||
}
|
|
||||||
|
|
||||||
if (min > -1) {
|
|
||||||
for (i in min until from)
|
|
||||||
toggleItemSelection(false, i)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class ViewHolder(val view: View, val adapterListener: MyAdapterListener, val activity: SimpleActivity, val multiSelectorCallback: ModalMultiSelectorCallback,
|
|
||||||
val multiSelector: MultiSelector, val listener: DirOperationsListener?, val isPickIntent: Boolean, val itemClick: (Directory) -> (Unit)) :
|
|
||||||
SwappingHolder(view, MultiSelector()) {
|
|
||||||
fun bindView(directory: Directory, isPinned: Boolean, scrollHorizontally: Boolean, isListView: Boolean, textColor: Int, showMediaCount: Boolean,
|
|
||||||
animateGifs: Boolean, cropThumbnails: Boolean): View {
|
|
||||||
itemView.apply {
|
|
||||||
dir_name.text = directory.name
|
dir_name.text = directory.name
|
||||||
dir_path?.text = "${directory.path.substringBeforeLast("/")}/"
|
dir_path?.text = "${directory.path.substringBeforeLast("/")}/"
|
||||||
photo_cnt.text = directory.mediaCnt.toString()
|
photo_cnt.text = directory.mediaCnt.toString()
|
||||||
activity.loadImage(directory.tmb, dir_thumbnail, scrollHorizontally, animateGifs, cropThumbnails)
|
activity.loadImage(directory.tmb, dir_thumbnail, scrollHorizontally, animateGifs, cropThumbnails)
|
||||||
dir_pin.beVisibleIf(isPinned)
|
dir_pin.beVisibleIf(pinnedFolders.contains(directory.path))
|
||||||
dir_sd_card.beVisibleIf(activity.isPathOnSD(directory.path))
|
dir_sd_card.beVisibleIf(activity.isPathOnSD(directory.path))
|
||||||
photo_cnt.beVisibleIf(showMediaCount)
|
photo_cnt.beVisibleIf(showMediaCount)
|
||||||
|
|
||||||
if (isListView) {
|
if (isListViewType) {
|
||||||
dir_name.setTextColor(textColor)
|
dir_name.setTextColor(textColor)
|
||||||
dir_path.setTextColor(textColor)
|
dir_path.setTextColor(textColor)
|
||||||
photo_cnt.setTextColor(textColor)
|
photo_cnt.setTextColor(textColor)
|
||||||
dir_pin.setColorFilter(textColor, PorterDuff.Mode.SRC_IN)
|
dir_pin.setColorFilter(textColor, PorterDuff.Mode.SRC_IN)
|
||||||
dir_sd_card.setColorFilter(textColor, PorterDuff.Mode.SRC_IN)
|
dir_sd_card.setColorFilter(textColor, PorterDuff.Mode.SRC_IN)
|
||||||
}
|
}
|
||||||
|
|
||||||
setOnClickListener { viewClicked(directory) }
|
|
||||||
setOnLongClickListener { if (isPickIntent) viewClicked(directory) else viewLongClicked(); true }
|
|
||||||
}
|
|
||||||
return itemView
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun viewClicked(directory: Directory) {
|
|
||||||
if (multiSelector.isSelectable) {
|
|
||||||
val isSelected = adapterListener.getSelectedPositions().contains(adapterPosition)
|
|
||||||
adapterListener.toggleItemSelectionAdapter(!isSelected, adapterPosition)
|
|
||||||
} else {
|
|
||||||
itemClick(directory)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun viewLongClicked() {
|
|
||||||
if (listener != null) {
|
|
||||||
if (!multiSelector.isSelectable) {
|
|
||||||
activity.startSupportActionMode(multiSelectorCallback)
|
|
||||||
adapterListener.toggleItemSelectionAdapter(true, adapterPosition)
|
|
||||||
}
|
|
||||||
|
|
||||||
listener.itemLongClicked(adapterPosition)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun stopLoad() {
|
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1 || !activity.isDestroyed)
|
|
||||||
Glide.with(activity).clear(view.dir_thumbnail)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -497,8 +366,6 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
|
||||||
|
|
||||||
fun tryDeleteFolders(folders: ArrayList<File>)
|
fun tryDeleteFolders(folders: ArrayList<File>)
|
||||||
|
|
||||||
fun itemLongClicked(position: Int)
|
|
||||||
|
|
||||||
fun recheckPinnedFolders()
|
fun recheckPinnedFolders()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package com.simplemobiletools.gallery.adapters
|
||||||
|
|
||||||
import android.graphics.PorterDuff
|
import android.graphics.PorterDuff
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Build
|
|
||||||
import android.support.v7.view.ActionMode
|
import android.support.v7.view.ActionMode
|
||||||
import android.support.v7.widget.RecyclerView
|
import android.support.v7.widget.RecyclerView
|
||||||
import android.util.SparseArray
|
import android.util.SparseArray
|
||||||
|
@ -11,14 +10,15 @@ import com.bignerdranch.android.multiselector.ModalMultiSelectorCallback
|
||||||
import com.bignerdranch.android.multiselector.MultiSelector
|
import com.bignerdranch.android.multiselector.MultiSelector
|
||||||
import com.bignerdranch.android.multiselector.SwappingHolder
|
import com.bignerdranch.android.multiselector.SwappingHolder
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
|
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
import com.simplemobiletools.commons.dialogs.PropertiesDialog
|
import com.simplemobiletools.commons.dialogs.PropertiesDialog
|
||||||
import com.simplemobiletools.commons.dialogs.RenameItemDialog
|
import com.simplemobiletools.commons.dialogs.RenameItemDialog
|
||||||
import com.simplemobiletools.commons.extensions.applyColorFilter
|
import com.simplemobiletools.commons.extensions.applyColorFilter
|
||||||
import com.simplemobiletools.commons.extensions.beGone
|
import com.simplemobiletools.commons.extensions.beGone
|
||||||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||||
|
import com.simplemobiletools.commons.extensions.isActivityDestroyed
|
||||||
import com.simplemobiletools.commons.interfaces.MyAdapterListener
|
import com.simplemobiletools.commons.interfaces.MyAdapterListener
|
||||||
import com.simplemobiletools.gallery.R
|
import com.simplemobiletools.gallery.R
|
||||||
import com.simplemobiletools.gallery.activities.SimpleActivity
|
|
||||||
import com.simplemobiletools.gallery.dialogs.DeleteWithRememberDialog
|
import com.simplemobiletools.gallery.dialogs.DeleteWithRememberDialog
|
||||||
import com.simplemobiletools.gallery.extensions.*
|
import com.simplemobiletools.gallery.extensions.*
|
||||||
import com.simplemobiletools.gallery.helpers.VIEW_TYPE_LIST
|
import com.simplemobiletools.gallery.helpers.VIEW_TYPE_LIST
|
||||||
|
@ -27,7 +27,7 @@ import kotlinx.android.synthetic.main.photo_video_item_grid.view.*
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>, val listener: MediaOperationsListener?, val isAGetIntent: Boolean,
|
class MediaAdapter(val activity: BaseSimpleActivity, var media: MutableList<Medium>, val listener: MediaOperationsListener?, val isAGetIntent: Boolean,
|
||||||
val allowMultiplePicks: Boolean, val itemClick: (Medium) -> Unit) : RecyclerView.Adapter<MediaAdapter.ViewHolder>() {
|
val allowMultiplePicks: Boolean, val itemClick: (Medium) -> Unit) : RecyclerView.Adapter<MediaAdapter.ViewHolder>() {
|
||||||
|
|
||||||
private val config = activity.config
|
private val config = activity.config
|
||||||
|
@ -77,6 +77,8 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getSelectedPositions(): HashSet<Int> = selectedPositions
|
override fun getSelectedPositions(): HashSet<Int> = selectedPositions
|
||||||
|
|
||||||
|
override fun itemLongClicked(position: Int) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val multiSelectorMode = object : ModalMultiSelectorCallback(multiSelector) {
|
private val multiSelectorMode = object : ModalMultiSelectorCallback(multiSelector) {
|
||||||
|
@ -366,7 +368,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ViewHolder(val view: View, val adapterListener: MyAdapterListener, val activity: SimpleActivity, val multiSelectorCallback: ModalMultiSelectorCallback,
|
class ViewHolder(val view: View, val adapterListener: MyAdapterListener, val activity: BaseSimpleActivity, val multiSelectorCallback: ModalMultiSelectorCallback,
|
||||||
val multiSelector: MultiSelector, val listener: MediaOperationsListener?, val allowMultiplePicks: Boolean,
|
val multiSelector: MultiSelector, val listener: MediaOperationsListener?, val allowMultiplePicks: Boolean,
|
||||||
val itemClick: (Medium) -> (Unit)) :
|
val itemClick: (Medium) -> (Unit)) :
|
||||||
SwappingHolder(view, MultiSelector()) {
|
SwappingHolder(view, MultiSelector()) {
|
||||||
|
@ -410,7 +412,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fun stopLoad() {
|
fun stopLoad() {
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1 || !activity.isDestroyed)
|
if (!activity.isActivityDestroyed())
|
||||||
Glide.with(activity).clear(view.medium_thumbnail)
|
Glide.with(activity).clear(view.medium_thumbnail)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,15 +4,15 @@ import android.content.DialogInterface
|
||||||
import android.support.v7.app.AlertDialog
|
import android.support.v7.app.AlertDialog
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||||
import com.simplemobiletools.commons.helpers.*
|
import com.simplemobiletools.commons.helpers.*
|
||||||
import com.simplemobiletools.gallery.R
|
import com.simplemobiletools.gallery.R
|
||||||
import com.simplemobiletools.gallery.activities.SimpleActivity
|
|
||||||
import com.simplemobiletools.gallery.extensions.config
|
import com.simplemobiletools.gallery.extensions.config
|
||||||
import kotlinx.android.synthetic.main.dialog_change_sorting.view.*
|
import kotlinx.android.synthetic.main.dialog_change_sorting.view.*
|
||||||
|
|
||||||
class ChangeSortingDialog(val activity: SimpleActivity, val isDirectorySorting: Boolean, showFolderCheckbox: Boolean,
|
class ChangeSortingDialog(val activity: BaseSimpleActivity, val isDirectorySorting: Boolean, showFolderCheckbox: Boolean,
|
||||||
val path: String = "", val callback: () -> Unit) :
|
val path: String = "", val callback: () -> Unit) :
|
||||||
DialogInterface.OnClickListener {
|
DialogInterface.OnClickListener {
|
||||||
private var currSorting = 0
|
private var currSorting = 0
|
||||||
|
|
|
@ -5,15 +5,15 @@ import android.view.LayoutInflater
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.RadioButton
|
import android.widget.RadioButton
|
||||||
import android.widget.RadioGroup
|
import android.widget.RadioGroup
|
||||||
|
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||||
import com.simplemobiletools.commons.extensions.getBasePath
|
import com.simplemobiletools.commons.extensions.getBasePath
|
||||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||||
import com.simplemobiletools.gallery.R
|
import com.simplemobiletools.gallery.R
|
||||||
import com.simplemobiletools.gallery.activities.SimpleActivity
|
|
||||||
import com.simplemobiletools.gallery.extensions.config
|
import com.simplemobiletools.gallery.extensions.config
|
||||||
import kotlinx.android.synthetic.main.dialog_exclude_folder.view.*
|
import kotlinx.android.synthetic.main.dialog_exclude_folder.view.*
|
||||||
|
|
||||||
class ExcludeFolderDialog(val activity: SimpleActivity, val selectedPaths: List<String>, val callback: () -> Unit) {
|
class ExcludeFolderDialog(val activity: BaseSimpleActivity, val selectedPaths: List<String>, val callback: () -> Unit) {
|
||||||
val alternativePaths = getAlternativePathsList()
|
val alternativePaths = getAlternativePathsList()
|
||||||
var radioGroup: RadioGroup? = null
|
var radioGroup: RadioGroup? = null
|
||||||
|
|
||||||
|
|
|
@ -3,16 +3,16 @@ package com.simplemobiletools.gallery.dialogs
|
||||||
import android.support.v7.app.AlertDialog
|
import android.support.v7.app.AlertDialog
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||||
import com.simplemobiletools.gallery.R
|
import com.simplemobiletools.gallery.R
|
||||||
import com.simplemobiletools.gallery.activities.SimpleActivity
|
|
||||||
import com.simplemobiletools.gallery.extensions.config
|
import com.simplemobiletools.gallery.extensions.config
|
||||||
import com.simplemobiletools.gallery.helpers.GIFS
|
import com.simplemobiletools.gallery.helpers.GIFS
|
||||||
import com.simplemobiletools.gallery.helpers.IMAGES
|
import com.simplemobiletools.gallery.helpers.IMAGES
|
||||||
import com.simplemobiletools.gallery.helpers.VIDEOS
|
import com.simplemobiletools.gallery.helpers.VIDEOS
|
||||||
import kotlinx.android.synthetic.main.dialog_filter_media.view.*
|
import kotlinx.android.synthetic.main.dialog_filter_media.view.*
|
||||||
|
|
||||||
class FilterMediaDialog(val activity: SimpleActivity, val callback: (result: Int) -> Unit) {
|
class FilterMediaDialog(val activity: BaseSimpleActivity, val callback: (result: Int) -> Unit) {
|
||||||
private var view: View = LayoutInflater.from(activity).inflate(R.layout.dialog_filter_media, null)
|
private var view: View = LayoutInflater.from(activity).inflate(R.layout.dialog_filter_media, null)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.simplemobiletools.gallery.dialogs
|
||||||
import android.support.v7.app.AlertDialog
|
import android.support.v7.app.AlertDialog
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||||
import com.simplemobiletools.gallery.R
|
import com.simplemobiletools.gallery.R
|
||||||
import com.simplemobiletools.gallery.activities.SimpleActivity
|
import com.simplemobiletools.gallery.activities.SimpleActivity
|
||||||
|
@ -10,7 +11,7 @@ import com.simplemobiletools.gallery.extensions.config
|
||||||
import com.simplemobiletools.gallery.helpers.*
|
import com.simplemobiletools.gallery.helpers.*
|
||||||
import kotlinx.android.synthetic.main.dialog_manage_extended_details.view.*
|
import kotlinx.android.synthetic.main.dialog_manage_extended_details.view.*
|
||||||
|
|
||||||
class ManageExtendedDetailsDialog(val activity: SimpleActivity, val callback: (result: Int) -> Unit) {
|
class ManageExtendedDetailsDialog(val activity: BaseSimpleActivity, val callback: (result: Int) -> Unit) {
|
||||||
private var view: View = LayoutInflater.from(activity).inflate(R.layout.dialog_manage_extended_details, null)
|
private var view: View = LayoutInflater.from(activity).inflate(R.layout.dialog_manage_extended_details, null)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
|
|
@ -3,15 +3,16 @@ package com.simplemobiletools.gallery.dialogs
|
||||||
import android.support.v7.app.AlertDialog
|
import android.support.v7.app.AlertDialog
|
||||||
import android.support.v7.widget.GridLayoutManager
|
import android.support.v7.widget.GridLayoutManager
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
|
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
||||||
import com.simplemobiletools.commons.extensions.beGoneIf
|
import com.simplemobiletools.commons.extensions.beGoneIf
|
||||||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||||
import com.simplemobiletools.commons.extensions.toast
|
import com.simplemobiletools.commons.extensions.toast
|
||||||
import com.simplemobiletools.gallery.R
|
import com.simplemobiletools.gallery.R
|
||||||
import com.simplemobiletools.gallery.activities.SimpleActivity
|
|
||||||
import com.simplemobiletools.gallery.adapters.DirectoryAdapter
|
import com.simplemobiletools.gallery.adapters.DirectoryAdapter
|
||||||
import com.simplemobiletools.gallery.asynctasks.GetDirectoriesAsynctask
|
import com.simplemobiletools.gallery.asynctasks.GetDirectoriesAsynctask
|
||||||
|
import com.simplemobiletools.gallery.extensions.addTempFolderIfNeeded
|
||||||
import com.simplemobiletools.gallery.extensions.config
|
import com.simplemobiletools.gallery.extensions.config
|
||||||
import com.simplemobiletools.gallery.extensions.getCachedDirectories
|
import com.simplemobiletools.gallery.extensions.getCachedDirectories
|
||||||
import com.simplemobiletools.gallery.extensions.getSortedDirectories
|
import com.simplemobiletools.gallery.extensions.getSortedDirectories
|
||||||
|
@ -19,7 +20,7 @@ import com.simplemobiletools.gallery.helpers.VIEW_TYPE_GRID
|
||||||
import com.simplemobiletools.gallery.models.Directory
|
import com.simplemobiletools.gallery.models.Directory
|
||||||
import kotlinx.android.synthetic.main.dialog_directory_picker.view.*
|
import kotlinx.android.synthetic.main.dialog_directory_picker.view.*
|
||||||
|
|
||||||
class PickDirectoryDialog(val activity: SimpleActivity, val sourcePath: String, val callback: (path: String) -> Unit) {
|
class PickDirectoryDialog(val activity: BaseSimpleActivity, val sourcePath: String, val callback: (path: String) -> Unit) {
|
||||||
var dialog: AlertDialog
|
var dialog: AlertDialog
|
||||||
var shownDirectories = ArrayList<Directory>()
|
var shownDirectories = ArrayList<Directory>()
|
||||||
var view = LayoutInflater.from(activity).inflate(R.layout.dialog_directory_picker, null)
|
var view = LayoutInflater.from(activity).inflate(R.layout.dialog_directory_picker, null)
|
||||||
|
@ -62,8 +63,8 @@ class PickDirectoryDialog(val activity: SimpleActivity, val sourcePath: String,
|
||||||
return
|
return
|
||||||
|
|
||||||
shownDirectories = dirs
|
shownDirectories = dirs
|
||||||
val adapter = DirectoryAdapter(activity, dirs, null, true) {
|
val adapter = DirectoryAdapter(activity, dirs, null, view.directories_grid, true) {
|
||||||
if (it.path.trimEnd('/') == sourcePath) {
|
if ((it as Directory).path.trimEnd('/') == sourcePath) {
|
||||||
activity.toast(R.string.source_and_destination_same)
|
activity.toast(R.string.source_and_destination_same)
|
||||||
return@DirectoryAdapter
|
return@DirectoryAdapter
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -3,11 +3,11 @@ package com.simplemobiletools.gallery.dialogs
|
||||||
import android.support.v7.app.AlertDialog
|
import android.support.v7.app.AlertDialog
|
||||||
import android.support.v7.widget.GridLayoutManager
|
import android.support.v7.widget.GridLayoutManager
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
|
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
import com.simplemobiletools.commons.extensions.beGoneIf
|
import com.simplemobiletools.commons.extensions.beGoneIf
|
||||||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||||
import com.simplemobiletools.gallery.R
|
import com.simplemobiletools.gallery.R
|
||||||
import com.simplemobiletools.gallery.activities.SimpleActivity
|
|
||||||
import com.simplemobiletools.gallery.adapters.MediaAdapter
|
import com.simplemobiletools.gallery.adapters.MediaAdapter
|
||||||
import com.simplemobiletools.gallery.asynctasks.GetMediaAsynctask
|
import com.simplemobiletools.gallery.asynctasks.GetMediaAsynctask
|
||||||
import com.simplemobiletools.gallery.extensions.config
|
import com.simplemobiletools.gallery.extensions.config
|
||||||
|
@ -16,7 +16,7 @@ import com.simplemobiletools.gallery.helpers.VIEW_TYPE_GRID
|
||||||
import com.simplemobiletools.gallery.models.Medium
|
import com.simplemobiletools.gallery.models.Medium
|
||||||
import kotlinx.android.synthetic.main.dialog_medium_picker.view.*
|
import kotlinx.android.synthetic.main.dialog_medium_picker.view.*
|
||||||
|
|
||||||
class PickMediumDialog(val activity: SimpleActivity, val path: String, val callback: (path: String) -> Unit) {
|
class PickMediumDialog(val activity: BaseSimpleActivity, val path: String, val callback: (path: String) -> Unit) {
|
||||||
var dialog: AlertDialog
|
var dialog: AlertDialog
|
||||||
var shownMedia = ArrayList<Medium>()
|
var shownMedia = ArrayList<Medium>()
|
||||||
val view = LayoutInflater.from(activity).inflate(R.layout.dialog_medium_picker, null)
|
val view = LayoutInflater.from(activity).inflate(R.layout.dialog_medium_picker, null)
|
||||||
|
|
|
@ -7,14 +7,14 @@ import android.text.TextWatcher
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import android.widget.EditText
|
import android.widget.EditText
|
||||||
|
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||||
import com.simplemobiletools.commons.extensions.toast
|
import com.simplemobiletools.commons.extensions.toast
|
||||||
import com.simplemobiletools.commons.extensions.value
|
import com.simplemobiletools.commons.extensions.value
|
||||||
import com.simplemobiletools.gallery.R
|
import com.simplemobiletools.gallery.R
|
||||||
import com.simplemobiletools.gallery.activities.SimpleActivity
|
|
||||||
import kotlinx.android.synthetic.main.resize_image.view.*
|
import kotlinx.android.synthetic.main.resize_image.view.*
|
||||||
|
|
||||||
class ResizeDialog(val activity: SimpleActivity, val size: Point, val callback: (newSize: Point) -> Unit) {
|
class ResizeDialog(val activity: BaseSimpleActivity, val size: Point, val callback: (newSize: Point) -> Unit) {
|
||||||
init {
|
init {
|
||||||
val view = LayoutInflater.from(activity).inflate(R.layout.resize_image, null)
|
val view = LayoutInflater.from(activity).inflate(R.layout.resize_image, null)
|
||||||
val widthView = view.image_width
|
val widthView = view.image_width
|
||||||
|
|
|
@ -3,15 +3,15 @@ package com.simplemobiletools.gallery.dialogs
|
||||||
import android.support.v7.app.AlertDialog
|
import android.support.v7.app.AlertDialog
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
|
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
||||||
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.gallery.R
|
import com.simplemobiletools.gallery.R
|
||||||
import com.simplemobiletools.gallery.activities.SimpleActivity
|
|
||||||
import kotlinx.android.synthetic.main.dialog_save_as.view.*
|
import kotlinx.android.synthetic.main.dialog_save_as.view.*
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
class SaveAsDialog(val activity: SimpleActivity, val path: String, val appendFilename: Boolean, val callback: (savePath: String) -> Unit) {
|
class SaveAsDialog(val activity: BaseSimpleActivity, val path: String, val appendFilename: Boolean, val callback: (savePath: String) -> Unit) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
var realPath = File(path).parent.trimEnd('/')
|
var realPath = File(path).parent.trimEnd('/')
|
||||||
|
|
|
@ -4,16 +4,16 @@ import android.support.v7.app.AlertDialog
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
|
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
import com.simplemobiletools.commons.extensions.hideKeyboard
|
import com.simplemobiletools.commons.extensions.hideKeyboard
|
||||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||||
import com.simplemobiletools.commons.extensions.toast
|
import com.simplemobiletools.commons.extensions.toast
|
||||||
import com.simplemobiletools.gallery.R
|
import com.simplemobiletools.gallery.R
|
||||||
import com.simplemobiletools.gallery.activities.SimpleActivity
|
|
||||||
import com.simplemobiletools.gallery.extensions.config
|
import com.simplemobiletools.gallery.extensions.config
|
||||||
import com.simplemobiletools.gallery.helpers.SLIDESHOW_DEFAULT_INTERVAL
|
import com.simplemobiletools.gallery.helpers.SLIDESHOW_DEFAULT_INTERVAL
|
||||||
import kotlinx.android.synthetic.main.dialog_slideshow.view.*
|
import kotlinx.android.synthetic.main.dialog_slideshow.view.*
|
||||||
|
|
||||||
class SlideshowDialog(val activity: SimpleActivity, val callback: () -> Unit) {
|
class SlideshowDialog(val activity: BaseSimpleActivity, val callback: () -> Unit) {
|
||||||
val view: View
|
val view: View
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
|
|
@ -14,11 +14,13 @@ import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
|
||||||
import com.bumptech.glide.request.RequestOptions
|
import com.bumptech.glide.request.RequestOptions
|
||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
import com.google.gson.reflect.TypeToken
|
import com.google.gson.reflect.TypeToken
|
||||||
|
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.*
|
import com.simplemobiletools.commons.helpers.*
|
||||||
import com.simplemobiletools.gallery.BuildConfig
|
import com.simplemobiletools.gallery.BuildConfig
|
||||||
import com.simplemobiletools.gallery.R
|
import com.simplemobiletools.gallery.R
|
||||||
import com.simplemobiletools.gallery.activities.SimpleActivity
|
import com.simplemobiletools.gallery.activities.SimpleActivity
|
||||||
|
import com.simplemobiletools.gallery.dialogs.PickDirectoryDialog
|
||||||
import com.simplemobiletools.gallery.helpers.NOMEDIA
|
import com.simplemobiletools.gallery.helpers.NOMEDIA
|
||||||
import com.simplemobiletools.gallery.models.Directory
|
import com.simplemobiletools.gallery.models.Directory
|
||||||
import com.simplemobiletools.gallery.models.Medium
|
import com.simplemobiletools.gallery.models.Medium
|
||||||
|
@ -89,7 +91,7 @@ fun AppCompatActivity.hideSystemUI() {
|
||||||
View.SYSTEM_UI_FLAG_IMMERSIVE
|
View.SYSTEM_UI_FLAG_IMMERSIVE
|
||||||
}
|
}
|
||||||
|
|
||||||
fun SimpleActivity.addNoMedia(path: String, callback: () -> Unit) {
|
fun BaseSimpleActivity.addNoMedia(path: String, callback: () -> Unit) {
|
||||||
val file = File(path, NOMEDIA)
|
val file = File(path, NOMEDIA)
|
||||||
if (file.exists())
|
if (file.exists())
|
||||||
return
|
return
|
||||||
|
@ -116,14 +118,14 @@ fun SimpleActivity.addNoMedia(path: String, callback: () -> Unit) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun SimpleActivity.removeNoMedia(path: String, callback: (() -> Unit)? = null) {
|
fun BaseSimpleActivity.removeNoMedia(path: String, callback: (() -> Unit)? = null) {
|
||||||
val file = File(path, NOMEDIA)
|
val file = File(path, NOMEDIA)
|
||||||
deleteFile(file) {
|
deleteFile(file) {
|
||||||
callback?.invoke()
|
callback?.invoke()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun SimpleActivity.toggleFileVisibility(oldFile: File, hide: Boolean, callback: ((newFile: File) -> Unit)? = null) {
|
fun BaseSimpleActivity.toggleFileVisibility(oldFile: File, hide: Boolean, callback: ((newFile: File) -> Unit)? = null) {
|
||||||
val path = oldFile.parent
|
val path = oldFile.parent
|
||||||
var filename = oldFile.name
|
var filename = oldFile.name
|
||||||
filename = if (hide) {
|
filename = if (hide) {
|
||||||
|
@ -162,6 +164,29 @@ fun Activity.loadImage(path: String, target: MySquareImageView, horizontalScroll
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun BaseSimpleActivity.tryCopyMoveFilesTo(files: ArrayList<File>, isCopyOperation: Boolean, callback: () -> Unit) {
|
||||||
|
if (files.isEmpty()) {
|
||||||
|
toast(R.string.unknown_error_occurred)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val source = if (files[0].isFile) files[0].parent else files[0].absolutePath
|
||||||
|
PickDirectoryDialog(this, source) {
|
||||||
|
copyMoveFilesTo(files, source.trimEnd('/'), it, isCopyOperation, true, callback)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun BaseSimpleActivity.addTempFolderIfNeeded(dirs: ArrayList<Directory>): ArrayList<Directory> {
|
||||||
|
val directories = ArrayList<Directory>()
|
||||||
|
val tempFolderPath = config.tempFolderPath
|
||||||
|
if (tempFolderPath.isNotEmpty()) {
|
||||||
|
val newFolder = Directory(tempFolderPath, "", tempFolderPath.getFilenameFromPath(), 0, 0, 0, 0L)
|
||||||
|
directories.add(newFolder)
|
||||||
|
}
|
||||||
|
directories.addAll(dirs)
|
||||||
|
return directories
|
||||||
|
}
|
||||||
|
|
||||||
fun Activity.loadPng(path: String, target: MySquareImageView, cropThumbnails: Boolean) {
|
fun Activity.loadPng(path: String, target: MySquareImageView, cropThumbnails: Boolean) {
|
||||||
val options = RequestOptions()
|
val options = RequestOptions()
|
||||||
.signature(path.getFileSignature())
|
.signature(path.getFileSignature())
|
||||||
|
|
|
@ -7,7 +7,6 @@ import android.graphics.Color
|
||||||
import android.graphics.Matrix
|
import android.graphics.Matrix
|
||||||
import android.graphics.drawable.ColorDrawable
|
import android.graphics.drawable.ColorDrawable
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Build
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
@ -302,7 +301,7 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
super.onDestroyView()
|
super.onDestroyView()
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && !activity!!.isDestroyed) {
|
if (activity?.isActivityDestroyed() == false) {
|
||||||
Glide.with(context).clear(view.gif_view)
|
Glide.with(context).clear(view.gif_view)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
android:text="@string/change_filters_underlined"
|
android:text="@string/change_filters_underlined"
|
||||||
android:visibility="gone"/>
|
android:visibility="gone"/>
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyScalableRecyclerView
|
<com.simplemobiletools.commons.views.MyRecyclerView
|
||||||
android:id="@+id/directories_grid"
|
android:id="@+id/directories_grid"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
android:text="@string/change_filters_underlined"
|
android:text="@string/change_filters_underlined"
|
||||||
android:visibility="gone"/>
|
android:visibility="gone"/>
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyScalableRecyclerView
|
<com.simplemobiletools.commons.views.MyRecyclerView
|
||||||
android:id="@+id/media_grid"
|
android:id="@+id/media_grid"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingTop="@dimen/activity_margin">
|
android:paddingTop="@dimen/activity_margin">
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyScalableRecyclerView
|
<com.simplemobiletools.commons.views.MyRecyclerView
|
||||||
android:id="@+id/directories_grid"
|
android:id="@+id/directories_grid"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingTop="@dimen/activity_margin">
|
android:paddingTop="@dimen/activity_margin">
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyScalableRecyclerView
|
<com.simplemobiletools.commons.views.MyRecyclerView
|
||||||
android:id="@+id/media_grid"
|
android:id="@+id/media_grid"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
android:id="@+id/dir_holder"
|
android:id="@+id/dir_holder"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true"
|
||||||
android:padding="1px">
|
android:padding="1px">
|
||||||
|
|
||||||
<com.simplemobiletools.gallery.views.MySquareImageView
|
<com.simplemobiletools.gallery.views.MySquareImageView
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingLeft="@dimen/small_margin"
|
android:paddingLeft="@dimen/small_margin"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true"
|
||||||
android:paddingTop="@dimen/small_margin">
|
android:paddingTop="@dimen/small_margin">
|
||||||
|
|
||||||
<com.simplemobiletools.gallery.views.MySquareImageView
|
<com.simplemobiletools.gallery.views.MySquareImageView
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
android:id="@+id/media_item_holder"
|
android:id="@+id/media_item_holder"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true"
|
||||||
android:padding="1px">
|
android:padding="1px">
|
||||||
|
|
||||||
<com.simplemobiletools.gallery.views.MySquareImageView
|
<com.simplemobiletools.gallery.views.MySquareImageView
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
android:id="@+id/media_item_holder"
|
android:id="@+id/media_item_holder"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true"
|
||||||
android:paddingLeft="@dimen/small_margin"
|
android:paddingLeft="@dimen/small_margin"
|
||||||
android:paddingTop="@dimen/small_margin">
|
android:paddingTop="@dimen/small_margin">
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<background android:drawable="@color/ic_launcher_background"/>
|
<background android:drawable="@color/color_primary"/>
|
||||||
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||||
</adaptive-icon>
|
</adaptive-icon>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<background android:drawable="@color/ic_launcher_background"/>
|
<background android:drawable="@color/color_primary"/>
|
||||||
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||||
</adaptive-icon>
|
</adaptive-icon>
|
||||||
|
|
|
@ -7,6 +7,4 @@
|
||||||
<!-- Default colors -->
|
<!-- Default colors -->
|
||||||
<color name="default_text_color">@color/default_dark_theme_text_color</color>
|
<color name="default_text_color">@color/default_dark_theme_text_color</color>
|
||||||
<color name="default_background_color">@color/default_dark_theme_background_color</color>
|
<color name="default_background_color">@color/default_dark_theme_background_color</color>
|
||||||
|
|
||||||
<color name="ic_launcher_background">@color/color_primary</color>
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue