Use delegated properties for viewBinding in activities

This commit is contained in:
Ensar Sarajčić 2023-08-17 16:12:58 +02:00
parent dd91cfe713
commit b3b5a9dff7
15 changed files with 19 additions and 34 deletions

View file

@ -89,11 +89,10 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
private var oldExif: ExifInterface? = null
private var filterInitialBitmap: Bitmap? = null
private var originalUri: Uri? = null
private lateinit var binding: ActivityEditBinding
private val binding by viewBinding(ActivityEditBinding::inflate)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityEditBinding.inflate(layoutInflater)
setContentView(binding.root)
if (checkAppSideloading()) {

View file

@ -2,10 +2,7 @@ package com.simplemobiletools.gallery.pro.activities
import android.os.Bundle
import com.simplemobiletools.commons.dialogs.FilePickerDialog
import com.simplemobiletools.commons.extensions.beVisibleIf
import com.simplemobiletools.commons.extensions.getProperTextColor
import com.simplemobiletools.commons.extensions.internalStoragePath
import com.simplemobiletools.commons.extensions.isExternalStorageManager
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.NavigationIcon
import com.simplemobiletools.commons.helpers.isRPlus
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
@ -16,12 +13,11 @@ import com.simplemobiletools.gallery.pro.extensions.config
class ExcludedFoldersActivity : SimpleActivity(), RefreshRecyclerViewListener {
private lateinit var binding: ActivityManageFoldersBinding
private val binding by viewBinding(ActivityManageFoldersBinding::inflate)
override fun onCreate(savedInstanceState: Bundle?) {
isMaterialActivity = true
super.onCreate(savedInstanceState)
binding = ActivityManageFoldersBinding.inflate(layoutInflater)
setContentView(binding.root)
updateFolders()
setupOptionsMenu()

View file

@ -4,6 +4,7 @@ import android.os.Bundle
import com.simplemobiletools.commons.dialogs.FilePickerDialog
import com.simplemobiletools.commons.extensions.beVisibleIf
import com.simplemobiletools.commons.extensions.getProperTextColor
import com.simplemobiletools.commons.extensions.viewBinding
import com.simplemobiletools.commons.helpers.NavigationIcon
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
@ -16,11 +17,10 @@ import com.simplemobiletools.gallery.pro.extensions.getNoMediaFolders
class HiddenFoldersActivity : SimpleActivity(), RefreshRecyclerViewListener {
private lateinit var binding: ActivityManageFoldersBinding
private val binding by viewBinding(ActivityManageFoldersBinding::inflate)
override fun onCreate(savedInstanceState: Bundle?) {
isMaterialActivity = true
super.onCreate(savedInstanceState)
binding = ActivityManageFoldersBinding.inflate(layoutInflater)
setContentView(binding.root)
updateFolders()
setupOptionsMenu()

View file

@ -3,6 +3,7 @@ package com.simplemobiletools.gallery.pro.activities
import android.os.Bundle
import com.simplemobiletools.commons.extensions.beVisibleIf
import com.simplemobiletools.commons.extensions.getProperTextColor
import com.simplemobiletools.commons.extensions.viewBinding
import com.simplemobiletools.commons.helpers.NavigationIcon
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
import com.simplemobiletools.gallery.pro.R
@ -12,12 +13,11 @@ import com.simplemobiletools.gallery.pro.extensions.config
class IncludedFoldersActivity : SimpleActivity(), RefreshRecyclerViewListener {
private lateinit var binding: ActivityManageFoldersBinding
private val binding by viewBinding(ActivityManageFoldersBinding::inflate)
override fun onCreate(savedInstanceState: Bundle?) {
isMaterialActivity = true
super.onCreate(savedInstanceState)
binding = ActivityManageFoldersBinding.inflate(layoutInflater)
setContentView(binding.root)
updateFolders()
setupOptionsMenu()

View file

@ -83,12 +83,11 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
private var mStoredTextColor = 0
private var mStoredPrimaryColor = 0
private var mStoredStyleString = ""
private lateinit var binding: ActivityMainBinding
private val binding by viewBinding(ActivityMainBinding::inflate)
override fun onCreate(savedInstanceState: Bundle?) {
isMaterialActivity = true
super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
appLaunched(BuildConfig.APPLICATION_ID)

View file

@ -70,7 +70,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
private var mStoredPrimaryColor = 0
private var mStoredThumbnailSpacing = 0
private lateinit var binding: ActivityMediaBinding
private val binding by viewBinding(ActivityMediaBinding::inflate)
companion object {
var mMedia = ArrayList<ThumbnailItem>()
@ -79,7 +79,6 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
override fun onCreate(savedInstanceState: Bundle?) {
isMaterialActivity = true
super.onCreate(savedInstanceState)
binding = ActivityMediaBinding.inflate(layoutInflater)
setContentView(binding.root)
intent.apply {

View file

@ -29,13 +29,12 @@ open class PanoramaPhotoActivity : SimpleActivity() {
private var isExploreEnabled = true
private var isRendering = false
private lateinit var binding: ActivityPanoramaPhotoBinding
private val binding by viewBinding(ActivityPanoramaPhotoBinding::inflate)
public override fun onCreate(savedInstanceState: Bundle?) {
useDynamicTheme = false
requestWindowFeature(Window.FEATURE_NO_TITLE)
super.onCreate(savedInstanceState)
binding = ActivityPanoramaPhotoBinding.inflate(layoutInflater)
setContentView(binding.root)
checkNotchSupport()

View file

@ -38,13 +38,12 @@ open class PanoramaVideoActivity : SimpleActivity(), SeekBar.OnSeekBarChangeList
private var mCurrTime = 0
private var mTimerHandler = Handler()
private lateinit var binding: ActivityPanoramaVideoBinding
private val binding by viewBinding(ActivityPanoramaVideoBinding::inflate)
public override fun onCreate(savedInstanceState: Bundle?) {
useDynamicTheme = false
requestWindowFeature(Window.FEATURE_NO_TITLE)
super.onCreate(savedInstanceState)
binding = ActivityPanoramaVideoBinding.inflate(layoutInflater)
setContentView(binding.root)
checkNotchSupport()

View file

@ -34,13 +34,12 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
var mIsVideo = false
private lateinit var binding: FragmentHolderBinding
private val binding by viewBinding(FragmentHolderBinding::inflate)
public override fun onCreate(savedInstanceState: Bundle?) {
showTransparentTop = true
super.onCreate(savedInstanceState)
binding = FragmentHolderBinding.inflate(layoutInflater)
setContentView(binding.root)
if (checkAppSideloading()) {
return

View file

@ -31,12 +31,11 @@ class SearchActivity : SimpleActivity(), MediaOperationsListener {
private var mCurrAsyncTask: GetMediaAsynctask? = null
private var mAllMedia = ArrayList<ThumbnailItem>()
private lateinit var binding: ActivitySearchBinding
private val binding by viewBinding(ActivitySearchBinding::inflate)
override fun onCreate(savedInstanceState: Bundle?) {
isMaterialActivity = true
super.onCreate(savedInstanceState)
binding = ActivitySearchBinding.inflate(layoutInflater)
setContentView(binding.root)
setupOptionsMenu()
updateMaterialActivityViews(binding.searchCoordinator, binding.searchGrid, useTransparentNavigation = true, useTopSearchMenu = true)

View file

@ -10,6 +10,7 @@ import com.canhub.cropper.CropImageView
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
import com.simplemobiletools.commons.extensions.checkAppSideloading
import com.simplemobiletools.commons.extensions.toast
import com.simplemobiletools.commons.extensions.viewBinding
import com.simplemobiletools.commons.helpers.NavigationIcon
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
import com.simplemobiletools.commons.helpers.isNougatPlus
@ -29,11 +30,10 @@ class SetWallpaperActivity : SimpleActivity(), CropImageView.OnCropImageComplete
lateinit var uri: Uri
lateinit var wallpaperManager: WallpaperManager
private lateinit var binding: ActivitySetWallpaperBinding
private val binding by viewBinding(ActivitySetWallpaperBinding::inflate)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivitySetWallpaperBinding.inflate(layoutInflater)
setContentView(binding.root)
setupBottomActions()

View file

@ -32,12 +32,11 @@ class SettingsActivity : SimpleActivity() {
}
private var mRecycleBinContentSize = 0L
private lateinit var binding: ActivitySettingsBinding
private val binding by viewBinding(ActivitySettingsBinding::inflate)
override fun onCreate(savedInstanceState: Bundle?) {
isMaterialActivity = true
super.onCreate(savedInstanceState)
binding = ActivitySettingsBinding.inflate(layoutInflater)
setContentView(binding.root)
updateMaterialActivityViews(binding.settingsCoordinator, binding.settingsHolder, useTransparentNavigation = true, useTopSearchMenu = false)

View file

@ -58,12 +58,11 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen
private var mIgnoreCloseDown = false
private lateinit var binding: ActivityVideoPlayerBinding
private val binding by viewBinding(ActivityVideoPlayerBinding::inflate)
public override fun onCreate(savedInstanceState: Bundle?) {
showTransparentTop = true
super.onCreate(savedInstanceState)
binding = ActivityVideoPlayerBinding.inflate(layoutInflater)
setContentView(binding.root)
setupOptionsMenu()
setupOrientation()

View file

@ -82,12 +82,11 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
private var mFavoritePaths = ArrayList<String>()
private var mIgnoredPaths = ArrayList<String>()
private lateinit var binding: ActivityMediumBinding
private val binding by viewBinding(ActivityMediumBinding::inflate)
override fun onCreate(savedInstanceState: Bundle?) {
showTransparentTop = true
super.onCreate(savedInstanceState)
binding = ActivityMediumBinding.inflate(layoutInflater)
setContentView(binding.root)
setupOptionsMenu()
refreshMenuItems()

View file

@ -30,13 +30,12 @@ class WidgetConfigureActivity : SimpleActivity() {
private var mFolderPath = ""
private var mDirectories = ArrayList<Directory>()
private lateinit var binding: ActivityWidgetConfigBinding
private val binding by viewBinding(ActivityWidgetConfigBinding::inflate)
public override fun onCreate(savedInstanceState: Bundle?) {
useDynamicTheme = false
super.onCreate(savedInstanceState)
setResult(RESULT_CANCELED)
binding = ActivityWidgetConfigBinding.inflate(layoutInflater)
setContentView(binding.root)
initVariables()