Skip to content

Commit

Permalink
#49: Special Icon for 2 or bigger Teams
Browse files Browse the repository at this point in the history
  • Loading branch information
Entreco committed Jul 17, 2018
1 parent d43ce1d commit 8ba6602
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@ object ProfileBinding {
val uri = Uri.parse(path)
if (uri == null || uri.toString().isBlank()) {
view.setImageResource(R.drawable.ic_no_profile)
} else if(path == "team"){
view.setImageResource(R.drawable.ic_team_profile)
} else if(path?.startsWith("team") == true){
when(path){
"team0" -> view.setImageResource(R.drawable.ic_no_profile)
"team2" -> view.setImageResource(R.drawable.ic_team_profile2)
else -> view.setImageResource(R.drawable.ic_team_profile)
}
} else {
GlideApp.with(view).load(uri).into(view)
}
Expand All @@ -29,18 +33,6 @@ object ProfileBinding {
}
}

@JvmStatic
@BindingAdapter("profileDouble")
fun showProfileDouble(view: TextView, favDouble: String?) {
try {
val double = view.context.resources.getStringArray(R.array.fav_doubles)[favDouble?.toInt()!!]
view.text = view.context.getString(R.string.favourite_double, double)
} catch (oops: Exception) {
val double = view.context.resources.getStringArray(R.array.fav_doubles)[0]
view.text = view.context.getString(R.string.favourite_double, double)
}
}

