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
41cbecc5
Commit
41cbecc5
authored
May 29, 2013
by
Alexander Ivanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unused ChatViewHolder.
parent
8dc9519f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
67 additions
and
91 deletions
+67
-91
ChatViewerFragment.java
src/com/xabber/android/ui/ChatViewerFragment.java
+67
-91
No files found.
src/com/xabber/android/ui/ChatViewerFragment.java
View file @
41cbecc5
...
...
@@ -44,24 +44,31 @@ public class ChatViewerFragment {
private
AbstractAvatarInflaterHelper
avatarInflaterHelper
;
private
Animation
shake
;
private
boolean
skipOnTextChanges
;
private
ChatViewHolder
chatViewHolder
;
private
TextView
pageView
;
private
View
titleView
;
private
EditText
inputView
;
private
ListView
listView
;
private
ChatMessageAdapter
chatMessageAdapter
;
/**
* Whether pages are shown.
*/
private
boolean
pagesShown
;
private
Handler
handler
;
/**
* Animation used to hide pages.
*/
private
Animation
pagesHideAnimation
;
/**
* Animation used for incoming message notification.
*/
private
Animation
shakeAnimation
;
private
Handler
handler
;
/**
* Runnable called to hide pages.
*/
...
...
@@ -69,7 +76,7 @@ public class ChatViewerFragment {
@Override
public
void
run
()
{
handler
.
removeCallbacks
(
this
);
chatViewHolder
.
page
.
startAnimation
(
pagesHideAnimation
);
pageView
.
startAnimation
(
pagesHideAnimation
);
}
};
...
...
@@ -105,7 +112,8 @@ public class ChatViewerFragment {
public
View
onCreateView
(
LayoutInflater
inflater
,
ViewGroup
container
,
Bundle
savedInstanceState
)
{
shake
=
AnimationUtils
.
loadAnimation
(
getActivity
(),
R
.
anim
.
shake
);
shakeAnimation
=
AnimationUtils
.
loadAnimation
(
getActivity
(),
R
.
anim
.
shake
);
pagesHideAnimation
=
AnimationUtils
.
loadAnimation
(
getActivity
(),
R
.
anim
.
chat_page_out
);
pagesHideAnimation
.
setAnimationListener
(
new
AnimationListener
()
{
...
...
@@ -116,7 +124,7 @@ public class ChatViewerFragment {
@Override
public
void
onAnimationEnd
(
Animation
animation
)
{
chatViewHolder
.
page
.
setVisibility
(
View
.
GONE
);
pageView
.
setVisibility
(
View
.
GONE
);
}
@Override
...
...
@@ -126,17 +134,20 @@ public class ChatViewerFragment {
});
View
view
=
inflater
.
inflate
(
R
.
layout
.
chat_viewer_item
,
container
,
false
);
ChatMessageAdapter
chatMessageAdapter
=
new
ChatMessageAdapter
(
getActivity
());
chatViewHolder
=
new
ChatViewHolder
(
view
,
chatMessageAdapter
);
chatViewHolder
.
list
.
setAdapter
(
chatViewHolder
.
chatMessageAdapter
);
chatViewHolder
.
send
.
setOnClickListener
((
OnClickListener
)
getActivity
());
chatViewHolder
.
title
.
setOnClickListener
((
OnClickListener
)
getActivity
());
chatViewHolder
.
input
.
setOnKeyListener
((
OnKeyListener
)
getActivity
());
chatViewHolder
.
input
chatMessageAdapter
=
new
ChatMessageAdapter
(
getActivity
());
pageView
=
(
TextView
)
view
.
findViewById
(
R
.
id
.
chat_page
);
titleView
=
view
.
findViewById
(
R
.
id
.
title
);
inputView
=
(
EditText
)
view
.
findViewById
(
R
.
id
.
chat_input
);
listView
=
(
ListView
)
view
.
findViewById
(
android
.
R
.
id
.
list
);
listView
.
setAdapter
(
chatMessageAdapter
);
view
.
findViewById
(
R
.
id
.
chat_send
).
setOnClickListener
(
(
OnClickListener
)
getActivity
());
titleView
.
setOnClickListener
((
OnClickListener
)
getActivity
());
inputView
.
setOnKeyListener
((
OnKeyListener
)
getActivity
());
inputView
.
setOnEditorActionListener
((
OnEditorActionListener
)
getActivity
());
chatViewHolder
.
input
.
addTextChangedListener
(
new
TextWatcher
()
{
inputView
.
addTextChangedListener
(
new
TextWatcher
()
{
@Override
public
void
onTextChanged
(
CharSequence
s
,
int
start
,
int
before
,
...
...
@@ -153,11 +164,11 @@ public class ChatViewerFragment {
if
(
skipOnTextChanges
)
return
;
((
OnTextChangedListener
)
getActivity
()).
onTextChanged
(
chatViewHolder
.
input
,
s
);
inputView
,
s
);
}
});
chatViewHolder
.
list
.
setOnCreateContextMenuListener
(
getActivity
());
listView
.
setOnCreateContextMenuListener
(
getActivity
());
return
view
;
}
...
...
@@ -166,73 +177,64 @@ public class ChatViewerFragment {
final
String
user
=
chat
.
getUser
();
final
AbstractContact
abstractContact
=
RosterManager
.
getInstance
()
.
getBestContact
(
account
,
user
);
if
(
chat
.
equals
(
chat
ViewHolder
.
chat
MessageAdapter
.
getAccount
(),
chat
ViewHolder
.
chat
MessageAdapter
.
getUser
()))
{
chat
ViewHolder
.
chat
MessageAdapter
.
updateInfo
();
if
(
chat
.
equals
(
chatMessageAdapter
.
getAccount
(),
chatMessageAdapter
.
getUser
()))
{
chatMessageAdapter
.
updateInfo
();
}
else
{
if
(
chat
ViewHolder
.
chat
MessageAdapter
.
getAccount
()
!=
null
&&
chat
ViewHolder
.
chat
MessageAdapter
.
getUser
()
!=
null
)
if
(
chatMessageAdapter
.
getAccount
()
!=
null
&&
chatMessageAdapter
.
getUser
()
!=
null
)
saveState
();
if
(
PageSwitcher
.
LOG
)
LogManager
.
i
(
this
,
"Load "
+
chatViewHolder
.
chatMessageAdapter
.
getUser
()
+
" in "
+
chatViewHolder
.
chatMessageAdapter
.
getAccount
());
LogManager
.
i
(
this
,
"Load "
+
chatMessageAdapter
.
getUser
()
+
" in "
+
chatMessageAdapter
.
getAccount
());
skipOnTextChanges
=
true
;
chatViewHolder
.
input
.
setText
(
ChatManager
.
getInstance
()
.
getTypedMessage
(
account
,
user
));
chatViewHolder
.
input
.
setSelection
(
ChatManager
.
getInstance
()
.
getSelectionStart
(
account
,
user
),
ChatManager
.
getInstance
().
getSelectionEnd
(
account
,
user
));
inputView
.
setText
(
ChatManager
.
getInstance
().
getTypedMessage
(
account
,
user
));
inputView
.
setSelection
(
ChatManager
.
getInstance
().
getSelectionStart
(
account
,
user
),
ChatManager
.
getInstance
().
getSelectionEnd
(
account
,
user
));
skipOnTextChanges
=
false
;
chat
ViewHolder
.
chat
MessageAdapter
.
setChat
(
account
,
user
);
chatViewHolder
.
list
.
setAdapter
(
chatViewHolder
.
list
.
getAdapter
());
chatMessageAdapter
.
setChat
(
account
,
user
);
listView
.
setAdapter
(
listView
.
getAdapter
());
}
chatViewHolder
.
page
.
setText
(
getString
(
R
.
string
.
chat_page
,
((
ChatViewer
)
getActivity
()).
getChatPosition
(
account
,
user
)
+
1
,
((
ChatViewer
)
getActivity
())
.
getChatCount
()));
ContactTitleInflater
.
updateTitle
(
chatViewHolder
.
title
,
getActivity
(),
pageView
.
setText
(
getString
(
R
.
string
.
chat_page
,
((
ChatViewer
)
getActivity
()).
getChatPosition
(
account
,
user
)
+
1
,
((
ChatViewer
)
getActivity
()).
getChatCount
()));
ContactTitleInflater
.
updateTitle
(
titleView
,
getActivity
(),
abstractContact
);
avatarInflaterHelper
.
updateAvatar
(
chatViewHolder
.
avatar
,
avatarInflaterHelper
.
updateAvatar
(
(
ImageView
)
titleView
.
findViewById
(
R
.
id
.
avatar
),
abstractContact
);
SecurityLevel
securityLevel
=
OTRManager
.
getInstance
()
.
getSecurityLevel
(
chat
.
getAccount
(),
chat
.
getUser
());
SecurityOtrMode
securityOtrMode
=
SettingsManager
.
securityOtrMode
();
ImageView
securityView
=
(
ImageView
)
titleView
.
findViewById
(
R
.
id
.
security
);
if
(
securityLevel
==
SecurityLevel
.
plain
&&
(
securityOtrMode
==
SecurityOtrMode
.
disabled
||
securityOtrMode
==
SecurityOtrMode
.
manual
))
{
chatViewHolder
.
security
.
setVisibility
(
View
.
GONE
);
securityView
.
setVisibility
(
View
.
GONE
);
}
else
{
chatViewHolder
.
security
.
setVisibility
(
View
.
VISIBLE
);
chatViewHolder
.
security
.
setImageLevel
(
securityLevel
.
getImageLevel
());
securityView
.
setVisibility
(
View
.
VISIBLE
);
securityView
.
setImageLevel
(
securityLevel
.
getImageLevel
());
}
}
public
void
saveState
()
{
if
(
PageSwitcher
.
LOG
)
LogManager
.
i
(
this
,
"Save "
+
chatViewHolder
.
chatMessageAdapter
.
getUser
()
+
" in "
+
chatViewHolder
.
chatMessageAdapter
.
getAccount
());
ChatManager
.
getInstance
().
setTyped
(
chatViewHolder
.
chatMessageAdapter
.
getAccount
(),
chatViewHolder
.
chatMessageAdapter
.
getUser
(),
chatViewHolder
.
input
.
getText
().
toString
(),
chatViewHolder
.
input
.
getSelectionStart
(),
chatViewHolder
.
input
.
getSelectionEnd
());
LogManager
.
i
(
this
,
"Save "
+
chatMessageAdapter
.
getUser
()
+
" in "
+
chatMessageAdapter
.
getAccount
());
ChatManager
.
getInstance
().
setTyped
(
chatMessageAdapter
.
getAccount
(),
chatMessageAdapter
.
getUser
(),
inputView
.
getText
().
toString
(),
inputView
.
getSelectionStart
(),
inputView
.
getSelectionEnd
());
}
public
void
onChatChange
(
boolean
incomingMessage
)
{
if
(
incomingMessage
)
chatViewHolder
.
nameHolder
.
startAnimation
(
shake
);
chatViewHolder
.
chatMessageAdapter
.
onChange
();
titleView
.
findViewById
(
R
.
id
.
name_holder
).
startAnimation
(
shakeAnimation
);
chatMessageAdapter
.
onChange
();
}
/**
...
...
@@ -243,8 +245,8 @@ public class ChatViewerFragment {
return
;
pagesShown
=
true
;
handler
.
removeCallbacks
(
pagesHideRunnable
);
chatViewHolder
.
page
.
clearAnimation
();
chatViewHolder
.
page
.
setVisibility
(
View
.
VISIBLE
);
pageView
.
clearAnimation
();
pageView
.
setVisibility
(
View
.
VISIBLE
);
}
/**
...
...
@@ -257,30 +259,4 @@ public class ChatViewerFragment {
handler
.
postDelayed
(
pagesHideRunnable
,
PAGES_HIDDER_DELAY
);
}
private
static
class
ChatViewHolder
{
final
TextView
page
;
final
View
title
;
final
View
nameHolder
;
final
ImageView
avatar
;
final
ImageView
security
;
final
View
send
;
final
EditText
input
;
final
ListView
list
;
final
ChatMessageAdapter
chatMessageAdapter
;
public
ChatViewHolder
(
View
view
,
ChatMessageAdapter
chatMessageAdapter
)
{
page
=
(
TextView
)
view
.
findViewById
(
R
.
id
.
chat_page
);
title
=
view
.
findViewById
(
R
.
id
.
title
);
nameHolder
=
title
.
findViewById
(
R
.
id
.
name_holder
);
avatar
=
(
ImageView
)
title
.
findViewById
(
R
.
id
.
avatar
);
security
=
(
ImageView
)
title
.
findViewById
(
R
.
id
.
security
);
send
=
view
.
findViewById
(
R
.
id
.
chat_send
);
input
=
(
EditText
)
view
.
findViewById
(
R
.
id
.
chat_input
);
list
=
(
ListView
)
view
.
findViewById
(
android
.
R
.
id
.
list
);
this
.
chatMessageAdapter
=
chatMessageAdapter
;
}
}
}
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