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
b29e71b5
Commit
b29e71b5
authored
Sep 22, 2017
by
Filipe de Lima Brito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update RoomListFragment.kt
parent
41bae5a7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
79 additions
and
45 deletions
+79
-45
RoomListFragment.kt
...rocket/android/fragment/chatroom/list/RoomListFragment.kt
+79
-45
No files found.
app/src/main/java/chat/rocket/android/fragment/chatroom/list/RoomListFragment.kt
View file @
b29e71b5
...
...
@@ -3,26 +3,23 @@ package chat.rocket.android.fragment.chatroom.list
import
android.os.Bundle
import
android.support.v4.app.Fragment
import
android.support.v7.widget.LinearLayoutManager
import
android.support.v7.widget.RecyclerView
import
android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
import
chat.rocket.android.R
import
chat.rocket.android.
layouthelper.chatroom.list.RoomFileListAdapt
er
import
chat.rocket.android.
helper.EndlessRecyclerViewScrollListen
er
import
chat.rocket.android.layouthelper.chatroom.list.RoomMemberListAdapter
import
chat.rocket.android.layouthelper.chatroom.list.RoomMessagesAdapter
import
chat.rocket.core.models.Message
import
chat.rocket.core.models.User
import
kotlinx.android.synthetic.main.fragment_room_list.*
import
java.util.*
/**
* Created by Filipe de Lima Brito (filipedelimabrito@gmail.com) on 9/22/17.
*/
class
RoomListFragment
:
Fragment
(),
RoomListContract
.
View
{
var
actionId
:
Int
=
0
lateinit
var
roomId
:
String
lateinit
var
roomType
:
String
lateinit
var
hostname
:
String
lateinit
var
token
:
String
lateinit
var
userId
:
String
lateinit
var
presenter
:
RoomListPresenter
var
isDataRequested
:
Boolean
=
false
companion
object
{
fun
newInstance
(
actionId
:
Int
,
...
...
@@ -48,6 +45,7 @@ class RoomListFragment : Fragment(), RoomListContract.View {
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
activity
.
title
=
""
actionId
=
arguments
.
getInt
(
"actionId"
)
roomId
=
arguments
.
getString
(
"roomId"
)
roomType
=
arguments
.
getString
(
"roomType"
)
...
...
@@ -66,28 +64,28 @@ class RoomListFragment : Fragment(), RoomListContract.View {
override
fun
onResume
()
{
super
.
onResume
()
if
(!
isDataRequested
)
{
requestData
()
requestData
(
0
)
isDataRequested
=
true
}
}
private
fun
requestData
()
{
private
fun
requestData
(
offset
:
Int
)
{
when
(
actionId
)
{
R
.
id
.
action_pinned_messages
->
{
activity
.
title
=
getString
(
R
.
string
.
fragment_room_list_pinned_message_title
)
presenter
.
requestPinnedMessages
(
roomId
,
roomType
,
hostname
,
token
,
userId
)
userId
,
offset
)
}
R
.
id
.
action_favorite_messages
->
{
activity
.
title
=
getString
(
R
.
string
.
fragment_room_list_favorite_message_title
)
presenter
.
requestFavoriteMessages
(
roomId
,
roomType
,
hostname
,
token
,
userId
)
userId
,
offset
)
}
// R.id.action_file_list -> {
// activity.title = getString(R.string.fragment_room_list_file_list_title)
...
...
@@ -98,60 +96,96 @@ class RoomListFragment : Fragment(), RoomListContract.View {
// userId)
// }
R
.
id
.
action_member_list
->
{
activity
.
title
=
getString
(
R
.
string
.
fragment_room_list_member_list_title
)
presenter
.
requestMemberList
(
roomId
,
roomType
,
hostname
,
token
,
userId
)
userId
,
offset
)
}
}
}
override
fun
showPinnedMessages
(
dataSet
:
ArrayList
<
Message
>)
{
waitingView
.
visibility
=
View
.
GONE
if
(
dataSet
.
isEmpty
())
{
showMessage
(
getString
(
R
.
string
.
fragment_room_list_no_pinned_message_to_show
))
}
else
{
override
fun
showPinnedMessages
(
dataSet
:
ArrayList
<
Message
>,
total
:
String
)
{
activity
.
title
=
getString
(
R
.
string
.
fragment_room_list_pinned_message_title
,
total
)
if
(
recyclerView
.
adapter
==
null
)
{
recyclerView
.
adapter
=
RoomMessagesAdapter
(
dataSet
,
hostname
,
context
)
recyclerView
.
layoutManager
=
LinearLayoutManager
(
context
,
LinearLayoutManager
.
VERTICAL
,
false
)
}
}
override
fun
showFavoriteMessages
(
dataSet
:
ArrayList
<
Message
>)
{
if
(
dataSet
.
isEmpty
())
{
showMessage
(
getString
(
R
.
string
.
fragment_room_list_no_favorite_message_to_show
))
val
linearLayoutManager
=
LinearLayoutManager
(
context
,
LinearLayoutManager
.
VERTICAL
,
false
)
recyclerView
.
layoutManager
=
linearLayoutManager
if
(
dataSet
.
size
>=
50
)
{
recyclerView
.
addOnScrollListener
(
object
:
EndlessRecyclerViewScrollListener
(
linearLayoutManager
)
{
override
fun
onLoadMore
(
page
:
Int
,
totalItemsCount
:
Int
,
recyclerView
:
RecyclerView
?)
{
loadNextDataFromApi
(
page
)
}
})
}
}
else
{
waitingView
.
visibility
=
View
.
GONE
recyclerView
.
adapter
=
RoomMessagesAdapter
(
dataSet
,
hostname
,
context
)
recyclerView
.
layoutManager
=
LinearLayoutManager
(
context
,
LinearLayoutManager
.
VERTICAL
,
false
)
(
recyclerView
.
adapter
as
RoomMessagesAdapter
).
setDataSet
(
dataSet
)
}
}
override
fun
showFileList
(
dataSet
:
ArrayList
<
String
>)
{
if
(
dataSet
.
isEmpty
())
{
showMessage
(
getString
(
R
.
string
.
fragment_room_list_no_file_list_to_show
))
override
fun
showFavoriteMessages
(
dataSet
:
ArrayList
<
Message
>,
total
:
String
)
{
activity
.
title
=
getString
(
R
.
string
.
fragment_room_list_favorite_message_title
,
total
)
if
(
recyclerView
.
adapter
==
null
)
{
recyclerView
.
adapter
=
RoomMessagesAdapter
(
dataSet
,
hostname
,
context
)
val
linearLayoutManager
=
LinearLayoutManager
(
context
,
LinearLayoutManager
.
VERTICAL
,
false
)
recyclerView
.
layoutManager
=
linearLayoutManager
if
(
dataSet
.
size
>=
50
)
{
recyclerView
.
addOnScrollListener
(
object
:
EndlessRecyclerViewScrollListener
(
linearLayoutManager
)
{
override
fun
onLoadMore
(
page
:
Int
,
totalItemsCount
:
Int
,
recyclerView
:
RecyclerView
?)
{
loadNextDataFromApi
(
page
)
}
})
}
}
else
{
waitingView
.
visibility
=
View
.
GONE
recyclerView
.
adapter
=
RoomFileListAdapter
(
dataSet
)
recyclerView
.
layoutManager
=
LinearLayoutManager
(
context
,
LinearLayoutManager
.
VERTICAL
,
false
)
(
recyclerView
.
adapter
as
RoomMessagesAdapter
).
setDataSet
(
dataSet
)
}
}
// TODO (after REST api fixes)
override
fun
showFileList
(
dataSet
:
ArrayList
<
String
>,
total
:
String
)
{}
override
fun
showMemberList
(
dataSet
:
ArrayList
<
User
>,
total
:
String
)
{
if
(
dataSet
.
isEmpty
())
{
showMessage
(
getString
(
R
.
string
.
fragment_room_list_no_member_list_to_show
))
}
else
{
waitingView
.
visibility
=
View
.
GONE
activity
.
title
=
getString
(
R
.
string
.
fragment_room_list_member_list_title
)
+
" ("
+
total
+
")"
activity
.
title
=
getString
(
R
.
string
.
fragment_room_list_member_list_title
,
total
)
if
(
recyclerView
.
adapter
==
null
)
{
recyclerView
.
adapter
=
RoomMemberListAdapter
(
dataSet
,
hostname
,
context
)
recyclerView
.
layoutManager
=
LinearLayoutManager
(
context
,
LinearLayoutManager
.
VERTICAL
,
false
)
val
linearLayoutManager
=
LinearLayoutManager
(
context
,
LinearLayoutManager
.
VERTICAL
,
false
)
recyclerView
.
layoutManager
=
linearLayoutManager
if
(
dataSet
.
size
>=
50
)
{
recyclerView
.
addOnScrollListener
(
object
:
EndlessRecyclerViewScrollListener
(
linearLayoutManager
)
{
override
fun
onLoadMore
(
page
:
Int
,
totalItemsCount
:
Int
,
recyclerView
:
RecyclerView
?)
{
loadNextDataFromApi
(
page
)
}
})
}
}
else
{
(
recyclerView
.
adapter
as
RoomMemberListAdapter
).
setDataSet
(
dataSet
)
}
}
override
fun
showMessage
(
message
:
String
)
{
waitingView
.
visibility
=
View
.
GONE
messageText
.
text
=
message
messageText
.
visibility
=
View
.
VISIBLE
}
override
fun
showWaitingView
(
shouldShow
:
Boolean
)
{
if
(
shouldShow
)
{
waitingView
.
visibility
=
View
.
VISIBLE
}
else
{
waitingView
.
visibility
=
View
.
GONE
}
}
private
fun
loadNextDataFromApi
(
page
:
Int
)
{
requestData
(
page
*
50
)
}
private
var
actionId
:
Int
=
0
private
lateinit
var
roomId
:
String
private
lateinit
var
roomType
:
String
private
lateinit
var
hostname
:
String
private
lateinit
var
token
:
String
private
lateinit
var
userId
:
String
private
lateinit
var
presenter
:
RoomListPresenter
private
var
isDataRequested
:
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