Skip to content

Commit

Permalink
Glimpse: Handle not found and empty albums again
Browse files Browse the repository at this point in the history
Change-Id: I21ad32034710f65ce6ed22502b733893b0e36b86
  • Loading branch information
SebaUbuntu committed Jan 2, 2025
1 parent 4797054 commit 37f3b68
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/src/main/java/org/lineageos/glimpse/ViewActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
}
}
}
}
Expand Down

0 comments on commit 37f3b68

Please sign in to comment.