This commit is contained in:
Amine 2017-07-02 19:31:18 +02:00
parent 585c57fe3a
commit e68c16c7a4
3 changed files with 61 additions and 14 deletions

View File

@ -20,6 +20,7 @@ import android.support.v7.widget.helper.ItemTouchHelper
import android.view.Menu
import android.view.MenuItem
import android.view.View
import android.widget.TextView
import android.widget.Toast
import com.anupcowkur.reservoir.Reservoir
@ -86,6 +87,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
private var maybeSourceFilter: Sources? = null
private var maybeSearchFilter: String? = null
private lateinit var emptyText: TextView
private lateinit var mRecyclerView: RecyclerView
private lateinit var mBottomBar: BottomBar
private lateinit var mCoordinatorLayout: CoordinatorLayout
@ -157,6 +159,8 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
mSwipeRefreshLayout = findViewById(R.id.swipeRefreshLayout)
mRecyclerView = findViewById(R.id.my_recycler_view)
emptyText = findViewById(R.id.emptyText)
reloadLayoutManager()
mSwipeRefreshLayout.setColorSchemeResources(
@ -518,7 +522,13 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
}
if (didUpdate)
handleListResult()
if (items.isEmpty()) Toast.makeText(this@HomeActivity, R.string.nothing_here, Toast.LENGTH_SHORT).show()
if (items.isEmpty()) {
emptyText.visibility = View.VISIBLE
mRecyclerView.visibility = View.GONE
} else {
emptyText.visibility = View.GONE
mRecyclerView.visibility = View.VISIBLE
}
mSwipeRefreshLayout.isRefreshing = false
}

View File

@ -90,6 +90,22 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/emptyText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="fill"
android:paddingTop="100dp"
android:text="@string/nothing_here"
android:textAlignment="center"
android:textAppearance="@style/TextAppearance.AppCompat.Headline"
android:textColor="@color/about_libraries_card_dark"
android:visibility="gone" />
<android.support.v7.widget.RecyclerView
android:id="@+id/my_recycler_view"
android:layout_width="match_parent"
@ -97,6 +113,9 @@
android:background="@color/background_grey"
android:scrollbars="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</LinearLayout>
</android.support.v4.widget.SwipeRefreshLayout>
</FrameLayout>

View File

@ -70,6 +70,22 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/emptyText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="fill"
android:paddingTop="100dp"
android:text="@string/nothing_here"
android:textAlignment="center"
android:textAppearance="@style/TextAppearance.AppCompat.Headline"
android:textColor="@color/about_libraries_card_dark"
android:visibility="gone" />
<android.support.v7.widget.RecyclerView
android:id="@+id/my_recycler_view"
android:layout_width="match_parent"
@ -78,6 +94,8 @@
android:clipToPadding="false"
android:scrollbars="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</LinearLayout>
</android.support.v4.widget.SwipeRefreshLayout>
</FrameLayout>