Skip to content

Commit

Permalink
#89 feat: NRLoading 커스텀 뷰 구현 및 전체 적용
Browse files Browse the repository at this point in the history
로딩중에 터치가 되지 않도록 커스텀뷰를 제작하여 적용함
  • Loading branch information
juhwankim-dev committed Sep 1, 2024
1 parent 03b1b85 commit f566ccd
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.nextroom.nextroom.presentation.common

import android.content.Context
import android.util.AttributeSet
import android.view.ViewGroup
import android.widget.FrameLayout
import android.widget.ProgressBar
import androidx.core.content.ContextCompat

class NRLoading @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0,
) : FrameLayout(context, attrs, defStyleAttr) {

init {
// 레이아웃의 크기를 부모의 크기로 설정
layoutParams = ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT,
)

// 배경을 투명하게 설정
setBackgroundColor(ContextCompat.getColor(context, android.R.color.transparent))

// ProgressBar를 가운데에 배치
val progressBar = ProgressBar(context).apply {
layoutParams = LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT,
).apply {
// 가운데 정렬
gravity = android.view.Gravity.CENTER
}
}

// 로딩중에 하위 뷰 터치 막기
setOnTouchListener { _, _ ->
true
}

// ProgressBar를 이 뷰에 추가
addView(progressBar)
}
}
8 changes: 4 additions & 4 deletions presentation/src/main/res/layout/fragment_login.xml
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,14 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />

<ProgressBar
<com.nextroom.nextroom.presentation.common.NRLoading
android:id="@+id/pb_loading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_height="0dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:visibility="visible" />
tools:visibility="gone" />
</androidx.constraintlayout.widget.ConstraintLayout>
6 changes: 3 additions & 3 deletions presentation/src/main/res/layout/fragment_mypage.xml
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />

<ProgressBar
<com.nextroom.nextroom.presentation.common.NRLoading
android:id="@+id/pb_loading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand Down
6 changes: 3 additions & 3 deletions presentation/src/main/res/layout/fragment_purchase.xml
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />

<ProgressBar
<com.nextroom.nextroom.presentation.common.NRLoading
android:id="@+id/pb_loading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@
app:layout_constraintTop_toTopOf="@id/tv_label_subscription_period"
tools:text="2024.2.13 ~ 2024.3.12" />

<ProgressBar
<com.nextroom.nextroom.presentation.common.NRLoading
android:id="@+id/pb_loading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand Down

0 comments on commit f566ccd

Please sign in to comment.