Add empty list layout

This commit is contained in:
Shinokuni 2019-05-20 10:40:27 +02:00
parent 2ecc707d0e
commit c771086989
4 changed files with 36 additions and 1 deletions

View File

@ -85,6 +85,7 @@ public class MainActivity extends AppCompatActivity implements SwipeRefreshLayou
private MainViewModel viewModel;
private DrawerManager drawerManager;
private RelativeLayout emptyListLayout;
private RelativeLayout syncProgressLayout;
private TextView syncProgress;
private ProgressBar syncProgressBar;
@ -107,6 +108,8 @@ public class MainActivity extends AppCompatActivity implements SwipeRefreshLayou
setSupportActionBar(toolbar);
toolbar.setTitleTextColor(Color.WHITE);
emptyListLayout = findViewById(R.id.empty_list_layout);
actionMenu = findViewById(R.id.fab_menu);
viewModel = ViewModelProviders.of(this).get(MainViewModel.class);
@ -117,6 +120,11 @@ public class MainActivity extends AppCompatActivity implements SwipeRefreshLayou
viewModel.getItemsWithFeed().observe(this, itemWithFeeds -> {
allItems = itemWithFeeds;
if (itemWithFeeds.size() > 0)
emptyListLayout.setVisibility(View.GONE);
else
emptyListLayout.setVisibility(View.VISIBLE);
if (!refreshLayout.isRefreshing())
adapter.submitList(itemWithFeeds);
});

View File

@ -71,7 +71,8 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
tools:listitem="@layout/image_item" />
tools:listitem="@layout/image_item"
tools:visibility="visible" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
@ -82,6 +83,30 @@
android:layout_height="match_parent"
android:animateLayoutChanges="true">
<RelativeLayout
android:id="@+id/empty_list_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:visibility="gone">
<ImageView
android:id="@+id/empty_list_imageview"
android:layout_width="200dp"
android:layout_height="200dp"
android:src="@drawable/ic_rss_feed_grey" />
<TextView
style="@style/TextAppearance.AppCompat.Large"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/empty_list_imageview"
android:layout_centerInParent="true"
android:text="@string/no_feed" />
</RelativeLayout>
<com.github.clans.fab.FloatingActionMenu
android:id="@+id/fab_menu"
android:layout_width="wrap_content"

View File

@ -56,5 +56,6 @@
<string name="password">Mot de passe</string>
<string name="account_settings">Paramètres du compte</string>
<string name="add_account">Ajouter un compte</string>
<string name="no_feed">Aucun flux</string>
</resources>

View File

@ -59,4 +59,5 @@
<string name="nextcloud_news" translatable="false">Nextcloud News</string>
<string name="account_settings">Account settings</string>
<string name="add_account">Add account</string>
<string name="no_feed">No feed</string>
</resources>