Skip to content

Commit

Permalink
[feature] #306 - 비로그인 시 로그인 유도
Browse files Browse the repository at this point in the history
  • Loading branch information
hansh0101 committed Jun 22, 2022
1 parent 251b648 commit af1eba6
Showing 1 changed file with 40 additions and 21 deletions.
61 changes: 40 additions & 21 deletions app/src/main/java/co/kr/bemyplan/ui/main/home/HomeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import androidx.fragment.app.viewModels
import androidx.recyclerview.widget.RecyclerView
import androidx.viewpager2.widget.CompositePageTransformer
import co.kr.bemyplan.data.firebase.FirebaseAnalyticsProvider
import co.kr.bemyplan.data.local.BeMyPlanDataStore
import co.kr.bemyplan.databinding.FragmentHomeBinding
import co.kr.bemyplan.ui.list.ListActivity
import co.kr.bemyplan.ui.purchase.after.AfterPurchaseActivity
Expand All @@ -27,6 +28,9 @@ class HomeFragment : Fragment() {
private val binding get() = _binding ?: error("Binding이 초기화 되지 않았습니다.")
private val homeViewModel: HomeViewModel by viewModels()

@Inject
lateinit var beMyPlanDataStore: BeMyPlanDataStore

@Inject
lateinit var firebaseAnalyticsProvider: FirebaseAnalyticsProvider

Expand Down Expand Up @@ -82,39 +86,54 @@ class HomeFragment : Fragment() {

private fun initAdapterNew() {
recentAdapter = HomeAdapter {
homeViewModel.checkPurchased(it.planId)
observeDataForStartActivity(
it.planId,
it.user.nickname,
it.user.userId,
it.thumbnailUrl
)
if (beMyPlanDataStore.userId != 0) {
homeViewModel.checkPurchased(it.planId)
observeDataForStartActivity(
it.planId,
it.user.nickname,
it.user.userId,
it.thumbnailUrl
)
} else {
val intent = Intent(requireContext(), PurchaseActivity::class.java)
startActivity(intent)
}
}
binding.rvRecent.adapter = recentAdapter
}

private fun initAdapterSuggest() {
editorAdapter = HomeAdapter {
homeViewModel.checkPurchased(it.planId)
observeDataForStartActivity(
it.planId,
it.user.nickname,
it.user.userId,
it.thumbnailUrl
)
if (beMyPlanDataStore.userId != 0) {
homeViewModel.checkPurchased(it.planId)
observeDataForStartActivity(
it.planId,
it.user.nickname,
it.user.userId,
it.thumbnailUrl
)
} else {
val intent = Intent(requireContext(), PurchaseActivity::class.java)
startActivity(intent)
}
}
binding.rvEditorSuggest.adapter = editorAdapter
}

private fun initAdapterPopular() {
homeViewPagerAdapter = HomeViewPagerAdapter {
homeViewModel.checkPurchased(it.planId)
observeDataForStartActivity(
it.planId,
it.user.nickname,
it.user.userId,
it.thumbnailUrl
)
if (beMyPlanDataStore.userId != 0) {
homeViewModel.checkPurchased(it.planId)
observeDataForStartActivity(
it.planId,
it.user.nickname,
it.user.userId,
it.thumbnailUrl
)
} else {
val intent = Intent(requireContext(), PurchaseActivity::class.java)
startActivity(intent)
}
}

with(binding.vpPopular) {
Expand Down

0 comments on commit af1eba6

Please sign in to comment.