diff --git a/app/src/main/java/org/lineageos/glimpse/ViewActivity.kt b/app/src/main/java/org/lineageos/glimpse/ViewActivity.kt index e101c13..63e6e5b 100644 --- a/app/src/main/java/org/lineageos/glimpse/ViewActivity.kt +++ b/app/src/main/java/org/lineageos/glimpse/ViewActivity.kt @@ -36,6 +36,7 @@ import com.google.android.material.button.MaterialButton import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.launch +import org.lineageos.glimpse.datasources.MediaError import org.lineageos.glimpse.ext.buildEditIntent import org.lineageos.glimpse.ext.buildShareIntent import org.lineageos.glimpse.ext.buildUseAsIntent @@ -356,12 +357,22 @@ class ViewActivity : AppCompatActivity(R.layout.activity_view) { viewModel.setMediaPosition(position) } + + if (medias.isEmpty()) { + // Get out of here + finish() + } } is RequestStatus.Error -> { Log.e(LOG_TAG, "Failed to load medias, error: ${it.error}") mediaViewerAdapter.submitList(listOf()) + + if (it.error == MediaError.NOT_FOUND) { + // Get out of here + finish() + } } } } diff --git a/app/src/main/java/org/lineageos/glimpse/fragments/AlbumFragment.kt b/app/src/main/java/org/lineageos/glimpse/fragments/AlbumFragment.kt index c2c928e..f81f5d7 100644 --- a/app/src/main/java/org/lineageos/glimpse/fragments/AlbumFragment.kt +++ b/app/src/main/java/org/lineageos/glimpse/fragments/AlbumFragment.kt @@ -48,6 +48,7 @@ import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.launch import org.lineageos.glimpse.R import org.lineageos.glimpse.ViewActivity +import org.lineageos.glimpse.datasources.MediaError import org.lineageos.glimpse.ext.buildShareIntent import org.lineageos.glimpse.ext.createDeleteRequest import org.lineageos.glimpse.ext.createTrashRequest @@ -473,6 +474,11 @@ class AlbumFragment : Fragment(R.layout.fragment_album) { recyclerView.isVisible = false toolbar.menu.findItem(R.id.emptyTrash)?.isVisible = false noMediaLinearLayout.isVisible = true + + if (it.error == MediaError.NOT_FOUND) { + // Get out of here + findNavController().navigateUp() + } } } }