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; ...@@ -16,12 +16,12 @@ package com.xabber.android.ui.adapter;
import android.app.Activity; import android.app.Activity;
import android.os.Handler; import android.os.Handler;
import android.view.View;
import android.widget.ListView; import android.widget.ListView;
import com.xabber.android.data.SettingsManager; import com.xabber.android.data.SettingsManager;
import com.xabber.android.data.account.AccountManager; import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.account.CommonState; 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.RoomChat;
import com.xabber.android.data.extension.muc.RoomContact; import com.xabber.android.data.extension.muc.RoomContact;
import com.xabber.android.data.message.AbstractChat; import com.xabber.android.data.message.AbstractChat;
...@@ -299,7 +299,14 @@ public class ContactListAdapter extends GroupedContactAdapter<ChatContactInflate ...@@ -299,7 +299,14 @@ public class ContactListAdapter extends GroupedContactAdapter<ChatContactInflate
} }
} }
if (showAccounts) { if (showAccounts) {
boolean isFirst = baseEntities.isEmpty();
for (AccountConfiguration rosterAccount : accounts.values()) { for (AccountConfiguration rosterAccount : accounts.values()) {
if (isFirst) {
isFirst = false;
} else {
baseEntities.add(new AccountTopSeparator(null, null));
}
baseEntities.add(rosterAccount); baseEntities.add(rosterAccount);
if (showGroups) { if (showGroups) {
if (rosterAccount.isExpanded()) { if (rosterAccount.isExpanded()) {
...@@ -406,4 +413,9 @@ public class ContactListAdapter extends GroupedContactAdapter<ChatContactInflate ...@@ -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 ...@@ -55,7 +55,7 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
*/ */
static final Collection<Group> NO_GROUP_LIST; 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. * View type used for contact items.
...@@ -66,9 +66,8 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater ...@@ -66,9 +66,8 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
* View type used for groups and accounts expanders. * View type used for groups and accounts expanders.
*/ */
static final int TYPE_GROUP = 1; static final int TYPE_GROUP = 1;
static final int TYPE_ACCOUNT = 2; static final int TYPE_ACCOUNT = 2;
static final int TYPE_ACCOUNT_TOP_SEPARATOR = 3;
static { static {
Collection<Group> groups = new ArrayList<>(1); Collection<Group> groups = new ArrayList<>(1);
...@@ -125,6 +124,8 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater ...@@ -125,6 +124,8 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
return TYPE_ACCOUNT; return TYPE_ACCOUNT;
} else if (object instanceof GroupConfiguration) { } else if (object instanceof GroupConfiguration) {
return TYPE_GROUP; return TYPE_GROUP;
} else if (object instanceof ContactListAdapter.AccountTopSeparator) {
return TYPE_ACCOUNT_TOP_SEPARATOR;
} else { } else {
throw new IllegalStateException(); throw new IllegalStateException();
} }
...@@ -179,7 +180,7 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater ...@@ -179,7 +180,7 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
return view; return view;
} }
case TYPE_ACCOUNT: case TYPE_ACCOUNT: {
final View view; final View view;
final AccountViewHolder viewHolder; final AccountViewHolder viewHolder;
if (convertView == null) { if (convertView == null) {
...@@ -233,6 +234,18 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater ...@@ -233,6 +234,18 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
viewHolder.offlineContactsIndicator.setImageLevel(showOfflineMode.ordinal()); viewHolder.offlineContactsIndicator.setImageLevel(showOfflineMode.ordinal());
return view; 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: default:
throw new IllegalStateException(); 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