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 {
mDirectoryDao.deleteDirPath(it.path) try {
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,11 +243,13 @@ 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 {
measureScreen() if (activity != null) {
Handler().postDelayed({ measureScreen()
mView.gif_view_frame.controller.resetState() Handler().postDelayed({
loadGif() mView.gif_view_frame.controller.resetState()
}, 50) loadGif()
}, 50)
}
} }
} else { } else {
hideZoomableView() hideZoomableView()
@ -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
} }