Skip to content

Commit 1f72257

Browse files
committed
Show card only when all elements have been loaded
1 parent 9fd1048 commit 1f72257

File tree

1 file changed

+31
-11
lines changed

1 file changed

+31
-11
lines changed

app/src/main/java/com/klee/sapio/ui/view/EvaluationsActivity.kt

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import android.os.Bundle
1010
import android.os.Environment
1111
import android.provider.MediaStore.Images.Media
1212
import android.util.Log
13+
import android.view.View
1314
import androidx.activity.viewModels
1415
import androidx.annotation.RequiresApi
1516
import androidx.appcompat.app.AppCompatActivity
@@ -109,27 +110,46 @@ class EvaluationsActivity : AppCompatActivity() {
109110
startActivity(intent)
110111
}
111112

113+
hideCard()
112114
mViewModel.listEvaluations(packageName)
113115

114116
val shareImmediately = intent.getBooleanExtra(EXTRA_SHARE_IMMEDIATELY, false)
115117
if (shareImmediately) {
116-
if (settings.isRootConfigurationEnabled()) {
117-
combine(
118-
microgUserReceived, microgRootReceived, bareAospUserReceived,
119-
bareAospRootReceived, iconReceived
120-
) { _, _, _, _, _ ->
121-
share(takeScreenshot(), appName)
122-
}.launchIn(lifecycleScope)
123-
} else {
124-
combine(microgUserReceived, bareAospUserReceived, iconReceived) { _, _, _ ->
125-
share(takeScreenshot(), appName)
126-
}.launchIn(lifecycleScope)
118+
onElementsLoaded {
119+
share(takeScreenshot(), appName)
127120
}
128121
}
129122

123+
onElementsLoaded {
124+
showCard()
125+
}
126+
130127
handleRootConfigurationSetting()
131128
}
132129

130+
private fun hideCard() {
131+
mBinding.card.visibility = View.INVISIBLE
132+
}
133+
134+
private fun showCard() {
135+
mBinding.card.visibility = View.VISIBLE
136+
}
137+
138+
private fun onElementsLoaded(callback: () -> Unit) {
139+
if (settings.isRootConfigurationEnabled()) {
140+
combine(
141+
microgUserReceived, microgRootReceived, bareAospUserReceived,
142+
bareAospRootReceived, iconReceived
143+
) { _, _, _, _, _ ->
144+
callback.invoke()
145+
}.launchIn(lifecycleScope)
146+
} else {
147+
combine(microgUserReceived, bareAospUserReceived, iconReceived) { _, _, _ ->
148+
callback.invoke()
149+
}.launchIn(lifecycleScope)
150+
}
151+
}
152+
133153
private fun handleRootConfigurationSetting() {
134154
val shouldShow = settings.isRootConfigurationEnabled()
135155
with(mBinding) {

0 commit comments

Comments
 (0)