Commit d5f0a2b3 authored by Grigory Fedorov's avatar Grigory Fedorov

Contact list: special separator list item added above each account group...

Contact list: special separator list item added above each account group (except top one, when no active chats opened).
parent bc592c20
......@@ -16,12 +16,12 @@ package com.xabber.android.ui.adapter;
import android.app.Activity;
import android.os.Handler;
import android.view.View;
import android.widget.ListView;
import com.xabber.android.data.SettingsManager;
import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.account.CommonState;
import com.xabber.android.data.entity.BaseEntity;
import com.xabber.android.data.extension.muc.RoomChat;
import com.xabber.android.data.extension.muc.RoomContact;
import com.xabber.android.data.message.AbstractChat;
......@@ -299,7 +299,14 @@ public class ContactListAdapter extends GroupedContactAdapter<ChatContactInflate
}
}
if (showAccounts) {
boolean isFirst = baseEntities.isEmpty();
for (AccountConfiguration rosterAccount : accounts.values()) {
if (isFirst) {
isFirst = false;
} else {
baseEntities.add(new AccountTopSeparator(null, null));
}
baseEntities.add(rosterAccount);
if (showGroups) {
if (rosterAccount.isExpanded()) {
......@@ -406,4 +413,9 @@ public class ContactListAdapter extends GroupedContactAdapter<ChatContactInflate
}
public static class AccountTopSeparator extends BaseEntity {
public AccountTopSeparator(String account, String user) {
super(account, user);
}
}
}
......@@ -55,7 +55,7 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
*/
static final Collection<Group> NO_GROUP_LIST;
static final int TYPE_COUNT = 3;
static final int TYPE_COUNT = 4;
/**
* View type used for contact items.
......@@ -66,9 +66,8 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
* View type used for groups and accounts expanders.
*/
static final int TYPE_GROUP = 1;
static final int TYPE_ACCOUNT = 2;
static final int TYPE_ACCOUNT_TOP_SEPARATOR = 3;
static {
Collection<Group> groups = new ArrayList<>(1);
......@@ -125,6 +124,8 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
return TYPE_ACCOUNT;
} else if (object instanceof GroupConfiguration) {
return TYPE_GROUP;
} else if (object instanceof ContactListAdapter.AccountTopSeparator) {
return TYPE_ACCOUNT_TOP_SEPARATOR;
} else {
throw new IllegalStateException();
}
......@@ -179,7 +180,7 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
return view;
}
case TYPE_ACCOUNT:
case TYPE_ACCOUNT: {
final View view;
final AccountViewHolder viewHolder;
if (convertView == null) {
......@@ -233,6 +234,18 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
viewHolder.offlineContactsIndicator.setImageLevel(showOfflineMode.ordinal());
return view;
}
case TYPE_ACCOUNT_TOP_SEPARATOR: {
final View view;
if (convertView == null) {
view = layoutInflater.inflate(R.layout.account_group_item_top_separator, parent, false);
} else {
view = convertView;
}
return view;
}
default:
throw new IllegalStateException();
......
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="6dp"
android:clickable="true"
>
</FrameLayout>
\ No newline at end of file
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