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
23e3e407
Commit
23e3e407
authored
May 28, 2013
by
Alexander Ivanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Separate contact list, account toggler and intent methods.
parent
68a6c838
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
95 additions
and
78 deletions
+95
-78
ContactList.java
src/com/xabber/android/ui/ContactList.java
+90
-74
ContactListAdapter.java
src/com/xabber/android/ui/adapter/ContactListAdapter.java
+5
-4
No files found.
src/com/xabber/android/ui/ContactList.java
View file @
23e3e407
...
...
@@ -162,7 +162,7 @@ public class ContactList extends ManagedListActivity implements
listView
.
setItemsCanFocus
(
true
);
registerForContextMenu
(
listView
);
contactListAdapter
=
new
ContactListAdapter
(
this
);
contactListAdapter
=
new
ContactListAdapter
(
this
,
listView
);
setListAdapter
(
contactListAdapter
);
accountToggleAdapter
=
new
AccountToggleAdapter
(
this
,
this
,
(
LinearLayout
)
findViewById
(
R
.
id
.
account_list
));
...
...
@@ -498,21 +498,24 @@ public class ContactList extends ManagedListActivity implements
String
account
=
accountToggleAdapter
.
getItemForView
(
view
);
if
(
account
==
null
)
// Check for tap on account in the title
break
;
ListView
listView
=
getListView
();
if
(!
SettingsManager
.
contactsShowAccounts
())
{
if
(
AccountManager
.
getInstance
().
getAccounts
().
size
()
<
2
)
{
if
(
AccountManager
.
getInstance
().
getAccounts
().
size
()
<
2
)
scrollUp
();
}
else
{
if
(
account
.
equals
(
AccountManager
.
getInstance
()
.
getSelectedAccount
()))
SettingsManager
.
setContactsSelectedAccount
(
""
);
else
SettingsManager
.
setContacts
SelectedAccount
(
account
);
rebuildAccountToggler
();
contactListAdapter
.
onChange
(
);
stopMovement
()
;
set
SelectedAccount
(
account
);
}
else
scrollTo
(
account
);
break
;
}
}
else
{
}
/**
* Scroll contact list to specified account.
*
* @param account
*/
private
void
scrollTo
(
String
account
)
{
ListView
listView
=
getListView
();
long
count
=
listView
.
getCount
();
for
(
int
position
=
0
;
position
<
(
int
)
count
;
position
++)
{
BaseEntity
baseEntity
=
(
BaseEntity
)
listView
...
...
@@ -526,8 +529,20 @@ public class ContactList extends ManagedListActivity implements
}
}
}
break
;
}
/**
* Filter out contact list for selected account.
*
* @param account
*/
private
void
setSelectedAccount
(
String
account
)
{
if
(
account
.
equals
(
AccountManager
.
getInstance
().
getSelectedAccount
()))
SettingsManager
.
setContactsSelectedAccount
(
""
);
else
SettingsManager
.
setContactsSelectedAccount
(
account
);
rebuildAccountToggler
();
contactListAdapter
.
onChange
();
stopMovement
();
}
/**
...
...
@@ -567,7 +582,16 @@ public class ContactList extends ManagedListActivity implements
if
(
object
==
null
)
{
// Account toggler
}
else
if
(
object
instanceof
AbstractContact
)
{
AbstractContact
abstractContact
=
(
AbstractContact
)
object
;
onContactClick
((
AbstractContact
)
object
);
}
else
if
(
object
instanceof
GroupConfiguration
)
{
GroupConfiguration
groupConfiguration
=
(
GroupConfiguration
)
object
;
contactListAdapter
.
setExpanded
(
groupConfiguration
.
getAccount
(),
groupConfiguration
.
getUser
(),
!
groupConfiguration
.
isExpanded
());
}
}
private
void
onContactClick
(
AbstractContact
abstractContact
)
{
if
(
ACTION_ROOM_INVITE
.
equals
(
action
))
{
action
=
null
;
Intent
intent
=
getIntent
();
...
...
@@ -584,8 +608,8 @@ public class ContactList extends ManagedListActivity implements
}
else
if
(
Intent
.
ACTION_SEND
.
equals
(
action
))
{
action
=
null
;
startActivity
(
ChatViewer
.
createSendIntent
(
this
,
abstractContact
.
getAccount
(),
abstractContact
.
getUser
(),
sendText
));
abstractContact
.
getAccount
(),
abstractContact
.
getUser
(),
sendText
));
finish
();
}
else
if
(
Intent
.
ACTION_CREATE_SHORTCUT
.
equals
(
action
))
{
Intent
intent
=
new
Intent
();
...
...
@@ -597,8 +621,7 @@ public class ContactList extends ManagedListActivity implements
intent
.
putExtra
(
Intent
.
EXTRA_SHORTCUT_NAME
,
abstractContact
.
getName
());
Bitmap
bitmap
;
if
(
MUCManager
.
getInstance
()
.
hasRoom
(
abstractContact
.
getAccount
(),
if
(
MUCManager
.
getInstance
().
hasRoom
(
abstractContact
.
getAccount
(),
abstractContact
.
getUser
()))
bitmap
=
AvatarManager
.
getInstance
().
getRoomBitmap
(
abstractContact
.
getUser
());
...
...
@@ -610,15 +633,8 @@ public class ContactList extends ManagedListActivity implements
setResult
(
RESULT_OK
,
intent
);
finish
();
}
else
{
startActivity
(
ChatViewer
.
createIntent
(
this
,
abstractContact
.
getAccount
(),
abstractContact
.
getUser
()));
}
}
else
if
(
object
instanceof
GroupConfiguration
)
{
GroupConfiguration
groupConfiguration
=
(
GroupConfiguration
)
object
;
contactListAdapter
.
setExpanded
(
groupConfiguration
.
getAccount
(),
groupConfiguration
.
getUser
(),
!
groupConfiguration
.
isExpanded
());
startActivity
(
ChatViewer
.
createIntent
(
this
,
abstractContact
.
getAccount
(),
abstractContact
.
getUser
()));
}
}
...
...
src/com/xabber/android/ui/adapter/ContactListAdapter.java
View file @
23e3e407
...
...
@@ -22,12 +22,14 @@ import java.util.Date;
import
java.util.Map.Entry
;
import
java.util.TreeMap
;
import
android.app.Activity
;
import
android.os.Handler
;
import
android.view.View
;
import
android.view.View.OnClickListener
;
import
android.view.animation.Animation
;
import
android.view.animation.AnimationUtils
;
import
android.widget.Button
;
import
android.widget.ListView
;
import
android.widget.TextView
;
import
com.xabber.android.data.SettingsManager
;
...
...
@@ -47,7 +49,6 @@ import com.xabber.android.data.roster.RosterManager;
import
com.xabber.android.ui.AccountAdd
;
import
com.xabber.android.ui.AccountList
;
import
com.xabber.android.ui.ContactAdd
;
import
com.xabber.android.ui.helper.ManagedListActivity
;
import
com.xabber.androiddev.R
;
/**
...
...
@@ -120,9 +121,9 @@ public class ContactListAdapter extends
*/
private
Date
nextRefresh
;
public
ContactListAdapter
(
ManagedListActivity
activity
)
{
super
(
activity
,
activity
.
getListView
(),
new
ChatContactInflater
(
activity
),
GroupManager
.
getInstance
());
public
ContactListAdapter
(
Activity
activity
,
ListView
listView
)
{
super
(
activity
,
listView
,
new
ChatContactInflater
(
activity
),
GroupManager
.
getInstance
());
infoView
=
activity
.
findViewById
(
R
.
id
.
info
);
if
(
infoView
!=
null
)
{
connectedView
=
infoView
.
findViewById
(
R
.
id
.
connected
);
...
...
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