fixing some crashes

This commit is contained in:
tibbi 2019-05-02 19:38:08 +02:00
parent e599087b81
commit 654b3c353b
3 changed files with 13 additions and 9 deletions

View file

@ -1122,7 +1122,10 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
dirs.removeAll(invalidDirs) dirs.removeAll(invalidDirs)
setupAdapter(dirs) setupAdapter(dirs)
invalidDirs.forEach { invalidDirs.forEach {
try {
mDirectoryDao.deleteDirPath(it.path) mDirectoryDao.deleteDirPath(it.path)
} catch (ignored: Exception) {
}
} }
} }
} }

View file

@ -6,7 +6,6 @@ import android.content.Context
import android.content.Intent import android.content.Intent
import android.content.res.Configuration import android.content.res.Configuration
import android.database.Cursor import android.database.Cursor
import android.database.sqlite.SQLiteException
import android.graphics.Point import android.graphics.Point
import android.graphics.drawable.PictureDrawable import android.graphics.drawable.PictureDrawable
import android.media.AudioManager import android.media.AudioManager
@ -477,7 +476,7 @@ fun Context.getCachedDirectories(getVideosOnly: Boolean = false, getImagesOnly:
Thread { Thread {
val directories = try { val directories = try {
directoryDao.getAll() as ArrayList<Directory> directoryDao.getAll() as ArrayList<Directory>
} catch (e: SQLiteException) { } catch (e: Exception) {
ArrayList<Directory>() ArrayList<Directory>()
} }

View file

@ -243,12 +243,14 @@ class PhotoFragment : ViewPagerFragment() {
// avoid GIFs being skewed, played in wrong aspect ratio // avoid GIFs being skewed, played in wrong aspect ratio
if (mMedium.isGIF()) { if (mMedium.isGIF()) {
mView.onGlobalLayout { mView.onGlobalLayout {
if (activity != null) {
measureScreen() measureScreen()
Handler().postDelayed({ Handler().postDelayed({
mView.gif_view_frame.controller.resetState() mView.gif_view_frame.controller.resetState()
loadGif() loadGif()
}, 50) }, 50)
} }
}
} else { } else {
hideZoomableView() hideZoomableView()
loadImage() loadImage()
@ -286,7 +288,7 @@ class PhotoFragment : ViewPagerFragment() {
private fun measureScreen() { private fun measureScreen() {
val metrics = DisplayMetrics() val metrics = DisplayMetrics()
activity!!.windowManager.defaultDisplay.getRealMetrics(metrics) activity?.windowManager?.defaultDisplay?.getRealMetrics(metrics)
mScreenWidth = metrics.widthPixels mScreenWidth = metrics.widthPixels
mScreenHeight = metrics.heightPixels mScreenHeight = metrics.heightPixels
} }