Skip to content

Commit

Permalink
fix(MessageListActivity): 로그인한 사용자가 보내는 거면 방금 보낸 메세지를 보여주기 위해 onNewIn…
Browse files Browse the repository at this point in the history
…tent() 메서드에서 새로고침 하도록 수정
  • Loading branch information
ki960213 committed Jan 7, 2024
1 parent 594de44 commit 1e3283d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion android/2023-emmsale/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<activity android:name=".presentation.ui.feedDetail.FeedDetailActivity" />
<activity
android:name=".presentation.ui.messageList.MessageListActivity"
android:launchMode="singleTop"
android:launchMode="singleTask"
android:parentActivityName=".presentation.ui.main.MainActivity"
android:windowSoftInputMode="adjustResize" />
<activity android:name=".presentation.ui.feedWriting.FeedWritingActivity" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ class MessageListActivity :
super.onNewIntent(intent)

val roomId = intent.getStringExtra(KEY_ROOM_ID) ?: return
if (intent.getBooleanExtra(KEY_IS_SEND_BY_LOGIN_USER, false)) {
viewModel.refresh()
smoothScrollToEnd()
}

val profileUrl = intent.getStringExtra(KEY_PROFILE_URL)
val otherName = intent.getStringExtra(KEY_OTHER_NAME) ?: return
val messageContent = intent.getStringExtra(KEY_MESSAGE_CONTENT) ?: return
Expand Down Expand Up @@ -192,18 +197,26 @@ class MessageListActivity :
private const val KEY_PROFILE_URL = "KEY_PROFILE_URL"
private const val KEY_OTHER_NAME = "KEY_OTHER_NAME"
private const val KEY_MESSAGE_CONTENT = "KEY_MESSAGE_CONTENT"
private const val KEY_IS_SEND_BY_LOGIN_USER = "KEY_IS_SEND_BY_LOGIN_USER"

fun startActivity(context: Context, roomId: String, otherUid: Long) {
context.startActivity(getIntent(context, roomId, otherUid))
fun startActivity(
context: Context,
roomId: String,
otherUid: Long,
isSendByLoginUser: Boolean = false,
) {
context.startActivity(getIntent(context, roomId, otherUid, isSendByLoginUser))
}

fun getIntent(
context: Context,
roomId: String,
otherUid: Long,
isSendByLoginUser: Boolean = false,
) = Intent(context, MessageListActivity::class.java)
.putExtra(KEY_ROOM_ID, roomId)
.putExtra(KEY_OTHER_UID, otherUid)
.putExtra(KEY_IS_SEND_BY_LOGIN_USER, isSendByLoginUser)

fun getIntent(
context: Context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ class ProfileActivity : NetworkActivity<ActivityProfileBinding>(R.layout.activit
this,
uiEvent.roomId,
uiEvent.otherId,
true,
)
sendMessageDialog.clearText()
sendMessageDialog.dismiss()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ class RecruitmentDetailActivity :
this,
uiEvent.roomId,
uiEvent.otherId,
true,
)
sendMessageDialog.clearText()
sendMessageDialog.dismiss()
Expand Down

0 comments on commit 1e3283d

Please sign in to comment.