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
ac4f99d5
Commit
ac4f99d5
authored
Aug 30, 2017
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement add new server and switching between them
parent
293d6225
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
0 deletions
+49
-0
MainActivity.java
.../main/java/chat/rocket/android/activity/MainActivity.java
+48
-0
sidebar.xml
app/src/main/res/layout/sidebar.xml
+1
-0
No files found.
app/src/main/java/chat/rocket/android/activity/MainActivity.java
View file @
ac4f99d5
package
chat
.
rocket
.
android
.
activity
;
import
android.content.Intent
;
import
android.graphics.drawable.Drawable
;
import
android.os.Bundle
;
import
android.support.annotation.Nullable
;
import
android.support.design.widget.Snackbar
;
import
android.support.v4.widget.SlidingPaneLayout
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.widget.Button
;
import
android.widget.LinearLayout
;
import
com.facebook.drawee.backends.pipeline.Fresco
;
import
com.facebook.drawee.view.SimpleDraweeView
;
import
chat.rocket.android.LaunchUtil
;
import
chat.rocket.android.R
;
...
...
@@ -18,6 +24,7 @@ import chat.rocket.android.fragment.sidebar.SidebarMainFragment;
import
chat.rocket.android.helper.KeyboardHelper
;
import
chat.rocket.android.service.ConnectivityManager
;
import
chat.rocket.android.widget.RoomToolbar
;
import
chat.rocket.android.widget.helper.UserAvatarHelper
;
import
chat.rocket.core.interactors.CanCreateRoomInteractor
;
import
chat.rocket.core.interactors.RoomInteractor
;
import
chat.rocket.core.interactors.SessionInteractor
;
...
...
@@ -109,6 +116,8 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
closeUserActionContainer
();
}
});
updateServerListBar
();
}
private
void
showAddServerActivity
()
{
...
...
@@ -147,6 +156,7 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
new
RealmSessionRepository
(
hostname
)
);
presenter
=
new
MainPresenter
(
roomInteractor
,
createRoomInteractor
,
...
...
@@ -161,6 +171,44 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
presenter
.
bindView
(
this
);
}
@DebugLog
private
void
updateServerListBar
()
{
final
SlidingPaneLayout
subPane
=
(
SlidingPaneLayout
)
findViewById
(
R
.
id
.
sub_sliding_pane
);
if
(
subPane
!=
null
)
{
RocketChatCache
rocketChatCache
=
new
RocketChatCache
(
getApplicationContext
());
//TODO: get the server avatar uri and set
rocketChatCache
.
addHostname
(
hostname
,
null
);
LinearLayout
serverListContainer
=
subPane
.
findViewById
(
R
.
id
.
server_list_bar
);
for
(
String
serverHostname
:
rocketChatCache
.
getServerList
())
{
if
(
serverListContainer
.
findViewWithTag
(
serverHostname
)
==
null
)
{
int
serverCount
=
serverListContainer
.
getChildCount
();
SimpleDraweeView
serverButton
=
(
SimpleDraweeView
)
LayoutInflater
.
from
(
this
).
inflate
(
R
.
layout
.
server_button
,
serverListContainer
,
false
);
serverButton
.
setTag
(
serverHostname
);
serverButton
.
setOnClickListener
(
view
->
changeServerIfNeeded
(
serverHostname
));
Drawable
drawable
=
UserAvatarHelper
.
INSTANCE
.
getTextDrawable
(
serverHostname
,
this
);
serverButton
.
getHierarchy
().
setPlaceholderImage
(
drawable
);
serverButton
.
setController
(
Fresco
.
newDraweeControllerBuilder
().
setAutoPlayAnimations
(
true
).
build
());
serverListContainer
.
addView
(
serverButton
,
serverCount
-
1
);
serverListContainer
.
requestLayout
();
}
}
}
}
private
void
changeServerIfNeeded
(
String
serverHostname
)
{
if
(!
hostname
.
equalsIgnoreCase
(
serverHostname
))
{
RocketChatCache
rocketChatCache
=
new
RocketChatCache
(
getApplicationContext
());
rocketChatCache
.
setSelectedServerHostname
(
serverHostname
);
recreate
();
}
}
private
void
updateSidebarMainFragment
()
{
getSupportFragmentManager
().
beginTransaction
()
.
replace
(
R
.
id
.
sidebar_fragment_container
,
SidebarMainFragment
.
create
(
hostname
))
...
...
app/src/main/res/layout/sidebar.xml
View file @
ac4f99d5
...
...
@@ -13,6 +13,7 @@
android:background=
"?attr/colorPrimaryDark"
>
<LinearLayout
android:id=
"@+id/server_list_bar"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
>
...
...
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