Skip to content

Commit c3ee550

Browse files
committed
Removed several adapter post calls that were causing issues
1 parent 7dd6fc0 commit c3ee550

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

app/src/main/java/com/michaelfotiads/xkcdreader/ui/MainActivity.kt

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ class MainActivity : AppCompatActivity(), HasSupportFragmentInjector {
161161
private fun onItemSwiped(direction: SwipeDirection?) {
162162
Timber.d("On Card Swiped $direction and we are now at top index ${card_stack_view.topIndex}")
163163
// remove the item so it won't refresh with the adapter
164-
card_stack_view.post { adapter.remove(adapter.getItem(card_stack_view.topIndex - 1)) }
164+
adapter.remove(adapter.getItem(card_stack_view.topIndex - 1))
165165
if (adapter.count == 0) {
166166
Toasty.success(this@MainActivity, getString(R.string.message_all_caught_up)).show()
167167
} else {
@@ -181,20 +181,16 @@ class MainActivity : AppCompatActivity(), HasSupportFragmentInjector {
181181
private fun onResetAdapter(shouldReset: Boolean) {
182182
if (shouldReset) {
183183
Timber.d("Resetting adapter data")
184-
card_stack_view.post {
185-
adapter.clear()
186-
adapter.notifyDataSetChanged()
187-
}
184+
adapter.clear()
185+
adapter.notifyDataSetChanged()
188186
}
189187
}
190188

191189
private fun onResult(comicStrip: UiComicStrip) {
192190
Timber.d("Loaded item with ID ${comicStrip.number}")
193-
card_stack_view.post {
194-
adapter.add(comicStrip)
195-
Timber.d("Adapter has ${adapter.count} items")
196-
viewModel.loadAdditionalData(adapter.count)
197-
}
191+
adapter.add(comicStrip)
192+
Timber.d("Adapter has ${adapter.count} items")
193+
viewModel.loadAdditionalData(adapter.count)
198194
}
199195

200196
private fun onError(uiError: UiError?) {

0 commit comments

Comments
 (0)