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
eac9af44
Commit
eac9af44
authored
Aug 09, 2017
by
Filipe de Lima Brito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update RoomListAdapter.java
parent
ab8de8ed
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
16 deletions
+15
-16
RoomListAdapter.java
...droid/layouthelper/chatroom/roomlist/RoomListAdapter.java
+15
-16
No files found.
app/src/main/java/chat/rocket/android/layouthelper/chatroom/roomlist/RoomListAdapter.java
View file @
eac9af44
...
@@ -5,6 +5,7 @@ import android.support.v7.widget.RecyclerView;
...
@@ -5,6 +5,7 @@ import android.support.v7.widget.RecyclerView;
import
android.view.LayoutInflater
;
import
android.view.LayoutInflater
;
import
android.view.ViewGroup
;
import
android.view.ViewGroup
;
import
chat.rocket.core.models.Spotlight
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
...
@@ -12,18 +13,17 @@ import java.util.Map;
...
@@ -12,18 +13,17 @@ import java.util.Map;
import
chat.rocket.android.R
;
import
chat.rocket.android.R
;
import
chat.rocket.android.widget.internal.RoomListItemView
;
import
chat.rocket.android.widget.internal.RoomListItemView
;
import
chat.rocket.core.models.Room
;
import
chat.rocket.core.models.Room
;
import
chat.rocket.core.models.SpotlightRoom
;
public
class
RoomListAdapter
extends
RecyclerView
.
Adapter
<
RecyclerView
.
ViewHolder
>
{
public
class
RoomListAdapter
extends
RecyclerView
.
Adapter
<
RecyclerView
.
ViewHolder
>
{
public
static
final
int
MODE_ROOM
=
0
;
public
static
final
int
MODE_ROOM
=
0
;
public
static
final
int
MODE_SPOTLIGHT
_ROOM
=
1
;
public
static
final
int
MODE_SPOTLIGHT
=
1
;
private
static
final
int
VIEW_TYPE_HEADER
=
0
;
private
static
final
int
VIEW_TYPE_HEADER
=
0
;
private
static
final
int
VIEW_TYPE_ROOM
=
1
;
private
static
final
int
VIEW_TYPE_ROOM
=
1
;
private
List
<
Room
>
roomList
=
Collections
.
emptyList
();
private
List
<
Room
>
roomList
=
Collections
.
emptyList
();
private
List
<
Spotlight
Room
>
spotlightRoom
List
=
Collections
.
emptyList
();
private
List
<
Spotlight
>
spotlight
List
=
Collections
.
emptyList
();
private
List
<
RoomListHeader
>
roomListHeaders
=
Collections
.
emptyList
();
private
List
<
RoomListHeader
>
roomListHeaders
=
Collections
.
emptyList
();
private
Map
<
Integer
,
RoomListHeader
>
headersPosition
=
new
HashMap
<>();
private
Map
<
Integer
,
RoomListHeader
>
headersPosition
=
new
HashMap
<>();
...
@@ -39,9 +39,9 @@ public class RoomListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
...
@@ -39,9 +39,9 @@ public class RoomListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
}
}
@Override
@Override
public
void
onItemClick
(
Spotlight
Room
spotlightRoom
)
{
public
void
onItemClick
(
Spotlight
spotlight
)
{
if
(
externalListener
!=
null
)
{
if
(
externalListener
!=
null
)
{
externalListener
.
onItemClick
(
spotlight
Room
);
externalListener
.
onItemClick
(
spotlight
);
}
}
}
}
};
};
...
@@ -56,8 +56,8 @@ public class RoomListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
...
@@ -56,8 +56,8 @@ public class RoomListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
updateRoomList
();
updateRoomList
();
}
}
public
void
setSpotlight
RoomList
(
@NonNull
List
<
SpotlightRoom
>
spotlightRoom
List
)
{
public
void
setSpotlight
List
(
@NonNull
List
<
Spotlight
>
spotlight
List
)
{
this
.
spotlight
RoomList
=
spotlightRoom
List
;
this
.
spotlight
List
=
spotlight
List
;
updateRoomList
();
updateRoomList
();
}
}
...
@@ -66,7 +66,7 @@ public class RoomListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
...
@@ -66,7 +66,7 @@ public class RoomListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
if
(
mode
==
MODE_ROOM
)
{
if
(
mode
==
MODE_ROOM
)
{
// clean up
// clean up
spotlight
Room
List
.
clear
();
spotlightList
.
clear
();
}
}
}
}
...
@@ -96,23 +96,22 @@ public class RoomListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
...
@@ -96,23 +96,22 @@ public class RoomListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
((
RoomListItemViewHolder
)
holder
)
((
RoomListItemViewHolder
)
holder
)
.
bind
(
roomList
.
get
(
position
-
getTotalHeadersBeforePosition
(
position
)));
.
bind
(
roomList
.
get
(
position
-
getTotalHeadersBeforePosition
(
position
)));
}
else
if
(
mode
==
MODE_SPOTLIGHT_ROOM
)
{
}
else
if
(
mode
==
MODE_SPOTLIGHT
)
{
((
RoomListItemViewHolder
)
holder
)
((
RoomListItemViewHolder
)
holder
).
bind
(
spotlightList
.
get
(
position
));
.
bind
(
spotlightRoomList
.
get
(
position
));
}
}
}
}
@Override
@Override
public
int
getItemCount
()
{
public
int
getItemCount
()
{
if
(
mode
==
MODE_SPOTLIGHT
_ROOM
)
{
if
(
mode
==
MODE_SPOTLIGHT
)
{
return
spotlight
Room
List
.
size
();
return
spotlightList
.
size
();
}
}
return
roomList
.
size
()
+
headersPosition
.
size
();
return
roomList
.
size
()
+
headersPosition
.
size
();
}
}
@Override
@Override
public
int
getItemViewType
(
int
position
)
{
public
int
getItemViewType
(
int
position
)
{
if
(
mode
==
MODE_SPOTLIGHT
_ROOM
)
{
if
(
mode
==
MODE_SPOTLIGHT
)
{
return
VIEW_TYPE_ROOM
;
return
VIEW_TYPE_ROOM
;
}
}
...
@@ -188,6 +187,6 @@ public class RoomListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
...
@@ -188,6 +187,6 @@ public class RoomListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
public
interface
OnItemClickListener
{
public
interface
OnItemClickListener
{
void
onItemClick
(
Room
room
);
void
onItemClick
(
Room
room
);
void
onItemClick
(
Spotlight
Room
spotlightRoom
);
void
onItemClick
(
Spotlight
spotlight
);
}
}
}
}
\ 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