@JvmStatic
@BindingAdapter("profileDouble")
fun showProfileDoubleInt(view: TextView, favDouble: Int?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class ProfileViewModel @Inject constructor(private val fetchProfileUsecase: Fetc
} else {
Profile(response.profiles.joinToString("&") { it.name },
0,
"team",
"team${response.profiles.size}",
PlayerPrefs(-1))
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="100dp"
android:height="100dp"
android:viewportHeight="240"
android:viewportWidth="240">

<group
android:pivotX="120"
android:pivotY="120"
android:scaleX="0.92"
android:scaleY="0.92"
android:translateX="-48">
<path
android:fillColor="#3E3939"
android:fillType="nonZero"
android:pathData="M188.6,201L188.56,201.03L188.56,199.58C188.56,185.52 179.47,170.5 168.35,166.22L153.78,160.6L154.08,160.09L147.9,152.64C146.91,151.44 145.3,151.39 144.26,152.53L144.08,152.72C143.55,149.57 143.45,146.36 143.44,143.99C147.57,138.58 150.73,131.88 152.93,124.72C157.9,127 162.04,114.55 162.04,108.95C162.04,104.66 159.97,102.18 156.68,102.27C156.71,101.29 156.73,100.32 156.73,99.36C156.73,73.76 140.11,64.2 119.6,64.2C99.1,64.2 82.48,73.76 82.48,99.36C82.48,100.33 82.5,101.32 82.53,102.31C79.25,101.94 77.17,104.45 77.17,108.95C77.17,114.81 81.32,128.17 86.15,124.3C88.36,131.62 91.55,138.46 95.76,143.98C95.75,146.34 95.63,149.54 95.09,152.68L94.95,152.53C93.91,151.39 92.3,151.44 91.31,152.64L85.13,160.09L85.43,160.6L70.86,166.22C59.75,170.5 50.65,185.52 50.65,199.58L50.65,201.02L50.61,201C49.39,200.33 48,201.41 48,203.03L48,207.3C48,209.01 48.83,210.56 50.12,211.27L53.3,213.01L53.3,230.41C53.3,235.71 56.87,240 61.26,240L177.95,240C182.34,240 185.91,235.71 185.91,230.41L185.91,213.01L189.09,211.27C190.38,210.56 191.21,209.01 191.21,207.3L191.21,203.03C191.21,201.41 189.82,200.33 188.6,201Z"
android:strokeColor="#00000000"
android:strokeWidth="1" />
<path
android:fillColor="#3E3939"
android:fillType="nonZero"
android:pathData="M162.53,102.33C162.58,101.35 162.6,100.38 162.6,99.41C162.6,73.78 142.58,64.2 117.88,64.2C93.18,64.2 73.15,73.78 73.15,99.41C73.15,100.39 73.18,101.37 73.22,102.37C69.27,102 66.77,104.52 66.77,109.02C66.77,114.89 71.76,128.27 77.58,124.4C83.98,142.06 97.36,157.04 117.88,157.04C138.23,157.04 151.56,142.3 158.02,124.81C164,127.1 168.99,114.63 168.99,109.02C168.99,104.73 166.5,102.24 162.53,102.33Z"
android:strokeColor="#00000000"
android:strokeWidth="1" />

<path
android:fillColor="#3E3939"
android:fillType="nonZero"
android:pathData="M162.57,92.53C150.95,71.21 138.04,68.66 138.04,68.66C138.04,68.66 107.94,55.87 85.18,77.94C79.07,83.87 73.96,92.27 73.68,97.28C73.53,59.12 87.96,40.05 116.97,40.05C128.28,40.05 132.5,38.6 145.94,52.06C154.9,61.03 160.44,74.52 162.57,92.53Z"
android:strokeColor="#00000000"
android:strokeWidth="1" />
</group>

<group
android:pivotX="120"
android:pivotY="120"
android:scaleX="0.92"
android:scaleY="0.92"
android:translateX="48">
<path
android:fillColor="#3E3939"
android:fillType="nonZero"
android:pathData="M188.6,201L188.56,201.03L188.56,199.58C188.56,185.52 179.47,170.5 168.35,166.22L153.78,160.6L154.08,160.09L147.9,152.64C146.91,151.44 145.3,151.39 144.26,152.53L144.08,152.72C143.55,149.57 143.45,146.36 143.44,143.99C147.57,138.58 150.73,131.88 152.93,124.72C157.9,127 162.04,114.55 162.04,108.95C162.04,104.66 159.97,102.18 156.68,102.27C156.71,101.29 156.73,100.32 156.73,99.36C156.73,73.76 140.11,64.2 119.6,64.2C99.1,64.2 82.48,73.76 82.48,99.36C82.48,100.33 82.5,101.32 82.53,102.31C79.25,101.94 77.17,104.45 77.17,108.95C77.17,114.81 81.32,128.17 86.15,124.3C88.36,131.62 91.55,138.46 95.76,143.98C95.75,146.34 95.63,149.54 95.09,152.68L94.95,152.53C93.91,151.39 92.3,151.44 91.31,152.64L85.13,160.09L85.43,160.6L70.86,166.22C59.75,170.5 50.65,185.52 50.65,199.58L50.65,201.02L50.61,201C49.39,200.33 48,201.41 48,203.03L48,207.3C48,209.01 48.83,210.56 50.12,211.27L53.3,213.01L53.3,230.41C53.3,235.71 56.87,240 61.26,240L177.95,240C182.34,240 185.91,235.71 185.91,230.41L185.91,213.01L189.09,211.27C190.38,210.56 191.21,209.01 191.21,207.3L191.21,203.03C191.21,201.41 189.82,200.33 188.6,201Z"
android:strokeColor="#00000000"
android:strokeWidth="1" />
<path
android:fillColor="#3E3939"
android:fillType="nonZero"
android:pathData="M162.53,102.33C162.58,101.35 162.6,100.38 162.6,99.41C162.6,73.78 142.58,64.2 117.88,64.2C93.18,64.2 73.15,73.78 73.15,99.41C73.15,100.39 73.18,101.37 73.22,102.37C69.27,102 66.77,104.52 66.77,109.02C66.77,114.89 71.76,128.27 77.58,124.4C83.98,142.06 97.36,157.04 117.88,157.04C138.23,157.04 151.56,142.3 158.02,124.81C164,127.1 168.99,114.63 168.99,109.02C168.99,104.73 166.5,102.24 162.53,102.33Z"
android:strokeColor="#00000000"
android:strokeWidth="1" />

<path
android:fillColor="#3E3939"
android:fillType="nonZero"
android:pathData="M162.57,92.53C150.95,71.21 138.04,68.66 138.04,68.66C138.04,68.66 107.94,55.87 85.18,77.94C79.07,83.87 73.96,92.27 73.68,97.28C73.53,59.12 87.96,40.05 116.97,40.05C128.28,40.05 132.5,38.6 145.94,52.06C154.9,61.03 160.44,74.52 162.57,92.53Z"
android:strokeColor="#00000000"
android:strokeWidth="1" />
</group>
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,36 @@ class ProfileBindingTest {
verify(mockImageView).setImageResource(R.drawable.ic_no_profile)
}

@Test
fun loadProfileImage_team() {
ProfileBinding.loadProfileImage(mockImageView, "team")
verify(mockImageView).setImageResource(R.drawable.ic_team_profile2)
}

@Test
fun loadProfileImage_team0() {
ProfileBinding.loadProfileImage(mockImageView, "team0")
verify(mockImageView).setImageResource(R.drawable.ic_no_profile)
}

@Test
fun loadProfileImage_team1() {
ProfileBinding.loadProfileImage(mockImageView, "team1")
verify(mockImageView).setImageResource(R.drawable.ic_team_profile)
}

@Test
fun loadProfileImage_team2() {
ProfileBinding.loadProfileImage(mockImageView, "team2")
verify(mockImageView).setImageResource(R.drawable.ic_team_profile2)
}

@Test
fun loadProfileImage_team3() {
ProfileBinding.loadProfileImage(mockImageView, "team3")
verify(mockImageView).setImageResource(R.drawable.ic_team_profile)
}

@Test
fun loadProfileImage_blank() {
ProfileBinding.loadProfileImage(mockImageView, " ")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class Team(val players: Array<Player> = emptyArray()) {
}

fun imageUrl(): String? {
return players[0].image
return if(players.size <= 1) players[0].image else "team${players.size}"
}

fun toTeamString() : String {
Expand Down

0 comments on commit 8ba6602

Please sign in to comment.