move some constants outside of the constants object
This commit is contained in:
parent
b3f285f7f4
commit
56ba895302
8 changed files with 29 additions and 34 deletions
|
@ -23,14 +23,12 @@ val SORT_DESCENDING = 1024
|
|||
// global intents
|
||||
val OPEN_DOCUMENT_TREE = 1000
|
||||
|
||||
object Constants {
|
||||
val DIRECTORY = "directory"
|
||||
val MEDIUM = "medium"
|
||||
val GET_IMAGE_INTENT = "get_image_intent"
|
||||
val GET_VIDEO_INTENT = "get_video_intent"
|
||||
val GET_ANY_INTENT = "get_any_intent"
|
||||
val SET_WALLPAPER_INTENT = "set_wallpaper_intent"
|
||||
}
|
||||
val DIRECTORY = "directory"
|
||||
val MEDIUM = "medium"
|
||||
val GET_IMAGE_INTENT = "get_image_intent"
|
||||
val GET_VIDEO_INTENT = "get_video_intent"
|
||||
val GET_ANY_INTENT = "get_any_intent"
|
||||
val SET_WALLPAPER_INTENT = "set_wallpaper_intent"
|
||||
|
||||
val REQUEST_EDIT_IMAGE = 1
|
||||
val REQUEST_SET_WALLPAPER = 2
|
||||
|
|
|
@ -14,9 +14,7 @@ import android.view.Menu
|
|||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import com.simplemobiletools.filepicker.extensions.*
|
||||
import com.simplemobiletools.gallery.Constants
|
||||
import com.simplemobiletools.gallery.R
|
||||
import com.simplemobiletools.gallery.Utils
|
||||
import com.simplemobiletools.gallery.*
|
||||
import com.simplemobiletools.gallery.adapters.DirectoryAdapter
|
||||
import com.simplemobiletools.gallery.asynctasks.GetDirectoriesAsynctask
|
||||
import com.simplemobiletools.gallery.dialogs.ChangeSortingDialog
|
||||
|
@ -277,15 +275,15 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
|||
|
||||
fun itemClicked(path: String) {
|
||||
Intent(this, MediaActivity::class.java).apply {
|
||||
putExtra(Constants.DIRECTORY, path)
|
||||
putExtra(DIRECTORY, path)
|
||||
|
||||
if (mIsSetWallpaperIntent) {
|
||||
putExtra(Constants.SET_WALLPAPER_INTENT, true)
|
||||
putExtra(SET_WALLPAPER_INTENT, true)
|
||||
startActivityForResult(this, PICK_WALLPAPER)
|
||||
} else {
|
||||
putExtra(Constants.GET_IMAGE_INTENT, mIsPickImageIntent || mIsGetImageContentIntent)
|
||||
putExtra(Constants.GET_VIDEO_INTENT, mIsPickVideoIntent || mIsGetVideoContentIntent)
|
||||
putExtra(Constants.GET_ANY_INTENT, mIsGetAnyContentIntent)
|
||||
putExtra(GET_IMAGE_INTENT, mIsPickImageIntent || mIsGetImageContentIntent)
|
||||
putExtra(GET_VIDEO_INTENT, mIsPickVideoIntent || mIsGetVideoContentIntent)
|
||||
putExtra(GET_ANY_INTENT, mIsGetAnyContentIntent)
|
||||
startActivityForResult(this, PICK_MEDIA)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,8 +16,7 @@ import com.bumptech.glide.Glide
|
|||
import com.bumptech.glide.request.animation.GlideAnimation
|
||||
import com.bumptech.glide.request.target.SimpleTarget
|
||||
import com.simplemobiletools.filepicker.extensions.*
|
||||
import com.simplemobiletools.gallery.Constants
|
||||
import com.simplemobiletools.gallery.R
|
||||
import com.simplemobiletools.gallery.*
|
||||
import com.simplemobiletools.gallery.adapters.MediaAdapter
|
||||
import com.simplemobiletools.gallery.asynctasks.GetMediaAsynctask
|
||||
import com.simplemobiletools.gallery.dialogs.ChangeSortingDialog
|
||||
|
@ -48,13 +47,13 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_media)
|
||||
intent.apply {
|
||||
mIsGetImageIntent = getBooleanExtra(Constants.GET_IMAGE_INTENT, false)
|
||||
mIsGetVideoIntent = getBooleanExtra(Constants.GET_VIDEO_INTENT, false)
|
||||
mIsGetAnyIntent = getBooleanExtra(Constants.GET_ANY_INTENT, false)
|
||||
mIsGetImageIntent = getBooleanExtra(GET_IMAGE_INTENT, false)
|
||||
mIsGetVideoIntent = getBooleanExtra(GET_VIDEO_INTENT, false)
|
||||
mIsGetAnyIntent = getBooleanExtra(GET_ANY_INTENT, false)
|
||||
}
|
||||
|
||||
media_holder.setOnRefreshListener({ getMedia() })
|
||||
mPath = intent.getStringExtra(Constants.DIRECTORY)
|
||||
mPath = intent.getStringExtra(DIRECTORY)
|
||||
mToBeDeleted = ArrayList<String>()
|
||||
mMedia = ArrayList<Medium>()
|
||||
}
|
||||
|
@ -260,7 +259,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||
}
|
||||
}
|
||||
|
||||
private fun isSetWallpaperIntent() = intent.getBooleanExtra(Constants.SET_WALLPAPER_INTENT, false)
|
||||
private fun isSetWallpaperIntent() = intent.getBooleanExtra(SET_WALLPAPER_INTENT, false)
|
||||
|
||||
fun itemClicked(path: String) {
|
||||
if (isSetWallpaperIntent()) {
|
||||
|
@ -294,7 +293,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||
finish()
|
||||
} else {
|
||||
Intent(this, ViewPagerActivity::class.java).apply {
|
||||
putExtra(Constants.MEDIUM, path)
|
||||
putExtra(MEDIUM, path)
|
||||
startActivity(this)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import android.os.Bundle
|
|||
import android.provider.MediaStore
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import com.simplemobiletools.gallery.Constants
|
||||
import com.simplemobiletools.gallery.MEDIUM
|
||||
import com.simplemobiletools.gallery.R
|
||||
import com.simplemobiletools.gallery.fragments.PhotoFragment
|
||||
import com.simplemobiletools.gallery.fragments.VideoFragment
|
||||
|
@ -32,7 +32,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentClic
|
|||
|
||||
if (mUri.scheme == "file") {
|
||||
Intent(this, ViewPagerActivity::class.java).apply {
|
||||
putExtra(Constants.MEDIUM, mUri.path)
|
||||
putExtra(MEDIUM, mUri.path)
|
||||
startActivity(this)
|
||||
}
|
||||
finish()
|
||||
|
@ -42,7 +42,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentClic
|
|||
val bundle = Bundle()
|
||||
val file = File(mUri.toString())
|
||||
val medium = Medium(file.name, mUri.toString(), mIsVideo, 0, file.length())
|
||||
bundle.putSerializable(Constants.MEDIUM, medium)
|
||||
bundle.putSerializable(MEDIUM, medium)
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
mFragment = if (mIsVideo) VideoFragment() else PhotoFragment()
|
||||
|
|
|
@ -64,7 +64,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||
cursor?.close()
|
||||
}
|
||||
} else {
|
||||
mPath = intent.getStringExtra(Constants.MEDIUM)
|
||||
mPath = intent.getStringExtra(MEDIUM)
|
||||
}
|
||||
|
||||
if (mPath.isEmpty()) {
|
||||
|
|
|
@ -5,7 +5,7 @@ import android.support.v4.app.Fragment
|
|||
import android.support.v4.app.FragmentManager
|
||||
import android.support.v4.app.FragmentStatePagerAdapter
|
||||
import android.util.SparseArray
|
||||
import com.simplemobiletools.gallery.Constants
|
||||
import com.simplemobiletools.gallery.MEDIUM
|
||||
import com.simplemobiletools.gallery.activities.ViewPagerActivity
|
||||
import com.simplemobiletools.gallery.fragments.PhotoFragment
|
||||
import com.simplemobiletools.gallery.fragments.VideoFragment
|
||||
|
@ -24,7 +24,7 @@ class MyPagerAdapter(val activity: ViewPagerActivity, fm: FragmentManager, val m
|
|||
override fun getItem(position: Int): Fragment {
|
||||
val medium = media[position]
|
||||
val bundle = Bundle()
|
||||
bundle.putSerializable(Constants.MEDIUM, medium)
|
||||
bundle.putSerializable(MEDIUM, medium)
|
||||
val fragment: ViewPagerFragment
|
||||
|
||||
if (medium.isVideo) {
|
||||
|
|
|
@ -9,7 +9,7 @@ import com.bumptech.glide.Glide
|
|||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||
import com.davemorrissey.labs.subscaleview.ImageSource
|
||||
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
|
||||
import com.simplemobiletools.gallery.Constants
|
||||
import com.simplemobiletools.gallery.MEDIUM
|
||||
import com.simplemobiletools.gallery.R
|
||||
import com.simplemobiletools.gallery.extensions.getRealPathFromURI
|
||||
import com.simplemobiletools.gallery.models.Medium
|
||||
|
@ -22,7 +22,7 @@ class PhotoFragment : ViewPagerFragment(), View.OnClickListener {
|
|||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||
val view = inflater.inflate(R.layout.pager_photo_item, container, false)
|
||||
|
||||
medium = arguments.getSerializable(Constants.MEDIUM) as Medium
|
||||
medium = arguments.getSerializable(MEDIUM) as Medium
|
||||
if (medium.path.startsWith("content://"))
|
||||
medium.path = context.getRealPathFromURI(Uri.parse(medium.path)) ?: ""
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ import android.view.animation.AnimationUtils
|
|||
import android.widget.SeekBar
|
||||
import android.widget.TextView
|
||||
import com.simplemobiletools.gallery.Config
|
||||
import com.simplemobiletools.gallery.Constants
|
||||
import com.simplemobiletools.gallery.MEDIUM
|
||||
import com.simplemobiletools.gallery.R
|
||||
import com.simplemobiletools.gallery.Utils
|
||||
import com.simplemobiletools.gallery.models.Medium
|
||||
|
@ -51,7 +51,7 @@ class VideoFragment : ViewPagerFragment(), View.OnClickListener, SurfaceHolder.C
|
|||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
mView = inflater.inflate(R.layout.pager_video_item, container, false)
|
||||
|
||||
mMedium = arguments.getSerializable(Constants.MEDIUM) as Medium
|
||||
mMedium = arguments.getSerializable(MEDIUM) as Medium
|
||||
if (savedInstanceState != null) {
|
||||
mCurrTime = savedInstanceState.getInt(PROGRESS)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue