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
3871a0d0
Commit
3871a0d0
authored
Feb 09, 2015
by
Grigory Fedorov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Recent chats fragment update implemented.
parent
23408a81
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
8 deletions
+40
-8
ChatViewer.java
app/src/main/java/com/xabber/android/ui/ChatViewer.java
+19
-8
RecentChatFragment.java
...c/main/java/com/xabber/android/ui/RecentChatFragment.java
+17
-0
ChatViewerAdapter.java
...java/com/xabber/android/ui/adapter/ChatViewerAdapter.java
+4
-0
No files found.
app/src/main/java/com/xabber/android/ui/ChatViewer.java
View file @
3871a0d0
...
@@ -22,7 +22,6 @@ import android.support.v4.view.ViewPager;
...
@@ -22,7 +22,6 @@ import android.support.v4.view.ViewPager;
import
com.xabber.android.data.ActivityManager
;
import
com.xabber.android.data.ActivityManager
;
import
com.xabber.android.data.Application
;
import
com.xabber.android.data.Application
;
import
com.xabber.android.data.LogManager
;
import
com.xabber.android.data.account.OnAccountChangedListener
;
import
com.xabber.android.data.account.OnAccountChangedListener
;
import
com.xabber.android.data.entity.BaseEntity
;
import
com.xabber.android.data.entity.BaseEntity
;
import
com.xabber.android.data.extension.archive.MessageArchiveManager
;
import
com.xabber.android.data.extension.archive.MessageArchiveManager
;
...
@@ -71,6 +70,7 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
...
@@ -71,6 +70,7 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
ViewPager
viewPager
;
ViewPager
viewPager
;
Collection
<
ChatViewerFragment
>
registeredChats
=
new
HashSet
<>();
Collection
<
ChatViewerFragment
>
registeredChats
=
new
HashSet
<>();
Collection
<
RecentChatFragment
>
recentChatFragments
=
new
HashSet
<>();
private
String
actionWithAccount
=
null
;
private
String
actionWithAccount
=
null
;
private
String
actionWithUser
=
null
;
private
String
actionWithUser
=
null
;
...
@@ -167,8 +167,6 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
...
@@ -167,8 +167,6 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
return
;
return
;
}
}
LogManager
.
i
(
this
,
"onNewIntent account: "
+
account
+
", user: "
+
user
);
selectPage
(
account
,
user
,
false
);
selectPage
(
account
,
user
,
false
);
}
}
...
@@ -244,30 +242,29 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
...
@@ -244,30 +242,29 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
@Override
@Override
public
void
onChatChanged
(
final
String
account
,
final
String
user
,
public
void
onChatChanged
(
final
String
account
,
final
String
user
,
final
boolean
incoming
)
{
final
boolean
incoming
)
{
LogManager
.
i
(
this
,
"onChatChanged "
+
user
);
for
(
ChatViewerFragment
chat
:
registeredChats
)
{
for
(
ChatViewerFragment
chat
:
registeredChats
)
{
if
(
chat
.
isEqual
(
account
,
user
))
{
if
(
chat
.
isEqual
(
account
,
user
))
{
chat
.
updateChat
(
incoming
);
chat
.
updateChat
(
incoming
);
}
}
}
}
updateRegisteredRecentChatsFragments
();
}
}
@Override
@Override
public
void
onContactsChanged
(
Collection
<
BaseEntity
>
entities
)
{
public
void
onContactsChanged
(
Collection
<
BaseEntity
>
entities
)
{
LogManager
.
i
(
this
,
"onContactsChanged"
);
chatViewerAdapter
.
onChange
();
chatViewerAdapter
.
onChange
();
updateRegisteredChats
();
updateRegisteredChats
();
updateRegisteredRecentChatsFragments
();
}
}
@Override
@Override
public
void
onAccountsChanged
(
Collection
<
String
>
accounts
)
{
public
void
onAccountsChanged
(
Collection
<
String
>
accounts
)
{
LogManager
.
i
(
this
,
"onAccountsChanged"
);
chatViewerAdapter
.
onChange
();
chatViewerAdapter
.
onChange
();
updateRegisteredChats
();
updateRegisteredChats
();
updateRegisteredRecentChatsFragments
();
}
}
void
onSent
()
{
void
onSent
()
{
...
@@ -325,6 +322,12 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
...
@@ -325,6 +322,12 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
}
}
}
}
private
void
updateRegisteredRecentChatsFragments
()
{
for
(
RecentChatFragment
recentChatFragment
:
recentChatFragments
)
{
recentChatFragment
.
updateChats
(
chatViewerAdapter
.
getActiveChats
());
}
}
@Override
@Override
public
void
onPageScrollStateChanged
(
int
state
)
{
public
void
onPageScrollStateChanged
(
int
state
)
{
}
}
...
@@ -338,9 +341,17 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
...
@@ -338,9 +341,17 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
registeredChats
.
remove
(
chat
);
registeredChats
.
remove
(
chat
);
}
}
public
void
registerRecentChatsList
(
RecentChatFragment
recentChatFragment
)
{
recentChatFragments
.
add
(
recentChatFragment
);
}
public
void
unregisterRecentChatsList
(
RecentChatFragment
recentChatFragment
)
{
recentChatFragments
.
remove
(
recentChatFragment
);
}
@Override
@Override
public
void
onChatViewAdapterFinishUpdate
()
{
public
void
onChatViewAdapterFinishUpdate
()
{
LogManager
.
i
(
this
,
"onChatViewAdapterFinishUpdate position: user: "
+
actionWithUser
);
insertExtraText
();
insertExtraText
();
Fragment
currentFragment
=
chatViewerAdapter
.
getCurrentFragment
();
Fragment
currentFragment
=
chatViewerAdapter
.
getCurrentFragment
();
...
...
app/src/main/java/com/xabber/android/ui/RecentChatFragment.java
View file @
3871a0d0
...
@@ -73,6 +73,20 @@ public class RecentChatFragment extends ListFragment {
...
@@ -73,6 +73,20 @@ public class RecentChatFragment extends ListFragment {
return
inflater
.
inflate
(
R
.
layout
.
list
,
container
,
false
);
return
inflater
.
inflate
(
R
.
layout
.
list
,
container
,
false
);
}
}
@Override
public
void
onResume
()
{
super
.
onResume
();
((
ChatViewer
)
getActivity
()).
registerRecentChatsList
(
this
);
}
@Override
public
void
onPause
()
{
super
.
onPause
();
((
ChatViewer
)
getActivity
()).
unregisterRecentChatsList
(
this
);
}
@Override
@Override
public
void
onDetach
()
{
public
void
onDetach
()
{
listener
=
null
;
listener
=
null
;
...
@@ -93,4 +107,7 @@ public class RecentChatFragment extends ListFragment {
...
@@ -93,4 +107,7 @@ public class RecentChatFragment extends ListFragment {
public
void
onRecentChatSelected
(
AbstractChat
chat
);
public
void
onRecentChatSelected
(
AbstractChat
chat
);
}
}
public
void
updateChats
(
List
<
AbstractChat
>
chats
)
{
((
ChatListAdapter
)
getListAdapter
()).
updateChats
(
chats
);
}
}
}
app/src/main/java/com/xabber/android/ui/adapter/ChatViewerAdapter.java
View file @
3871a0d0
...
@@ -152,4 +152,8 @@ public class ChatViewerAdapter extends FragmentStatePagerAdapter implements Upda
...
@@ -152,4 +152,8 @@ public class ChatViewerAdapter extends FragmentStatePagerAdapter implements Upda
public
Fragment
getCurrentFragment
()
{
public
Fragment
getCurrentFragment
()
{
return
currentFragment
;
return
currentFragment
;
}
}
public
ArrayList
<
AbstractChat
>
getActiveChats
()
{
return
activeChats
;
}
}
}
\ No newline at end of file
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