Skip to content

Commit b1d212b

Browse files
committed
apply convention to UserShowDetailView
1 parent 7f2aa3c commit b1d212b

File tree

3 files changed

+25
-54
lines changed

3 files changed

+25
-54
lines changed

app/src/androidTest/kotlin/com/hana053/micropost/pages/usershow/UserShowActivityTest.kt

+7-9
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ class UserShowActivityTest : InjectableTest by InjectableTestImpl() {
4141
fakeLoadingDetail()
4242
}
4343
launchActivityWithUserId(1)
44-
onView(withText(R.string.followers)).check(matches(isDisplayed()))
45-
onView(withText(R.string.followings)).check(matches(isDisplayed()))
4644
}
4745

4846
@Test
@@ -67,7 +65,7 @@ class UserShowActivityTest : InjectableTest by InjectableTestImpl() {
6765
})
6866
}
6967
launchActivityWithUserId(1)
70-
onView(withText("John Doe")).check(matches(isDisplayed()))
68+
onView(withId(R.id.tv_user_name)).check(matches(withText("John Doe")))
7169
}
7270

7371
@Test
@@ -91,14 +89,14 @@ class UserShowActivityTest : InjectableTest by InjectableTestImpl() {
9189
}
9290

9391
launchActivityWithUserId(1)
94-
onView(withId(R.id.followBtn)).check(matches(withText(R.string.Follow)))
92+
onView(withId(R.id.btn_follow)).check(matches(withText(R.string.Follow)))
9593

9694
// Do Follow. It will finally fetch user again.
9795
`when`(userInteractor.get(1)).thenReturn(Observable.just(
9896
TestUser.copy(name = "John Doe", isFollowedByMe = true)
9997
))
100-
onView(withId(R.id.followBtn)).perform(click())
101-
onView(withId(R.id.followBtn)).check(matches(withText(R.string.Unfollow)))
98+
onView(withId(R.id.btn_follow)).perform(click())
99+
onView(withId(R.id.btn_follow)).check(matches(withText(R.string.Unfollow)))
102100
}
103101

104102
@Test
@@ -112,7 +110,7 @@ class UserShowActivityTest : InjectableTest by InjectableTestImpl() {
112110
}
113111

114112
launchActivityWithUserId(1)
115-
onView(withId(R.id.followers)).perform(click())
113+
onView(withId(R.id.tv_followers)).perform(click())
116114

117115
verify(navigator).navigateToFollowerList(1)
118116
}
@@ -128,7 +126,7 @@ class UserShowActivityTest : InjectableTest by InjectableTestImpl() {
128126
}
129127

130128
launchActivityWithUserId(1)
131-
onView(withId(R.id.followings)).perform(click())
129+
onView(withId(R.id.tv_followings)).perform(click())
132130

