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
f62fb1db
Commit
f62fb1db
authored
Feb 12, 2015
by
Grigory Fedorov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
AccountToggleAdapter: light refactoring.
parent
392f4a5d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
20 deletions
+20
-20
AccountToggleAdapter.java
...a/com/xabber/android/ui/adapter/AccountToggleAdapter.java
+20
-20
No files found.
app/src/main/java/com/xabber/android/ui/adapter/AccountToggleAdapter.java
View file @
f62fb1db
...
...
@@ -76,17 +76,16 @@ public class AccountToggleAdapter implements UpdatableAdapter {
final
LayoutInflater
inflater
=
(
LayoutInflater
)
activity
.
getSystemService
(
Activity
.
LAYOUT_INFLATER_SERVICE
);
while
(
linearLayout
.
getChildCount
()
<
size
)
{
final
View
view
=
inflater
.
inflate
(
R
.
layout
.
account_toggler_item
,
linearLayout
,
false
);
final
View
view
=
inflater
.
inflate
(
R
.
layout
.
account_toggler_item
,
linearLayout
,
false
);
linearLayout
.
addView
(
view
);
final
AccountViewHolder
accountViewHolder
=
new
AccountViewHolder
(
view
);
final
AccountViewHolder
accountViewHolder
=
new
AccountViewHolder
(
view
);
view
.
setTag
(
accountViewHolder
);
activity
.
registerForContextMenu
(
accountViewHolder
.
statusMode
);
accountViewHolder
.
statusMode
.
setOnClickListener
(
onClickListener
);
}
while
(
linearLayout
.
getChildCount
()
>
size
)
while
(
linearLayout
.
getChildCount
()
>
size
)
{
linearLayout
.
removeViewAt
(
size
);
}
onChange
();
}
...
...
@@ -96,26 +95,24 @@ public class AccountToggleAdapter implements UpdatableAdapter {
String
selected
=
AccountManager
.
getInstance
().
getSelectedAccount
();
for
(
int
index
=
0
;
index
<
accounts
.
size
();
index
++)
{
final
View
view
=
linearLayout
.
getChildAt
(
index
);
final
AccountViewHolder
accountViewHolder
=
(
AccountViewHolder
)
view
.
getTag
();
final
AccountViewHolder
accountViewHolder
=
(
AccountViewHolder
)
view
.
getTag
();
final
String
account
=
accounts
.
get
(
index
);
StatusMode
statusMode
=
AccountManager
.
getInstance
()
.
getAccount
(
account
).
getDisplayStatusMode
();
int
colorLevel
=
AccountManager
.
getInstance
()
.
getColorLevel
(
account
);
StatusMode
statusMode
=
AccountManager
.
getInstance
().
getAccount
(
account
).
getDisplayStatusMode
();
int
colorLevel
=
AccountManager
.
getInstance
().
getColorLevel
(
account
);
view
.
getBackground
().
setLevel
(
colorLevel
);
if
(
contactsShowAccounts
)
if
(
contactsShowAccounts
)
{
accountViewHolder
.
statusMode
.
setBackgroundResource
(
R
.
drawable
.
account_border
);
else
}
else
{
accountViewHolder
.
statusMode
.
setBackgroundResource
(
R
.
drawable
.
account_border_persistent
);
if
(
selected
==
null
||
account
.
equals
(
selected
))
}
if
(
selected
==
null
||
account
.
equals
(
selected
))
{
accountViewHolder
.
disabled
.
setVisibility
(
View
.
GONE
);
else
}
else
{
accountViewHolder
.
disabled
.
setVisibility
(
View
.
VISIBLE
);
}
accountViewHolder
.
statusMode
.
getBackground
().
setLevel
(
colorLevel
);
accountViewHolder
.
statusMode
.
setImageLevel
(
statusMode
.
ordinal
());
accountViewHolder
.
avatar
.
setImageDrawable
(
AvatarManager
.
getInstance
().
getAccountAvatar
(
account
));
accountViewHolder
.
avatar
.
setImageDrawable
(
AvatarManager
.
getInstance
().
getAccountAvatar
(
account
));
}
}
...
...
@@ -135,11 +132,14 @@ public class AccountToggleAdapter implements UpdatableAdapter {
* @return The data for the specified view.
*/
public
String
getItemForView
(
View
view
)
{
if
(
view
.
getId
()
==
R
.
id
.
status_mode
)
if
(
view
.
getId
()
==
R
.
id
.
status_mode
)
{
view
=
(
View
)
view
.
getParent
();
for
(
int
index
=
0
;
index
<
linearLayout
.
getChildCount
();
index
++)
if
(
view
==
linearLayout
.
getChildAt
(
index
))
}
for
(
int
index
=
0
;
index
<
linearLayout
.
getChildCount
();
index
++)
{
if
(
view
==
linearLayout
.
getChildAt
(
index
))
{
return
accounts
.
get
(
index
);
}
}
return
null
;
}
...
...
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