Commit f66a8419 authored by Grigory Fedorov's avatar Grigory Fedorov

Contact list scroll up button now shown only if there are active chats.

parent 44b8c707
...@@ -84,6 +84,7 @@ public class ContactListFragment extends Fragment implements OnAccountChangedLis ...@@ -84,6 +84,7 @@ public class ContactListFragment extends Fragment implements OnAccountChangedLis
*/ */
private Animation animation; private Animation animation;
private AccountActionButtonsAdapter accountActionButtonsAdapter; private AccountActionButtonsAdapter accountActionButtonsAdapter;
private View scrollToChatsActionButtonContainer;
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
...@@ -105,7 +106,9 @@ public class ContactListFragment extends Fragment implements OnAccountChangedLis ...@@ -105,7 +106,9 @@ public class ContactListFragment extends Fragment implements OnAccountChangedLis
this, (LinearLayout) view.findViewById(R.id.account_action_buttons)); this, (LinearLayout) view.findViewById(R.id.account_action_buttons));
accountActionButtonsAdapter.onChange(); accountActionButtonsAdapter.onChange();
view.findViewById(R.id.fab_up_container).setOnClickListener(this); scrollToChatsActionButtonContainer = view.findViewById(R.id.fab_up_container);
scrollToChatsActionButtonContainer.setOnClickListener(this);
scrollToChatsActionButtonContainer.setVisibility(View.GONE);
return view; return view;
} }
...@@ -177,6 +180,13 @@ public class ContactListFragment extends Fragment implements OnAccountChangedLis ...@@ -177,6 +180,13 @@ public class ContactListFragment extends Fragment implements OnAccountChangedLis
@Override @Override
public void onContactListChanged(CommonState commonState, boolean hasContacts, public void onContactListChanged(CommonState commonState, boolean hasContacts,
boolean hasVisibleContacts, boolean isFilterEnabled) { boolean hasVisibleContacts, boolean isFilterEnabled) {
if (adapter.isHasActiveChats()) {
scrollToChatsActionButtonContainer.setVisibility(View.VISIBLE);
} else {
scrollToChatsActionButtonContainer.setVisibility(View.GONE);
}
if (hasVisibleContacts) { if (hasVisibleContacts) {
infoView.setVisibility(View.GONE); infoView.setVisibility(View.GONE);
disconnectedView.clearAnimation(); disconnectedView.clearAnimation();
...@@ -296,6 +306,9 @@ public class ContactListFragment extends Fragment implements OnAccountChangedLis ...@@ -296,6 +306,9 @@ public class ContactListFragment extends Fragment implements OnAccountChangedLis
buttonView.setText(button); buttonView.setText(button);
} }
buttonView.setOnClickListener(listener); buttonView.setOnClickListener(listener);
} }
/** /**
......
...@@ -91,6 +91,7 @@ public class ContactListAdapter extends GroupedContactAdapter implements Runnabl ...@@ -91,6 +91,7 @@ public class ContactListAdapter extends GroupedContactAdapter implements Runnabl
String filterString; String filterString;
private final OnContactListChangedListener listener; private final OnContactListChangedListener listener;
private boolean hasActiveChats = false;
public ContactListAdapter(Activity activity, OnContactListChangedListener listener, public ContactListAdapter(Activity activity, OnContactListChangedListener listener,
OnClickListener onClickListener) { OnClickListener onClickListener) {
...@@ -296,6 +297,8 @@ public class ContactListAdapter extends GroupedContactAdapter implements Runnabl ...@@ -296,6 +297,8 @@ public class ContactListAdapter extends GroupedContactAdapter implements Runnabl
} }
} }
hasActiveChats = activeChats.getTotal() > 0;
// Remove empty groups, sort and apply structure. // Remove empty groups, sort and apply structure.
baseEntities.clear(); baseEntities.clear();
if (hasVisibleContacts) { if (hasVisibleContacts) {
...@@ -362,8 +365,7 @@ public class ContactListAdapter extends GroupedContactAdapter implements Runnabl ...@@ -362,8 +365,7 @@ public class ContactListAdapter extends GroupedContactAdapter implements Runnabl
} }
super.onChange(); super.onChange();
listener.onContactListChanged(commonState, hasContacts, hasVisibleContacts, listener.onContactListChanged(commonState, hasContacts, hasVisibleContacts, filterString != null);
filterString != null);
synchronized (refreshLock) { synchronized (refreshLock) {
nextRefresh = new Date(new Date().getTime() + REFRESH_INTERVAL); nextRefresh = new Date(new Date().getTime() + REFRESH_INTERVAL);
...@@ -467,4 +469,8 @@ public class ContactListAdapter extends GroupedContactAdapter implements Runnabl ...@@ -467,4 +469,8 @@ public class ContactListAdapter extends GroupedContactAdapter implements Runnabl
} }
} }
public boolean isHasActiveChats() {
return hasActiveChats;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment