Prepare code for click listener in AlbumActivity

This commit is contained in:
Fred 2023-07-30 13:45:33 +02:00
parent d9da842df7
commit f15c23cceb
2 changed files with 12 additions and 9 deletions

View File

@ -3,13 +3,15 @@ package org.pixeldroid.app.posts
import android.os.Bundle
import android.view.View
import androidx.activity.viewModels
import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.WindowInsetsControllerCompat
import org.pixeldroid.app.databinding.ActivityAlbumBinding
import org.pixeldroid.app.utils.BaseActivity
class AlbumActivity : BaseActivity() {
private lateinit var model: AlbumViewModel
private var isActionBarHidden = false
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@ -42,19 +44,19 @@ class AlbumActivity : BaseActivity() {
supportActionBar?.setDisplayShowTitleEnabled(false)
supportActionBar?.setBackgroundDrawable(null)
// TODO: Move from StatusViewHolder (877-893) to here
// TODO: Issue is that albumPager does not listen to the clicks
/*binding.albumPager.setOnClickListener {
// TODO: Remove from StatusViewHolder (877-893)
// TODO: Issue is that albumPager does not listen to the clicks here
binding.albumPager.setOnClickListener {
val windowInsetsController =
WindowCompat.getInsetsController(this.window, it)
// Configure the behavior of the hidden system bars
if (isActionBarHidden) {
if (model.uiState.value.isActionBarHidden) {
windowInsetsController.systemBarsBehavior =
WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
// Hide both the status bar and the navigation bar
supportActionBar?.show()
windowInsetsController.show(WindowInsetsCompat.Type.systemBars())
isActionBarHidden = false
model.uiState.value.isActionBarHidden = false
} else {
// Configure the behavior of the hidden system bars
windowInsetsController.systemBarsBehavior =
@ -62,9 +64,9 @@ class AlbumActivity : BaseActivity() {
// Hide both the status bar and the navigation bar
supportActionBar?.hide()
windowInsetsController.hide(WindowInsetsCompat.Type.systemBars())
isActionBarHidden = true
model.uiState.value.isActionBarHidden = true
}
}*/
}
}
}

View File

@ -13,7 +13,8 @@ import org.pixeldroid.app.utils.api.objects.Attachment
data class AlbumUiState(
val mediaAttachments: ArrayList<Attachment> = arrayListOf(),
val index: Int = 0
val index: Int = 0,
var isActionBarHidden: Boolean = false
)
class AlbumViewModel(application: Application, intent: Intent) : AndroidViewModel(application) {