Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xabber-android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
xabber-android
Commits
67ff3d03
Commit
67ff3d03
authored
Feb 13, 2015
by
Grigory Fedorov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Light code formatting.
parent
cfffc807
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
243 additions
and
313 deletions
+243
-313
ContactList.java
app/src/main/java/com/xabber/android/ui/ContactList.java
+8
-19
ContactListFragment.java
.../main/java/com/xabber/android/ui/ContactListFragment.java
+41
-66
BaseContactAdapter.java
...ava/com/xabber/android/ui/adapter/BaseContactAdapter.java
+9
-14
BaseContactInflater.java
...va/com/xabber/android/ui/adapter/BaseContactInflater.java
+12
-18
ContactListAdapter.java
...ava/com/xabber/android/ui/adapter/ContactListAdapter.java
+105
-110
GroupedContactAdapter.java
.../com/xabber/android/ui/adapter/GroupedContactAdapter.java
+67
-84
SmoothContactAdapter.java
...a/com/xabber/android/ui/adapter/SmoothContactAdapter.java
+1
-2
No files found.
app/src/main/java/com/xabber/android/ui/ContactList.java
View file @
67ff3d03
...
@@ -45,7 +45,6 @@ import com.xabber.android.data.NetworkException;
...
@@ -45,7 +45,6 @@ import com.xabber.android.data.NetworkException;
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.OnAccountChangedListener
;
import
com.xabber.android.data.account.OnAccountChangedListener
;
import
com.xabber.android.data.account.StatusMode
;
import
com.xabber.android.data.entity.BaseEntity
;
import
com.xabber.android.data.entity.BaseEntity
;
import
com.xabber.android.data.extension.avatar.AvatarManager
;
import
com.xabber.android.data.extension.avatar.AvatarManager
;
import
com.xabber.android.data.extension.muc.MUCManager
;
import
com.xabber.android.data.extension.muc.MUCManager
;
...
@@ -76,9 +75,8 @@ import java.util.Collection;
...
@@ -76,9 +75,8 @@ import java.util.Collection;
*
*
* @author alexander.ivanov
* @author alexander.ivanov
*/
*/
public
class
ContactList
extends
ManagedActivity
implements
public
class
ContactList
extends
ManagedActivity
implements
OnAccountChangedListener
,
OnAccountChangedListener
,
View
.
OnClickListener
,
View
.
OnClickListener
,
OnChoosedListener
,
OnContactClickListener
{
OnChoosedListener
,
OnContactClickListener
{
/**
/**
* Select contact to be invited to the room was requested.
* Select contact to be invited to the room was requested.
...
@@ -121,6 +119,7 @@ public class ContactList extends ManagedActivity implements
...
@@ -121,6 +119,7 @@ public class ContactList extends ManagedActivity implements
ActivityManager
.
getInstance
().
startNewTask
(
this
);
ActivityManager
.
getInstance
().
startNewTask
(
this
);
}
}
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
if
(
isFinishing
())
{
if
(
isFinishing
())
{
return
;
return
;
}
}
...
@@ -233,7 +232,6 @@ public class ContactList extends ManagedActivity implements
...
@@ -233,7 +232,6 @@ public class ContactList extends ManagedActivity implements
@Override
@Override
protected
void
onResume
()
{
protected
void
onResume
()
{
super
.
onResume
();
super
.
onResume
();
updateStatusBar
();
rebuildAccountToggle
();
rebuildAccountToggle
();
Application
.
getInstance
().
addUIListener
(
OnAccountChangedListener
.
class
,
this
);
Application
.
getInstance
().
addUIListener
(
OnAccountChangedListener
.
class
,
this
);
...
@@ -281,9 +279,9 @@ public class ContactList extends ManagedActivity implements
...
@@ -281,9 +279,9 @@ public class ContactList extends ManagedActivity implements
}
}
}
}
}
}
if
(
Application
.
getInstance
().
doNotify
())
{
if
(
Application
.
getInstance
().
doNotify
())
{
if
(
SettingsManager
.
bootCount
()
>
2
if
(
SettingsManager
.
bootCount
()
>
2
&&
!
SettingsManager
.
connectionStartAtBoot
()
&&
!
SettingsManager
.
connectionStartAtBoot
()
&&
!
SettingsManager
.
startAtBootSuggested
())
{
&&
!
SettingsManager
.
startAtBootSuggested
())
{
StartAtBootDialogFragment
.
newInstance
().
show
(
getFragmentManager
(),
"START_AT_BOOT"
);
StartAtBootDialogFragment
.
newInstance
().
show
(
getFragmentManager
(),
"START_AT_BOOT"
);
}
}
...
@@ -458,8 +456,9 @@ public class ContactList extends ManagedActivity implements
...
@@ -458,8 +456,9 @@ public class ContactList extends ManagedActivity implements
break
;
break
;
default
:
default
:
String
account
=
accountToggleAdapter
.
getItemForView
(
view
);
String
account
=
accountToggleAdapter
.
getItemForView
(
view
);
if
(
account
==
null
)
// Check for tap on account in the title
if
(
account
==
null
)
{
// Check for tap on account in the title
break
;
break
;
}
if
(!
SettingsManager
.
contactsShowAccounts
())
{
if
(!
SettingsManager
.
contactsShowAccounts
())
{
if
(
AccountManager
.
getInstance
().
getAccounts
().
size
()
<
2
)
{
if
(
AccountManager
.
getInstance
().
getAccounts
().
size
()
<
2
)
{
getContactListFragment
().
scrollUp
();
getContactListFragment
().
scrollUp
();
...
@@ -538,7 +537,6 @@ public class ContactList extends ManagedActivity implements
...
@@ -538,7 +537,6 @@ public class ContactList extends ManagedActivity implements
}
}
private
void
rebuildAccountToggle
()
{
private
void
rebuildAccountToggle
()
{
updateStatusBar
();
accountToggleAdapter
.
rebuild
();
accountToggleAdapter
.
rebuild
();
if
(
SettingsManager
.
contactsShowPanel
()
&&
accountToggleAdapter
.
getCount
()
>
0
)
{
if
(
SettingsManager
.
contactsShowPanel
()
&&
accountToggleAdapter
.
getCount
()
>
0
)
{
actionBarView
.
setVisibility
(
View
.
VISIBLE
);
actionBarView
.
setVisibility
(
View
.
VISIBLE
);
...
@@ -547,14 +545,6 @@ public class ContactList extends ManagedActivity implements
...
@@ -547,14 +545,6 @@ public class ContactList extends ManagedActivity implements
}
}
}
}
private
void
updateStatusBar
()
{
String
statusText
=
SettingsManager
.
statusText
();
StatusMode
statusMode
=
SettingsManager
.
statusMode
();
if
(
""
.
equals
(
statusText
))
{
statusText
=
getString
(
statusMode
.
getStringID
());
}
}
public
static
Intent
createPersistentIntent
(
Context
context
)
{
public
static
Intent
createPersistentIntent
(
Context
context
)
{
Intent
intent
=
new
Intent
(
context
,
ContactList
.
class
);
Intent
intent
=
new
Intent
(
context
,
ContactList
.
class
);
intent
.
setAction
(
"android.intent.action.MAIN"
);
intent
.
setAction
(
"android.intent.action.MAIN"
);
...
@@ -567,8 +557,7 @@ public class ContactList extends ManagedActivity implements
...
@@ -567,8 +557,7 @@ public class ContactList extends ManagedActivity implements
return
new
Intent
(
context
,
ContactList
.
class
);
return
new
Intent
(
context
,
ContactList
.
class
);
}
}
public
static
Intent
createRoomInviteIntent
(
Context
context
,
public
static
Intent
createRoomInviteIntent
(
Context
context
,
String
account
,
String
room
)
{
String
account
,
String
room
)
{
Intent
intent
=
new
EntityIntentBuilder
(
context
,
ContactList
.
class
)
Intent
intent
=
new
EntityIntentBuilder
(
context
,
ContactList
.
class
)
.
setAccount
(
account
).
setUser
(
room
).
build
();
.
setAccount
(
account
).
setUser
(
room
).
build
();
intent
.
setAction
(
ACTION_ROOM_INVITE
);
intent
.
setAction
(
ACTION_ROOM_INVITE
);
...
...
app/src/main/java/com/xabber/android/ui/ContactListFragment.java
View file @
67ff3d03
...
@@ -43,9 +43,8 @@ import com.xabber.androiddev.R;
...
@@ -43,9 +43,8 @@ import com.xabber.androiddev.R;
import
java.util.Collection
;
import
java.util.Collection
;
public
class
ContactListFragment
extends
Fragment
implements
public
class
ContactListFragment
extends
Fragment
implements
OnAccountChangedListener
,
OnAccountChangedListener
,
OnContactChangedListener
,
OnContactChangedListener
,
OnChatChangedListener
,
OnItemClickListener
,
OnChatChangedListener
,
OnItemClickListener
,
OnContactListChangedListener
{
OnContactListChangedListener
{
private
ContactListAdapter
adapter
;
private
ContactListAdapter
adapter
;
...
@@ -85,8 +84,7 @@ public class ContactListFragment extends Fragment implements
...
@@ -85,8 +84,7 @@ public class ContactListFragment extends Fragment implements
@Override
@Override
public
View
onCreateView
(
LayoutInflater
inflater
,
ViewGroup
container
,
public
View
onCreateView
(
LayoutInflater
inflater
,
ViewGroup
container
,
Bundle
savedInstanceState
)
{
Bundle
savedInstanceState
)
{
View
view
=
inflater
.
inflate
(
R
.
layout
.
contact_list_fragment
,
container
,
View
view
=
inflater
.
inflate
(
R
.
layout
.
contact_list_fragment
,
container
,
false
);
false
);
listView
=
(
ListView
)
view
.
findViewById
(
android
.
R
.
id
.
list
);
listView
=
(
ListView
)
view
.
findViewById
(
android
.
R
.
id
.
list
);
listView
.
setOnItemClickListener
(
this
);
listView
.
setOnItemClickListener
(
this
);
listView
.
setItemsCanFocus
(
true
);
listView
.
setItemsCanFocus
(
true
);
...
@@ -98,20 +96,16 @@ public class ContactListFragment extends Fragment implements
...
@@ -98,20 +96,16 @@ public class ContactListFragment extends Fragment implements
disconnectedView
=
infoView
.
findViewById
(
R
.
id
.
disconnected
);
disconnectedView
=
infoView
.
findViewById
(
R
.
id
.
disconnected
);
textView
=
(
TextView
)
infoView
.
findViewById
(
R
.
id
.
text
);
textView
=
(
TextView
)
infoView
.
findViewById
(
R
.
id
.
text
);
buttonView
=
(
Button
)
infoView
.
findViewById
(
R
.
id
.
button
);
buttonView
=
(
Button
)
infoView
.
findViewById
(
R
.
id
.
button
);
animation
=
AnimationUtils
.
loadAnimation
(
getActivity
(),
animation
=
AnimationUtils
.
loadAnimation
(
getActivity
(),
R
.
anim
.
connection
);
R
.
anim
.
connection
);
return
view
;
return
view
;
}
}
@Override
@Override
public
void
onResume
()
{
public
void
onResume
()
{
super
.
onResume
();
super
.
onResume
();
Application
.
getInstance
().
addUIListener
(
OnAccountChangedListener
.
class
,
Application
.
getInstance
().
addUIListener
(
OnAccountChangedListener
.
class
,
this
);
this
);
Application
.
getInstance
().
addUIListener
(
OnContactChangedListener
.
class
,
this
);
Application
.
getInstance
().
addUIListener
(
OnContactChangedListener
.
class
,
Application
.
getInstance
().
addUIListener
(
OnChatChangedListener
.
class
,
this
);
this
);
Application
.
getInstance
().
addUIListener
(
OnChatChangedListener
.
class
,
this
);
adapter
.
onChange
();
adapter
.
onChange
();
}
}
...
@@ -122,38 +116,35 @@ public class ContactListFragment extends Fragment implements
...
@@ -122,38 +116,35 @@ public class ContactListFragment extends Fragment implements
}
}
@Override
@Override
public
void
onCreateContextMenu
(
ContextMenu
menu
,
View
view
,
public
void
onCreateContextMenu
(
ContextMenu
menu
,
View
view
,
ContextMenuInfo
menuInfo
)
{
ContextMenuInfo
menuInfo
)
{
AdapterContextMenuInfo
info
=
(
AdapterContextMenuInfo
)
menuInfo
;
AdapterContextMenuInfo
info
=
(
AdapterContextMenuInfo
)
menuInfo
;
BaseEntity
baseEntity
=
(
BaseEntity
)
listView
BaseEntity
baseEntity
=
(
BaseEntity
)
listView
.
getItemAtPosition
(
info
.
position
);
.
getItemAtPosition
(
info
.
position
);
if
(
baseEntity
instanceof
AbstractContact
)
{
if
(
baseEntity
instanceof
AbstractContact
)
{
ContextMenuHelper
.
createContactContextMenu
(
getActivity
(),
adapter
,
ContextMenuHelper
.
createContactContextMenu
(
(
AbstractContact
)
baseEntity
,
menu
);
getActivity
(),
adapter
,
(
AbstractContact
)
baseEntity
,
menu
);
}
else
if
(
baseEntity
instanceof
AccountConfiguration
)
{
}
else
if
(
baseEntity
instanceof
AccountConfiguration
)
{
ContextMenuHelper
.
createAccountContextMenu
(
getActivity
(),
adapter
,
ContextMenuHelper
.
createAccountContextMenu
(
baseEntity
.
getAccount
(),
menu
);
getActivity
(),
adapter
,
baseEntity
.
getAccount
(),
menu
);
}
else
if
(
baseEntity
instanceof
GroupConfiguration
)
{
}
else
if
(
baseEntity
instanceof
GroupConfiguration
)
{
ContextMenuHelper
.
createGroupContextMenu
(
getActivity
(),
adapter
,
ContextMenuHelper
.
createGroupContextMenu
(
getActivity
(),
adapter
,
baseEntity
.
getAccount
(),
baseEntity
.
getUser
(),
menu
);
baseEntity
.
getAccount
(),
baseEntity
.
getUser
(),
menu
);
}
else
}
else
{
throw
new
IllegalStateException
();
throw
new
IllegalStateException
();
}
}
}
@Override
@Override
public
void
onItemClick
(
AdapterView
<?>
parent
,
View
view
,
int
position
,
public
void
onItemClick
(
AdapterView
<?>
parent
,
View
view
,
int
position
,
long
id
)
{
long
id
)
{
Object
object
=
parent
.
getAdapter
().
getItem
(
position
);
Object
object
=
parent
.
getAdapter
().
getItem
(
position
);
if
(
object
instanceof
AbstractContact
)
{
if
(
object
instanceof
AbstractContact
)
{
((
OnContactClickListener
)
getActivity
())
((
OnContactClickListener
)
getActivity
()).
onContactClick
((
AbstractContact
)
object
);
.
onContactClick
((
AbstractContact
)
object
);
}
else
if
(
object
instanceof
GroupConfiguration
)
{
}
else
if
(
object
instanceof
GroupConfiguration
)
{
GroupConfiguration
groupConfiguration
=
(
GroupConfiguration
)
object
;
GroupConfiguration
groupConfiguration
=
(
GroupConfiguration
)
object
;
adapter
.
setExpanded
(
groupConfiguration
.
getAccount
(),
adapter
.
setExpanded
(
groupConfiguration
.
getAccount
(),
groupConfiguration
.
getUser
(),
groupConfiguration
.
getUser
(),
!
groupConfiguration
.
isExpanded
());
!
groupConfiguration
.
isExpanded
());
}
else
}
else
{
throw
new
IllegalStateException
();
throw
new
IllegalStateException
();
}
}
}
@Override
@Override
...
@@ -168,14 +159,14 @@ public class ContactListFragment extends Fragment implements
...
@@ -168,14 +159,14 @@ public class ContactListFragment extends Fragment implements
@Override
@Override
public
void
onChatChanged
(
String
account
,
String
user
,
boolean
incoming
)
{
public
void
onChatChanged
(
String
account
,
String
user
,
boolean
incoming
)
{
if
(
incoming
)
if
(
incoming
)
{
adapter
.
refreshRequest
();
adapter
.
refreshRequest
();
}
}
}
@Override
@Override
public
void
onContactListChanged
(
CommonState
commonState
,
public
void
onContactListChanged
(
CommonState
commonState
,
boolean
hasContacts
,
boolean
hasContacts
,
boolean
hasVisibleContacts
,
boolean
hasVisibleContacts
,
boolean
isFilterEnabled
)
{
boolean
isFilterEnabled
)
{
if
(
hasVisibleContacts
)
{
if
(
hasVisibleContacts
)
{
infoView
.
setVisibility
(
View
.
GONE
);
infoView
.
setVisibility
(
View
.
GONE
);
disconnectedView
.
clearAnimation
();
disconnectedView
.
clearAnimation
();
...
@@ -187,13 +178,13 @@ public class ContactListFragment extends Fragment implements
...
@@ -187,13 +178,13 @@ public class ContactListFragment extends Fragment implements
final
ContactListState
state
;
final
ContactListState
state
;
final
OnClickListener
listener
;
final
OnClickListener
listener
;
if
(
isFilterEnabled
)
{
if
(
isFilterEnabled
)
{
if
(
commonState
==
CommonState
.
online
)
if
(
commonState
==
CommonState
.
online
)
{
state
=
ContactListState
.
online
;
state
=
ContactListState
.
online
;
else
if
(
commonState
==
CommonState
.
roster
}
else
if
(
commonState
==
CommonState
.
roster
||
commonState
==
CommonState
.
connecting
)
{
||
commonState
==
CommonState
.
connecting
)
state
=
ContactListState
.
connecting
;
state
=
ContactListState
.
connecting
;
else
}
else
{
state
=
ContactListState
.
offline
;
state
=
ContactListState
.
offline
;
}
text
=
R
.
string
.
application_state_no_online
;
text
=
R
.
string
.
application_state_no_online
;
button
=
0
;
button
=
0
;
listener
=
null
;
listener
=
null
;
...
@@ -202,25 +193,21 @@ public class ContactListFragment extends Fragment implements
...
@@ -202,25 +193,21 @@ public class ContactListFragment extends Fragment implements
text
=
R
.
string
.
application_state_no_online
;
text
=
R
.
string
.
application_state_no_online
;
button
=
R
.
string
.
application_action_no_online
;
button
=
R
.
string
.
application_action_no_online
;
listener
=
new
OnClickListener
()
{
listener
=
new
OnClickListener
()
{
@Override
@Override
public
void
onClick
(
View
view
)
{
public
void
onClick
(
View
view
)
{
SettingsManager
.
setContactsShowOffline
(
true
);
SettingsManager
.
setContactsShowOffline
(
true
);
adapter
.
onChange
();
adapter
.
onChange
();
}
}
};
};
}
else
if
(
commonState
==
CommonState
.
online
)
{
}
else
if
(
commonState
==
CommonState
.
online
)
{
state
=
ContactListState
.
online
;
state
=
ContactListState
.
online
;
text
=
R
.
string
.
application_state_no_contacts
;
text
=
R
.
string
.
application_state_no_contacts
;
button
=
R
.
string
.
application_action_no_contacts
;
button
=
R
.
string
.
application_action_no_contacts
;
listener
=
new
OnClickListener
()
{
listener
=
new
OnClickListener
()
{
@Override
@Override
public
void
onClick
(
View
view
)
{
public
void
onClick
(
View
view
)
{
startActivity
(
ContactAdd
.
createIntent
(
getActivity
()));
startActivity
(
ContactAdd
.
createIntent
(
getActivity
()));
}
}
};
};
}
else
if
(
commonState
==
CommonState
.
roster
)
{
}
else
if
(
commonState
==
CommonState
.
roster
)
{
state
=
ContactListState
.
connecting
;
state
=
ContactListState
.
connecting
;
...
@@ -237,49 +224,41 @@ public class ContactListFragment extends Fragment implements
...
@@ -237,49 +224,41 @@ public class ContactListFragment extends Fragment implements
text
=
R
.
string
.
application_state_waiting
;
text
=
R
.
string
.
application_state_waiting
;
button
=
R
.
string
.
application_action_waiting
;
button
=
R
.
string
.
application_action_waiting
;
listener
=
new
OnClickListener
()
{
listener
=
new
OnClickListener
()
{
@Override
@Override
public
void
onClick
(
View
view
)
{
public
void
onClick
(
View
view
)
{
ConnectionManager
.
getInstance
().
updateConnections
(
true
);
ConnectionManager
.
getInstance
().
updateConnections
(
true
);
}
}
};
};
}
else
if
(
commonState
==
CommonState
.
offline
)
{
}
else
if
(
commonState
==
CommonState
.
offline
)
{
state
=
ContactListState
.
offline
;
state
=
ContactListState
.
offline
;
text
=
R
.
string
.
application_state_offline
;
text
=
R
.
string
.
application_state_offline
;
button
=
R
.
string
.
application_action_offline
;
button
=
R
.
string
.
application_action_offline
;
listener
=
new
OnClickListener
()
{
listener
=
new
OnClickListener
()
{
@Override
@Override
public
void
onClick
(
View
view
)
{
public
void
onClick
(
View
view
)
{
AccountManager
.
getInstance
().
setStatus
(
AccountManager
.
getInstance
().
setStatus
(
StatusMode
.
available
,
null
);
StatusMode
.
available
,
null
);
}
}
};
};
}
else
if
(
commonState
==
CommonState
.
disabled
)
{
}
else
if
(
commonState
==
CommonState
.
disabled
)
{
state
=
ContactListState
.
offline
;
state
=
ContactListState
.
offline
;
text
=
R
.
string
.
application_state_disabled
;
text
=
R
.
string
.
application_state_disabled
;
button
=
R
.
string
.
application_action_disabled
;
button
=
R
.
string
.
application_action_disabled
;
listener
=
new
OnClickListener
()
{
listener
=
new
OnClickListener
()
{
@Override
@Override
public
void
onClick
(
View
view
)
{
public
void
onClick
(
View
view
)
{
startActivity
(
AccountList
.
createIntent
(
getActivity
()));
startActivity
(
AccountList
.
createIntent
(
getActivity
()));
}
}
};
};
}
else
if
(
commonState
==
CommonState
.
empty
)
{
}
else
if
(
commonState
==
CommonState
.
empty
)
{
state
=
ContactListState
.
offline
;
state
=
ContactListState
.
offline
;
text
=
R
.
string
.
application_state_empty
;
text
=
R
.
string
.
application_state_empty
;
button
=
R
.
string
.
application_action_empty
;
button
=
R
.
string
.
application_action_empty
;
listener
=
new
OnClickListener
()
{
listener
=
new
OnClickListener
()
{
@Override
@Override
public
void
onClick
(
View
view
)
{
public
void
onClick
(
View
view
)
{
startActivity
(
AccountAdd
.
createIntent
(
getActivity
()));
startActivity
(
AccountAdd
.
createIntent
(
getActivity
()));
}
}
};
};
}
else
{
}
else
{
throw
new
IllegalStateException
();
throw
new
IllegalStateException
();
...
@@ -291,9 +270,10 @@ public class ContactListFragment extends Fragment implements
...
@@ -291,9 +270,10 @@ public class ContactListFragment extends Fragment implements
}
else
if
(
state
==
ContactListState
.
connecting
)
{
}
else
if
(
state
==
ContactListState
.
connecting
)
{
connectedView
.
setVisibility
(
View
.
VISIBLE
);
connectedView
.
setVisibility
(
View
.
VISIBLE
);
disconnectedView
.
setVisibility
(
View
.
VISIBLE
);
disconnectedView
.
setVisibility
(
View
.
VISIBLE
);
if
(
disconnectedView
.
getAnimation
()
==
null
)
if
(
disconnectedView
.
getAnimation
()
==
null
)
{
disconnectedView
.
startAnimation
(
animation
);
disconnectedView
.
startAnimation
(
animation
);
}
else
if
(
state
==
ContactListState
.
online
)
{
}
}
else
{
connectedView
.
setVisibility
(
View
.
VISIBLE
);
connectedView
.
setVisibility
(
View
.
VISIBLE
);
disconnectedView
.
setVisibility
(
View
.
INVISIBLE
);
disconnectedView
.
setVisibility
(
View
.
INVISIBLE
);
disconnectedView
.
clearAnimation
();
disconnectedView
.
clearAnimation
();
...
@@ -312,12 +292,9 @@ public class ContactListFragment extends Fragment implements
...
@@ -312,12 +292,9 @@ public class ContactListFragment extends Fragment implements
* Force stop contact list updates before pause or application close.
* Force stop contact list updates before pause or application close.
*/
*/
void
unregisterListeners
()
{
void
unregisterListeners
()
{
Application
.
getInstance
().
removeUIListener
(
Application
.
getInstance
().
removeUIListener
(
OnAccountChangedListener
.
class
,
this
);
OnAccountChangedListener
.
class
,
this
);
Application
.
getInstance
().
removeUIListener
(
OnContactChangedListener
.
class
,
this
);
Application
.
getInstance
().
removeUIListener
(
Application
.
getInstance
().
removeUIListener
(
OnChatChangedListener
.
class
,
this
);
OnContactChangedListener
.
class
,
this
);
Application
.
getInstance
().
removeUIListener
(
OnChatChangedListener
.
class
,
this
);
adapter
.
removeRefreshRequests
();
adapter
.
removeRefreshRequests
();
}
}
...
@@ -337,10 +314,8 @@ public class ContactListFragment extends Fragment implements
...
@@ -337,10 +314,8 @@ public class ContactListFragment extends Fragment implements
void
scrollTo
(
String
account
)
{
void
scrollTo
(
String
account
)
{
long
count
=
listView
.
getCount
();
long
count
=
listView
.
getCount
();
for
(
int
position
=
0
;
position
<
(
int
)
count
;
position
++)
{
for
(
int
position
=
0
;
position
<
(
int
)
count
;
position
++)
{
BaseEntity
baseEntity
=
(
BaseEntity
)
listView
BaseEntity
baseEntity
=
(
BaseEntity
)
listView
.
getItemAtPosition
(
position
);
.
getItemAtPosition
(
position
);
if
(
baseEntity
!=
null
&&
baseEntity
instanceof
AccountConfiguration
if
(
baseEntity
!=
null
&&
baseEntity
instanceof
AccountConfiguration
&&
baseEntity
.
getAccount
().
equals
(
account
))
{
&&
baseEntity
.
getAccount
().
equals
(
account
))
{
stopMovement
();
stopMovement
();
listView
.
setSelection
(
position
);
listView
.
setSelection
(
position
);
...
@@ -355,10 +330,11 @@ public class ContactListFragment extends Fragment implements
...
@@ -355,10 +330,11 @@ public class ContactListFragment extends Fragment implements
* @param account
* @param account
*/
*/
void
setSelectedAccount
(
String
account
)
{
void
setSelectedAccount
(
String
account
)
{
if
(
account
.
equals
(
AccountManager
.
getInstance
().
getSelectedAccount
()))
if
(
account
.
equals
(
AccountManager
.
getInstance
().
getSelectedAccount
()))
{
SettingsManager
.
setContactsSelectedAccount
(
""
);
SettingsManager
.
setContactsSelectedAccount
(
""
);
else
}
else
{
SettingsManager
.
setContactsSelectedAccount
(
account
);
SettingsManager
.
setContactsSelectedAccount
(
account
);
}
stopMovement
();
stopMovement
();
adapter
.
onChange
();
adapter
.
onChange
();
}
}
...
@@ -367,8 +343,9 @@ public class ContactListFragment extends Fragment implements
...
@@ -367,8 +343,9 @@ public class ContactListFragment extends Fragment implements
* Scroll to the top of contact list.
* Scroll to the top of contact list.
*/
*/
void
scrollUp
()
{
void
scrollUp
()
{
if
(
listView
.
getCount
()
>
0
)
if
(
listView
.
getCount
()
>
0
)
{
listView
.
setSelection
(
0
);
listView
.
setSelection
(
0
);
}
stopMovement
();
stopMovement
();
}
}
...
@@ -383,9 +360,7 @@ public class ContactListFragment extends Fragment implements
...
@@ -383,9 +360,7 @@ public class ContactListFragment extends Fragment implements
}
}
public
interface
OnContactClickListener
{
public
interface
OnContactClickListener
{
void
onContactClick
(
AbstractContact
contact
);
void
onContactClick
(
AbstractContact
contact
);
}
}
}
}
app/src/main/java/com/xabber/android/ui/adapter/BaseContactAdapter.java
View file @
67ff3d03
...
@@ -14,9 +14,6 @@
...
@@ -14,9 +14,6 @@
*/
*/
package
com
.
xabber
.
android
.
ui
.
adapter
;
package
com
.
xabber
.
android
.
ui
.
adapter
;
import
java.util.ArrayList
;
import
java.util.Locale
;
import
android.app.Activity
;
import
android.app.Activity
;
import
android.view.View
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.view.ViewGroup
;
...
@@ -27,6 +24,9 @@ import android.widget.Filterable;
...
@@ -27,6 +24,9 @@ import android.widget.Filterable;
import
com.xabber.android.data.entity.BaseEntity
;
import
com.xabber.android.data.entity.BaseEntity
;
import
com.xabber.android.data.roster.AbstractContact
;
import
com.xabber.android.data.roster.AbstractContact
;
import
java.util.ArrayList
;
import
java.util.Locale
;
/**
/**
* Base adapter for the list of contacts.
* Base adapter for the list of contacts.
*
*
...
@@ -62,20 +62,13 @@ public abstract class BaseContactAdapter<Inflater extends BaseContactInflater>
...
@@ -62,20 +62,13 @@ public abstract class BaseContactAdapter<Inflater extends BaseContactInflater>
public
BaseContactAdapter
(
Activity
activity
,
Inflater
inflater
)
{
public
BaseContactAdapter
(
Activity
activity
,
Inflater
inflater
)
{
this
.
activity
=
activity
;
this
.
activity
=
activity
;
this
.
locale
=
Locale
.
getDefault
();
this
.
locale
=
Locale
.
getDefault
();
this
.
baseEntities
=
new
ArrayList
<
BaseEntity
>();
this
.
baseEntities
=
new
ArrayList
<>();
this
.
inflater
=
inflater
;
this
.
inflater
=
inflater
;
inflater
.
setAdapter
(
this
);
inflater
.
setAdapter
(
this
);
contactFilter
=
null
;
contactFilter
=
null
;
filterString
=
null
;
filterString
=
null
;
}
}
/**
* @return View inflater.
*/
public
Inflater
getInflater
()
{
return
inflater
;
}
@Override
@Override
public
void
onChange
()
{
public
void
onChange
()
{
notifyDataSetChanged
();
notifyDataSetChanged
();
...
@@ -111,8 +104,9 @@ public abstract class BaseContactAdapter<Inflater extends BaseContactInflater>
...
@@ -111,8 +104,9 @@ public abstract class BaseContactAdapter<Inflater extends BaseContactInflater>
@Override
@Override
public
Filter
getFilter
()
{
public
Filter
getFilter
()
{
if
(
contactFilter
==
null
)
if
(
contactFilter
==
null
)
{
contactFilter
=
new
ContactFilter
();
contactFilter
=
new
ContactFilter
();
}
return
contactFilter
;
return
contactFilter
;
}
}
...
@@ -126,10 +120,11 @@ public abstract class BaseContactAdapter<Inflater extends BaseContactInflater>
...
@@ -126,10 +120,11 @@ public abstract class BaseContactAdapter<Inflater extends BaseContactInflater>
@Override
@Override
protected
void
publishResults
(
CharSequence
constraint
,
protected
void
publishResults
(
CharSequence
constraint
,
FilterResults
results
)
{
FilterResults
results
)
{
if
(
constraint
==
null
||
constraint
.
length
()
==
0
)
if
(
constraint
==
null
||
constraint
.
length
()
==
0
)
{
filterString
=
null
;
filterString
=
null
;
else
}
else
{
filterString
=
constraint
.
toString
().
toLowerCase
(
locale
);
filterString
=
constraint
.
toString
().
toLowerCase
(
locale
);
}
onChange
();
onChange
();
}
}
...
...
app/src/main/java/com/xabber/android/ui/adapter/BaseContactInflater.java
View file @
67ff3d03
...
@@ -59,14 +59,11 @@ public abstract class BaseContactInflater {
...
@@ -59,14 +59,11 @@ public abstract class BaseContactInflater {
public
BaseContactInflater
(
Activity
activity
)
{
public
BaseContactInflater
(
Activity
activity
)
{
this
.
activity
=
activity
;
this
.
activity
=
activity
;
layoutInflater
=
(
LayoutInflater
)
activity
layoutInflater
=
(
LayoutInflater
)
activity
.
getSystemService
(
Context
.
LAYOUT_INFLATER_SERVICE
);
.
getSystemService
(
Context
.
LAYOUT_INFLATER_SERVICE
);
avatarInflaterHelper
=
AbstractAvatarInflaterHelper
.
createAbstractContactInflaterHelper
();
avatarInflaterHelper
=
AbstractAvatarInflaterHelper
.
createAbstractContactInflaterHelper
();
Bitmap
bitmap
=
BitmapFactory
.
decodeResource
(
activity
.
getResources
(),
R
.
drawable
.
shadow
);
shadowDrawable
=
new
BitmapDrawable
(
activity
.
getResources
(),
bitmap
);
Bitmap
bitmap
=
BitmapFactory
.
decodeResource
(
activity
.
getResources
(),
R
.
drawable
.
shadow
);
shadowDrawable
=
new
BitmapDrawable
(
bitmap
);
shadowDrawable
.
setTileModeXY
(
TileMode
.
REPEAT
,
TileMode
.
REPEAT
);
shadowDrawable
.
setTileModeXY
(
TileMode
.
REPEAT
,
TileMode
.
REPEAT
);
}
}
...
@@ -115,19 +112,18 @@ public abstract class BaseContactInflater {
...
@@ -115,19 +112,18 @@ public abstract class BaseContactInflater {
*/
*/
public
void
getView
(
View
view
,
AbstractContact
abstractContact
)
{
public
void
getView
(
View
view
,
AbstractContact
abstractContact
)
{
final
ViewHolder
viewHolder
=
(
ViewHolder
)
view
.
getTag
();
final
ViewHolder
viewHolder
=
(
ViewHolder
)
view
.
getTag
();
if
(
abstractContact
.
isConnected
())
if
(
abstractContact
.
isConnected
())
{
viewHolder
.
shadow
.
setVisibility
(
View
.
GONE
);
viewHolder
.
shadow
.
setVisibility
(
View
.
GONE
);
else
}
else
{
viewHolder
.
shadow
.
setVisibility
(
View
.
VISIBLE
);
viewHolder
.
shadow
.
setVisibility
(
View
.
VISIBLE
);
}
viewHolder
.
color
.
setImageLevel
(
abstractContact
.
getColorLevel
());
viewHolder
.
color
.
setImageLevel
(
abstractContact
.
getColorLevel
());
if
(
SettingsManager
.
contactsShowAvatars
())
{
if
(
SettingsManager
.
contactsShowAvatars
())
{
viewHolder
.
avatar
.
setVisibility
(
View
.
VISIBLE
);
viewHolder
.
avatar
.
setVisibility
(
View
.
VISIBLE
);
viewHolder
.
avatar
.
setImageDrawable
(
abstractContact
viewHolder
.
avatar
.
setImageDrawable
(
abstractContact
.
getAvatarForContactList
());
.
getAvatarForContactList
());
avatarInflaterHelper
.
updateAvatar
(
viewHolder
.
avatar
,
abstractContact
);
avatarInflaterHelper
.
updateAvatar
(
viewHolder
.
avatar
,
abstractContact
);
((
RelativeLayout
.
LayoutParams
)
viewHolder
.
panel
.
getLayoutParams
())
((
RelativeLayout
.
LayoutParams
)
viewHolder
.
panel
.
getLayoutParams
())
.
addRule
(
RelativeLayout
.
RIGHT_OF
,
R
.
id
.
avatar
);
.
addRule
(
RelativeLayout
.
RIGHT_OF
,
R
.
id
.
avatar
);
}
else
{
}
else
{
...
@@ -140,14 +136,12 @@ public abstract class BaseContactInflater {
...
@@ -140,14 +136,12 @@ public abstract class BaseContactInflater {
final
String
statusText
=
getStatusText
(
abstractContact
);
final
String
statusText
=
getStatusText
(
abstractContact
);
if
(
""
.
equals
(
statusText
))
{
if
(
""
.
equals
(
statusText
))
{
viewHolder
.
name
.
getLayoutParams
().
height
=
activity
.
getResources
()
viewHolder
.
name
.
getLayoutParams
().
height
=
activity
.
getResources
()
.
getDimensionPixelSize
(
.
getDimensionPixelSize
(
R
.
dimen
.
contact_name_height_hide_status
);
R
.
dimen
.
contact_name_height_hide_status
);
viewHolder
.
name
.
setGravity
(
Gravity
.
CENTER_VERTICAL
);
viewHolder
.
name
.
setGravity
(
Gravity
.
CENTER_VERTICAL
);
viewHolder
.
status
.
setVisibility
(
View
.
GONE
);
viewHolder
.
status
.
setVisibility
(
View
.
GONE
);
}
else
{
}
else
{
viewHolder
.
name
.
getLayoutParams
().
height
=
activity
.
getResources
()
viewHolder
.
name
.
getLayoutParams
().
height
=
activity
.
getResources
()
.
getDimensionPixelSize
(
.
getDimensionPixelSize
(
R
.
dimen
.
contact_name_height_show_status
);
R
.
dimen
.
contact_name_height_show_status
);
viewHolder
.
name
.
setGravity
(
Gravity
.
BOTTOM
);
viewHolder
.
name
.
setGravity
(
Gravity
.
BOTTOM
);
viewHolder
.
status
.
setText
(
statusText
);
viewHolder
.
status
.
setText
(
statusText
);
viewHolder
.
status
.
setVisibility
(
View
.
VISIBLE
);
viewHolder
.
status
.
setVisibility
(
View
.
VISIBLE
);
...
...
app/src/main/java/com/xabber/android/ui/adapter/ContactListAdapter.java
View file @
67ff3d03
...
@@ -14,14 +14,6 @@
...
@@ -14,14 +14,6 @@
*/
*/
package
com
.
xabber
.
android
.
ui
.
adapter
;
package
com
.
xabber
.
android
.
ui
.
adapter
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.Date
;
import
java.util.Map.Entry
;
import
java.util.TreeMap
;
import
android.app.Activity
;
import
android.app.Activity
;
import
android.os.Handler
;
import
android.os.Handler
;
import
android.widget.ListView
;
import
android.widget.ListView
;
...
@@ -39,14 +31,21 @@ import com.xabber.android.data.roster.GroupManager;
...
@@ -39,14 +31,21 @@ import com.xabber.android.data.roster.GroupManager;
import
com.xabber.android.data.roster.RosterContact
;
import
com.xabber.android.data.roster.RosterContact
;
import
com.xabber.android.data.roster.RosterManager
;
import
com.xabber.android.data.roster.RosterManager
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.Date
;
import
java.util.Map.Entry
;
import
java.util.TreeMap
;
/**
/**
* Adapter for contact list in the main activity.
* Adapter for contact list in the main activity.
*
*
* @author alexander.ivanov
* @author alexander.ivanov
*/
*/
public
class
ContactListAdapter
extends
public
class
ContactListAdapter
extends
GroupedContactAdapter
<
ChatContactInflater
,
GroupManager
>
GroupedContactAdapter
<
ChatContactInflater
,
GroupManager
>
implements
implements
Runnable
{
Runnable
{
/**
/**
* Number of milliseconds between lazy refreshes.
* Number of milliseconds between lazy refreshes.
...
@@ -71,7 +70,7 @@ public class ContactListAdapter extends
...
@@ -71,7 +70,7 @@ public class ContactListAdapter extends
/**
/**
* Whether refresh is in progress.
* Whether refresh is in progress.
*/
*/
private
boolean
refreshInProgess
;
private
boolean
refreshInProg
r
ess
;
/**
/**
* Minimal time when next refresh can be executed.
* Minimal time when next refresh can be executed.
...
@@ -80,15 +79,14 @@ public class ContactListAdapter extends
...
@@ -80,15 +79,14 @@ public class ContactListAdapter extends
private
final
OnContactListChangedListener
listener
;
private
final
OnContactListChangedListener
listener
;
public
ContactListAdapter
(
Activity
activity
,
ListView
listView
,
public
ContactListAdapter
(
OnContactListChangedListener
listener
)
{
Activity
activity
,
ListView
listView
,
OnContactListChangedListener
listener
)
{
super
(
activity
,
listView
,
new
ChatContactInflater
(
activity
),
super
(
activity
,
listView
,
new
ChatContactInflater
(
activity
),
GroupManager
.
getInstance
());
GroupManager
.
getInstance
());
this
.
listener
=
listener
;
this
.
listener
=
listener
;
handler
=
new
Handler
();
handler
=
new
Handler
();
refreshLock
=
new
Object
();
refreshLock
=
new
Object
();
refreshRequested
=
false
;
refreshRequested
=
false
;
refreshInProgess
=
false
;
refreshInProg
r
ess
=
false
;
nextRefresh
=
new
Date
();
nextRefresh
=
new
Date
();
}
}
...
@@ -97,11 +95,12 @@ public class ContactListAdapter extends
...
@@ -97,11 +95,12 @@ public class ContactListAdapter extends
*/
*/
public
void
refreshRequest
()
{
public
void
refreshRequest
()
{
synchronized
(
refreshLock
)
{
synchronized
(
refreshLock
)
{
if
(
refreshRequested
)
if
(
refreshRequested
)
{
return
;
return
;
if
(
refreshInProgess
)
}
if
(
refreshInProgress
)
{
refreshRequested
=
true
;
refreshRequested
=
true
;
else
{
}
else
{
long
delay
=
nextRefresh
.
getTime
()
-
new
Date
().
getTime
();
long
delay
=
nextRefresh
.
getTime
()
-
new
Date
().
getTime
();
handler
.
postDelayed
(
this
,
delay
>
0
?
delay
:
0
);
handler
.
postDelayed
(
this
,
delay
>
0
?
delay
:
0
);
}
}
...
@@ -114,7 +113,7 @@ public class ContactListAdapter extends
...
@@ -114,7 +113,7 @@ public class ContactListAdapter extends
public
void
removeRefreshRequests
()
{
public
void
removeRefreshRequests
()
{
synchronized
(
refreshLock
)
{
synchronized
(
refreshLock
)
{
refreshRequested
=
false
;
refreshRequested
=
false
;
refreshInProgess
=
false
;
refreshInProg
r
ess
=
false
;
handler
.
removeCallbacks
(
this
);
handler
.
removeCallbacks
(
this
);
}
}
}
}
...
@@ -123,32 +122,25 @@ public class ContactListAdapter extends
...
@@ -123,32 +122,25 @@ public class ContactListAdapter extends
public
void
onChange
()
{
public
void
onChange
()
{
synchronized
(
refreshLock
)
{
synchronized
(
refreshLock
)
{
refreshRequested
=
false
;
refreshRequested
=
false
;
refreshInProgess
=
true
;
refreshInProg
r
ess
=
true
;
handler
.
removeCallbacks
(
this
);
handler
.
removeCallbacks
(
this
);
}
}
final
Collection
<
RosterContact
>
rosterContacts
=
RosterManager
final
Collection
<
RosterContact
>
rosterContacts
=
RosterManager
.
getInstance
().
getContacts
();
.
getInstance
().
getContacts
();
final
boolean
showOffline
=
SettingsManager
.
contactsShowOffline
();
final
boolean
showOffline
=
SettingsManager
.
contactsShowOffline
();
final
boolean
showGroups
=
SettingsManager
.
contactsShowGroups
();
final
boolean
showGroups
=
SettingsManager
.
contactsShowGroups
();
final
boolean
showEmptyGroups
=
SettingsManager
final
boolean
showEmptyGroups
=
SettingsManager
.
contactsShowEmptyGroups
();
.
contactsShowEmptyGroups
();
final
boolean
showActiveChats
=
SettingsManager
.
contactsShowActiveChats
();
final
boolean
showActiveChats
=
SettingsManager
final
boolean
stayActiveChats
=
SettingsManager
.
contactsStayActiveChats
();
.
contactsShowActiveChats
();
final
boolean
stayActiveChats
=
SettingsManager
.
contactsStayActiveChats
();
final
boolean
showAccounts
=
SettingsManager
.
contactsShowAccounts
();
final
boolean
showAccounts
=
SettingsManager
.
contactsShowAccounts
();
final
Comparator
<
AbstractContact
>
comparator
=
SettingsManager
final
Comparator
<
AbstractContact
>
comparator
=
SettingsManager
.
contactsOrder
();
.
contactsOrder
();
final
CommonState
commonState
=
AccountManager
.
getInstance
().
getCommonState
();
final
CommonState
commonState
=
AccountManager
.
getInstance
()
final
String
selectedAccount
=
AccountManager
.
getInstance
().
getSelectedAccount
();
.
getCommonState
();
final
String
selectedAccount
=
AccountManager
.
getInstance
()
.
getSelectedAccount
();
/**
/**
* Accounts.
* Accounts.
*/
*/
final
TreeMap
<
String
,
AccountConfiguration
>
accounts
=
new
TreeMap
<
String
,
AccountConfiguration
>();
final
TreeMap
<
String
,
AccountConfiguration
>
accounts
=
new
TreeMap
<>();
/**
/**
* Groups.
* Groups.
...
@@ -168,7 +160,7 @@ public class ContactListAdapter extends
...
@@ -168,7 +160,7 @@ public class ContactListAdapter extends
/**
/**
* List of rooms and active chats grouped by users inside accounts.
* List of rooms and active chats grouped by users inside accounts.
*/
*/
final
TreeMap
<
String
,
TreeMap
<
String
,
AbstractChat
>>
abstractChats
=
new
TreeMap
<
String
,
TreeMap
<
String
,
AbstractChat
>
>();
final
TreeMap
<
String
,
TreeMap
<
String
,
AbstractChat
>>
abstractChats
=
new
TreeMap
<>();
/**
/**
* Whether there is at least one contact.
* Whether there is at least one contact.
...
@@ -180,18 +172,17 @@ public class ContactListAdapter extends
...
@@ -180,18 +172,17 @@ public class ContactListAdapter extends
*/
*/
boolean
hasVisibleContacts
=
false
;
boolean
hasVisibleContacts
=
false
;
for
(
String
account
:
AccountManager
.
getInstance
().
getAccounts
())
for
(
String
account
:
AccountManager
.
getInstance
().
getAccounts
())
{
accounts
.
put
(
account
,
null
);
accounts
.
put
(
account
,
null
);
}
for
(
AbstractChat
abstractChat
:
MessageManager
.
getInstance
()
for
(
AbstractChat
abstractChat
:
MessageManager
.
getInstance
().
getChats
())
{
.
getChats
())
{
if
((
abstractChat
instanceof
RoomChat
||
abstractChat
.
isActive
())
if
((
abstractChat
instanceof
RoomChat
||
abstractChat
.
isActive
())
&&
accounts
.
containsKey
(
abstractChat
.
getAccount
()))
{
&&
accounts
.
containsKey
(
abstractChat
.
getAccount
()))
{
final
String
account
=
abstractChat
.
getAccount
();
final
String
account
=
abstractChat
.
getAccount
();
TreeMap
<
String
,
AbstractChat
>
users
=
abstractChats
TreeMap
<
String
,
AbstractChat
>
users
=
abstractChats
.
get
(
account
);
.
get
(
account
);
if
(
users
==
null
)
{
if
(
users
==
null
)
{
users
=
new
TreeMap
<
String
,
AbstractChat
>();
users
=
new
TreeMap
<>();
abstractChats
.
put
(
account
,
users
);
abstractChats
.
put
(
account
,
users
);
}
}
users
.
put
(
abstractChat
.
getUser
(),
abstractChat
);
users
.
put
(
abstractChat
.
getUser
(),
abstractChat
);
...
@@ -203,77 +194,82 @@ public class ContactListAdapter extends
...
@@ -203,77 +194,82 @@ public class ContactListAdapter extends
if
(
showAccounts
)
{
if
(
showAccounts
)
{
groups
=
null
;
groups
=
null
;
contacts
=
null
;
contacts
=
null
;
for
(
Entry
<
String
,
AccountConfiguration
>
entry
:
accounts
for
(
Entry
<
String
,
AccountConfiguration
>
entry
:
accounts
.
entrySet
())
{
.
entrySet
())
{
entry
.
setValue
(
new
AccountConfiguration
(
entry
.
getKey
(),
entry
.
setValue
(
new
AccountConfiguration
(
entry
.
getKey
(),
GroupManager
.
IS_ACCOUNT
,
groupStateProvider
));
GroupManager
.
IS_ACCOUNT
,
groupStateProvider
));
}
}
}
else
{
}
else
{
if
(
showGroups
)
{
if
(
showGroups
)
{
groups
=
new
TreeMap
<
String
,
GroupConfiguration
>();
groups
=
new
TreeMap
<>();
contacts
=
null
;
contacts
=
null
;
}
else
{
}
else
{
groups
=
null
;
groups
=
null
;
contacts
=
new
ArrayList
<
AbstractContact
>();
contacts
=
new
ArrayList
<>();
}
}
}
}
if
(
showActiveChats
)
if
(
showActiveChats
)
{
activeChats
=
new
GroupConfiguration
(
GroupManager
.
NO_ACCOUNT
,
activeChats
=
new
GroupConfiguration
(
GroupManager
.
NO_ACCOUNT
,
GroupManager
.
ACTIVE_CHATS
,
groupStateProvider
);
GroupManager
.
ACTIVE_CHATS
,
groupStateProvider
);
else
}
else
{
activeChats
=
null
;
activeChats
=
null
;
}
// Build structure.
// Build structure.
for
(
RosterContact
rosterContact
:
rosterContacts
)
{
for
(
RosterContact
rosterContact
:
rosterContacts
)
{
if
(!
rosterContact
.
isEnabled
())
if
(!
rosterContact
.
isEnabled
())
{
continue
;
continue
;
}
hasContacts
=
true
;
hasContacts
=
true
;
final
boolean
online
=
rosterContact
.
getStatusMode
().
isOnline
();
final
boolean
online
=
rosterContact
.
getStatusMode
().
isOnline
();
final
String
account
=
rosterContact
.
getAccount
();
final
String
account
=
rosterContact
.
getAccount
();
final
TreeMap
<
String
,
AbstractChat
>
users
=
abstractChats
final
TreeMap
<
String
,
AbstractChat
>
users
=
abstractChats
.
get
(
account
);
.
get
(
account
);
final
AbstractChat
abstractChat
;
final
AbstractChat
abstractChat
;
if
(
users
==
null
)
if
(
users
==
null
)
{
abstractChat
=
null
;
abstractChat
=
null
;
else
}
else
{
abstractChat
=
users
.
remove
(
rosterContact
.
getUser
());
abstractChat
=
users
.
remove
(
rosterContact
.
getUser
());
if
(
showActiveChats
&&
abstractChat
!=
null
}
&&
abstractChat
.
isActive
())
{
if
(
showActiveChats
&&
abstractChat
!=
null
&&
abstractChat
.
isActive
())
{
activeChats
.
setNotEmpty
();
activeChats
.
setNotEmpty
();
hasVisibleContacts
=
true
;
hasVisibleContacts
=
true
;
if
(
activeChats
.
isExpanded
())
if
(
activeChats
.
isExpanded
())
{
activeChats
.
addAbstractContact
(
rosterContact
);
activeChats
.
addAbstractContact
(
rosterContact
);
}
activeChats
.
increment
(
online
);
activeChats
.
increment
(
online
);
if
(!
stayActiveChats
||
(!
showAccounts
&&
!
showGroups
))
if
(!
stayActiveChats
||
(!
showAccounts
&&
!
showGroups
))
{
continue
;
continue
;
}
}
}
if
(
selectedAccount
!=
null
&&
!
selectedAccount
.
equals
(
account
))
if
(
selectedAccount
!=
null
&&
!
selectedAccount
.
equals
(
account
))
{
continue
;
continue
;
}
if
(
addContact
(
rosterContact
,
online
,
accounts
,
groups
,
if
(
addContact
(
rosterContact
,
online
,
accounts
,
groups
,
contacts
,
showAccounts
,
showGroups
,
showOffline
))
contacts
,
showAccounts
,
showGroups
,
showOffline
))
{
hasVisibleContacts
=
true
;
hasVisibleContacts
=
true
;
}
}
}
for
(
TreeMap
<
String
,
AbstractChat
>
users
:
abstractChats
.
values
())
for
(
TreeMap
<
String
,
AbstractChat
>
users
:
abstractChats
.
values
())
{
for
(
AbstractChat
abstractChat
:
users
.
values
())
{
for
(
AbstractChat
abstractChat
:
users
.
values
())
{
final
AbstractContact
abstractContact
;
final
AbstractContact
abstractContact
;
if
(
abstractChat
instanceof
RoomChat
)
if
(
abstractChat
instanceof
RoomChat
)
{
abstractContact
=
new
RoomContact
(
abstractContact
=
new
RoomContact
((
RoomChat
)
abstractChat
);
(
RoomChat
)
abstractChat
);
}
else
{
else
abstractContact
=
new
ChatContact
(
abstractChat
);
abstractContact
=
new
ChatContact
(
abstractChat
);
}
if
(
showActiveChats
&&
abstractChat
.
isActive
())
{
if
(
showActiveChats
&&
abstractChat
.
isActive
())
{
activeChats
.
setNotEmpty
();
activeChats
.
setNotEmpty
();
hasVisibleContacts
=
true
;
hasVisibleContacts
=
true
;
if
(
activeChats
.
isExpanded
())
if
(
activeChats
.
isExpanded
())
{
activeChats
.
addAbstractContact
(
abstractContact
);
activeChats
.
addAbstractContact
(
abstractContact
);
}
activeChats
.
increment
(
false
);
activeChats
.
increment
(
false
);
if
(!
stayActiveChats
||
(!
showAccounts
&&
!
showGroups
))
if
(!
stayActiveChats
||
(!
showAccounts
&&
!
showGroups
))
{
continue
;
continue
;
}
}
}
if
(
selectedAccount
!=
null
if
(
selectedAccount
!=
null
&&
!
selectedAccount
.
equals
(
abstractChat
.
getAccount
()))
{
&&
!
selectedAccount
.
equals
(
abstractChat
.
getAccount
()))
continue
;
continue
;
}
final
String
group
;
final
String
group
;
final
boolean
online
;
final
boolean
online
;
if
(
abstractChat
instanceof
RoomChat
)
{
if
(
abstractChat
instanceof
RoomChat
)
{
...
@@ -284,19 +280,20 @@ public class ContactListAdapter extends
...
@@ -284,19 +280,20 @@ public class ContactListAdapter extends
online
=
false
;
online
=
false
;
}
}
hasVisibleContacts
=
true
;
hasVisibleContacts
=
true
;
addContact
(
abstractContact
,
group
,
online
,
accounts
,
addContact
(
abstractContact
,
group
,
online
,
accounts
,
groups
,
contacts
,
groups
,
contacts
,
showAccounts
,
showGroups
);
showAccounts
,
showGroups
);
}
}
}
// Remove empty groups, sort and apply structure.
// Remove empty groups, sort and apply structure.
baseEntities
.
clear
();
baseEntities
.
clear
();
if
(
hasVisibleContacts
)
{
if
(
hasVisibleContacts
)
{
if
(
showActiveChats
)
{
if
(
showActiveChats
)
{
if
(!
activeChats
.
isEmpty
())
{
if
(!
activeChats
.
isEmpty
())
{
if
(
showAccounts
||
showGroups
)
if
(
showAccounts
||
showGroups
)
{
baseEntities
.
add
(
activeChats
);
baseEntities
.
add
(
activeChats
);
activeChats
}
.
sortAbstractContacts
(
ComparatorByChat
.
COMPARATOR_BY_CHAT
);
activeChats
.
sortAbstractContacts
(
ComparatorByChat
.
COMPARATOR_BY_CHAT
);
baseEntities
.
addAll
(
activeChats
.
getAbstractContacts
());
baseEntities
.
addAll
(
activeChats
.
getAbstractContacts
());
}
}
}
}
...
@@ -304,35 +301,30 @@ public class ContactListAdapter extends
...
@@ -304,35 +301,30 @@ public class ContactListAdapter extends
for
(
AccountConfiguration
rosterAccount
:
accounts
.
values
())
{
for
(
AccountConfiguration
rosterAccount
:
accounts
.
values
())
{
baseEntities
.
add
(
rosterAccount
);
baseEntities
.
add
(
rosterAccount
);
if
(
showGroups
)
{
if
(
showGroups
)
{
if
(
rosterAccount
.
isExpanded
())
if
(
rosterAccount
.
isExpanded
())
{
for
(
GroupConfiguration
rosterConfiguration
:
rosterAccount
for
(
GroupConfiguration
rosterConfiguration
:
rosterAccount
.
getSortedGroupConfigurations
())
.
getSortedGroupConfigurations
())
{
if
(
showEmptyGroups
if
(
showEmptyGroups
||
!
rosterConfiguration
.
isEmpty
())
{
||
!
rosterConfiguration
.
isEmpty
())
{
baseEntities
.
add
(
rosterConfiguration
);
baseEntities
.
add
(
rosterConfiguration
);
rosterConfiguration
rosterConfiguration
.
sortAbstractContacts
(
comparator
);
.
sortAbstractContacts
(
comparator
);
baseEntities
.
addAll
(
rosterConfiguration
.
getAbstractContacts
());
baseEntities
.
addAll
(
rosterConfiguration
.
getAbstractContacts
());
}
}
}
}
}
else
{
}
else
{
rosterAccount
.
sortAbstractContacts
(
comparator
);
rosterAccount
.
sortAbstractContacts
(
comparator
);
baseEntities
.
addAll
(
rosterAccount
baseEntities
.
addAll
(
rosterAccount
.
getAbstractContacts
());
.
getAbstractContacts
());
}
}
}
}
}
else
{
}
else
{
if
(
showGroups
)
{
if
(
showGroups
)
{
for
(
GroupConfiguration
rosterConfiguration
:
groups
for
(
GroupConfiguration
rosterConfiguration
:
groups
.
values
())
{
.
values
())
if
(
showEmptyGroups
||
!
rosterConfiguration
.
isEmpty
())
{
if
(
showEmptyGroups
||
!
rosterConfiguration
.
isEmpty
())
{
baseEntities
.
add
(
rosterConfiguration
);
baseEntities
.
add
(
rosterConfiguration
);
rosterConfiguration
rosterConfiguration
.
sortAbstractContacts
(
comparator
);
.
sortAbstractContacts
(
comparator
);
baseEntities
.
addAll
(
rosterConfiguration
.
getAbstractContacts
());
baseEntities
.
addAll
(
rosterConfiguration
.
getAbstractContacts
());
}
}
}
}
else
{
}
else
{
Collections
.
sort
(
contacts
,
comparator
);
Collections
.
sort
(
contacts
,
comparator
);
baseEntities
.
addAll
(
contacts
);
baseEntities
.
addAll
(
contacts
);
...
@@ -340,33 +332,35 @@ public class ContactListAdapter extends
...
@@ -340,33 +332,35 @@ public class ContactListAdapter extends
}
}
}
}
}
else
{
// Search
}
else
{
// Search
final
ArrayList
<
AbstractContact
>
baseEntities
=
new
ArrayList
<
AbstractContact
>();
final
ArrayList
<
AbstractContact
>
baseEntities
=
new
ArrayList
<>();
// Build structure.
// Build structure.
for
(
RosterContact
rosterContact
:
rosterContacts
)
{
for
(
RosterContact
rosterContact
:
rosterContacts
)
{
if
(!
rosterContact
.
isEnabled
())
if
(!
rosterContact
.
isEnabled
())
{
continue
;
continue
;
}
final
String
account
=
rosterContact
.
getAccount
();
final
String
account
=
rosterContact
.
getAccount
();
final
TreeMap
<
String
,
AbstractChat
>
users
=
abstractChats
final
TreeMap
<
String
,
AbstractChat
>
users
=
abstractChats
.
get
(
account
);
.
get
(
account
);
if
(
users
!=
null
)
{
if
(
users
!=
null
)
users
.
remove
(
rosterContact
.
getUser
());
users
.
remove
(
rosterContact
.
getUser
());
if
(
rosterContact
.
getName
().
toLowerCase
(
locale
)
}
.
contains
(
filterString
))
if
(
rosterContact
.
getName
().
toLowerCase
(
locale
).
contains
(
filterString
))
{
baseEntities
.
add
(
rosterContact
);
baseEntities
.
add
(
rosterContact
);
}
}
}
for
(
TreeMap
<
String
,
AbstractChat
>
users
:
abstractChats
.
values
())
for
(
TreeMap
<
String
,
AbstractChat
>
users
:
abstractChats
.
values
())
{
for
(
AbstractChat
abstractChat
:
users
.
values
())
{
for
(
AbstractChat
abstractChat
:
users
.
values
())
{
final
AbstractContact
abstractContact
;
final
AbstractContact
abstractContact
;
if
(
abstractChat
instanceof
RoomChat
)
if
(
abstractChat
instanceof
RoomChat
)
{
abstractContact
=
new
RoomContact
(
abstractContact
=
new
RoomContact
((
RoomChat
)
abstractChat
);
(
RoomChat
)
abstractChat
);
}
else
{
else
abstractContact
=
new
ChatContact
(
abstractChat
);
abstractContact
=
new
ChatContact
(
abstractChat
);
if
(
abstractContact
.
getName
().
toLowerCase
(
locale
)
}
.
contains
(
filterString
))
if
(
abstractContact
.
getName
().
toLowerCase
(
locale
).
contains
(
filterString
))
{
baseEntities
.
add
(
abstractContact
);
baseEntities
.
add
(
abstractContact
);
}
}
}
}
Collections
.
sort
(
baseEntities
,
comparator
);
Collections
.
sort
(
baseEntities
,
comparator
);
this
.
baseEntities
.
clear
();
this
.
baseEntities
.
clear
();
this
.
baseEntities
.
addAll
(
baseEntities
);
this
.
baseEntities
.
addAll
(
baseEntities
);
...
@@ -379,10 +373,11 @@ public class ContactListAdapter extends
...
@@ -379,10 +373,11 @@ public class ContactListAdapter extends
synchronized
(
refreshLock
)
{
synchronized
(
refreshLock
)
{
nextRefresh
=
new
Date
(
new
Date
().
getTime
()
+
REFRESH_INTERVAL
);
nextRefresh
=
new
Date
(
new
Date
().
getTime
()
+
REFRESH_INTERVAL
);
refreshInProgess
=
false
;
refreshInProg
r
ess
=
false
;
handler
.
removeCallbacks
(
this
);
// Just to be sure.
handler
.
removeCallbacks
(
this
);
// Just to be sure.
if
(
refreshRequested
)
if
(
refreshRequested
)
{
handler
.
postDelayed
(
this
,
REFRESH_INTERVAL
);
handler
.
postDelayed
(
this
,
REFRESH_INTERVAL
);
}
}
}
}
}
...
...
app/src/main/java/com/xabber/android/ui/adapter/GroupedContactAdapter.java
View file @
67ff3d03
...
@@ -14,11 +14,6 @@
...
@@ -14,11 +14,6 @@
*/
*/
package
com
.
xabber
.
android
.
ui
.
adapter
;
package
com
.
xabber
.
android
.
ui
.
adapter
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.TreeMap
;
import
android.app.Activity
;
import
android.app.Activity
;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.res.ColorStateList
;
import
android.content.res.ColorStateList
;
...
@@ -38,6 +33,11 @@ import com.xabber.android.data.roster.GroupStateProvider;
...
@@ -38,6 +33,11 @@ import com.xabber.android.data.roster.GroupStateProvider;
import
com.xabber.android.data.roster.ShowOfflineMode
;
import
com.xabber.android.data.roster.ShowOfflineMode
;
import
com.xabber.androiddev.R
;
import
com.xabber.androiddev.R
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.TreeMap
;
/**
/**
* Provide grouping implementation for the list of contacts.
* Provide grouping implementation for the list of contacts.
*
*
...
@@ -62,7 +62,7 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
...
@@ -62,7 +62,7 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
static
final
int
TYPE_GROUP
=
1
;
static
final
int
TYPE_GROUP
=
1
;
static
{
static
{
Collection
<
Group
>
groups
=
new
ArrayList
<
Group
>(
1
);
Collection
<
Group
>
groups
=
new
ArrayList
<>(
1
);
groups
.
add
(
new
Group
()
{
groups
.
add
(
new
Group
()
{
@Override
@Override
public
String
getName
()
{
public
String
getName
()
{
...
@@ -95,28 +95,15 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
...
@@ -95,28 +95,15 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
public
GroupedContactAdapter
(
Activity
activity
,
ListView
listView
,
public
GroupedContactAdapter
(
Activity
activity
,
ListView
listView
,
Inflater
inflater
,
StateProvider
groupStateProvider
)
{
Inflater
inflater
,
StateProvider
groupStateProvider
)
{
super
(
activity
,
listView
,
inflater
);
super
(
activity
,
listView
,
inflater
);
layoutInflater
=
(
LayoutInflater
)
activity
layoutInflater
=
(
LayoutInflater
)
activity
.
getSystemService
(
Context
.
LAYOUT_INFLATER_SERVICE
);
.
getSystemService
(
Context
.
LAYOUT_INFLATER_SERVICE
);
this
.
groupStateProvider
=
groupStateProvider
;
this
.
groupStateProvider
=
groupStateProvider
;
TypedArray
typedArray
;
TypedArray
typedArray
;
typedArray
=
activity
.
getTheme
().
obtainStyledAttributes
(
typedArray
=
activity
.
getTheme
().
obtainStyledAttributes
(
R
.
styleable
.
ContactList
);
R
.
styleable
.
ContactList
);
expanderAccountTextColor
=
typedArray
.
getColorStateList
(
R
.
styleable
.
ContactList_expanderAccountColor
);
expanderAccountTextColor
=
typedArray
expanderGroupTextColor
=
typedArray
.
getColorStateList
(
R
.
styleable
.
ContactList_expanderGroupColor
);
.
getColorStateList
(
R
.
styleable
.
ContactList_expanderAccountColor
);
expanderGroupTextColor
=
typedArray
.
getColorStateList
(
R
.
styleable
.
ContactList_expanderGroupColor
);
typedArray
.
recycle
();
typedArray
.
recycle
();
}
}
/**
* Returns group state provider.
*
* @return
*/
public
StateProvider
getGroupStateProvider
()
{
return
groupStateProvider
;
}
@Override
@Override
public
int
getViewTypeCount
()
{
public
int
getViewTypeCount
()
{
return
2
;
return
2
;
...
@@ -125,12 +112,13 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
...
@@ -125,12 +112,13 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
@Override
@Override
public
int
getItemViewType
(
int
position
)
{
public
int
getItemViewType
(
int
position
)
{
Object
object
=
getItem
(
position
);
Object
object
=
getItem
(
position
);
if
(
object
instanceof
AbstractContact
)
if
(
object
instanceof
AbstractContact
)
{
return
TYPE_CONTACT
;
return
TYPE_CONTACT
;
else
if
(
object
instanceof
GroupConfiguration
)
}
else
if
(
object
instanceof
GroupConfiguration
)
{
return
TYPE_GROUP
;
return
TYPE_GROUP
;
else
}
else
{
throw
new
IllegalStateException
();
throw
new
IllegalStateException
();
}
}
}
@Override
@Override
...
@@ -141,15 +129,12 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
...
@@ -141,15 +129,12 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
final
View
view
;
final
View
view
;
final
GroupViewHolder
viewHolder
;
final
GroupViewHolder
viewHolder
;
if
(
convertView
==
null
)
{
if
(
convertView
==
null
)
{
view
=
layoutInflater
.
inflate
(
R
.
layout
.
base_group_item
,
parent
,
view
=
layoutInflater
.
inflate
(
R
.
layout
.
base_group_item
,
parent
,
false
);
false
);
TypedArray
typedArray
=
activity
.
obtainStyledAttributes
(
R
.
styleable
.
ContactList
);
TypedArray
typedArray
=
activity
view
.
setBackgroundDrawable
(
.
obtainStyledAttributes
(
R
.
styleable
.
ContactList
);
typedArray
.
getDrawable
(
R
.
styleable
.
ContactList_expanderBackground
));
view
.
setBackgroundDrawable
(
typedArray
((
ImageView
)
view
.
findViewById
(
R
.
id
.
indicator
)).
setImageDrawable
(
.
getDrawable
(
R
.
styleable
.
ContactList_expanderBackground
));
typedArray
.
getDrawable
(
R
.
styleable
.
ContactList_expanderIndicator
));
((
ImageView
)
view
.
findViewById
(
R
.
id
.
indicator
))
.
setImageDrawable
(
typedArray
.
getDrawable
(
R
.
styleable
.
ContactList_expanderIndicator
));
typedArray
.
recycle
();
typedArray
.
recycle
();
viewHolder
=
new
GroupViewHolder
(
view
);
viewHolder
=
new
GroupViewHolder
(
view
);
...
@@ -161,25 +146,23 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
...
@@ -161,25 +146,23 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
final
GroupConfiguration
configuration
=
(
GroupConfiguration
)
getItem
(
position
);
final
GroupConfiguration
configuration
=
(
GroupConfiguration
)
getItem
(
position
);
final
int
level
;
final
int
level
;
if
(
configuration
instanceof
AccountConfiguration
)
{
if
(
configuration
instanceof
AccountConfiguration
)
{
level
=
AccountManager
.
getInstance
().
getColorLevel
(
level
=
AccountManager
.
getInstance
().
getColorLevel
(
configuration
.
getAccount
());
configuration
.
getAccount
());
viewHolder
.
name
.
setTextColor
(
expanderAccountTextColor
);
viewHolder
.
name
.
setTextColor
(
expanderAccountTextColor
);
}
else
{
}
else
{
level
=
AccountManager
.
getInstance
().
getColorCount
();
level
=
AccountManager
.
getInstance
().
getColorCount
();
viewHolder
.
name
.
setTextColor
(
expanderGroupTextColor
);
viewHolder
.
name
.
setTextColor
(
expanderGroupTextColor
);
}
}
view
.
getBackground
().
setLevel
(
level
);
view
.
getBackground
().
setLevel
(
level
);
viewHolder
.
name
.
getBackground
().
setLevel
(
viewHolder
.
name
.
getBackground
().
setLevel
(
configuration
.
getShowOfflineMode
().
ordinal
());
configuration
.
getShowOfflineMode
().
ordinal
());
final
String
name
=
GroupManager
.
getInstance
().
getGroupName
(
final
String
name
=
GroupManager
.
getInstance
().
getGroupName
(
configuration
.
getAccount
(),
configuration
.
getUser
());
configuration
.
getAccount
(),
configuration
.
getUser
());
viewHolder
.
name
.
setText
(
name
+
" ("
+
configuration
.
getOnline
()
viewHolder
.
name
.
setText
(
name
+
" ("
+
configuration
.
getOnline
()
+
"/"
+
configuration
.
getTotal
()
+
")"
);
+
"/"
+
configuration
.
getTotal
()
+
")"
);
viewHolder
.
indicator
.
setImageLevel
(
configuration
.
isExpanded
()
?
1
viewHolder
.
indicator
.
setImageLevel
(
configuration
.
isExpanded
()
?
1
:
0
);
:
0
);
return
view
;
return
view
;
}
else
}
else
{
throw
new
IllegalStateException
();
throw
new
IllegalStateException
();
}
}
}
/**
/**
...
@@ -191,10 +174,10 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
...
@@ -191,10 +174,10 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
*/
*/
protected
GroupConfiguration
getGroupConfiguration
(
protected
GroupConfiguration
getGroupConfiguration
(
AccountConfiguration
accountConfiguration
,
String
name
)
{
AccountConfiguration
accountConfiguration
,
String
name
)
{
GroupConfiguration
groupConfiguration
=
accountConfiguration
GroupConfiguration
groupConfiguration
=
accountConfiguration
.
getGroupConfiguration
(
name
);
.
getGroupConfiguration
(
name
);
if
(
groupConfiguration
!=
null
)
{
if
(
groupConfiguration
!=
null
)
return
groupConfiguration
;
return
groupConfiguration
;
}
groupConfiguration
=
new
GroupConfiguration
(
groupConfiguration
=
new
GroupConfiguration
(
accountConfiguration
.
getAccount
(),
name
,
groupStateProvider
);
accountConfiguration
.
getAccount
(),
name
,
groupStateProvider
);
accountConfiguration
.
addGroupConfiguration
(
groupConfiguration
);
accountConfiguration
.
addGroupConfiguration
(
groupConfiguration
);
...
@@ -211,10 +194,10 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
...
@@ -211,10 +194,10 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
protected
GroupConfiguration
getGroupConfiguration
(
protected
GroupConfiguration
getGroupConfiguration
(
TreeMap
<
String
,
GroupConfiguration
>
groups
,
String
name
)
{
TreeMap
<
String
,
GroupConfiguration
>
groups
,
String
name
)
{
GroupConfiguration
groupConfiguration
=
groups
.
get
(
name
);
GroupConfiguration
groupConfiguration
=
groups
.
get
(
name
);
if
(
groupConfiguration
!=
null
)
if
(
groupConfiguration
!=
null
)
{
return
groupConfiguration
;
return
groupConfiguration
;
groupConfiguration
=
new
GroupConfiguration
(
GroupManager
.
NO_ACCOUNT
,
}
name
,
groupStateProvider
);
groupConfiguration
=
new
GroupConfiguration
(
GroupManager
.
NO_ACCOUNT
,
name
,
groupStateProvider
);
groups
.
put
(
name
,
groupConfiguration
);
groups
.
put
(
name
,
groupConfiguration
);
return
groupConfiguration
;
return
groupConfiguration
;
}
}
...
@@ -231,38 +214,39 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
...
@@ -231,38 +214,39 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
* @param showAccounts
* @param showAccounts
* @param showGroups
* @param showGroups
*/
*/
protected
void
addContact
(
AbstractContact
abstractContact
,
String
group
,
protected
void
addContact
(
AbstractContact
abstractContact
,
String
group
,
boolean
online
,
boolean
online
,
TreeMap
<
String
,
AccountConfiguration
>
accounts
,
TreeMap
<
String
,
AccountConfiguration
>
accounts
,
TreeMap
<
String
,
GroupConfiguration
>
groups
,
TreeMap
<
String
,
GroupConfiguration
>
groups
,
ArrayList
<
AbstractContact
>
contacts
,
boolean
showAccounts
,
boolean
showGroups
)
{
ArrayList
<
AbstractContact
>
contacts
,
boolean
showAccounts
,
boolean
showGroups
)
{
if
(
showAccounts
)
{
if
(
showAccounts
)
{
final
String
account
=
abstractContact
.
getAccount
();
final
String
account
=
abstractContact
.
getAccount
();
final
AccountConfiguration
accountConfiguration
;
final
AccountConfiguration
accountConfiguration
;
accountConfiguration
=
accounts
.
get
(
account
);
accountConfiguration
=
accounts
.
get
(
account
);
if
(
accountConfiguration
==
null
)
if
(
accountConfiguration
==
null
)
{
return
;
return
;
}
if
(
showGroups
)
{
if
(
showGroups
)
{
GroupConfiguration
groupConfiguration
=
getGroupConfiguration
(
GroupConfiguration
groupConfiguration
accountConfiguration
,
group
);
=
getGroupConfiguration
(
accountConfiguration
,
group
);
if
(
accountConfiguration
.
isExpanded
())
{
if
(
accountConfiguration
.
isExpanded
())
{
groupConfiguration
.
setNotEmpty
();
groupConfiguration
.
setNotEmpty
();
if
(
groupConfiguration
.
isExpanded
())
if
(
groupConfiguration
.
isExpanded
())
{
groupConfiguration
.
addAbstractContact
(
abstractContact
);
groupConfiguration
.
addAbstractContact
(
abstractContact
);
}
}
}
groupConfiguration
.
increment
(
online
);
groupConfiguration
.
increment
(
online
);
}
else
{
}
else
{
if
(
accountConfiguration
.
isExpanded
())
if
(
accountConfiguration
.
isExpanded
())
{
accountConfiguration
.
addAbstractContact
(
abstractContact
);
accountConfiguration
.
addAbstractContact
(
abstractContact
);
}
}
}
accountConfiguration
.
increment
(
online
);
accountConfiguration
.
increment
(
online
);
}
else
{
}
else
{
if
(
showGroups
)
{
if
(
showGroups
)
{
GroupConfiguration
groupConfiguration
=
getGroupConfiguration
(
GroupConfiguration
groupConfiguration
=
getGroupConfiguration
(
groups
,
group
);
groups
,
group
);
groupConfiguration
.
setNotEmpty
();
groupConfiguration
.
setNotEmpty
();
if
(
groupConfiguration
.
isExpanded
())
if
(
groupConfiguration
.
isExpanded
())
{
groupConfiguration
.
addAbstractContact
(
abstractContact
);
groupConfiguration
.
addAbstractContact
(
abstractContact
);
}
groupConfiguration
.
increment
(
online
);
groupConfiguration
.
increment
(
online
);
}
else
{
}
else
{
contacts
.
add
(
abstractContact
);
contacts
.
add
(
abstractContact
);
...
@@ -292,13 +276,14 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
...
@@ -292,13 +276,14 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
if
(
showAccounts
)
{
if
(
showAccounts
)
{
final
AccountConfiguration
accountConfiguration
;
final
AccountConfiguration
accountConfiguration
;
accountConfiguration
=
accounts
.
get
(
abstractContact
.
getAccount
());
accountConfiguration
=
accounts
.
get
(
abstractContact
.
getAccount
());
if
(
accountConfiguration
==
null
)
if
(
accountConfiguration
==
null
)
{
return
hasVisible
;
return
false
;
}
if
(
showGroups
)
{
if
(
showGroups
)
{
Collection
<?
extends
Group
>
abstractGroups
=
abstractContact
Collection
<?
extends
Group
>
abstractGroups
=
abstractContact
.
getGroups
();
.
getGroups
();
if
(
abstractGroups
.
size
()
==
0
)
{
if
(
abstractGroups
.
size
()
==
0
)
abstractGroups
=
NO_GROUP_LIST
;
abstractGroups
=
NO_GROUP_LIST
;
}
for
(
Group
abstractGroup
:
abstractGroups
)
{
for
(
Group
abstractGroup
:
abstractGroups
)
{
GroupConfiguration
groupConfiguration
=
getGroupConfiguration
(
GroupConfiguration
groupConfiguration
=
getGroupConfiguration
(
accountConfiguration
,
abstractGroup
.
getName
());
accountConfiguration
,
abstractGroup
.
getName
());
...
@@ -316,41 +301,39 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
...
@@ -316,41 +301,39 @@ public abstract class GroupedContactAdapter<Inflater extends BaseContactInflater
hasVisible
=
true
;
hasVisible
=
true
;
if
(
accountConfiguration
.
isExpanded
())
{
if
(
accountConfiguration
.
isExpanded
())
{
groupConfiguration
.
setNotEmpty
();
groupConfiguration
.
setNotEmpty
();
if
(
groupConfiguration
.
isExpanded
())
if
(
groupConfiguration
.
isExpanded
())
{
groupConfiguration
groupConfiguration
.
addAbstractContact
(
abstractContact
);
.
addAbstractContact
(
abstractContact
);
}
}
}
}
}
groupConfiguration
.
increment
(
online
);
groupConfiguration
.
increment
(
online
);
}
}
}
else
{
}
else
{
if
(
online
if
(
online
||
(
accountConfiguration
.
getShowOfflineMode
()
==
ShowOfflineMode
.
always
)
||
(
accountConfiguration
.
getShowOfflineMode
()
==
ShowOfflineMode
.
always
)
||
(
accountConfiguration
.
getShowOfflineMode
()
==
ShowOfflineMode
.
normal
&&
showOffline
))
{
||
(
accountConfiguration
.
getShowOfflineMode
()
==
ShowOfflineMode
.
normal
&&
showOffline
))
{
hasVisible
=
true
;
hasVisible
=
true
;
if
(
accountConfiguration
.
isExpanded
())
if
(
accountConfiguration
.
isExpanded
())
{
accountConfiguration
accountConfiguration
.
addAbstractContact
(
abstractContact
);
.
addAbstractContact
(
abstractContact
);
}
}
}
}
}
accountConfiguration
.
increment
(
online
);
accountConfiguration
.
increment
(
online
);
}
else
{
}
else
{
if
(
showGroups
)
{
if
(
showGroups
)
{
Collection
<?
extends
Group
>
abstractGroups
=
abstractContact
Collection
<?
extends
Group
>
abstractGroups
=
abstractContact
.
getGroups
();
.
getGroups
();
if
(
abstractGroups
.
size
()
==
0
)
{
if
(
abstractGroups
.
size
()
==
0
)
abstractGroups
=
NO_GROUP_LIST
;
abstractGroups
=
NO_GROUP_LIST
;
}
for
(
Group
abstractGroup
:
abstractGroups
)
{
for
(
Group
abstractGroup
:
abstractGroups
)
{
GroupConfiguration
groupConfiguration
=
getGroupConfiguration
(
GroupConfiguration
groupConfiguration
groups
,
abstractGroup
.
getName
());
=
getGroupConfiguration
(
groups
,
abstractGroup
.
getName
());
if
(
online
if
(
online
||
(
groupConfiguration
.
getShowOfflineMode
()
==
ShowOfflineMode
.
always
)
||
(
groupConfiguration
.
getShowOfflineMode
()
==
ShowOfflineMode
.
always
)
||
(
groupConfiguration
.
getShowOfflineMode
()
==
ShowOfflineMode
.
normal
&&
showOffline
))
{
||
(
groupConfiguration
.
getShowOfflineMode
()
==
ShowOfflineMode
.
normal
&&
showOffline
))
{
groupConfiguration
.
setNotEmpty
();
groupConfiguration
.
setNotEmpty
();
hasVisible
=
true
;
hasVisible
=
true
;
if
(
groupConfiguration
.
isExpanded
())
if
(
groupConfiguration
.
isExpanded
())
{
groupConfiguration
groupConfiguration
.
addAbstractContact
(
abstractContact
);
.
addAbstractContact
(
abstractContact
);
}
}
}
groupConfiguration
.
increment
(
online
);
groupConfiguration
.
increment
(
online
);
}
}
...
...
app/src/main/java/com/xabber/android/ui/adapter/SmoothContactAdapter.java
View file @
67ff3d03
...
@@ -36,8 +36,7 @@ public abstract class SmoothContactAdapter<Inflater extends BaseContactInflater>
...
@@ -36,8 +36,7 @@ public abstract class SmoothContactAdapter<Inflater extends BaseContactInflater>
*/
*/
ListView
listView
;
ListView
listView
;
public
SmoothContactAdapter
(
Activity
activity
,
ListView
listView
,
public
SmoothContactAdapter
(
Activity
activity
,
ListView
listView
,
Inflater
inflater
)
{
Inflater
inflater
)
{
super
(
activity
,
inflater
);
super
(
activity
,
inflater
);
this
.
listView
=
listView
;
this
.
listView
=
listView
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment