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
fd970766
Commit
fd970766
authored
Apr 16, 2018
by
Lucio Maciel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix crash on ProfileFragment
parent
eb73cd48
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
27 deletions
+43
-27
ProfilePresenter.kt
...t/rocket/android/profile/presentation/ProfilePresenter.kt
+2
-5
ProfileFragment.kt
...in/java/chat/rocket/android/profile/ui/ProfileFragment.kt
+41
-22
No files found.
app/src/main/java/chat/rocket/android/profile/presentation/ProfilePresenter.kt
View file @
fd970766
package
chat.rocket.android.profile.presentation
package
chat.rocket.android.profile.presentation
import
chat.rocket.android.core.behaviours.showMessage
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.server.domain.GetCurrentServerInteractor
import
chat.rocket.android.server.domain.GetCurrentServerInteractor
import
chat.rocket.android.server.infraestructure.RocketChatClientFactory
import
chat.rocket.android.server.infraestructure.RocketChatClientFactory
...
@@ -36,11 +37,7 @@ class ProfilePresenter @Inject constructor(private val view: ProfileView,
...
@@ -36,11 +37,7 @@ class ProfilePresenter @Inject constructor(private val view: ProfileView,
myself
.
emails
?.
get
(
0
)
?.
address
!!
myself
.
emails
?.
get
(
0
)
?.
address
!!
)
)
}
catch
(
exception
:
RocketChatException
)
{
}
catch
(
exception
:
RocketChatException
)
{
exception
.
message
?.
let
{
view
.
showMessage
(
exception
)
view
.
showMessage
(
it
)
}.
ifNull
{
view
.
showGenericErrorMessage
()
}
}
finally
{
}
finally
{
view
.
hideLoading
()
view
.
hideLoading
()
}
}
...
...
app/src/main/java/chat/rocket/android/profile/ui/ProfileFragment.kt
View file @
fd970766
...
@@ -12,6 +12,7 @@ import chat.rocket.android.profile.presentation.ProfilePresenter
...
@@ -12,6 +12,7 @@ import chat.rocket.android.profile.presentation.ProfilePresenter
import
chat.rocket.android.profile.presentation.ProfileView
import
chat.rocket.android.profile.presentation.ProfileView
import
chat.rocket.android.util.extensions.*
import
chat.rocket.android.util.extensions.*
import
dagger.android.support.AndroidSupportInjection
import
dagger.android.support.AndroidSupportInjection
import
io.reactivex.disposables.CompositeDisposable
import
io.reactivex.rxkotlin.Observables
import
io.reactivex.rxkotlin.Observables
import
kotlinx.android.synthetic.main.app_bar.*
import
kotlinx.android.synthetic.main.app_bar.*
import
kotlinx.android.synthetic.main.avatar_profile.*
import
kotlinx.android.synthetic.main.avatar_profile.*
...
@@ -25,6 +26,7 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
...
@@ -25,6 +26,7 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
private
lateinit
var
currentEmail
:
String
private
lateinit
var
currentEmail
:
String
private
lateinit
var
currentAvatar
:
String
private
lateinit
var
currentAvatar
:
String
private
var
actionMode
:
ActionMode
?
=
null
private
var
actionMode
:
ActionMode
?
=
null
private
val
disposables
=
CompositeDisposable
()
companion
object
{
companion
object
{
fun
newInstance
()
=
ProfileFragment
()
fun
newInstance
()
=
ProfileFragment
()
...
@@ -48,22 +50,29 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
...
@@ -48,22 +50,29 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
presenter
.
loadUserProfile
()
presenter
.
loadUserProfile
()
}
}
override
fun
onDestroyView
()
{
disposables
.
clear
()
super
.
onDestroyView
()
}
override
fun
showProfile
(
avatarUrl
:
String
,
name
:
String
,
username
:
String
,
email
:
String
)
{
override
fun
showProfile
(
avatarUrl
:
String
,
name
:
String
,
username
:
String
,
email
:
String
)
{
image_avatar
.
setImageURI
(
avatarUrl
)
ui
{
image_avatar
.
setImageURI
(
avatarUrl
)
text_name
.
textContent
=
name
text_name
.
textContent
=
name
text_username
.
textContent
=
username
text_username
.
textContent
=
username
text_email
.
textContent
=
email
text_email
.
textContent
=
email
text_avatar_url
.
textContent
=
""
text_avatar_url
.
textContent
=
""
currentName
=
name
currentName
=
name
currentUsername
=
username
currentUsername
=
username
currentEmail
=
email
currentEmail
=
email
currentAvatar
=
avatarUrl
currentAvatar
=
avatarUrl
profile_container
.
setVisible
(
true
)
profile_container
.
setVisible
(
true
)
listenToChanges
()
listenToChanges
()
}
}
}
override
fun
showProfileUpdateSuccessfullyMessage
()
{
override
fun
showProfileUpdateSuccessfullyMessage
()
{
...
@@ -72,22 +81,30 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
...
@@ -72,22 +81,30 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
override
fun
showLoading
()
{
override
fun
showLoading
()
{
enableUserInput
(
false
)
enableUserInput
(
false
)
view_loading
.
setVisible
(
true
)
ui
{
view_loading
.
setVisible
(
true
)
}
}
}
override
fun
hideLoading
()
{
override
fun
hideLoading
()
{
if
(
view_loading
!=
null
)
{
ui
{
view_loading
.
setVisible
(
false
)
if
(
view_loading
!=
null
)
{
view_loading
.
setVisible
(
false
)
}
}
}
enableUserInput
(
true
)
enableUserInput
(
true
)
}
}
override
fun
showMessage
(
resId
:
Int
)
{
override
fun
showMessage
(
resId
:
Int
)
{
showToast
(
resId
)
ui
{
showToast
(
resId
)
}
}
}
override
fun
showMessage
(
message
:
String
)
{
override
fun
showMessage
(
message
:
String
)
{
showToast
(
message
)
ui
{
showToast
(
message
)
}
}
}
override
fun
showGenericErrorMessage
()
=
showMessage
(
getString
(
R
.
string
.
msg_generic_error
))
override
fun
showGenericErrorMessage
()
=
showMessage
(
getString
(
R
.
string
.
msg_generic_error
))
...
@@ -136,7 +153,7 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
...
@@ -136,7 +153,7 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
}
}
private
fun
listenToChanges
()
{
private
fun
listenToChanges
()
{
Observables
.
combineLatest
(
text_name
.
asObservable
(),
disposables
.
add
(
Observables
.
combineLatest
(
text_name
.
asObservable
(),
text_username
.
asObservable
(),
text_username
.
asObservable
(),
text_email
.
asObservable
(),
text_email
.
asObservable
(),
text_avatar_url
.
asObservable
())
{
text_name
,
text_username
,
text_email
,
text_avatar_url
->
text_avatar_url
.
asObservable
())
{
text_name
,
text_username
,
text_email
,
text_avatar_url
->
...
@@ -144,7 +161,7 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
...
@@ -144,7 +161,7 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
text_username
.
toString
()
!=
currentUsername
||
text_username
.
toString
()
!=
currentUsername
||
text_email
.
toString
()
!=
currentEmail
||
text_email
.
toString
()
!=
currentEmail
||
(
text_avatar_url
.
toString
()
!=
""
&&
text_avatar_url
.
toString
()
!=
currentAvatar
))
(
text_avatar_url
.
toString
()
!=
""
&&
text_avatar_url
.
toString
()
!=
currentAvatar
))
}.
subscribe
(
{
isValid
->
}.
subscribe
{
isValid
->
if
(
isValid
)
{
if
(
isValid
)
{
startActionMode
()
startActionMode
()
}
else
{
}
else
{
...
@@ -162,9 +179,11 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
...
@@ -162,9 +179,11 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
private
fun
finishActionMode
()
=
actionMode
?.
finish
()
private
fun
finishActionMode
()
=
actionMode
?.
finish
()
private
fun
enableUserInput
(
value
:
Boolean
)
{
private
fun
enableUserInput
(
value
:
Boolean
)
{
text_username
.
isEnabled
=
value
ui
{
text_username
.
isEnabled
=
value
text_username
.
isEnabled
=
value
text_email
.
isEnabled
=
value
text_username
.
isEnabled
=
value
text_avatar_url
.
isEnabled
=
value
text_email
.
isEnabled
=
value
text_avatar_url
.
isEnabled
=
value
}
}
}
}
}
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