Hide notification count when no notification available (#1258)

Closes #1251

Co-authored-by: M M Arif <mmarif@swatian.com>
Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1258
Reviewed-by: qwerty287 <qwerty287@noreply.codeberg.org>
This commit is contained in:
M M Arif 2023-03-11 08:59:11 +00:00
parent 9c7fdccd26
commit 959049891c
2 changed files with 21 additions and 7 deletions

View File

@ -874,11 +874,24 @@ public class MainActivity extends BaseActivity
if (response.code() == 200) {
assert notificationCount != null;
notificationCounter =
navNotifications
.getActionView()
.findViewById(R.id.counterBadgeNotification);
notificationCounter.setText(String.valueOf(notificationCount.getNew()));
if (notificationCount.getNew() > 0) {
navNotifications
.getActionView()
.findViewById(R.id.counterBadgeNotification)
.setVisibility(View.VISIBLE);
notificationCounter =
navNotifications
.getActionView()
.findViewById(R.id.counterBadgeNotification);
notificationCounter.setText(
String.valueOf(notificationCount.getNew()));
} else {
navNotifications
.getActionView()
.findViewById(R.id.counterBadgeNotification)
.setVisibility(View.GONE);
}
}
}

View File

@ -15,7 +15,8 @@
android:paddingStart="@dimen/dimen4dp"
android:paddingEnd="@dimen/dimen4dp"
android:singleLine="true"
android:textColor="@color/colorWhite"
android:textSize="@dimen/dimen12sp"/>
android:textColor="?attr/primaryTextColor"
android:textSize="@dimen/dimen12sp"
android:visibility="gone" />
</LinearLayout>