Several fixes to make code work with platform 30

This commit is contained in:
baron 2021-02-03 13:07:46 +01:00
parent 8df146cd39
commit 198b6281ec
6 changed files with 19 additions and 17 deletions

View file

@ -808,7 +808,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
if (newPath.isEmpty()) {
val filename = applicationContext.getFilenameFromContentUri(saveUri) ?: ""
if (filename.isNotEmpty()) {
val path = if (intent.extras?.containsKey(REAL_FILE_PATH) == true) intent.getStringExtra(REAL_FILE_PATH).getParentPath() else internalStoragePath
val path = if (intent.extras?.containsKey(REAL_FILE_PATH) == true) intent.getStringExtra(REAL_FILE_PATH)?.getParentPath() else internalStoragePath
newPath = "$path/$filename"
shouldAppendFilename = false
}

View file

@ -97,7 +97,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
media_refresh_layout.setOnRefreshListener { getMedia() }
try {
mPath = intent.getStringExtra(DIRECTORY)
mPath = intent.getStringExtra(DIRECTORY) ?: ""
} catch (e: Exception) {
showErrorToast(e)
finish()

View file

@ -20,13 +20,15 @@ import com.simplemobiletools.gallery.pro.extensions.updateDirectoryPath
open class SimpleActivity : BaseSimpleActivity() {
val observer = object : ContentObserver(null) {
override fun onChange(selfChange: Boolean, uri: Uri) {
override fun onChange(selfChange: Boolean, uri: Uri?) {
super.onChange(selfChange, uri)
val path = getRealPathFromURI(uri)
if (path != null) {
updateDirectoryPath(path.getParentPath())
addPathToDB(path)
}
if (uri != null) {
val path = getRealPathFromURI(uri)
if (path != null) {
updateDirectoryPath(path.getParentPath())
addPathToDB(path)
}
}
}
}

View file

@ -618,16 +618,16 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen
mIsDragged = false
}
override fun onSurfaceTextureUpdated(surface: SurfaceTexture?) {
override fun onSurfaceTextureUpdated(surface: SurfaceTexture) {
}
override fun onSurfaceTextureDestroyed(surface: SurfaceTexture?) = false
override fun onSurfaceTextureDestroyed(surface: SurfaceTexture) = false
override fun onSurfaceTextureAvailable(surface: SurfaceTexture?, width: Int, height: Int) {
override fun onSurfaceTextureAvailable(surface: SurfaceTexture, width: Int, height: Int) {
ensureBackgroundThread {
mExoPlayer?.setVideoSurface(Surface(video_surface!!.surfaceTexture))
}
}
override fun onSurfaceTextureSizeChanged(surface: SurfaceTexture?, width: Int, height: Int) {}
override fun onSurfaceTextureSizeChanged(surface: SurfaceTexture, width: Int, height: Int) {}
}

View file

@ -272,7 +272,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
}
} else {
try {
mPath = intent.getStringExtra(PATH)
mPath = intent.getStringExtra(PATH) ?: ""
mShowAll = config.showAll
} catch (e: Exception) {
showErrorToast(e)

View file

@ -759,13 +759,13 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
}
}
override fun onSurfaceTextureSizeChanged(surface: SurfaceTexture?, width: Int, height: Int) {}
override fun onSurfaceTextureSizeChanged(surface: SurfaceTexture, width: Int, height: Int) {}
override fun onSurfaceTextureUpdated(surface: SurfaceTexture?) {}
override fun onSurfaceTextureUpdated(surface: SurfaceTexture) {}
override fun onSurfaceTextureDestroyed(surface: SurfaceTexture?) = false
override fun onSurfaceTextureDestroyed(surface: SurfaceTexture) = false
override fun onSurfaceTextureAvailable(surface: SurfaceTexture?, width: Int, height: Int) {
override fun onSurfaceTextureAvailable(surface: SurfaceTexture, width: Int, height: Int) {
ensureBackgroundThread {
mExoPlayer?.setVideoSurface(Surface(mTextureView.surfaceTexture))
}