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
5c217510
Commit
5c217510
authored
Sep 20, 2017
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove all view before adding a new server to the list of signed in hosts
parent
4b84a8c8
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
17 deletions
+34
-17
MainActivity.java
.../main/java/chat/rocket/android/activity/MainActivity.java
+30
-14
SidebarMainFragment.java
.../rocket/android/fragment/sidebar/SidebarMainFragment.java
+3
-2
SidebarMainPresenter.java
...rocket/android/fragment/sidebar/SidebarMainPresenter.java
+1
-1
No files found.
app/src/main/java/chat/rocket/android/activity/MainActivity.java
View file @
5c217510
...
@@ -140,9 +140,20 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
...
@@ -140,9 +140,20 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
return
false
;
return
false
;
}
}
public
void
onLogout
()
{
public
void
onLogout
(
String
oldHost
)
{
onHostnameUpdated
();
onHostnameUpdated
();
onRoomIdUpdated
();
SlidingPaneLayout
subPane
=
(
SlidingPaneLayout
)
findViewById
(
R
.
id
.
sub_sliding_pane
);
if
(
subPane
!=
null
)
{
LinearLayout
serverListContainer
=
subPane
.
findViewById
(
R
.
id
.
server_list_bar
);
serverListContainer
.
post
(()
->
{
View
row
=
serverListContainer
.
findViewWithTag
(
oldHost
);
if
(
row
!=
null
)
{
serverListContainer
.
setLayoutTransition
(
null
);
serverListContainer
.
removeView
(
row
);
}
});
}
}
}
@DebugLog
@DebugLog
...
@@ -257,6 +268,7 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
...
@@ -257,6 +268,7 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
LinearLayout
serverListContainer
=
subPane
.
findViewById
(
R
.
id
.
server_list_bar
);
LinearLayout
serverListContainer
=
subPane
.
findViewById
(
R
.
id
.
server_list_bar
);
View
addServerButton
=
subPane
.
findViewById
(
R
.
id
.
btn_add_server
);
View
addServerButton
=
subPane
.
findViewById
(
R
.
id
.
btn_add_server
);
addServerButton
.
setOnClickListener
(
view
->
showAddServerActivity
());
addServerButton
.
setOnClickListener
(
view
->
showAddServerActivity
());
serverListContainer
.
removeAllViews
();
for
(
Pair
<
String
,
Pair
<
String
,
String
>>
server
:
serverList
)
{
for
(
Pair
<
String
,
Pair
<
String
,
String
>>
server
:
serverList
)
{
String
serverHostname
=
server
.
first
;
String
serverHostname
=
server
.
first
;
Pair
<
String
,
String
>
serverInfoPair
=
server
.
second
;
Pair
<
String
,
String
>
serverInfoPair
=
server
.
second
;
...
@@ -264,27 +276,30 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
...
@@ -264,27 +276,30 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
String
siteName
=
serverInfoPair
.
second
;
String
siteName
=
serverInfoPair
.
second
;
View
serverView
=
serverListContainer
.
findViewWithTag
(
serverHostname
);
View
serverView
=
serverListContainer
.
findViewWithTag
(
serverHostname
);
if
(
serverView
==
null
)
{
if
(
serverView
==
null
)
{
int
serverCount
=
serverListContainer
.
getChildCount
();
View
newServerView
=
LayoutInflater
.
from
(
this
).
inflate
(
R
.
layout
.
server_row
,
serverListContainer
,
false
);
SimpleDraweeView
serverButton
=
newServerView
.
findViewById
(
R
.
id
.
drawee_server_button
);
TextView
hostnameLabel
=
newServerView
.
findViewById
(
R
.
id
.
text_view_server_label
);
TextView
siteNameLabel
=
newServerView
.
findViewById
(
R
.
id
.
text_view_site_name_label
);
ImageView
dotView
=
newServerView
.
findViewById
(
R
.
id
.
selected_server_dot
);
View
serverRow
=
LayoutInflater
.
from
(
this
).
inflate
(
R
.
layout
.
server_row
,
serverListContainer
,
false
);
newServerView
.
setTag
(
serverHostname
);
SimpleDraweeView
serverButton
=
serverRow
.
findViewById
(
R
.
id
.
drawee_server_button
);
TextView
hostnameLabel
=
serverRow
.
findViewById
(
R
.
id
.
text_view_server_label
);
TextView
siteNameLabel
=
serverRow
.
findViewById
(
R
.
id
.
text_view_site_name_label
);
ImageView
dotView
=
serverRow
.
findViewById
(
R
.
id
.
selected_server_dot
);
serverRow
.
setTag
(
serverHostname
);
hostnameLabel
.
setText
(
serverHostname
);
hostnameLabel
.
setText
(
serverHostname
);
siteNameLabel
.
setText
(
siteName
);
siteNameLabel
.
setText
(
siteName
);
// Currently selected server
// Currently selected server
serverRow
.
setSelected
(
true
);
if
(
hostname
.
equalsIgnoreCase
(
serverHostname
))
{
newServerView
.
setSelected
(
true
);
dotView
.
setVisibility
(
View
.
VISIBLE
);
dotView
.
setVisibility
(
View
.
VISIBLE
);
}
else
{
newServerView
.
setSelected
(
false
);
dotView
.
setVisibility
(
View
.
GONE
);
}
serverRo
w
.
setOnClickListener
(
view
->
changeServerIfNeeded
(
serverHostname
));
newServerVie
w
.
setOnClickListener
(
view
->
changeServerIfNeeded
(
serverHostname
));
FrescoHelper
.
INSTANCE
.
loadImage
(
serverButton
,
logoUrl
,
ContextCompat
.
getDrawable
(
this
,
R
.
mipmap
.
ic_launcher
));
FrescoHelper
.
INSTANCE
.
loadImage
(
serverButton
,
logoUrl
,
ContextCompat
.
getDrawable
(
this
,
R
.
mipmap
.
ic_launcher
));
serverListContainer
.
addView
(
serverRow
,
serverCount
-
1
);
serverListContainer
.
addView
(
newServerView
);
}
else
{
}
else
{
View
dotView
=
serverView
.
findViewById
(
R
.
id
.
selected_server_dot
);
View
dotView
=
serverView
.
findViewById
(
R
.
id
.
selected_server_dot
);
if
(
hostname
.
equalsIgnoreCase
(
serverHostname
))
{
if
(
hostname
.
equalsIgnoreCase
(
serverHostname
))
{
...
@@ -296,6 +311,7 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
...
@@ -296,6 +311,7 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
}
}
}
}
}
}
serverListContainer
.
addView
(
addServerButton
);
}
}
}
}
...
...
app/src/main/java/chat/rocket/android/fragment/sidebar/SidebarMainFragment.java
View file @
5c217510
...
@@ -304,13 +304,14 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
...
@@ -304,13 +304,14 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
private
void
setupLogoutButton
()
{
private
void
setupLogoutButton
()
{
rootView
.
findViewById
(
R
.
id
.
btn_logout
).
setOnClickListener
(
view
->
{
rootView
.
findViewById
(
R
.
id
.
btn_logout
).
setOnClickListener
(
view
->
{
final
String
oldHost
=
hostname
;
presenter
.
onLogout
(
task
->
{
presenter
.
onLogout
(
task
->
{
if
(
task
.
isFaulted
())
{
if
(
task
.
isFaulted
())
{
return
Task
.
forError
(
task
.
getError
());
return
Task
.
forError
(
task
.
getError
());
}
}
// destroy Activity on logout to be able to recreate most of the environment
if
(
getActivity
()
instanceof
MainActivity
)
{
if
(
getActivity
()
instanceof
MainActivity
)
{
((
MainActivity
)
getActivity
()).
onLogout
();
((
MainActivity
)
getActivity
()).
onLogout
(
oldHost
);
}
}
return
null
;
return
null
;
});
});
...
...
app/src/main/java/chat/rocket/android/fragment/sidebar/SidebarMainPresenter.java
View file @
5c217510
...
@@ -139,7 +139,7 @@ public class SidebarMainPresenter extends BasePresenter<SidebarMainContract.View
...
@@ -139,7 +139,7 @@ public class SidebarMainPresenter extends BasePresenter<SidebarMainContract.View
Logger
.
report
(
task
.
getError
());
Logger
.
report
(
task
.
getError
());
return
Task
.
forError
(
task
.
getError
());
return
Task
.
forError
(
task
.
getError
());
}
}
return
task
.
continueWith
(
continuation
);
return
task
.
onSuccess
(
continuation
);
});
});
}
}
...
...
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