Skip to content

Commit 580ab0b

Browse files
committed
Leaderboard updated with position numbers
1 parent cd9f106 commit 580ab0b

File tree

7 files changed

+106
-71
lines changed

7 files changed

+106
-71
lines changed
Binary file not shown.

.idea/workspace.xml

Lines changed: 52 additions & 56 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/java/com/example/offlinemaps/LeaderboardAdapterClass.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,27 @@ public View getView(int position, @Nullable View convertView, @NonNull ViewGroup
3333
View listItem = convertView;
3434
if (listItem == null)
3535
listItem = LayoutInflater.from(mContext).inflate(R.layout.leaderboard_listview, parent, false);
36-
3736
//Get the user and populate the variables.
3837
User currentUser = userList.get(position);
3938

39+
ImageView medal = listItem.findViewById(R.id.iv_medal);
40+
if (position == 0) {
41+
medal.setImageResource(R.drawable.first);
42+
} else if (position == 1) {
43+
medal.setImageResource(R.drawable.second);
44+
} else if (position == 2) {
45+
medal.setImageResource(R.drawable.third);
46+
} else {
47+
//No medal
48+
}
49+
50+
TextView leaderboardNumber = listItem.findViewById(R.id.tv_medal);
51+
for (int i = 3; i < userList.size(); i++) {
52+
if (position == i) {
53+
leaderboardNumber.setText(i+1 + "");
54+
}
55+
}
56+
4057
ImageView image = (ImageView) listItem.findViewById(R.id.iv_profile_pic);
4158
//image.setImageResource((String) currentUser.getmProfilePicture());
4259
if (!currentUser.getmProfilePicture().isEmpty()) {

app/src/main/res/drawable/first.png

1.51 KB
Loading

app/src/main/res/drawable/second.png

1.49 KB
Loading

app/src/main/res/drawable/third.png

1.62 KB
Loading

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

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55

66
<de.hdodenhof.circleimageview.CircleImageView
77
android:id="@+id/iv_profile_pic"
8-
android:layout_width="75sp"
9-
android:layout_height="75sp"
10-
android:layout_margin="10sp" />
8+
android:layout_width="75dp"
9+
android:layout_height="75dp"
10+
android:layout_margin="10dp" />
1111

1212
<TextView
1313
android:id="@+id/tv_username"
1414
android:layout_width="wrap_content"
1515
android:layout_height="wrap_content"
16-
android:layout_marginStart="4sp"
17-
android:layout_marginTop="22sp"
16+
android:layout_marginStart="4dp"
17+
android:layout_marginTop="22dp"
1818
android:layout_toEndOf="@id/iv_profile_pic"
1919
android:textSize="20sp"
2020
android:textStyle="bold" />
@@ -23,8 +23,8 @@
2323
android:id="@+id/iv_vip"
2424
android:layout_width="wrap_content"
2525
android:layout_height="wrap_content"
26-
android:layout_marginStart="4sp"
27-
android:layout_marginTop="26sp"
26+
android:layout_marginStart="4dp"
27+
android:layout_marginTop="26dp"
2828
android:layout_toEndOf="@id/tv_username"
2929
android:textSize="20sp"
3030
android:textStyle="bold" />
@@ -35,7 +35,7 @@
3535
android:layout_width="wrap_content"
3636
android:layout_height="wrap_content"
3737
android:layout_below="@id/tv_username"
38-
android:layout_marginTop="2sp"
38+
android:layout_marginTop="2dp"
3939
android:layout_toEndOf="@id/iv_profile_pic"
4040
android:src="@drawable/ic_person_pin_circle_black_24dp" />
4141

@@ -51,17 +51,39 @@
5151
android:id="@+id/iv_point_counter"
5252
android:layout_width="wrap_content"
5353
android:layout_height="wrap_content"
54-
android:layout_marginStart="160sp"
55-
android:layout_marginTop="16sp"
56-
android:paddingEnd="5dp"
54+
android:layout_marginStart="160dp"
55+
android:layout_marginTop="16dp"
5756
android:layout_toEndOf="@id/iv_profile_pic"
57+
android:paddingEnd="5dp"
5858
android:src="@drawable/ic_local_atm_green_24dp" />
5959

60+
<ImageView
61+
android:id="@+id/iv_medal"
62+
android:layout_width="wrap_content"
63+
android:layout_marginStart="195dp"
64+
android:layout_height="wrap_content"
65+
android:layout_marginTop="34dp"
66+
android:layout_toEndOf="@id/iv_point_counter"
67+
/>
68+
<!--android:layout_marginStart="70dp"-->
69+
70+
<TextView
71+
android:id="@+id/tv_medal"
72+
android:layout_width="wrap_content"
73+
android:layout_marginStart="200dp"
74+
android:layout_height="wrap_content"
75+
android:layout_marginTop="24dp"
76+
android:layout_toEndOf="@id/iv_point_counter"
77+
android:textStyle="bold"
78+
android:textSize="32sp"
79+
/>
80+
<!--android:layout_marginStart="75dp"-->
81+
6082
<TextView
6183
android:id="@+id/tv_point_counter"
6284
android:layout_width="wrap_content"
6385
android:layout_height="wrap_content"
64-
android:layout_marginTop="15sp"
86+
android:layout_marginTop="15dp"
6587
android:layout_toEndOf="@+id/iv_point_counter"
6688
android:textSize="17sp"
6789
android:textStyle="bold" />
@@ -70,10 +92,10 @@
7092
android:id="@+id/iv_calorie"
7193
android:layout_width="wrap_content"
7294
android:layout_height="wrap_content"
73-
android:paddingEnd="5dp"
7495
android:layout_below="@id/iv_point_counter"
75-
android:layout_marginTop="16sp"
96+
android:layout_marginTop="16dp"
7697
android:layout_toStartOf="@id/tv_calories_burnt"
98+
android:paddingEnd="5dp"
7799
android:src="@drawable/ic_whatshot_black_24dp" />
78100

79101
<TextView

0 commit comments

Comments
 (0)