-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: 활동 관련 뷰 더보기 팝업메뉴 구현 #412
Open
yeonjeen
wants to merge
15
commits into
develop
Choose a base branch
from
feat/376
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
0c23a47
refactor: 클릭리스너 익명객체로 구현
yeonjeen 8f67fd3
feat: 내 활동 더보기 팝업메뉴 xml
yeonjeen 525f7f8
feat: 내 활동 더보기 팝업 수정하기 구현
yeonjeen 720908d
feat: 내 활동 UiState 적용
yeonjeen a292131
feat: 내 활동 더 보기 메뉴 삭제하기 구현
yeonjeen a2ca01f
feat: 다른유저활동 더보기 메뉴 xml 구현
yeonjeen be434a3
refactor: 다른유저 활동 uistate 적용
yeonjeen 159de6a
feat: 다른유저 활동 더보기 메뉴 구현
yeonjeen bb91c50
refactor: 활동 디테일 uistate 적용
yeonjeen 451850c
feat: 활동디테일 더보기 메뉴 기능 구현
yeonjeen 5df73ec
refactor: 뷰바인딩 적용
yeonjeen 367fddb
feat: 스트링 추출
yeonjeen 08cfce7
Merge remote-tracking branch 'origin/develop' into feat/376
yeonjeen 7397dbd
fix: 충돌해결
yeonjeen 2e70566
refactor: 불필요한 공백 제거
yeonjeen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,16 +3,29 @@ package com.teamwss.websoso.ui.activityDetail | |
import android.content.Context | ||
import android.content.Intent | ||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.WindowManager | ||
import android.widget.PopupWindow | ||
import android.widget.TextView | ||
import androidx.activity.viewModels | ||
import androidx.databinding.ViewDataBinding | ||
import com.teamwss.websoso.R | ||
import com.teamwss.websoso.R.string.my_activity_detail_title | ||
import com.teamwss.websoso.R.string.other_user_page_activity | ||
import com.teamwss.websoso.common.ui.base.BaseActivity | ||
import com.teamwss.websoso.databinding.ActivityActivityDetailBinding | ||
import com.teamwss.websoso.databinding.MenuMyActivityPopupBinding | ||
import com.teamwss.websoso.databinding.MenuOtherUserActivityPopupBinding | ||
import com.teamwss.websoso.ui.activityDetail.adapter.ActivityDetailAdapter | ||
import com.teamwss.websoso.ui.createFeed.CreateFeedActivity | ||
import com.teamwss.websoso.ui.feedDetail.FeedDetailActivity | ||
import com.teamwss.websoso.ui.feedDetail.model.EditFeedModel | ||
import com.teamwss.websoso.ui.main.feed.dialog.FeedRemoveDialogFragment | ||
import com.teamwss.websoso.ui.main.feed.dialog.FeedReportDialogFragment | ||
import com.teamwss.websoso.ui.main.feed.dialog.FeedReportDoneDialogFragment | ||
import com.teamwss.websoso.ui.main.feed.dialog.RemoveMenuType | ||
import com.teamwss.websoso.ui.main.feed.dialog.ReportMenuType | ||
import com.teamwss.websoso.ui.main.myPage.MyPageViewModel | ||
import com.teamwss.websoso.ui.main.myPage.myActivity.ActivityItemClickListener | ||
import com.teamwss.websoso.ui.main.myPage.myActivity.MyActivityFragment | ||
|
@@ -38,6 +51,7 @@ class ActivityDetailActivity : | |
intent.getStringExtra(MyActivityFragment.EXTRA_SOURCE) ?: "" | ||
} | ||
private val userId: Long by lazy { intent.getLongExtra(USER_ID_KEY, DEFAULT_USER_ID) } | ||
private var _popupWindow: PopupWindow? = null | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
@@ -74,9 +88,9 @@ class ActivityDetailActivity : | |
} | ||
|
||
private fun setupObserver() { | ||
activityDetailViewModel.userActivity.observe(this) { activities -> | ||
activityDetailViewModel.activityDetailUiState.observe(this) { uiState -> | ||
val userProfile = getUserProfile() | ||
updateAdapterWithActivitiesAndProfile(activities, userProfile) | ||
updateAdapterWithActivitiesAndProfile(uiState.activities, userProfile) | ||
} | ||
|
||
when (activityDetailViewModel.source) { | ||
|
@@ -85,7 +99,7 @@ class ActivityDetailActivity : | |
uiState.myProfile?.let { myProfile -> | ||
val userProfile = myProfile.toUserProfileModel() | ||
updateAdapterWithActivitiesAndProfile( | ||
activityDetailViewModel.userActivity.value, | ||
activityDetailViewModel.activityDetailUiState.value?.activities, | ||
userProfile | ||
) | ||
} | ||
|
@@ -97,8 +111,8 @@ class ActivityDetailActivity : | |
otherUserProfile?.let { | ||
val userProfile = otherUserProfile.toUserProfileModel() | ||
updateAdapterWithActivitiesAndProfile( | ||
activityDetailViewModel.userActivity.value, | ||
userProfile | ||
activityDetailViewModel.activityDetailUiState.value?.activities, | ||
userProfile, | ||
) | ||
} | ||
} | ||
|
@@ -162,18 +176,113 @@ class ActivityDetailActivity : | |
likeCountTextView.text = updatedLikeCount.toString() | ||
view.isSelected = !view.isSelected | ||
|
||
activityDetailViewModel.updateActivityLike( | ||
view.isSelected, | ||
feedId, | ||
updatedLikeCount, | ||
) | ||
activityDetailViewModel.updateActivityLike(view.isSelected, feedId, updatedLikeCount) | ||
} | ||
|
||
override fun onMoreButtonClick(view: View, feedId: Long) { | ||
// TODO 팝업메뉴 수정 및 차단 | ||
showPopupMenu(view, feedId) | ||
} | ||
} | ||
|
||
private fun showPopupMenu(view: View, feedId: Long) { | ||
val inflater = LayoutInflater.from(this) | ||
val binding = when (source) { | ||
SOURCE_MY_ACTIVITY -> MenuMyActivityPopupBinding.inflate(inflater) | ||
SOURCE_OTHER_USER_ACTIVITY -> MenuOtherUserActivityPopupBinding.inflate(inflater) | ||
else -> return | ||
} | ||
|
||
_popupWindow?.dismiss() | ||
_popupWindow = PopupWindow( | ||
binding.root, | ||
WindowManager.LayoutParams.WRAP_CONTENT, | ||
WindowManager.LayoutParams.WRAP_CONTENT, | ||
true | ||
).apply { | ||
elevation = 2f | ||
showAsDropDown(view) | ||
} | ||
setupPopupMenuClickListeners(binding, feedId) | ||
} | ||
|
||
private fun setupPopupMenuClickListeners(binding: ViewDataBinding, feedId: Long) { | ||
when (binding) { | ||
is MenuMyActivityPopupBinding -> { | ||
binding.tvMyActivityModification.setOnClickListener { | ||
navigateToFeedEdit(feedId) | ||
_popupWindow?.dismiss() | ||
} | ||
binding.tvMyActivityPopupDeletion.setOnClickListener { | ||
showRemoveDialog(feedId) | ||
_popupWindow?.dismiss() | ||
} | ||
} | ||
|
||
is MenuOtherUserActivityPopupBinding -> { | ||
binding.tvOtherUserActivityReportSpoiler.setOnClickListener { | ||
showReportDialog(feedId, ReportMenuType.SPOILER_FEED.name) | ||
_popupWindow?.dismiss() | ||
} | ||
binding.tvOtherUserActivityReportExpression.setOnClickListener { | ||
showReportDialog(feedId, ReportMenuType.IMPERTINENCE_FEED.name) | ||
_popupWindow?.dismiss() | ||
} | ||
} | ||
} | ||
} | ||
|
||
private fun navigateToFeedEdit(feedId: Long) { | ||
val activityModel = | ||
activityDetailViewModel.activityDetailUiState.value?.activities?.find { it.feedId == feedId } | ||
activityModel?.let { feed -> | ||
val editFeedModel = EditFeedModel( | ||
feedId = feed.feedId, | ||
novelId = feed.novelId ?: 0L, | ||
novelTitle = feed.title ?: "", | ||
feedContent = feed.feedContent, | ||
feedCategory = feed.relevantCategories?.split(", ") ?: emptyList() | ||
) | ||
startActivity(CreateFeedActivity.getIntent(this, editFeedModel)) | ||
} ?: throw IllegalArgumentException("Feed not found") | ||
} | ||
|
||
private fun showRemoveDialog(feedId: Long) { | ||
val dialogFragment = FeedRemoveDialogFragment.newInstance( | ||
menuType = RemoveMenuType.REMOVE_FEED.name, | ||
event = { | ||
activityDetailViewModel.updateRemovedFeed(feedId) | ||
} | ||
) | ||
dialogFragment.show(supportFragmentManager, FeedRemoveDialogFragment.TAG) | ||
} | ||
|
||
private fun showReportDialog(feedId: Long, menuType: String) { | ||
val dialogFragment = FeedReportDialogFragment.newInstance( | ||
menuType = menuType, | ||
event = { | ||
when (menuType) { | ||
ReportMenuType.SPOILER_FEED.name -> activityDetailViewModel.updateReportedSpoilerFeed( | ||
feedId | ||
) | ||
|
||
ReportMenuType.IMPERTINENCE_FEED.name -> activityDetailViewModel.updateReportedImpertinenceFeed( | ||
feedId | ||
) | ||
} | ||
showReportDoneDialog(menuType) | ||
} | ||
) | ||
dialogFragment.show(supportFragmentManager, FeedReportDialogFragment.TAG) | ||
} | ||
|
||
private fun showReportDoneDialog(menuType: String) { | ||
val doneDialogFragment = FeedReportDoneDialogFragment.newInstance( | ||
menuType = menuType, | ||
event = {} | ||
) | ||
doneDialogFragment.show(supportFragmentManager, FeedReportDoneDialogFragment.TAG) | ||
} | ||
Comment on lines
+278
to
+284
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. c: 신고는 지금 기능구현이 안되어 있는걸까요? |
||
|
||
companion object { | ||
const val USER_ID_KEY = "userId" | ||
const val DEFAULT_USER_ID = -1L | ||
|
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
10 changes: 10 additions & 0 deletions
10
app/src/main/java/com/teamwss/websoso/ui/activityDetail/model/ActivityDetailUiState.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,10 @@ | ||
package com.teamwss.websoso.ui.activityDetail.model | ||
|
||
import com.teamwss.websoso.ui.main.myPage.myActivity.model.ActivitiesModel | ||
|
||
data class ActivityDetailUiState( | ||
val isLoading: Boolean = false, | ||
val activities: List<ActivitiesModel.ActivityModel> = emptyList(), | ||
val lastFeedId: Long = 0L, | ||
val error: Boolean = false, | ||
) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r: 트콤