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

View file

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