From b3b5a9dff7e70efe596e4c714fbf831ae733b1bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ensar=20Saraj=C4=8Di=C4=87?= Date: Thu, 17 Aug 2023 16:12:58 +0200 Subject: [PATCH] Use delegated properties for viewBinding in activities --- .../gallery/pro/activities/EditActivity.kt | 3 +-- .../gallery/pro/activities/ExcludedFoldersActivity.kt | 8 ++------ .../gallery/pro/activities/HiddenFoldersActivity.kt | 4 ++-- .../gallery/pro/activities/IncludedFoldersActivity.kt | 4 ++-- .../gallery/pro/activities/MainActivity.kt | 3 +-- .../gallery/pro/activities/MediaActivity.kt | 3 +-- .../gallery/pro/activities/PanoramaPhotoActivity.kt | 3 +-- .../gallery/pro/activities/PanoramaVideoActivity.kt | 3 +-- .../gallery/pro/activities/PhotoVideoActivity.kt | 3 +-- .../gallery/pro/activities/SearchActivity.kt | 3 +-- .../gallery/pro/activities/SetWallpaperActivity.kt | 4 ++-- .../gallery/pro/activities/SettingsActivity.kt | 3 +-- .../gallery/pro/activities/VideoPlayerActivity.kt | 3 +-- .../gallery/pro/activities/ViewPagerActivity.kt | 3 +-- .../gallery/pro/activities/WidgetConfigureActivity.kt | 3 +-- 15 files changed, 19 insertions(+), 34 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/EditActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/EditActivity.kt index 4dc33ab25..5401ef3e7 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/EditActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/EditActivity.kt @@ -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()) { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ExcludedFoldersActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ExcludedFoldersActivity.kt index 99d98562f..11127c368 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ExcludedFoldersActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ExcludedFoldersActivity.kt @@ -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() diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/HiddenFoldersActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/HiddenFoldersActivity.kt index 456793bde..028815ae1 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/HiddenFoldersActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/HiddenFoldersActivity.kt @@ -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() diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/IncludedFoldersActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/IncludedFoldersActivity.kt index 640dc878e..5c54c2c57 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/IncludedFoldersActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/IncludedFoldersActivity.kt @@ -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() diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt index 415801039..26fae8cd9 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt @@ -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) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt index 29a33e66a..4959158e5 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt @@ -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() @@ -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 { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PanoramaPhotoActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PanoramaPhotoActivity.kt index e649bc4b7..d4e66c4b5 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PanoramaPhotoActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PanoramaPhotoActivity.kt @@ -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() diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PanoramaVideoActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PanoramaVideoActivity.kt index 8857aebf5..028fd557d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PanoramaVideoActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PanoramaVideoActivity.kt @@ -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() diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PhotoVideoActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PhotoVideoActivity.kt index 2dce4e054..30655d7b3 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PhotoVideoActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PhotoVideoActivity.kt @@ -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 diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SearchActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SearchActivity.kt index 608701497..ed0fbc636 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SearchActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SearchActivity.kt @@ -31,12 +31,11 @@ class SearchActivity : SimpleActivity(), MediaOperationsListener { private var mCurrAsyncTask: GetMediaAsynctask? = null private var mAllMedia = ArrayList() - 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) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SetWallpaperActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SetWallpaperActivity.kt index 9621ad358..f03bddbfd 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SetWallpaperActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SetWallpaperActivity.kt @@ -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() diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SettingsActivity.kt index 0d1d4f3a7..bce00c216 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SettingsActivity.kt @@ -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) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/VideoPlayerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/VideoPlayerActivity.kt index 2ddf8567f..81715f88c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/VideoPlayerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/VideoPlayerActivity.kt @@ -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() diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt index 1027578f6..3bc3f8371 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt @@ -82,12 +82,11 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View private var mFavoritePaths = ArrayList() private var mIgnoredPaths = ArrayList() - 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() diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/WidgetConfigureActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/WidgetConfigureActivity.kt index dc11e03bf..26c093814 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/WidgetConfigureActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/WidgetConfigureActivity.kt @@ -30,13 +30,12 @@ class WidgetConfigureActivity : SimpleActivity() { private var mFolderPath = "" private var mDirectories = ArrayList() - 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()