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
f3d9930c
Commit
f3d9930c
authored
Sep 25, 2017
by
Filipe de Lima Brito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update RoomListPresenter.kt
parent
f0b47aaf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
21 deletions
+28
-21
RoomListPresenter.kt
...ocket/android/fragment/chatroom/list/RoomListPresenter.kt
+28
-21
No files found.
app/src/main/java/chat/rocket/android/fragment/chatroom/list/RoomListPresenter.kt
View file @
f3d9930c
...
...
@@ -36,9 +36,11 @@ class RoomListPresenter(val context: Context, val view: RoomListContract.View) :
offset
.
toString
()))
.
enqueue
(
object
:
Callback
{
override
fun
onFailure
(
call
:
Call
,
e
:
IOException
)
{
val
message
=
e
.
message
if
(
message
!=
null
)
{
showErrorMessage
(
message
)
if
(!
call
.
isCanceled
)
{
val
message
=
e
.
message
if
(
message
!=
null
)
{
showErrorMessage
(
message
)
}
}
}
...
...
@@ -72,9 +74,11 @@ class RoomListPresenter(val context: Context, val view: RoomListContract.View) :
offset
.
toString
()))
.
enqueue
(
object
:
Callback
{
override
fun
onFailure
(
call
:
Call
,
e
:
IOException
)
{
val
message
=
e
.
message
if
(
message
!=
null
)
{
showErrorMessage
(
message
)
if
(!
call
.
isCanceled
)
{
val
message
=
e
.
message
if
(
message
!=
null
)
{
showErrorMessage
(
message
)
}
}
}
...
...
@@ -98,8 +102,7 @@ class RoomListPresenter(val context: Context, val view: RoomListContract.View) :
hostname
:
String
,
token
:
String
,
userId
:
String
,
offset
:
Int
)
{
}
offset
:
Int
)
{}
override
fun
requestMemberList
(
roomId
:
String
,
roomType
:
String
,
...
...
@@ -108,7 +111,6 @@ class RoomListPresenter(val context: Context, val view: RoomListContract.View) :
userId
:
String
,
offset
:
Int
)
{
view
.
showWaitingView
(
true
)
OkHttpHelper
.
getClient
()
.
newCall
(
RestApiHelper
.
getRequestForMemberList
(
roomId
,
roomType
,
...
...
@@ -118,9 +120,11 @@ class RoomListPresenter(val context: Context, val view: RoomListContract.View) :
offset
.
toString
()))
.
enqueue
(
object
:
Callback
{
override
fun
onFailure
(
call
:
Call
,
e
:
IOException
)
{
val
message
=
e
.
message
if
(
message
!=
null
)
{
showErrorMessage
(
message
)
if
(!
call
.
isCanceled
)
{
val
message
=
e
.
message
if
(
message
!=
null
)
{
showErrorMessage
(
message
)
}
}
}
...
...
@@ -138,6 +142,10 @@ class RoomListPresenter(val context: Context, val view: RoomListContract.View) :
})
}
override
fun
cancelRequest
()
{
OkHttpHelper
.
getClient
().
dispatcher
().
cancelAll
()
}
private
fun
handleMessagesJson
(
json
:
String
,
isPinnedMessage
:
Boolean
)
{
val
jSONObject
=
JSONObject
(
json
)
val
messagesJSONArray
=
jSONObject
.
getJSONArray
(
"messages"
)
...
...
@@ -174,15 +182,15 @@ class RoomListPresenter(val context: Context, val view: RoomListContract.View) :
.
build
()
}
if
(
dataSet
.
isEmpty
()
&&
previousMessageDataSet
.
isEmpty
()
)
{
if
(
dataSet
.
isEmpty
()
&&
!
hasItem
)
{
showEmptyViewMessage
(
context
.
getString
(
R
.
string
.
fragment_room_list_no_favorite_message_to_show
))
}
else
{
if
(
dataSet
.
isNotEmpty
())
{
previousMessageDataSet
+=
dataSet
hasItem
=
true
if
(
isPinnedMessage
)
{
showPinnedMessageList
(
previousMessageDataSet
as
ArrayList
<
Message
>
,
jSONObject
.
optString
(
"total"
))
showPinnedMessageList
(
dataSet
,
jSONObject
.
optString
(
"total"
))
}
else
{
showFavoriteMessageList
(
previousMessageDataSet
as
ArrayList
<
Message
>
,
jSONObject
.
optString
(
"total"
))
showFavoriteMessageList
(
dataSet
,
jSONObject
.
optString
(
"total"
))
}
}
}
...
...
@@ -198,12 +206,12 @@ class RoomListPresenter(val context: Context, val view: RoomListContract.View) :
getUserFromJsonObject
(
membersJsonArray
.
getJSONObject
(
it
))
}
if
(
dataSet
.
isEmpty
()
&&
previousUserDataSet
.
isEmpty
()
)
{
if
(
dataSet
.
isEmpty
()
&&
!
hasItem
)
{
showEmptyViewMessage
(
context
.
getString
(
R
.
string
.
fragment_room_list_no_member_list_to_show
))
}
else
{
if
(
dataSet
.
isNotEmpty
())
{
previousUserDataSet
+=
dataSet
showMemberList
(
previousUserDataSet
as
ArrayList
<
User
>
,
jsonObject
.
optString
(
"total"
))
hasItem
=
true
showMemberList
(
dataSet
,
jsonObject
.
optString
(
"total"
))
}
}
}
...
...
@@ -254,6 +262,5 @@ class RoomListPresenter(val context: Context, val view: RoomListContract.View) :
}
private
val
mainHandler
=
Handler
(
context
.
mainLooper
)
private
var
previousMessageDataSet
=
emptyList
<
Message
>()
private
var
previousUserDataSet
=
emptyList
<
User
>()
private
var
hasItem
:
Boolean
=
false
}
\ 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