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
*/
private Animation animation;
private AccountActionButtonsAdapter accountActionButtonsAdapter;
private View scrollToChatsActionButtonContainer;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
......@@ -105,7 +106,9 @@ public class ContactListFragment extends Fragment implements OnAccountChangedLis
this, (LinearLayout) view.findViewById(R.id.account_action_buttons));
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;
}
......@@ -177,6 +180,13 @@ public class ContactListFragment extends Fragment implements OnAccountChangedLis
@Override
public void onContactListChanged(CommonState commonState, boolean hasContacts,
boolean hasVisibleContacts, boolean isFilterEnabled) {
if (adapter.isHasActiveChats()) {
scrollToChatsActionButtonContainer.setVisibility(View.VISIBLE);
} else {
scrollToChatsActionButtonContainer.setVisibility(View.GONE);
}
if (hasVisibleContacts) {
infoView.setVisibility(View.GONE);
disconnectedView.clearAnimation();
......@@ -296,6 +306,9 @@ public class ContactListFragment extends Fragment implements OnAccountChangedLis
buttonView.setText(button);
}
buttonView.setOnClickListener(listener);
}
/**
......
......@@ -91,6 +91,7 @@ public class ContactListAdapter extends GroupedContactAdapter implements Runnabl
String filterString;
private final OnContactListChangedListener listener;
private boolean hasActiveChats = false;
public ContactListAdapter(Activity activity, OnContactListChangedListener listener,
OnClickListener onClickListener) {
......@@ -296,6 +297,8 @@ public class ContactListAdapter extends GroupedContactAdapter implements Runnabl
}
}
hasActiveChats = activeChats.getTotal() > 0;
// Remove empty groups, sort and apply structure.
baseEntities.clear();
if (hasVisibleContacts) {
......@@ -362,8 +365,7 @@ public class ContactListAdapter extends GroupedContactAdapter implements Runnabl
}
super.onChange();
listener.onContactListChanged(commonState, hasContacts, hasVisibleContacts,
filterString != null);
listener.onContactListChanged(commonState, hasContacts, hasVisibleContacts, filterString != null);
synchronized (refreshLock) {
nextRefresh = new Date(new Date().getTime() + REFRESH_INTERVAL);
......@@ -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