Minor code formatting
This commit is contained in:
parent
3eeb064c76
commit
99715ca47c
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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<String>, val sideElementWidth: Int, val itemClick: (Int, Int) -> Unit) :
|
||||
RecyclerView.Adapter<PortraitPhotosAdapter.ViewHolder>() {
|
||||
RecyclerView.Adapter<PortraitPhotosAdapter.ViewHolder>() {
|
||||
|
||||
var currentSelectionIndex = -1
|
||||
var views = HashMap<Int, View>()
|
||||
|
@ -48,7 +47,7 @@ class PortraitPhotosAdapter(val context: Context, val photos: ArrayList<String>,
|
|||
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<String>,
|
|||
}
|
||||
|
||||
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
|
||||
|
|
|
@ -147,7 +147,7 @@ class PickDirectoryDialog(
|
|||
if (currentPathPrefix.isEmpty()) {
|
||||
dialog?.dismiss()
|
||||
} else {
|
||||
openedSubfolders.removeAt(openedSubfolders.size - 1)
|
||||
openedSubfolders.removeLast()
|
||||
currentPathPrefix = openedSubfolders.last()
|
||||
gotDirectories(allDirectories)
|
||||
}
|
||||
|
|
|
@ -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])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue