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
5c67deb8
Commit
5c67deb8
authored
May 29, 2013
by
Alexander Ivanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Process chat viewer events directly in activity.
parent
b852d27b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
94 deletions
+21
-94
ChatViewer.java
src/com/xabber/android/ui/ChatViewer.java
+6
-7
ChatViewerAdapter.java
src/com/xabber/android/ui/adapter/ChatViewerAdapter.java
+15
-87
No files found.
src/com/xabber/android/ui/ChatViewer.java
View file @
5c67deb8
...
...
@@ -131,6 +131,8 @@ public class ChatViewer extends ManagedActivity implements
private
boolean
isVisible
;
private
boolean
skipOnTextChanges
;
@Override
public
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
...
...
@@ -156,11 +158,6 @@ public class ChatViewer extends ManagedActivity implements
setContentView
(
R
.
layout
.
chat_viewer
);
chatViewerAdapter
=
new
ChatViewerAdapter
(
this
,
account
,
user
);
chatViewerAdapter
.
setOnClickListener
(
this
);
chatViewerAdapter
.
setOnKeyListener
(
this
);
chatViewerAdapter
.
setOnEditorActionListener
(
this
);
chatViewerAdapter
.
setOnCreateContextMenuListener
(
this
);
chatViewerAdapter
.
setOnTextChangedListener
(
this
);
pageSwitcher
=
(
PageSwitcher
)
findViewById
(
R
.
id
.
switcher
);
pageSwitcher
.
setAdapter
(
chatViewerAdapter
);
pageSwitcher
.
setOnSelectListener
(
this
);
...
...
@@ -582,6 +579,8 @@ public class ChatViewer extends ManagedActivity implements
@Override
public
void
onTextChanged
(
EditText
editText
,
CharSequence
text
)
{
if
(
skipOnTextChanges
)
return
;
ChatStateManager
.
getInstance
().
onComposing
(
actionWithAccount
,
actionWithUser
,
text
);
}
...
...
@@ -635,9 +634,9 @@ public class ChatViewer extends ManagedActivity implements
text
=
text
.
substring
(
start
,
end
);
if
(
""
.
equals
(
text
))
return
;
chatViewerAdapter
.
setOnTextChangedListener
(
null
)
;
skipOnTextChanges
=
true
;
editView
.
setText
(
""
);
chatViewerAdapter
.
setOnTextChangedListener
(
this
)
;
skipOnTextChanges
=
false
;
sendMessage
(
text
);
if
(
exitOnSend
)
close
();
...
...
src/com/xabber/android/ui/adapter/ChatViewerAdapter.java
View file @
5c67deb8
...
...
@@ -22,7 +22,6 @@ import android.text.Editable;
import
android.text.TextWatcher
;
import
android.view.View
;
import
android.view.View.OnClickListener
;
import
android.view.View.OnCreateContextMenuListener
;
import
android.view.View.OnKeyListener
;
import
android.view.ViewGroup
;
import
android.view.animation.Animation
;
...
...
@@ -74,35 +73,12 @@ public class ChatViewerAdapter extends BaseAdapter implements SaveStateAdapter,
private
ArrayList
<
AbstractChat
>
activeChats
;
/**
* Listener for click on title bar and send button.
*/
private
OnClickListener
onClickListener
;
/**
* Listener for key press in edit view.
*/
private
OnKeyListener
onKeyListener
;
/**
* Listener for actions in edit view.
*/
private
OnEditorActionListener
onEditorActionListener
;
/**
* Listener for context menu in message list.
*/
private
OnCreateContextMenuListener
onCreateContextMenuListener
;
/**
* Listen for text to be changed.
*/
private
OnTextChangedListener
onTextChangedListener
;
private
final
AbstractAvatarInflaterHelper
avatarInflaterHelper
;
private
final
Animation
shake
;
private
boolean
skipOnTextChanges
;
public
ChatViewerAdapter
(
Activity
activity
,
String
account
,
String
user
)
{
this
.
activity
=
activity
;
avatarInflaterHelper
=
AbstractAvatarInflaterHelper
...
...
@@ -116,58 +92,10 @@ public class ChatViewerAdapter extends BaseAdapter implements SaveStateAdapter,
intentPosition
=
-
1
;
else
intentPosition
=
activeChats
.
size
();
onClickListener
=
null
;
onKeyListener
=
null
;
onEditorActionListener
=
null
;
onCreateContextMenuListener
=
null
;
onTextChangedListener
=
null
;
shake
=
AnimationUtils
.
loadAnimation
(
activity
,
R
.
anim
.
shake
);
onChange
();
}
public
OnClickListener
getOnClickListener
()
{
return
onClickListener
;
}
public
void
setOnClickListener
(
OnClickListener
onClickListener
)
{
this
.
onClickListener
=
onClickListener
;
}
public
OnKeyListener
getOnKeyListener
()
{
return
onKeyListener
;
}
public
void
setOnKeyListener
(
OnKeyListener
onKeyListener
)
{
this
.
onKeyListener
=
onKeyListener
;
}
public
OnEditorActionListener
getOnEditorActionListener
()
{
return
onEditorActionListener
;
}
public
void
setOnEditorActionListener
(
OnEditorActionListener
onEditorActionListener
)
{
this
.
onEditorActionListener
=
onEditorActionListener
;
}
public
OnCreateContextMenuListener
getOnCreateContextMenuListener
()
{
return
onCreateContextMenuListener
;
}
public
void
setOnCreateContextMenuListener
(
OnCreateContextMenuListener
onCreateContextMenuListener
)
{
this
.
onCreateContextMenuListener
=
onCreateContextMenuListener
;
}
public
OnTextChangedListener
getOnTextChangedListener
()
{
return
onTextChangedListener
;
}
public
void
setOnTextChangedListener
(
OnTextChangedListener
onTextChangedListener
)
{
this
.
onTextChangedListener
=
onTextChangedListener
;
}
@Override
public
int
getCount
()
{
return
activeChats
.
size
();
...
...
@@ -195,11 +123,11 @@ public class ChatViewerAdapter extends BaseAdapter implements SaveStateAdapter,
activity
);
chatViewHolder
=
new
ChatViewHolder
(
view
,
chatMessageAdapter
);
chatViewHolder
.
list
.
setAdapter
(
chatViewHolder
.
chatMessageAdapter
);
chatViewHolder
.
send
.
setOnClickListener
(
onClickListener
);
chatViewHolder
.
title
.
setOnClickListener
(
onClickListener
);
chatViewHolder
.
input
.
setOnKeyListener
(
onKeyListener
);
chatViewHolder
.
send
.
setOnClickListener
(
(
OnClickListener
)
activity
);
chatViewHolder
.
title
.
setOnClickListener
(
(
OnClickListener
)
activity
);
chatViewHolder
.
input
.
setOnKeyListener
(
(
OnKeyListener
)
activity
);
chatViewHolder
.
input
.
setOnEditorActionListener
(
onEditorActionListener
);
.
setOnEditorActionListener
(
(
OnEditorActionListener
)
activity
);
chatViewHolder
.
input
.
addTextChangedListener
(
new
TextWatcher
()
{
@Override
...
...
@@ -214,14 +142,14 @@ public class ChatViewerAdapter extends BaseAdapter implements SaveStateAdapter,
@Override
public
void
afterTextChanged
(
Editable
s
)
{
if
(
onTextChangedListener
!=
null
)
onTextChangedListener
.
onTextChanged
(
chatViewHolder
.
input
,
s
);
if
(
skipOnTextChanges
)
return
;
((
OnTextChangedListener
)
activity
).
onTextChanged
(
chatViewHolder
.
input
,
s
);
}
});
chatViewHolder
.
list
.
setOnCreateContextMenuListener
(
onCreateContextMenuListener
);
chatViewHolder
.
list
.
setOnCreateContextMenuListener
(
activity
);
view
.
setTag
(
chatViewHolder
);
}
else
{
view
=
convertView
;
...
...
@@ -243,21 +171,21 @@ public class ChatViewerAdapter extends BaseAdapter implements SaveStateAdapter,
LogManager
.
i
(
this
,
"Load "
+
view
+
" for "
+
chatViewHolder
.
chatMessageAdapter
.
getUser
()
+
" in "
+
chatViewHolder
.
chatMessageAdapter
.
getAccount
());
OnTextChangedListener
temp
=
onTextChangedListener
;
onTextChangedListener
=
null
;
skipOnTextChanges
=
true
;
chatViewHolder
.
input
.
setText
(
ChatManager
.
getInstance
()
.
getTypedMessage
(
account
,
user
));
chatViewHolder
.
input
.
setSelection
(
ChatManager
.
getInstance
()
.
getSelectionStart
(
account
,
user
),
ChatManager
.
getInstance
().
getSelectionEnd
(
account
,
user
));
onTextChangedListener
=
temp
;
skipOnTextChanges
=
false
;
chatViewHolder
.
chatMessageAdapter
.
setChat
(
account
,
user
);
chatViewHolder
.
list
.
setAdapter
(
chatViewHolder
.
list
.
getAdapter
());
}
chatViewHolder
.
page
.
setText
(
activity
.
getString
(
R
.
string
.
chat_page
,
position
+
1
,
getCount
()));
ContactTitleInflater
.
updateTitle
(
chatViewHolder
.
title
,
activity
,
abstractContact
);
ContactTitleInflater
.
updateTitle
(
chatViewHolder
.
title
,
activity
,
abstractContact
);
avatarInflaterHelper
.
updateAvatar
(
chatViewHolder
.
avatar
,
abstractContact
);
SecurityLevel
securityLevel
=
OTRManager
.
getInstance
()
...
...
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