mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2026-05-16 04:52:39 +02:00
Empty view for notifs, back on toggle off
This commit is contained in:
+3
@@ -90,6 +90,9 @@ class GeneralTopBarFragment : TopFragment() {
|
|||||||
updateNotifCount();
|
updateNotifCount();
|
||||||
|
|
||||||
_buttonNotifs?.setOnClickListener {
|
_buttonNotifs?.setOnClickListener {
|
||||||
|
if(currentMain is NotificationOverlayView.Frag)
|
||||||
|
closeSegment();
|
||||||
|
else
|
||||||
navigate<NotificationOverlayView.Frag>();
|
navigate<NotificationOverlayView.Frag>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+9
-1
@@ -24,6 +24,7 @@ import com.futo.platformplayer.states.StateApp
|
|||||||
import com.futo.platformplayer.views.AnyAdapterView
|
import com.futo.platformplayer.views.AnyAdapterView
|
||||||
import com.futo.platformplayer.views.AnyAdapterView.Companion.asAny
|
import com.futo.platformplayer.views.AnyAdapterView.Companion.asAny
|
||||||
import com.futo.platformplayer.views.LoaderView
|
import com.futo.platformplayer.views.LoaderView
|
||||||
|
import com.futo.platformplayer.views.NoResultsView
|
||||||
import com.futo.platformplayer.views.adapters.AnyAdapter
|
import com.futo.platformplayer.views.adapters.AnyAdapter
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
@@ -31,22 +32,29 @@ import kotlinx.coroutines.launch
|
|||||||
class NotificationOverlayView: ConstraintLayout {
|
class NotificationOverlayView: ConstraintLayout {
|
||||||
|
|
||||||
lateinit var recycler: RecyclerView;
|
lateinit var recycler: RecyclerView;
|
||||||
|
lateinit var emptyView: NoResultsView;
|
||||||
var adapterNotifications: AnyAdapterView<Announcement, ViewHolder>;
|
var adapterNotifications: AnyAdapterView<Announcement, ViewHolder>;
|
||||||
|
|
||||||
constructor(context: Context) : super(context) {
|
constructor(context: Context) : super(context) {
|
||||||
inflate(context, R.layout.overlay_notifications, this)
|
inflate(context, R.layout.overlay_notifications, this)
|
||||||
|
|
||||||
recycler = findViewById<RecyclerView>(R.id.container_notifications);
|
recycler = findViewById<RecyclerView>(R.id.container_notifications);
|
||||||
|
emptyView = findViewById<NoResultsView>(R.id.no_results);
|
||||||
adapterNotifications = recycler.asAny<Announcement, ViewHolder>(RecyclerView.VERTICAL, false, {
|
adapterNotifications = recycler.asAny<Announcement, ViewHolder>(RecyclerView.VERTICAL, false, {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
emptyView.setText("Nothing to see here", "You don't have any notifications", R.drawable.ic_notifications)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onShown(parameter: Any?) {
|
fun onShown(parameter: Any?) {
|
||||||
val announcements = StateAnnouncement.instance.getVisibleAnnouncements();
|
val announcements = StateAnnouncement.instance.getVisibleAnnouncements();
|
||||||
adapterNotifications.adapter.setData(announcements);
|
adapterNotifications.adapter.setData(announcements);
|
||||||
|
|
||||||
|
if(announcements.any())
|
||||||
|
emptyView.isVisible = false;
|
||||||
|
else
|
||||||
|
emptyView.isVisible = true;
|
||||||
|
|
||||||
StateAnnouncement.instance.onAnnouncementChanged.subscribe(this) {
|
StateAnnouncement.instance.onAnnouncementChanged.subscribe(this) {
|
||||||
StateApp.instance.scopeOrNull?.launch(Dispatchers.Main) {
|
StateApp.instance.scopeOrNull?.launch(Dispatchers.Main) {
|
||||||
Logger.i("NotificationOverlayView", "Announcements Changed");
|
Logger.i("NotificationOverlayView", "Announcements Changed");
|
||||||
|
|||||||
@@ -17,6 +17,11 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1px"
|
android:layout_height="1px"
|
||||||
android:background="#181818" />
|
android:background="#181818" />
|
||||||
|
<com.futo.platformplayer.views.NoResultsView
|
||||||
|
android:id="@+id/no_results"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/container_notifications"
|
android:id="@+id/container_notifications"
|
||||||
app:layout_constraintTop_toBottomOf="@id/separator"
|
app:layout_constraintTop_toBottomOf="@id/separator"
|
||||||
|
|||||||
Reference in New Issue
Block a user