From d58f4d12321c7ef558629d806f624fec7ec278af Mon Sep 17 00:00:00 2001 From: Jake McGinty Date: Mon, 23 Nov 2015 10:46:01 -0800 Subject: [PATCH] don't allow fast scrolling until data is available fixes #4666 closes #4693 // FREEBIE --- res/layout/contact_selection_list_fragment.xml | 1 + .../securesms/ContactSelectionListFragment.java | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/res/layout/contact_selection_list_fragment.xml b/res/layout/contact_selection_list_fragment.xml index a0c8e9f44a..f537b502fb 100644 --- a/res/layout/contact_selection_list_fragment.xml +++ b/res/layout/contact_selection_list_fragment.xml @@ -28,6 +28,7 @@ android:id="@+id/fast_scroller" android:layout_width="wrap_content" android:layout_height="match_parent" + android:visibility="gone" android:layout_gravity="right"/> diff --git a/src/org/thoughtcrime/securesms/ContactSelectionListFragment.java b/src/org/thoughtcrime/securesms/ContactSelectionListFragment.java index 8991bb2d09..d89895e0fd 100644 --- a/src/org/thoughtcrime/securesms/ContactSelectionListFragment.java +++ b/src/org/thoughtcrime/securesms/ContactSelectionListFragment.java @@ -101,7 +101,6 @@ public class ContactSelectionListFragment extends Fragment swipeRefresh = ViewUtil.findById(view, R.id.swipe_refresh); fastScroller = ViewUtil.findById(view, R.id.fast_scroller); recyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); - fastScroller.setRecyclerView(recyclerView); swipeRefresh.setEnabled(getActivity().getIntent().getBooleanExtra(REFRESHABLE, true) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN); @@ -163,11 +162,16 @@ public class ContactSelectionListFragment extends Fragment public void onLoadFinished(Loader loader, Cursor data) { ((CursorRecyclerViewAdapter) recyclerView.getAdapter()).changeCursor(data); emptyText.setText(R.string.contact_selection_group_activity__no_contacts); + if (recyclerView.getAdapter().getItemCount() > 20) { + fastScroller.setVisibility(View.VISIBLE); + fastScroller.setRecyclerView(recyclerView); + } } @Override public void onLoaderReset(Loader loader) { ((CursorRecyclerViewAdapter) recyclerView.getAdapter()).changeCursor(null); + fastScroller.setVisibility(View.GONE); } private class ListClickListener implements ContactSelectionListAdapter.ItemClickListener {