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 fad2c47b8..0d91caba2 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 @@ -294,7 +294,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { if (mCurrentPathPrefix.isEmpty()) { super.onBackPressed() } else { - mOpenedSubfolders.removeAt(mOpenedSubfolders.size - 1) + mOpenedSubfolders.removeLast() mCurrentPathPrefix = mOpenedSubfolders.last() setupAdapter(mDirs) } 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 a9d1df0fa..81c108f08 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 @@ -1279,7 +1279,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View if (refetchViewPagerPosition || mPos == -1) { mPos = getPositionInList(media) if (mPos == -1) { - min(mPos, media.size - 1) + min(mPos, media.lastIndex) } } @@ -1384,7 +1384,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View putExtra(IS_FROM_GALLERY, true) putExtra(REAL_FILE_PATH, path) putExtra(SHOW_PREV_ITEM, view_pager.currentItem != 0) - putExtra(SHOW_NEXT_ITEM, view_pager.currentItem != mMediaFiles.size - 1) + putExtra(SHOW_NEXT_ITEM, view_pager.currentItem != mMediaFiles.lastIndex) try { startActivityForResult(this, REQUEST_VIEW_VIDEO) @@ -1439,7 +1439,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View return if (getCurrentMedia().isEmpty() || mPos == -1) { null } else { - getCurrentMedia()[min(mPos, getCurrentMedia().size - 1)] + getCurrentMedia()[min(mPos, getCurrentMedia().lastIndex)] } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/PortraitPhotosAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/PortraitPhotosAdapter.kt index 1752db8ca..6154e6df6 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/PortraitPhotosAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/PortraitPhotosAdapter.kt @@ -13,10 +13,9 @@ import com.bumptech.glide.signature.ObjectKey import com.simplemobiletools.commons.extensions.getFileKey import com.simplemobiletools.gallery.pro.R import kotlinx.android.synthetic.main.portrait_photo_item.view.* -import java.util.* class PortraitPhotosAdapter(val context: Context, val photos: ArrayList, val sideElementWidth: Int, val itemClick: (Int, Int) -> Unit) : - RecyclerView.Adapter() { + RecyclerView.Adapter() { var currentSelectionIndex = -1 var views = HashMap() @@ -48,7 +47,7 @@ class PortraitPhotosAdapter(val context: Context, val photos: ArrayList, inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) { fun bindView(photo: String, position: Int): View { itemView.apply { - portrait_photo_item_thumbnail.layoutParams.width = if (position == 0 || position == photos.size - 1) { + portrait_photo_item_thumbnail.layoutParams.width = if (position == 0 || position == photos.lastIndex) { sideElementWidth } else { itemWidth @@ -61,15 +60,15 @@ class PortraitPhotosAdapter(val context: Context, val photos: ArrayList, } val options = RequestOptions() - .signature(ObjectKey(photo.getFileKey())) - .diskCacheStrategy(DiskCacheStrategy.RESOURCE) - .centerCrop() + .signature(ObjectKey(photo.getFileKey())) + .diskCacheStrategy(DiskCacheStrategy.RESOURCE) + .centerCrop() Glide.with(context) - .load(photo) - .transition(DrawableTransitionOptions.withCrossFade()) - .apply(options) - .into(portrait_photo_item_thumbnail) + .load(photo) + .transition(DrawableTransitionOptions.withCrossFade()) + .apply(options) + .into(portrait_photo_item_thumbnail) if (photo.isNotEmpty()) { isClickable = true diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/PickDirectoryDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/PickDirectoryDialog.kt index 768567c7b..30424e724 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/PickDirectoryDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/PickDirectoryDialog.kt @@ -147,7 +147,7 @@ class PickDirectoryDialog( if (currentPathPrefix.isEmpty()) { dialog?.dismiss() } else { - openedSubfolders.removeAt(openedSubfolders.size - 1) + openedSubfolders.removeLast() currentPathPrefix = openedSubfolders.last() gotDirectories(allDirectories) } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/jobs/NewPhotoFetcher.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/jobs/NewPhotoFetcher.kt index ad5ada9f7..ad91c0d96 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/jobs/NewPhotoFetcher.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/jobs/NewPhotoFetcher.kt @@ -70,7 +70,7 @@ class NewPhotoFetcher : JobService() { for (uri in params.triggeredContentUris!!) { val path = uri.pathSegments if (path != null && (path.size == PHOTO_PATH_SEGMENTS.size + 1 || path.size == VIDEO_PATH_SEGMENTS.size + 1)) { - ids.add(path[path.size - 1]) + ids.add(path[path.lastIndex]) } }