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
b6b134db
Commit
b6b134db
authored
Jul 11, 2017
by
Filipe de Lima Brito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[WIP] RecyclerView wrong avatar solution
parent
043c783e
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
38 additions
and
41 deletions
+38
-41
RoomFragment.java
...a/chat/rocket/android/fragment/chatroom/RoomFragment.java
+2
-4
SidebarMainFragment.java
.../rocket/android/fragment/sidebar/SidebarMainFragment.java
+1
-2
ExtModelListAdapter.java
...chat/rocket/android/layouthelper/ExtModelListAdapter.java
+1
-2
AbstractMessageViewHolder.java
...roid/layouthelper/chatroom/AbstractMessageViewHolder.java
+7
-12
MessageListAdapter.java
...ket/android/layouthelper/chatroom/MessageListAdapter.java
+3
-5
MessageNormalViewHolder.java
...ndroid/layouthelper/chatroom/MessageNormalViewHolder.java
+2
-2
ModelListAdapter.java
...ocket/android/layouthelper/chatroom/ModelListAdapter.java
+1
-2
MessageRenderer.java
...in/java/chat/rocket/android/renderer/MessageRenderer.java
+13
-7
UserRenderer.java
.../main/java/chat/rocket/android/renderer/UserRenderer.java
+1
-2
LoadMessageProcedureObserver.java
...ndroid/service/observer/LoadMessageProcedureObserver.java
+7
-3
No files found.
app/src/main/java/chat/rocket/android/fragment/chatroom/RoomFragment.java
View file @
b6b134db
...
...
@@ -215,14 +215,12 @@ public class RoomFragment extends AbstractChatRoomFragment implements
}
};
messageRecyclerView
.
addOnScrollListener
(
scrollListener
);
messageRecyclerView
.
addOnScrollListener
(
new
RecyclerViewScrolledToBottomListener
(
linearLayoutManager
,
1
,
this
::
markAsReadIfNeeded
));
messageRecyclerView
.
addOnScrollListener
(
new
RecyclerViewScrolledToBottomListener
(
linearLayoutManager
,
1
,
this
::
markAsReadIfNeeded
));
newMessageIndicatorManager
=
new
AbstractNewMessageIndicatorManager
()
{
@Override
protected
void
onShowIndicator
(
int
count
,
boolean
onlyAlreadyShown
)
{
if
((
onlyAlreadyShown
&&
unreadIndicator
!=
null
&&
unreadIndicator
.
isShown
())
||
!
onlyAlreadyShown
)
{
if
((
onlyAlreadyShown
&&
unreadIndicator
!=
null
&&
unreadIndicator
.
isShown
())
||
!
onlyAlreadyShown
)
{
unreadIndicator
=
getUnreadCountIndicatorView
(
count
);
unreadIndicator
.
show
();
}
...
...
app/src/main/java/chat/rocket/android/fragment/sidebar/SidebarMainFragment.java
View file @
b6b134db
...
...
@@ -230,8 +230,7 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
private
void
onRenderCurrentUser
(
User
user
,
RocketChatAbsoluteUrl
absoluteUrl
)
{
if
(
user
!=
null
&&
absoluteUrl
!=
null
)
{
new
UserRenderer
(
getContext
(),
user
)
.
avatarInto
((
RocketChatAvatar
)
rootView
.
findViewById
(
R
.
id
.
current_user_avatar
),
absoluteUrl
)
.
avatarInto
((
RocketChatAvatar
)
rootView
.
findViewById
(
R
.
id
.
current_user_avatar
),
absoluteUrl
)
.
usernameInto
((
TextView
)
rootView
.
findViewById
(
R
.
id
.
current_user_name
))
.
statusColorInto
((
ImageView
)
rootView
.
findViewById
(
R
.
id
.
current_user_status
));
}
...
...
app/src/main/java/chat/rocket/android/layouthelper/ExtModelListAdapter.java
View file @
b6b134db
...
...
@@ -11,8 +11,7 @@ import chat.rocket.android.layouthelper.chatroom.ModelViewHolder;
/**
* ModelListAdapter with header and footer.
*/
public
abstract
class
ExtModelListAdapter
<
T
,
VM
,
VH
extends
ModelViewHolder
<
VM
>>
extends
ModelListAdapter
<
T
,
VM
,
VH
>
{
public
abstract
class
ExtModelListAdapter
<
T
,
VM
,
VH
extends
ModelViewHolder
<
VM
>>
extends
ModelListAdapter
<
T
,
VM
,
VH
>
{
protected
static
final
int
VIEW_TYPE_HEADER
=
-
1
;
protected
static
final
int
VIEW_TYPE_FOOTER
=
-
2
;
...
...
app/src/main/java/chat/rocket/android/layouthelper/chatroom/AbstractMessageViewHolder.java
View file @
b6b134db
...
...
@@ -40,17 +40,14 @@ public abstract class AbstractMessageViewHolder extends ModelViewHolder<PairedMe
* bind the view model.
*/
public
final
void
bind
(
PairedMessage
pairedMessage
,
boolean
autoloadImages
)
{
bindMessage
(
pairedMessage
,
autoloadImages
);
if
(
pairedMessage
.
target
!=
null
)
{
int
syncState
=
pairedMessage
.
target
.
getSyncState
();
if
(
syncState
==
SyncState
.
NOT_SYNCED
||
syncState
==
SyncState
.
SYNCING
)
{
if
(
pairedMessage
.
target
.
getSyncState
()
!=
SyncState
.
SYNCED
)
itemView
.
setAlpha
(
0.6f
);
}
else
{
else
itemView
.
setAlpha
(
1.0f
);
}
}
bindMessage
(
pairedMessage
,
autoloadImages
);
renderNewDayAndSequential
(
pairedMessage
);
}
...
...
@@ -73,21 +70,19 @@ public abstract class AbstractMessageViewHolder extends ModelViewHolder<PairedMe
private
void
setSequential
(
boolean
sequential
)
{
if
(
avatar
!=
null
)
{
if
(
sequential
)
{
if
(
sequential
)
avatar
.
setVisibility
(
View
.
GONE
);
}
else
{
else
avatar
.
setVisibility
(
View
.
VISIBLE
);
}
}
if
(
userAndTimeContainer
!=
null
)
{
if
(
sequential
)
{
if
(
sequential
)
userAndTimeContainer
.
setVisibility
(
View
.
GONE
);
}
else
{
else
userAndTimeContainer
.
setVisibility
(
View
.
VISIBLE
);
}
}
}
private
void
setNewDay
(
@Nullable
String
text
)
{
if
(
newDayContainer
!=
null
)
{
...
...
app/src/main/java/chat/rocket/android/layouthelper/chatroom/MessageListAdapter.java
View file @
b6b134db
...
...
@@ -16,8 +16,7 @@ import chat.rocket.core.models.Message;
/**
* target list adapter for chat room.
*/
public
class
MessageListAdapter
extends
ExtModelListAdapter
<
Message
,
PairedMessage
,
AbstractMessageViewHolder
>
{
public
class
MessageListAdapter
extends
ExtModelListAdapter
<
Message
,
PairedMessage
,
AbstractMessageViewHolder
>
{
private
static
final
int
VIEW_TYPE_UNKNOWN
=
0
;
private
static
final
int
VIEW_TYPE_NORMAL_MESSAGE
=
1
;
...
...
@@ -99,8 +98,7 @@ public class MessageListAdapter
default
:
return
new
AbstractMessageViewHolder
(
itemView
,
absoluteUrl
)
{
@Override
protected
void
bindMessage
(
PairedMessage
pairedMessage
,
boolean
autoloadImages
)
{
}
protected
void
bindMessage
(
PairedMessage
pairedMessage
,
boolean
autoloadImages
)
{}
};
}
}
...
...
app/src/main/java/chat/rocket/android/layouthelper/chatroom/MessageNormalViewHolder.java
View file @
b6b134db
...
...
@@ -8,6 +8,7 @@ import chat.rocket.android.widget.AbsoluteUrl;
import
chat.rocket.android.widget.message.RocketChatMessageAttachmentsLayout
;
import
chat.rocket.android.widget.message.RocketChatMessageLayout
;
import
chat.rocket.android.widget.message.RocketChatMessageUrlsLayout
;
import
chat.rocket.core.SyncState
;
/**
* ViewData holder of NORMAL chat message.
...
...
@@ -24,8 +25,7 @@ public class MessageNormalViewHolder extends AbstractMessageViewHolder {
super
(
itemView
,
absoluteUrl
);
body
=
(
RocketChatMessageLayout
)
itemView
.
findViewById
(
R
.
id
.
message_body
);
urls
=
(
RocketChatMessageUrlsLayout
)
itemView
.
findViewById
(
R
.
id
.
message_urls
);
attachments
=
(
RocketChatMessageAttachmentsLayout
)
itemView
.
findViewById
(
R
.
id
.
message_attachments
);
attachments
=
(
RocketChatMessageAttachmentsLayout
)
itemView
.
findViewById
(
R
.
id
.
message_attachments
);
}
@Override
...
...
app/src/main/java/chat/rocket/android/layouthelper/chatroom/ModelListAdapter.java
View file @
b6b134db
...
...
@@ -12,8 +12,7 @@ import android.view.ViewGroup;
import
java.util.List
;
@SuppressWarnings
(
"PMD.GenericsNaming"
)
public
abstract
class
ModelListAdapter
<
T
,
VM
,
VH
extends
ModelViewHolder
<
VM
>>
extends
RecyclerView
.
Adapter
<
VH
>
{
public
abstract
class
ModelListAdapter
<
T
,
VM
,
VH
extends
ModelViewHolder
<
VM
>>
extends
RecyclerView
.
Adapter
<
VH
>
{
protected
final
LayoutInflater
inflater
;
private
List
<
VM
>
adapterData
;
...
...
app/src/main/java/chat/rocket/android/renderer/MessageRenderer.java
View file @
b6b134db
...
...
@@ -39,15 +39,19 @@ public class MessageRenderer extends AbstractRenderer<Message> {
* show Avatar image.
*/
public
MessageRenderer
avatarInto
(
RocketChatAvatar
rocketChatAvatar
,
AbsoluteUrl
absoluteUrl
)
{
if
(
object
.
getSyncState
()
==
SyncState
.
FAILED
)
{
if
(!
shouldHandle
(
rocketChatAvatar
))
{
return
this
;
}
if
(
object
.
getSyncState
()
==
SyncState
.
FAILED
)
rocketChatAvatar
.
loadImage
(
VectorDrawableCompat
.
create
(
context
.
getResources
(),
R
.
drawable
.
ic_error_outline_black_24dp
,
null
));
}
else
if
(
TextUtils
.
isEmpty
(
object
.
getAvatar
()))
{
else
if
(
TextUtils
.
isEmpty
(
object
.
getAvatar
()))
userRenderer
.
avatarInto
(
rocketChatAvatar
,
absoluteUrl
);
}
else
{
else
{
final
User
user
=
object
.
getUser
();
setAvatarInto
(
object
.
getAvatar
(),
absoluteUrl
,
user
==
null
?
null
:
user
.
getUsername
(),
rocketChatAvatar
);
setAvatarInto
(
object
.
getAvatar
(),
absoluteUrl
,
user
==
null
?
null
:
user
.
getUsername
(),
rocketChatAvatar
);
}
return
this
;
}
...
...
@@ -78,6 +82,9 @@ public class MessageRenderer extends AbstractRenderer<Message> {
case
SyncState
.
SYNCING
:
textView
.
setText
(
R
.
string
.
sending
);
break
;
case
SyncState
.
NOT_SYNCED
:
textView
.
setText
(
R
.
string
.
not_synced
);
break
;
case
SyncState
.
FAILED
:
textView
.
setText
(
R
.
string
.
failed_to_sync
);
break
;
...
...
@@ -142,8 +149,7 @@ public class MessageRenderer extends AbstractRenderer<Message> {
return
this
;
}
private
void
setAvatarInto
(
String
avatar
,
AbsoluteUrl
absoluteUrl
,
String
username
,
RocketChatAvatar
imageView
)
{
private
void
setAvatarInto
(
String
avatar
,
AbsoluteUrl
absoluteUrl
,
String
username
,
RocketChatAvatar
imageView
)
{
imageView
.
loadImage
(
avatar
,
new
Avatar
(
absoluteUrl
,
username
).
getTextDrawable
(
context
));
}
...
...
app/src/main/java/chat/rocket/android/renderer/UserRenderer.java
View file @
b6b134db
...
...
@@ -3,12 +3,11 @@ package chat.rocket.android.renderer;
import
android.content.Context
;
import
android.widget.ImageView
;
import
android.widget.TextView
;
import
chat.rocket.android.helper.Avatar
;
import
chat.rocket.android.helper.TextUtils
;
import
chat.rocket.android.widget.AbsoluteUrl
;
import
chat.rocket.core.models.User
;
import
chat.rocket.android.widget.RocketChatAvatar
;
import
chat.rocket.core.models.User
;
/**
* Renderer for RealmUser model.
...
...
app/src/main/java/chat/rocket/android/service/observer/LoadMessageProcedureObserver.java
View file @
b6b134db
...
...
@@ -74,13 +74,17 @@ public class LoadMessageProcedureObserver extends AbstractModelObserver<LoadMess
).
continueWithTask
(
task
->
{
if
(
task
.
isFaulted
())
{
RCLog
.
w
(
task
.
getError
());
re
turn
re
almHelper
.
executeTransaction
(
realm
->
realmHelper
.
executeTransaction
(
realm
->
realm
.
createOrUpdateObjectFromJson
(
LoadMessageProcedure
.
class
,
new
JSONObject
()
.
put
(
LoadMessageProcedure
.
ID
,
roomId
)
.
put
(
LoadMessageProcedure
.
SYNC_STATE
,
SyncState
.
FAILED
)));
}
else
{
return
Task
.
forResult
(
null
);
realmHelper
.
executeTransaction
(
realm
->
realm
.
createOrUpdateObjectFromJson
(
LoadMessageProcedure
.
class
,
new
JSONObject
()
.
put
(
LoadMessageProcedure
.
ID
,
roomId
)
.
put
(
LoadMessageProcedure
.
SYNC_STATE
,
SyncState
.
SYNCED
)));
}
return
null
;
});
}
}
\ 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