-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[FEAT/#124] 대화 주제 사용성 개선
- Loading branch information
Showing
19 changed files
with
541 additions
and
293 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 0 additions & 83 deletions
83
app/src/main/java/com/teumteum/teumteum/presentation/familiar/shake/InterestView.kt
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
...src/main/java/com/teumteum/teumteum/presentation/familiar/shake/model/InterestViewData.kt
This file was deleted.
Oops, something went wrong.
120 changes: 0 additions & 120 deletions
120
app/src/main/java/com/teumteum/teumteum/presentation/familiar/topic/TopicActivity.kt
This file was deleted.
Oops, something went wrong.
79 changes: 79 additions & 0 deletions
79
app/src/main/java/com/teumteum/teumteum/presentation/shaketopic/ShakeTopicActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package com.teumteum.teumteum.presentation.shaketopic | ||
|
||
import android.os.Bundle | ||
import androidx.activity.viewModels | ||
import androidx.fragment.app.commit | ||
import com.teumteum.base.BindingActivity | ||
import com.teumteum.domain.entity.Friend | ||
import com.teumteum.teumteum.R | ||
import com.teumteum.teumteum.databinding.ActivityShakeTopicBinding | ||
import com.teumteum.teumteum.presentation.familiar.introduce.IntroduceActivity.Companion.EXTRA_FRIENDS | ||
import com.teumteum.teumteum.presentation.shaketopic.shake.ShakeFragment | ||
import com.teumteum.teumteum.presentation.shaketopic.topic.TopicFragment | ||
import dagger.hilt.android.AndroidEntryPoint | ||
import timber.log.Timber | ||
|
||
@AndroidEntryPoint | ||
class ShakeTopicActivity : | ||
BindingActivity<ActivityShakeTopicBinding>(R.layout.activity_shake_topic) { | ||
|
||
private val viewModel by viewModels<ShakeTopicViewModel>() | ||
private var isShakeCompleted = false | ||
private var isApiDataReceived = false | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
initView() | ||
passDataToViewModel() | ||
setUpObserver() | ||
} | ||
|
||
private fun initView() { | ||
val initialFragment = ShakeFragment() | ||
supportFragmentManager.commit { | ||
add(R.id.fl_main, initialFragment) | ||
} | ||
} | ||
|
||
private fun setUpObserver() { | ||
viewModel.topics.observe(this) { topics -> | ||
if (topics.size >= 2 && !isApiDataReceived) { | ||
onApiDataReceived() | ||
} | ||
} | ||
} | ||
fun onShakeCompleted() { | ||
Timber.d("흔들기 3초 완료") | ||
isShakeCompleted = true | ||
checkAndShowTopicFragment() | ||
} | ||
|
||
fun onApiDataReceived() { | ||
Timber.d("데이터 최소 2개 수신 완료") | ||
isApiDataReceived = true | ||
checkAndShowTopicFragment() | ||
} | ||
|
||
private fun checkAndShowTopicFragment() { | ||
Timber.d("조건 2개 충족 완료 페이지 이동 실행") | ||
if (isShakeCompleted && isApiDataReceived) { | ||
showTopicFragment() | ||
} | ||
} | ||
|
||
private fun showTopicFragment() { | ||
val topicFragment = TopicFragment() | ||
supportFragmentManager.commit { | ||
replace(R.id.fl_main, topicFragment) | ||
addToBackStack(null) | ||
} | ||
} | ||
|
||
private fun passDataToViewModel() { | ||
val friends = intent.getSerializableExtra(EXTRA_FRIENDS) as? List<Friend> | ||
viewModel.setFriendsData(friends ?: listOf()) | ||
} | ||
|
||
companion object {} | ||
} |
Oops, something went wrong.