diff --git a/app/src/main/java/www/thecodemonks/techbytes/ui/bookmarks/BookmarksFragment.kt b/app/src/main/java/www/thecodemonks/techbytes/ui/bookmarks/BookmarksFragment.kt index 9588539..4813bb4 100644 --- a/app/src/main/java/www/thecodemonks/techbytes/ui/bookmarks/BookmarksFragment.kt +++ b/app/src/main/java/www/thecodemonks/techbytes/ui/bookmarks/BookmarksFragment.kt @@ -28,6 +28,8 @@ package www.thecodemonks.techbytes.ui.bookmarks import android.os.Bundle import android.view.View +import android.view.View.GONE +import android.view.View.VISIBLE import androidx.fragment.app.Fragment import androidx.lifecycle.Observer import androidx.navigation.fragment.findNavController @@ -45,8 +47,10 @@ import www.thecodemonks.techbytes.utils.SpacesItemDecorator class BookmarksFragment : Fragment(R.layout.fragment_bookmarks) { + private lateinit var viewModel: ArticleViewModel private lateinit var newsAdapter: NewsAdapter + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) @@ -58,6 +62,7 @@ class BookmarksFragment : Fragment(R.layout.fragment_bookmarks) { // get saved articles from room db viewModel.getSavedArticle().observe(viewLifecycleOwner, Observer { + no_bookmarks.visibility = if (it.isNullOrEmpty()) VISIBLE else GONE newsAdapter.differ.submitList(it) }) diff --git a/app/src/main/res/layout/fragment_bookmarks.xml b/app/src/main/res/layout/fragment_bookmarks.xml index 3e67e81..37a38cc 100644 --- a/app/src/main/res/layout/fragment_bookmarks.xml +++ b/app/src/main/res/layout/fragment_bookmarks.xml @@ -40,5 +40,14 @@ app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" tools:listitem="@layout/item_post_article" /> + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f541f70..940aa84 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -31,5 +31,6 @@ By Sanju S Bookmark Bookmarks + No bookmarks yet Hello blank fragment \ No newline at end of file