Skip to content

Commit 26949af

Browse files
committed
fix StackOverflow in withProgressDialog
1 parent f80a1b5 commit 26949af

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

app/src/main/kotlin/com/hana053/micropost/pages/Presenter.kt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,20 @@ interface Presenter<out T : ViewWrapper> {
1515
fun bind()
1616

1717
fun <T> Observable<T>.withProgressDialog(): Observable<T> = Observable.using({
18-
ProgressBar(view.context(), null, android.R.attr.progressBarStyle).apply {
18+
val progressBar = ProgressBar(view.content.context, null, android.R.attr.progressBarStyle).apply {
1919
isIndeterminate = true
2020
visibility = View.VISIBLE
21-
22-
val rl = RelativeLayout(view.content.context).apply {
23-
gravity = Gravity.CENTER
24-
addView(this@apply)
25-
}
26-
val layoutParams = RelativeLayout.LayoutParams(
27-
RelativeLayout.LayoutParams.MATCH_PARENT,
28-
RelativeLayout.LayoutParams.MATCH_PARENT
29-
)
30-
view.content.addView(rl, layoutParams)
3121
}
22+
val rl = RelativeLayout(view.content.context).apply {
23+
gravity = Gravity.CENTER
24+
addView(progressBar)
25+
}
26+
val layoutParams = RelativeLayout.LayoutParams(
27+
RelativeLayout.LayoutParams.MATCH_PARENT,
28+
RelativeLayout.LayoutParams.MATCH_PARENT
29+
)
30+
view.content.addView(rl, layoutParams)
31+
progressBar
3232
}, { this }, {
3333
it.visibility = View.GONE
3434
})

0 commit comments

Comments
 (0)