Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AloqaIM-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
AloqaIM-Android
Commits
d0dc70b7
Commit
d0dc70b7
authored
Jan 14, 2017
by
Yusuke Iwaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implement unread count budge
parent
af2cdc34
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
1 deletion
+41
-1
MainActivity.java
.../main/java/chat/rocket/android/activity/MainActivity.java
+41
-0
AbstractChatRoomFragment.java
...t/android/fragment/chatroom/AbstractChatRoomFragment.java
+0
-1
No files found.
app/src/main/java/chat/rocket/android/activity/MainActivity.java
View file @
d0dc70b7
...
...
@@ -17,11 +17,14 @@ import chat.rocket.android.fragment.sidebar.SidebarMainFragment;
import
chat.rocket.android.helper.LogcatIfError
;
import
chat.rocket.android.helper.TextUtils
;
import
chat.rocket.android.model.ServerConfig
;
import
chat.rocket.android.model.ddp.RoomSubscription
;
import
chat.rocket.android.model.ddp.User
;
import
chat.rocket.android.model.internal.Session
;
import
chat.rocket.android.realm_helper.RealmHelper
;
import
chat.rocket.android.realm_helper.RealmListObserver
;
import
chat.rocket.android.realm_helper.RealmObjectObserver
;
import
chat.rocket.android.realm_helper.RealmStore
;
import
chat.rocket.android.widget.RoomToolbar
;
import
hugo.weaving.DebugLog
;
/**
...
...
@@ -30,6 +33,7 @@ import hugo.weaving.DebugLog;
public
class
MainActivity
extends
AbstractAuthedActivity
{
private
RealmObjectObserver
<
Session
>
sessionObserver
;
private
RealmListObserver
<
RoomSubscription
>
unreadRoomSubscriptionObserver
;
private
boolean
isForeground
;
private
StatusTicker
statusTicker
;
...
...
@@ -150,6 +154,7 @@ public class MainActivity extends AbstractAuthedActivity {
protected
void
onServerConfigIdUpdated
()
{
super
.
onServerConfigIdUpdated
();
updateSessionObserver
();
updateUnreadRoomSubscriptionObserver
();
updateSidebarMainFragment
();
}
...
...
@@ -207,6 +212,38 @@ public class MainActivity extends AbstractAuthedActivity {
}
}
private
void
updateUnreadRoomSubscriptionObserver
()
{
if
(
unreadRoomSubscriptionObserver
!=
null
)
{
unreadRoomSubscriptionObserver
.
unsub
();
unreadRoomSubscriptionObserver
=
null
;
}
if
(
serverConfigId
==
null
)
{
return
;
}
RealmHelper
realmHelper
=
RealmStore
.
get
(
serverConfigId
);
if
(
realmHelper
==
null
)
{
return
;
}
unreadRoomSubscriptionObserver
=
realmHelper
.
createListObserver
(
realm
->
realm
.
where
(
RoomSubscription
.
class
)
.
equalTo
(
RoomSubscription
.
ALERT
,
true
)
.
equalTo
(
RoomSubscription
.
OPEN
,
true
)
.
findAll
())
.
setOnUpdateListener
(
results
->
updateRoomToolbarUnreadCount
(
results
.
size
()));
unreadRoomSubscriptionObserver
.
sub
();
}
private
void
updateRoomToolbarUnreadCount
(
int
unreadCount
)
{
RoomToolbar
toolbar
=
(
RoomToolbar
)
findViewById
(
R
.
id
.
activity_main_toolbar
);
if
(
toolbar
!=
null
)
{
toolbar
.
setUnreadBudge
(
unreadCount
);
}
}
private
void
updateSidebarMainFragment
()
{
getSupportFragmentManager
().
beginTransaction
()
.
replace
(
R
.
id
.
sidebar_fragment_container
,
SidebarMainFragment
.
create
(
serverConfigId
))
...
...
@@ -231,6 +268,10 @@ public class MainActivity extends AbstractAuthedActivity {
sessionObserver
.
unsub
();
sessionObserver
=
null
;
}
if
(
unreadRoomSubscriptionObserver
!=
null
)
{
unreadRoomSubscriptionObserver
.
unsub
();
unreadRoomSubscriptionObserver
=
null
;
}
super
.
onDestroy
();
}
...
...
app/src/main/java/chat/rocket/android/fragment/chatroom/AbstractChatRoomFragment.java
View file @
d0dc70b7
...
...
@@ -46,6 +46,5 @@ abstract class AbstractChatRoomFragment extends AbstractFragment {
}
roomToolbar
.
setRoomIcon
(
drawableResId
);
roomToolbar
.
setUnreadBudge
((
int
)
(
System
.
currentTimeMillis
()
%
15
));
//TODO: just example!
}
}
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