feat: 마이페이지
- 상단에 최신 공지사항 추가
This commit is contained in:
		@@ -254,7 +254,7 @@ class AppDI(private val context: Context, isDebugMode: Boolean) {
 | 
			
		||||
        viewModel { FindPasswordViewModel(get()) }
 | 
			
		||||
        viewModel { MainViewModel(get(), get(), get(), get(), get()) }
 | 
			
		||||
        viewModel { LiveViewModel(get(), get(), get(), get(), get()) }
 | 
			
		||||
        viewModel { MyPageViewModel(get(), get()) }
 | 
			
		||||
        viewModel { MyPageViewModel(get(), get(), get()) }
 | 
			
		||||
        viewModel { CanStatusViewModel(get()) }
 | 
			
		||||
        viewModel { CanChargePgViewModel(get()) }
 | 
			
		||||
        viewModel { CanPaymentViewModel(get()) }
 | 
			
		||||
 
 | 
			
		||||
@@ -42,6 +42,7 @@ import kr.co.vividnext.sodalive.mypage.service_center.ServiceCenterActivity
 | 
			
		||||
import kr.co.vividnext.sodalive.settings.SettingsActivity
 | 
			
		||||
import kr.co.vividnext.sodalive.settings.event.EventActivity
 | 
			
		||||
import kr.co.vividnext.sodalive.settings.notice.NoticeActivity
 | 
			
		||||
import kr.co.vividnext.sodalive.settings.notice.NoticeDetailActivity
 | 
			
		||||
import kr.co.vividnext.sodalive.splash.SplashActivity
 | 
			
		||||
import org.koin.android.ext.android.inject
 | 
			
		||||
 | 
			
		||||
@@ -60,6 +61,32 @@ class MyPageFragment : BaseFragment<FragmentMyBinding>(FragmentMyBinding::inflat
 | 
			
		||||
        setupView()
 | 
			
		||||
        bindData()
 | 
			
		||||
        setupRecentContentSection()
 | 
			
		||||
        setupLatestNotice()
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private fun setupLatestNotice() {
 | 
			
		||||
        // Observe the latest notice LiveData
 | 
			
		||||
        viewModel.latestNoticeLiveData.observe(viewLifecycleOwner) { noticeItem ->
 | 
			
		||||
            noticeItem?.let {
 | 
			
		||||
                // Update the UI with the latest notice title
 | 
			
		||||
                binding.tvLatestNoticeTitle.text = it.title
 | 
			
		||||
 | 
			
		||||
                // Set click listener for the latest notice section
 | 
			
		||||
                binding.llLatestNotice.setOnClickListener { _ ->
 | 
			
		||||
                    startActivity(
 | 
			
		||||
                        Intent(
 | 
			
		||||
                            requireActivity(),
 | 
			
		||||
                            NoticeDetailActivity::class.java
 | 
			
		||||
                        ).apply {
 | 
			
		||||
                            putExtra(Constants.EXTRA_NOTICE, it)
 | 
			
		||||
                        }
 | 
			
		||||
                    )
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Fetch the latest notice using ViewModel
 | 
			
		||||
        viewModel.getLatestNotice()
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private fun setupRecentContentSection() {
 | 
			
		||||
 
 | 
			
		||||
@@ -6,15 +6,19 @@ import com.orhanobut.logger.Logger
 | 
			
		||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
 | 
			
		||||
import io.reactivex.rxjava3.schedulers.Schedulers
 | 
			
		||||
import kr.co.vividnext.sodalive.base.BaseViewModel
 | 
			
		||||
import kr.co.vividnext.sodalive.common.ApiResponse
 | 
			
		||||
import kr.co.vividnext.sodalive.common.SharedPreferenceManager
 | 
			
		||||
import kr.co.vividnext.sodalive.mypage.auth.AuthRepository
 | 
			
		||||
import kr.co.vividnext.sodalive.mypage.auth.AuthVerifyRequest
 | 
			
		||||
import kr.co.vividnext.sodalive.settings.ContentType
 | 
			
		||||
import kr.co.vividnext.sodalive.settings.notice.NoticeItem
 | 
			
		||||
import kr.co.vividnext.sodalive.settings.notice.NoticeRepository
 | 
			
		||||
import kr.co.vividnext.sodalive.user.UserRepository
 | 
			
		||||
 | 
			
		||||
class MyPageViewModel(
 | 
			
		||||
    private val userRepository: UserRepository,
 | 
			
		||||
    private val authRepository: AuthRepository
 | 
			
		||||
    private val authRepository: AuthRepository,
 | 
			
		||||
    private val noticeRepository: NoticeRepository
 | 
			
		||||
) : BaseViewModel() {
 | 
			
		||||
    private val _toastLiveData = MutableLiveData<String?>()
 | 
			
		||||
    val toastLiveData: LiveData<String?>
 | 
			
		||||
@@ -28,6 +32,10 @@ class MyPageViewModel(
 | 
			
		||||
    val myPageLiveData: LiveData<MyPageResponse>
 | 
			
		||||
        get() = _myPageLiveData
 | 
			
		||||
 | 
			
		||||
    private val _latestNoticeLiveData = MutableLiveData<NoticeItem?>()
 | 
			
		||||
    val latestNoticeLiveData: LiveData<NoticeItem?>
 | 
			
		||||
        get() = _latestNoticeLiveData
 | 
			
		||||
 | 
			
		||||
    fun getUserInfo() {
 | 
			
		||||
        if (!_isLoading.value!!) {
 | 
			
		||||
            _isLoading.value = true
 | 
			
		||||
@@ -100,4 +108,25 @@ class MyPageViewModel(
 | 
			
		||||
                )
 | 
			
		||||
        )
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fun getLatestNotice() {
 | 
			
		||||
        compositeDisposable.add(
 | 
			
		||||
            noticeRepository.getLatestNotice()
 | 
			
		||||
                .subscribeOn(Schedulers.io())
 | 
			
		||||
                .observeOn(AndroidSchedulers.mainThread())
 | 
			
		||||
                .subscribe(
 | 
			
		||||
                    { response ->
 | 
			
		||||
                        if (response.success && response.data != null) {
 | 
			
		||||
                            _latestNoticeLiveData.postValue(response.data)
 | 
			
		||||
                        } else {
 | 
			
		||||
                            Logger.e("Failed to get latest notice: ${response.message}")
 | 
			
		||||
                        }
 | 
			
		||||
                    },
 | 
			
		||||
                    { error ->
 | 
			
		||||
                        error.printStackTrace()
 | 
			
		||||
                        Logger.e("Error getting latest notice: ${error.message}")
 | 
			
		||||
                    }
 | 
			
		||||
                )
 | 
			
		||||
        )
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -14,4 +14,7 @@ interface NoticeApi {
 | 
			
		||||
        @Query("size") size: Int,
 | 
			
		||||
        @Header("Authorization") authHeader: String
 | 
			
		||||
    ): Single<ApiResponse<GetNoticeResponse>>
 | 
			
		||||
 | 
			
		||||
    @GET("/notice/latest")
 | 
			
		||||
    fun getLatestNotice(): Single<ApiResponse<NoticeItem>>
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -12,4 +12,6 @@ class NoticeRepository(private val api: NoticeApi) {
 | 
			
		||||
    ): Single<ApiResponse<GetNoticeResponse>> {
 | 
			
		||||
        return api.getNotices(TimeZone.getDefault().id, page, size, authHeader = token)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fun getLatestNotice() = api.getLatestNotice()
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -42,9 +42,9 @@
 | 
			
		||||
            android:src="@drawable/ic_settings" />
 | 
			
		||||
    </LinearLayout>
 | 
			
		||||
 | 
			
		||||
    <!-- Update Banner -->
 | 
			
		||||
    <!-- Latest Notice -->
 | 
			
		||||
    <LinearLayout
 | 
			
		||||
        android:id="@+id/ll_update_banner"
 | 
			
		||||
        android:id="@+id/ll_latest_notice"
 | 
			
		||||
        android:layout_width="0dp"
 | 
			
		||||
        android:layout_height="wrap_content"
 | 
			
		||||
        android:background="#000000"
 | 
			
		||||
@@ -57,7 +57,7 @@
 | 
			
		||||
        app:layout_constraintTop_toBottomOf="@id/ll_header">
 | 
			
		||||
 | 
			
		||||
        <TextView
 | 
			
		||||
            android:id="@+id/tv_update_title"
 | 
			
		||||
            android:id="@+id/tv_latest_notice_title"
 | 
			
		||||
            android:layout_width="0dp"
 | 
			
		||||
            android:layout_height="wrap_content"
 | 
			
		||||
            android:layout_weight="1"
 | 
			
		||||
@@ -83,7 +83,7 @@
 | 
			
		||||
        app:layout_constraintBottom_toBottomOf="parent"
 | 
			
		||||
        app:layout_constraintEnd_toEndOf="parent"
 | 
			
		||||
        app:layout_constraintStart_toStartOf="parent"
 | 
			
		||||
        app:layout_constraintTop_toBottomOf="@id/ll_update_banner">
 | 
			
		||||
        app:layout_constraintTop_toBottomOf="@id/ll_latest_notice">
 | 
			
		||||
 | 
			
		||||
        <LinearLayout
 | 
			
		||||
            android:layout_width="match_parent"
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user