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
85852bcb
Commit
85852bcb
authored
May 29, 2013
by
Alexander Ivanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move chat viewer page into the fake fragment.
parent
5c67deb8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
261 additions
and
154 deletions
+261
-154
chat_viewer_container.xml
res/layout/chat_viewer_container.xml
+21
-0
ChatViewer.java
src/com/xabber/android/ui/ChatViewer.java
+8
-0
ChatViewerFragment.java
src/com/xabber/android/ui/ChatViewerFragment.java
+214
-0
ChatViewerAdapter.java
src/com/xabber/android/ui/adapter/ChatViewerAdapter.java
+18
-154
No files found.
res/layout/chat_viewer_container.xml
0 → 100644
View file @
85852bcb
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2013, Redsolution LTD. All rights reserved.
This file is part of Xabber project; you can redistribute it and/or
modify it under the terms of the GNU General Public License, Version 3.
Xabber is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License,
along with this program. If not, see http://www.gnu.org/licenses/.
-->
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:id=
"@+id/container"
android:orientation=
"vertical"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
src/com/xabber/android/ui/ChatViewer.java
View file @
85852bcb
...
@@ -735,6 +735,14 @@ public class ChatViewer extends ManagedActivity implements
...
@@ -735,6 +735,14 @@ public class ChatViewer extends ManagedActivity implements
return
false
;
return
false
;
}
}
public
int
getChatCount
()
{
return
chatViewerAdapter
.
getCount
();
}
public
int
getChatPosition
(
String
account
,
String
user
)
{
return
chatViewerAdapter
.
getPosition
(
account
,
user
);
}
public
static
Intent
createIntent
(
Context
context
,
String
account
,
public
static
Intent
createIntent
(
Context
context
,
String
account
,
String
user
)
{
String
user
)
{
return
new
EntityIntentBuilder
(
context
,
ChatViewer
.
class
)
return
new
EntityIntentBuilder
(
context
,
ChatViewer
.
class
)
...
...
src/com/xabber/android/ui/ChatViewerFragment.java
0 → 100644
View file @
85852bcb
package
com
.
xabber
.
android
.
ui
;
import
android.os.Bundle
;
import
android.support.v4.app.FragmentActivity
;
import
android.text.Editable
;
import
android.text.TextWatcher
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.View.OnClickListener
;
import
android.view.View.OnKeyListener
;
import
android.view.ViewGroup
;
import
android.view.animation.Animation
;
import
android.view.animation.AnimationUtils
;
import
android.widget.EditText
;
import
android.widget.ImageView
;
import
android.widget.ListView
;
import
android.widget.TextView
;
import
android.widget.TextView.OnEditorActionListener
;
import
com.xabber.android.data.LogManager
;
import
com.xabber.android.data.SettingsManager
;
import
com.xabber.android.data.SettingsManager.SecurityOtrMode
;
import
com.xabber.android.data.extension.otr.OTRManager
;
import
com.xabber.android.data.extension.otr.SecurityLevel
;
import
com.xabber.android.data.message.AbstractChat
;
import
com.xabber.android.data.message.chat.ChatManager
;
import
com.xabber.android.data.roster.AbstractContact
;
import
com.xabber.android.data.roster.RosterManager
;
import
com.xabber.android.ui.adapter.ChatMessageAdapter
;
import
com.xabber.android.ui.adapter.OnTextChangedListener
;
import
com.xabber.android.ui.helper.AbstractAvatarInflaterHelper
;
import
com.xabber.android.ui.helper.ContactTitleInflater
;
import
com.xabber.android.ui.widget.PageSwitcher
;
import
com.xabber.androiddev.R
;
public
class
ChatViewerFragment
{
private
AbstractAvatarInflaterHelper
avatarInflaterHelper
;
private
Animation
shake
;
private
boolean
skipOnTextChanges
;
private
ChatViewHolder
chatViewHolder
;
private
final
FragmentActivity
activity
;
private
final
View
view
;
public
ChatViewerFragment
(
FragmentActivity
activity
)
{
this
.
activity
=
activity
;
onCreate
(
null
);
view
=
onCreateView
(
activity
.
getLayoutInflater
(),
null
,
null
);
}
private
FragmentActivity
getActivity
()
{
return
activity
;
}
private
String
getString
(
int
resId
,
Object
...
formatArgs
)
{
return
activity
.
getString
(
resId
,
formatArgs
);
}
public
View
getView
()
{
return
view
;
}
public
void
onCreate
(
Bundle
savedInstanceState
)
{
// super.onCreate(savedInstanceState);
avatarInflaterHelper
=
AbstractAvatarInflaterHelper
.
createAbstractContactInflaterHelper
();
}
public
View
onCreateView
(
LayoutInflater
inflater
,
ViewGroup
container
,
Bundle
savedInstanceState
)
{
shake
=
AnimationUtils
.
loadAnimation
(
getActivity
(),
R
.
anim
.
shake
);
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
.
setOnEditorActionListener
((
OnEditorActionListener
)
getActivity
());
chatViewHolder
.
input
.
addTextChangedListener
(
new
TextWatcher
()
{
@Override
public
void
onTextChanged
(
CharSequence
s
,
int
start
,
int
before
,
int
count
)
{
}
@Override
public
void
beforeTextChanged
(
CharSequence
s
,
int
start
,
int
count
,
int
after
)
{
}
@Override
public
void
afterTextChanged
(
Editable
s
)
{
if
(
skipOnTextChanges
)
return
;
((
OnTextChangedListener
)
getActivity
()).
onTextChanged
(
chatViewHolder
.
input
,
s
);
}
});
chatViewHolder
.
list
.
setOnCreateContextMenuListener
(
getActivity
());
return
view
;
}
public
void
setChat
(
AbstractChat
chat
)
{
final
String
account
=
chat
.
getAccount
();
final
String
user
=
chat
.
getUser
();
final
AbstractContact
abstractContact
=
RosterManager
.
getInstance
()
.
getBestContact
(
account
,
user
);
if
(
chat
.
equals
(
chatViewHolder
.
chatMessageAdapter
.
getAccount
(),
chatViewHolder
.
chatMessageAdapter
.
getUser
()))
{
chatViewHolder
.
chatMessageAdapter
.
updateInfo
();
}
else
{
if
(
chatViewHolder
.
chatMessageAdapter
.
getAccount
()
!=
null
&&
chatViewHolder
.
chatMessageAdapter
.
getUser
()
!=
null
)
saveState
();
if
(
PageSwitcher
.
LOG
)
LogManager
.
i
(
this
,
"Load "
+
chatViewHolder
.
chatMessageAdapter
.
getUser
()
+
" in "
+
chatViewHolder
.
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
));
skipOnTextChanges
=
false
;
chatViewHolder
.
chatMessageAdapter
.
setChat
(
account
,
user
);
chatViewHolder
.
list
.
setAdapter
(
chatViewHolder
.
list
.
getAdapter
());
}
chatViewHolder
.
page
.
setText
(
getString
(
R
.
string
.
chat_page
,
((
ChatViewer
)
getActivity
()).
getChatPosition
(
account
,
user
)
+
1
,
((
ChatViewer
)
getActivity
())
.
getChatCount
()));
ContactTitleInflater
.
updateTitle
(
chatViewHolder
.
title
,
getActivity
(),
abstractContact
);
avatarInflaterHelper
.
updateAvatar
(
chatViewHolder
.
avatar
,
abstractContact
);
SecurityLevel
securityLevel
=
OTRManager
.
getInstance
()
.
getSecurityLevel
(
chat
.
getAccount
(),
chat
.
getUser
());
SecurityOtrMode
securityOtrMode
=
SettingsManager
.
securityOtrMode
();
if
(
securityLevel
==
SecurityLevel
.
plain
&&
(
securityOtrMode
==
SecurityOtrMode
.
disabled
||
securityOtrMode
==
SecurityOtrMode
.
manual
))
{
chatViewHolder
.
security
.
setVisibility
(
View
.
GONE
);
}
else
{
chatViewHolder
.
security
.
setVisibility
(
View
.
VISIBLE
);
chatViewHolder
.
security
.
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
());
}
public
void
onChatChange
(
boolean
incomingMessage
)
{
if
(
incomingMessage
)
chatViewHolder
.
nameHolder
.
startAnimation
(
shake
);
chatViewHolder
.
chatMessageAdapter
.
onChange
();
}
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
;
}
}
}
src/com/xabber/android/ui/adapter/ChatViewerAdapter.java
View file @
85852bcb
...
@@ -17,37 +17,15 @@ package com.xabber.android.ui.adapter;
...
@@ -17,37 +17,15 @@ package com.xabber.android.ui.adapter;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Collection
;
import
android.app.Activity
;
import
android.support.v4.app.FragmentActivity
;
import
android.text.Editable
;
import
android.text.TextWatcher
;
import
android.view.View
;
import
android.view.View
;
import
android.view.View.OnClickListener
;
import
android.view.View.OnKeyListener
;
import
android.view.ViewGroup
;
import
android.view.ViewGroup
;
import
android.view.animation.Animation
;
import
android.view.animation.AnimationUtils
;
import
android.widget.BaseAdapter
;
import
android.widget.BaseAdapter
;
import
android.widget.EditText
;
import
android.widget.ImageView
;
import
android.widget.ListView
;
import
android.widget.TextView
;
import
android.widget.TextView.OnEditorActionListener
;
import
com.xabber.android.data.LogManager
;
import
com.xabber.android.data.SettingsManager
;
import
com.xabber.android.data.SettingsManager.SecurityOtrMode
;
import
com.xabber.android.data.entity.BaseEntity
;
import
com.xabber.android.data.entity.BaseEntity
;
import
com.xabber.android.data.extension.otr.OTRManager
;
import
com.xabber.android.data.extension.otr.SecurityLevel
;
import
com.xabber.android.data.message.AbstractChat
;
import
com.xabber.android.data.message.AbstractChat
;
import
com.xabber.android.data.message.MessageManager
;
import
com.xabber.android.data.message.MessageManager
;
import
com.xabber.android.data.message.chat.ChatManager
;
import
com.xabber.android.ui.ChatViewerFragment
;
import
com.xabber.android.data.roster.AbstractContact
;
import
com.xabber.android.data.roster.RosterManager
;
import
com.xabber.android.ui.helper.AbstractAvatarInflaterHelper
;
import
com.xabber.android.ui.helper.ContactTitleInflater
;
import
com.xabber.android.ui.widget.PageSwitcher
;
import
com.xabber.androiddev.R
;
import
com.xabber.xmpp.address.Jid
;
import
com.xabber.xmpp.address.Jid
;
/**
/**
...
@@ -59,7 +37,7 @@ import com.xabber.xmpp.address.Jid;
...
@@ -59,7 +37,7 @@ import com.xabber.xmpp.address.Jid;
public
class
ChatViewerAdapter
extends
BaseAdapter
implements
SaveStateAdapter
,
public
class
ChatViewerAdapter
extends
BaseAdapter
implements
SaveStateAdapter
,
UpdatableAdapter
{
UpdatableAdapter
{
private
final
Activity
activity
;
private
final
Fragment
Activity
activity
;
/**
/**
* Intent sent while opening chat activity.
* Intent sent while opening chat activity.
...
@@ -73,16 +51,9 @@ public class ChatViewerAdapter extends BaseAdapter implements SaveStateAdapter,
...
@@ -73,16 +51,9 @@ public class ChatViewerAdapter extends BaseAdapter implements SaveStateAdapter,
private
ArrayList
<
AbstractChat
>
activeChats
;
private
ArrayList
<
AbstractChat
>
activeChats
;
private
final
AbstractAvatarInflaterHelper
avatarInflaterHelper
;
public
ChatViewerAdapter
(
FragmentActivity
activity
,
String
account
,
String
user
)
{
private
final
Animation
shake
;
private
boolean
skipOnTextChanges
;
public
ChatViewerAdapter
(
Activity
activity
,
String
account
,
String
user
)
{
this
.
activity
=
activity
;
this
.
activity
=
activity
;
avatarInflaterHelper
=
AbstractAvatarInflaterHelper
.
createAbstractContactInflaterHelper
();
activeChats
=
new
ArrayList
<
AbstractChat
>();
activeChats
=
new
ArrayList
<
AbstractChat
>();
intent
=
MessageManager
.
getInstance
().
getOrCreateChat
(
account
,
intent
=
MessageManager
.
getInstance
().
getOrCreateChat
(
account
,
Jid
.
getBareAddress
(
user
));
Jid
.
getBareAddress
(
user
));
...
@@ -92,7 +63,6 @@ public class ChatViewerAdapter extends BaseAdapter implements SaveStateAdapter,
...
@@ -92,7 +63,6 @@ public class ChatViewerAdapter extends BaseAdapter implements SaveStateAdapter,
intentPosition
=
-
1
;
intentPosition
=
-
1
;
else
else
intentPosition
=
activeChats
.
size
();
intentPosition
=
activeChats
.
size
();
shake
=
AnimationUtils
.
loadAnimation
(
activity
,
R
.
anim
.
shake
);
onChange
();
onChange
();
}
}
...
@@ -115,116 +85,29 @@ public class ChatViewerAdapter extends BaseAdapter implements SaveStateAdapter,
...
@@ -115,116 +85,29 @@ public class ChatViewerAdapter extends BaseAdapter implements SaveStateAdapter,
public
View
getView
(
int
position
,
View
convertView
,
ViewGroup
parent
)
{
public
View
getView
(
int
position
,
View
convertView
,
ViewGroup
parent
)
{
View
view
;
View
view
;
final
AbstractChat
chat
=
(
AbstractChat
)
getItem
(
position
);
final
AbstractChat
chat
=
(
AbstractChat
)
getItem
(
position
);
final
ChatViewHolder
chatViewHolder
;
ChatViewerFragment
fragment
;
if
(
convertView
==
null
)
{
if
(
convertView
==
null
)
{
view
=
activity
.
getLayoutInflater
().
inflate
(
fragment
=
new
ChatViewerFragment
(
activity
);
R
.
layout
.
chat_viewer_item
,
parent
,
false
);
view
=
fragment
.
getView
();
ChatMessageAdapter
chatMessageAdapter
=
new
ChatMessageAdapter
(
view
.
setTag
(
fragment
);
activity
);
chatViewHolder
=
new
ChatViewHolder
(
view
,
chatMessageAdapter
);
chatViewHolder
.
list
.
setAdapter
(
chatViewHolder
.
chatMessageAdapter
);
chatViewHolder
.
send
.
setOnClickListener
((
OnClickListener
)
activity
);
chatViewHolder
.
title
.
setOnClickListener
((
OnClickListener
)
activity
);
chatViewHolder
.
input
.
setOnKeyListener
((
OnKeyListener
)
activity
);
chatViewHolder
.
input
.
setOnEditorActionListener
((
OnEditorActionListener
)
activity
);
chatViewHolder
.
input
.
addTextChangedListener
(
new
TextWatcher
()
{
@Override
public
void
onTextChanged
(
CharSequence
s
,
int
start
,
int
before
,
int
count
)
{
}
@Override
public
void
beforeTextChanged
(
CharSequence
s
,
int
start
,
int
count
,
int
after
)
{
}
@Override
public
void
afterTextChanged
(
Editable
s
)
{
if
(
skipOnTextChanges
)
return
;
((
OnTextChangedListener
)
activity
).
onTextChanged
(
chatViewHolder
.
input
,
s
);
}
});
chatViewHolder
.
list
.
setOnCreateContextMenuListener
(
activity
);
view
.
setTag
(
chatViewHolder
);
}
else
{
}
else
{
view
=
convertView
;
view
=
convertView
;
chatViewHolder
=
(
ChatViewHolder
)
view
.
getTag
();
fragment
=
(
ChatViewerFragment
)
view
.
getTag
();
}
final
String
account
=
chat
.
getAccount
();
final
String
user
=
chat
.
getUser
();
final
AbstractContact
abstractContact
=
RosterManager
.
getInstance
()
.
getBestContact
(
account
,
user
);
if
(
chat
.
equals
(
chatViewHolder
.
chatMessageAdapter
.
getAccount
(),
chatViewHolder
.
chatMessageAdapter
.
getUser
()))
{
chatViewHolder
.
chatMessageAdapter
.
updateInfo
();
}
else
{
if
(
chatViewHolder
.
chatMessageAdapter
.
getAccount
()
!=
null
&&
chatViewHolder
.
chatMessageAdapter
.
getUser
()
!=
null
)
saveState
(
view
);
if
(
PageSwitcher
.
LOG
)
LogManager
.
i
(
this
,
"Load "
+
view
+
" for "
+
chatViewHolder
.
chatMessageAdapter
.
getUser
()
+
" in "
+
chatViewHolder
.
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
));
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
);
avatarInflaterHelper
.
updateAvatar
(
chatViewHolder
.
avatar
,
abstractContact
);
SecurityLevel
securityLevel
=
OTRManager
.
getInstance
()
.
getSecurityLevel
(
chat
.
getAccount
(),
chat
.
getUser
());
SecurityOtrMode
securityOtrMode
=
SettingsManager
.
securityOtrMode
();
if
(
securityLevel
==
SecurityLevel
.
plain
&&
(
securityOtrMode
==
SecurityOtrMode
.
disabled
||
securityOtrMode
==
SecurityOtrMode
.
manual
))
{
chatViewHolder
.
security
.
setVisibility
(
View
.
GONE
);
}
else
{
chatViewHolder
.
security
.
setVisibility
(
View
.
VISIBLE
);
chatViewHolder
.
security
.
setImageLevel
(
securityLevel
.
getImageLevel
());
}
}
fragment
.
setChat
(
chat
);
return
view
;
return
view
;
}
}
@Override
@Override
public
void
saveState
(
View
view
)
{
public
void
saveState
(
View
view
)
{
ChatViewHolder
chatViewHolder
=
(
ChatViewHolder
)
view
.
getTag
();
((
ChatViewerFragment
)
view
.
getTag
()).
saveState
();
if
(
PageSwitcher
.
LOG
)
LogManager
.
i
(
this
,
"Save "
+
view
+
" for "
+
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
());
}
}
/**
/**
* Must be called on changes in chat (message sent, received, etc.).
* Must be called on changes in chat (message sent, received, etc.).
*/
*/
public
void
onChatChange
(
View
view
,
boolean
incomingMessage
)
{
public
void
onChatChange
(
View
view
,
boolean
incomingMessage
)
{
ChatViewHolder
holder
=
(
ChatViewHolder
)
view
.
getTag
();
((
ChatViewerFragment
)
view
.
getTag
()).
onChatChange
(
incomingMessage
);
if
(
incomingMessage
)
holder
.
nameHolder
.
startAnimation
(
shake
);
holder
.
chatMessageAdapter
.
onChange
();
}
}
@Override
@Override
...
@@ -243,30 +126,11 @@ public class ChatViewerAdapter extends BaseAdapter implements SaveStateAdapter,
...
@@ -243,30 +126,11 @@ public class ChatViewerAdapter extends BaseAdapter implements SaveStateAdapter,
notifyDataSetChanged
();
notifyDataSetChanged
();
}
}
private
static
class
ChatViewHolder
{
public
int
getPosition
(
String
account
,
String
user
)
{
for
(
int
position
=
0
;
position
<
activeChats
.
size
();
position
++)
final
TextView
page
;
if
(
activeChats
.
get
(
position
).
equals
(
account
,
user
))
final
View
title
;
return
position
;
final
View
nameHolder
;
return
-
1
;
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