implement the prev/next button functionality

This commit is contained in:
tibbi 2019-01-08 12:35:42 +01:00
parent 81857948be
commit 7f32e650c7
4 changed files with 26 additions and 15 deletions

View file

@ -176,6 +176,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
val mimeType = getUriMimeType(mUri.toString(), newUri)
Intent(applicationContext, VideoPlayerActivity::class.java).apply {
setDataAndType(newUri, mimeType)
addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT)
if (intent.extras != null) {
putExtras(intent.extras!!)
}

View file

@ -1,5 +1,7 @@
package com.simplemobiletools.gallery.pro.activities
import android.app.Activity
import android.content.Intent
import android.content.pm.ActivityInfo
import android.content.res.Configuration
import android.graphics.Color
@ -547,11 +549,19 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen
}
private fun handleNextFile() {
Intent().apply {
putExtra(GO_TO_NEXT_ITEM, true)
setResult(Activity.RESULT_OK, this)
}
finish()
}
private fun handlePrevFile() {
Intent().apply {
putExtra(GO_TO_PREV_ITEM, true)
setResult(Activity.RESULT_OK, this)
}
finish()
}
private fun resetPlayWhenReady() {

View file

@ -910,18 +910,18 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
}
override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) {
if (requestCode == REQUEST_EDIT_IMAGE) {
if (resultCode == Activity.RESULT_OK && resultData != null) {
if (requestCode == REQUEST_EDIT_IMAGE && resultCode == Activity.RESULT_OK && resultData != null) {
mPos = -1
mPrevHashcode = 0
refreshViewPager()
}
} else if (requestCode == REQUEST_SET_AS) {
if (resultCode == Activity.RESULT_OK) {
} else if (requestCode == REQUEST_SET_AS && resultCode == Activity.RESULT_OK) {
toast(R.string.wallpaper_set_successfully)
} else if (requestCode == REQUEST_VIEW_VIDEO && resultCode == Activity.RESULT_OK && resultData != null) {
if (resultData.getBooleanExtra(GO_TO_NEXT_ITEM, false)) {
goToNextItem()
} else if (resultData.getBooleanExtra(GO_TO_PREV_ITEM, false)) {
goToPrevItem()
}
} else if (requestCode == REQUEST_VIEW_VIDEO) {
}
super.onActivityResult(requestCode, resultCode, resultData)
}

View file

@ -94,13 +94,13 @@ const val SHOW_FAVORITES = "show_favorites"
const val SHOW_RECYCLE_BIN = "show_recycle_bin"
const val SHOW_NEXT_ITEM = "show_next_item"
const val SHOW_PREV_ITEM = "show_prev_item"
const val GO_TO_NEXT_ITEM = "go_to_next_item"
const val GO_TO_PREV_ITEM = "go_to_prev_item"
const val MAX_COLUMN_COUNT = 20
const val SHOW_TEMP_HIDDEN_DURATION = 300000L
const val CLICK_MAX_DURATION = 150
const val DRAG_THRESHOLD = 8
const val MONTH_MILLISECONDS = MONTH_SECONDS * 1000L
const val HIDE_PLAY_PAUSE_DELAY = 500L
const val PLAY_PAUSE_VISIBLE_ALPHA = 0.8f
const val MIN_SKIP_LENGTH = 2000
const val DIRECTORY = "directory"