Set dividers & bg correctly for notifications list

This commit is contained in:
Carl Vuorinen 2019-05-19 20:31:28 +03:00
parent 90fcb49e89
commit 716f649c35
4 changed files with 13 additions and 7 deletions

View file

@ -38,16 +38,15 @@
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="?attr/actionBarSize">
android:layout_height="match_parent">
<com.habitrpg.android.habitica.ui.views.PaddedLinearLayout
<LinearLayout
android:id="@+id/notification_items"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="?android:listDivider"
android:orientation="vertical"
android:showDividers="middle"></com.habitrpg.android.habitica.ui.views.PaddedLinearLayout>
android:showDividers="middle" />
</androidx.core.widget.NestedScrollView>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</FrameLayout>

View file

@ -3,6 +3,7 @@
android:id="@+id/notification_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="horizontal"
android:paddingLeft="20dp"
android:paddingTop="10dp"

View file

@ -3,9 +3,10 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="horizontal"
android:paddingLeft="20dp"
android:paddingTop="14dp"
android:paddingTop="10dp"
android:paddingRight="20dp">
<LinearLayout

View file

@ -8,6 +8,7 @@ import android.view.LayoutInflater
import android.view.View
import android.widget.Button
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import androidx.core.content.ContextCompat
import androidx.lifecycle.ViewModelProviders
@ -79,18 +80,22 @@ class NotificationsActivity : BaseActivity(), androidx.swiperefreshlayout.widget
notification_items.removeAllViewsInLayout()
when {
notifications.isEmpty() -> displayNoNotificationsVew()
notifications.isEmpty() -> displayNoNotificationsView()
else -> displayNotificationsListView(notifications)
}
}
private fun displayNoNotificationsVew() {
private fun displayNoNotificationsView() {
notification_items.showDividers = LinearLayout.SHOW_DIVIDER_NONE
notification_items.addView(
inflater.inflate(R.layout.no_notifications, notification_items, false)
)
}
private fun displayNotificationsListView(notifications: List<Notification>) {
notification_items.showDividers = LinearLayout.SHOW_DIVIDER_MIDDLE or LinearLayout.SHOW_DIVIDER_END
notification_items.addView(
createNotificationsHeaderView(notifications.count())
)