Implement "no notifications" view, display when notifications list empty

This commit is contained in:
Carl Vuorinen 2019-03-19 00:07:49 +02:00
parent 6c09f32e63
commit 4c2a48ae69
7 changed files with 70 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

View file

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/spacing_large">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:paddingLeft="@dimen/spacing_medium"
android:paddingTop="44dp"
android:paddingRight="@dimen/spacing_medium">
<ImageView
android:id="@+id/noNotifications"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/transparent"
android:clickable="false"
android:gravity="center"
android:src="@drawable/no_notifications" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="40dp"
android:paddingRight="40dp"
android:orientation="vertical"
android:paddingTop="26dp">
<TextView
style="@style/SectionTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/no_notifications_title" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:lineHeight="20dp"
android:paddingTop="16dp"
android:text="@string/no_notifications_text" />
</LinearLayout>
</LinearLayout>
</LinearLayout>

View file

@ -860,6 +860,8 @@
<string name="discover">Discover</string>
<string name="damage_paused">Damage paused</string>
<string name="preference_push_important_announcements">Important Announcements</string>
<string name="no_notifications_title">Youre all caught up!</string>
<string name="no_notifications_text">The notification fairies give you a raucous round of applause! Well done!</string>
<string name="create">Create</string>
<string name="only_leader_create_challenge">Only leader can create Challenges</string>
<string name="create_party">Create Party</string>

View file

@ -1,6 +1,8 @@
package com.habitrpg.android.habitica.ui.activities
import android.content.Context
import android.os.Bundle
import android.view.LayoutInflater
import com.habitrpg.android.habitica.R
import com.habitrpg.android.habitica.components.AppComponent
import com.habitrpg.android.habitica.data.UserRepository
@ -56,6 +58,19 @@ class NotificationsActivity : BaseActivity(), androidx.swiperefreshlayout.widget
}
private fun setNotifications(notifications: RealmList<GlobalNotification>) {
if (notification_items == null) {
return
}
notification_items.removeAllViewsInLayout()
val inflater = getSystemService(Context.LAYOUT_INFLATER_SERVICE) as? LayoutInflater
if (notifications.isEmpty()) {
val item = inflater?.inflate(R.layout.no_notifications, notification_items, false)
notification_items.addView(item)
return
}
//TODO("not implemented")
}
}