Minor code formatting

This commit is contained in:
Naveen 2022-09-24 01:13:28 +05:30
parent 3eeb064c76
commit 99715ca47c
5 changed files with 15 additions and 16 deletions

View file

@ -294,7 +294,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
if (mCurrentPathPrefix.isEmpty()) { if (mCurrentPathPrefix.isEmpty()) {
super.onBackPressed() super.onBackPressed()
} else { } else {
mOpenedSubfolders.removeAt(mOpenedSubfolders.size - 1) mOpenedSubfolders.removeLast()
mCurrentPathPrefix = mOpenedSubfolders.last() mCurrentPathPrefix = mOpenedSubfolders.last()
setupAdapter(mDirs) setupAdapter(mDirs)
} }

View file

@ -1279,7 +1279,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
if (refetchViewPagerPosition || mPos == -1) { if (refetchViewPagerPosition || mPos == -1) {
mPos = getPositionInList(media) mPos = getPositionInList(media)
if (mPos == -1) { 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(IS_FROM_GALLERY, true)
putExtra(REAL_FILE_PATH, path) putExtra(REAL_FILE_PATH, path)
putExtra(SHOW_PREV_ITEM, view_pager.currentItem != 0) 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 { try {
startActivityForResult(this, REQUEST_VIEW_VIDEO) startActivityForResult(this, REQUEST_VIEW_VIDEO)
@ -1439,7 +1439,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
return if (getCurrentMedia().isEmpty() || mPos == -1) { return if (getCurrentMedia().isEmpty() || mPos == -1) {
null null
} else { } else {
getCurrentMedia()[min(mPos, getCurrentMedia().size - 1)] getCurrentMedia()[min(mPos, getCurrentMedia().lastIndex)]
} }
} }

View file

@ -13,7 +13,6 @@ import com.bumptech.glide.signature.ObjectKey
import com.simplemobiletools.commons.extensions.getFileKey import com.simplemobiletools.commons.extensions.getFileKey
import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.R
import kotlinx.android.synthetic.main.portrait_photo_item.view.* import kotlinx.android.synthetic.main.portrait_photo_item.view.*
import java.util.*
class PortraitPhotosAdapter(val context: Context, val photos: ArrayList<String>, val sideElementWidth: Int, val itemClick: (Int, Int) -> Unit) : class PortraitPhotosAdapter(val context: Context, val photos: ArrayList<String>, val sideElementWidth: Int, val itemClick: (Int, Int) -> Unit) :
RecyclerView.Adapter<PortraitPhotosAdapter.ViewHolder>() { RecyclerView.Adapter<PortraitPhotosAdapter.ViewHolder>() {
@ -48,7 +47,7 @@ class PortraitPhotosAdapter(val context: Context, val photos: ArrayList<String>,
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) { inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
fun bindView(photo: String, position: Int): View { fun bindView(photo: String, position: Int): View {
itemView.apply { 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 sideElementWidth
} else { } else {
itemWidth itemWidth

View file

@ -147,7 +147,7 @@ class PickDirectoryDialog(
if (currentPathPrefix.isEmpty()) { if (currentPathPrefix.isEmpty()) {
dialog?.dismiss() dialog?.dismiss()
} else { } else {
openedSubfolders.removeAt(openedSubfolders.size - 1) openedSubfolders.removeLast()
currentPathPrefix = openedSubfolders.last() currentPathPrefix = openedSubfolders.last()
gotDirectories(allDirectories) gotDirectories(allDirectories)
} }

View file

@ -70,7 +70,7 @@ class NewPhotoFetcher : JobService() {
for (uri in params.triggeredContentUris!!) { for (uri in params.triggeredContentUris!!) {
val path = uri.pathSegments val path = uri.pathSegments
if (path != null && (path.size == PHOTO_PATH_SEGMENTS.size + 1 || path.size == VIDEO_PATH_SEGMENTS.size + 1)) { 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])
} }
} }