Skip to content

Commit

Permalink
Merge pull request #7 from GeorgCantor/master
Browse files Browse the repository at this point in the history
✅ UI improvements
  • Loading branch information
Spikeysanju authored Aug 30, 2020
2 parents 278973a + 112bebd commit 7f013de
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand All @@ -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)
})

Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/layout/fragment_bookmarks.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,14 @@
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
tools:listitem="@layout/item_post_article" />

<TextView
android:id="@+id/no_bookmarks"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/no_bookmarks"
android:textColor="@color/categoryText"
android:textSize="18sp"
android:visibility="gone" />

</androidx.coordinatorlayout.widget.CoordinatorLayout>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@
<string name="author">By Sanju S</string>
<string name="bookmark">Bookmark</string>
<string name="bookmarks_holder">Bookmarks</string>
<string name="no_bookmarks">No bookmarks yet</string>
<string name="hello_blank_fragment">Hello blank fragment</string>
</resources>

0 comments on commit 7f013de

Please sign in to comment.