133131
verify(navigator).navigateToFollowingList(1)
134132
}
@@ -159,7 +157,7 @@ class UserShowActivityTest : InjectableTest by InjectableTestImpl() {
159157

160158
private fun Kodein.Builder.fakeLoadingDetail() {
161159
bind<UserInteractor>(overrides = true) with instance(mock<UserInteractor> {
162-
on { get(any()) } doReturn Observable.empty()
160+
on { get(any()) } doReturn Observable.just(TestUser)
163161
})
164162
}
165163

app/src/main/kotlin/com/hana053/micropost/pages/usershow/detail/UserShowDetailView.kt

+8-9
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package com.hana053.micropost.pages.usershow.detail
22

33
import android.annotation.SuppressLint
44
import android.view.ViewGroup
5+
import com.hana053.micropost.R
56
import com.hana053.micropost.domain.User
67
import com.hana053.micropost.pages.ViewWrapper
78
import com.hana053.micropost.shared.avatar.AvatarView
@@ -13,15 +14,13 @@ class UserShowDetailView(
1314
override val content: ViewGroup
1415
) : ViewWrapper {
1516

16-
private val userName = content.userName
17-
private val followerCnt = content.followerCnt
18-
private val followingCnt = content.followingCnt
19-
private val followers = content.followers
20-
private val followings = content.followings
17+
private val userName = content.tv_user_name
18+
private val followers = content.tv_followers
19+
private val followings = content.tv_followings
2120

2221
// Sub View
23-
private val followBtnView = FollowBtnView(content.followBtn)
24-
private val avatarView = AvatarView(content.avatar)
22+
private val followBtnView = FollowBtnView(content.btn_follow)
23+
private val avatarView = AvatarView(content.img_avatar)
2524

2625
// Events
2726
val followersClicks = followers.clicks()
@@ -33,8 +32,8 @@ class UserShowDetailView(
3332
followBtnView.render(user)
3433
avatarView.render(user)
3534
userName.text = user.name
36-
followingCnt.text = "${user.userStats.followingCnt} "
37-
followerCnt.text = "${user.userStats.followerCnt} "
35+
followers.text = "${user.userStats.followerCnt} ${context().getString(R.string.followers)}"
36+
followings.text = "${user.userStats.followingCnt} ${context().getString(R.string.followings)}"
3837
}
3938

4039
}

app/src/main/res/layout/_user_detail.xml

+10-36
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
android:layout_height="wrap_content">
2727

2828
<ImageView
29-
android:id="@+id/avatar"
29+
android:id="@+id/img_avatar"
3030
android:layout_width="@dimen/avatar_size_large"
3131
android:layout_height="@dimen/avatar_size_large"
3232
android:layout_alignParentStart="true"
@@ -36,14 +36,14 @@
3636
/>
3737

3838
<TextView
39-
android:id="@+id/userName"
39+
android:id="@+id/tv_user_name"
4040
android:layout_width="wrap_content"
4141
android:layout_height="wrap_content"
4242
android:layout_centerVertical="true"
43-
android:layout_toEndOf="@+id/avatar"/>
43+
android:layout_toEndOf="@+id/img_avatar"/>
4444

4545
<Button
46-
android:id="@+id/followBtn"
46+
android:id="@+id/btn_follow"
4747
android:layout_width="wrap_content"
4848
android:layout_height="wrap_content"
4949
android:layout_alignParentEnd="true"
@@ -57,42 +57,16 @@
5757
android:layout_marginTop="10dp"
5858
android:orientation="horizontal">
5959

60-
<LinearLayout
61-
android:id="@+id/followings"
60+
<TextView
61+
android:id="@+id/tv_followings"
6262
android:layout_width="wrap_content"
63-
android:layout_height="wrap_content"
64-
android:layout_marginEnd="@dimen/margin_medium"
65-
android:orientation="horizontal">
66-
67-
<TextView
68-
android:id="@+id/followingCnt"
69-
android:layout_width="wrap_content"
70-
android:layout_height="wrap_content"
71-
android:textStyle="bold"/>
72-
73-
<TextView
74-
android:layout_width="wrap_content"
75-
android:layout_height="wrap_content"
76-
android:text="@string/followings"/>
77-
</LinearLayout>
63+
android:layout_height="wrap_content"/>
7864

79-
<LinearLayout
80-
android:id="@+id/followers"
65+
<TextView
66+
android:id="@+id/tv_followers"
8167
android:layout_width="wrap_content"
8268
android:layout_height="wrap_content"
83-
android:orientation="horizontal">
84-
85-
<TextView
86-
android:id="@+id/followerCnt"
87-
android:layout_width="wrap_content"
88-
android:layout_height="wrap_content"
89-
android:textStyle="bold"/>
90-
91-
<TextView
92-
android:layout_width="wrap_content"
93-
android:layout_height="wrap_content"
94-
android:text="@string/followers"/>
95-
</LinearLayout>
69+
android:layout_marginStart="@dimen/margin_small"/>
9670
</LinearLayout>
9771
</LinearLayout>
9872
</FrameLayout>

0 commit comments

Comments
 (0)