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
720d4500
Commit
720d4500
authored
Jul 11, 2017
by
Filipe de Lima Brito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update some classes.
parent
aea73b91
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
52 additions
and
25 deletions
+52
-25
RoomFragment.java
...a/chat/rocket/android/fragment/chatroom/RoomFragment.java
+14
-23
Avatar.java
app/src/main/java/chat/rocket/android/helper/Avatar.java
+10
-0
MessageRenderer.java
...in/java/chat/rocket/android/renderer/MessageRenderer.java
+2
-1
UserRenderer.java
.../main/java/chat/rocket/android/renderer/UserRenderer.java
+14
-0
RocketChatAvatar.java
...ain/java/chat/rocket/android/widget/RocketChatAvatar.java
+12
-1
No files found.
app/src/main/java/chat/rocket/android/fragment/chatroom/RoomFragment.java
View file @
720d4500
...
...
@@ -21,14 +21,6 @@ import android.support.v7.widget.LinearLayoutManager;
import
android.support.v7.widget.RecyclerView
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
com.fernandocejas.arrow.optional.Optional
;
import
com.jakewharton.rxbinding2.support.v4.widget.RxDrawerLayout
;
import
java.lang.reflect.Field
;
import
java.util.ArrayList
;
import
java.util.List
;
import
chat.rocket.android.BackgroundLooper
;
import
chat.rocket.android.R
;
import
chat.rocket.android.api.MethodCallHelper
;
...
...
@@ -78,10 +70,15 @@ import chat.rocket.persistence.realm.repositories.RealmSessionRepository;
import
chat.rocket.persistence.realm.repositories.RealmSpotlightRoomRepository
;
import
chat.rocket.persistence.realm.repositories.RealmSpotlightUserRepository
;
import
chat.rocket.persistence.realm.repositories.RealmUserRepository
;
import
com.fernandocejas.arrow.optional.Optional
;
import
com.jakewharton.rxbinding2.support.v4.widget.RxDrawerLayout
;
import
io.reactivex.Single
;
import
io.reactivex.android.schedulers.AndroidSchedulers
;
import
io.reactivex.disposables.CompositeDisposable
;
import
io.reactivex.disposables.Disposable
;
import
java.lang.reflect.Field
;
import
java.util.ArrayList
;
import
java.util.List
;
import
permissions.dispatcher.NeedsPermission
;
import
permissions.dispatcher.RuntimePermissions
;
...
...
@@ -104,6 +101,7 @@ public class RoomFragment extends AbstractChatRoomFragment implements
private
String
roomId
;
private
LoadMoreScrollListener
scrollListener
;
private
MessageFormManager
messageFormManager
;
private
RecyclerView
messageRecyclerView
;
private
RecyclerViewAutoScrollManager
recyclerViewAutoScrollManager
;
protected
AbstractNewMessageIndicatorManager
newMessageIndicatorManager
;
protected
Snackbar
unreadIndicator
;
...
...
@@ -188,7 +186,7 @@ public class RoomFragment extends AbstractChatRoomFragment implements
@Override
protected
void
onSetupView
()
{
RecyclerView
messageRecyclerView
=
(
RecyclerView
)
rootView
.
findViewById
(
R
.
id
.
messageRecyclerView
);
messageRecyclerView
=
rootView
.
findViewById
(
R
.
id
.
messageRecyclerView
);
messageListAdapter
=
new
MessageListAdapter
(
getContext
());
messageRecyclerView
.
setAdapter
(
messageListAdapter
);
...
...
@@ -247,10 +245,8 @@ public class RoomFragment extends AbstractChatRoomFragment implements
}
private
void
scrollToLatestMessage
()
{
RecyclerView
listView
=
(
RecyclerView
)
rootView
.
findViewById
(
R
.
id
.
messageRecyclerView
);
if
(
listView
!=
null
)
{
listView
.
scrollToPosition
(
0
);
}
if
(
messageRecyclerView
!=
null
)
messageRecyclerView
.
scrollToPosition
(
0
);
}
protected
Snackbar
getUnreadCountIndicatorView
(
int
count
)
{
...
...
@@ -264,13 +260,9 @@ public class RoomFragment extends AbstractChatRoomFragment implements
@Override
public
void
onDestroyView
()
{
RecyclerView
listView
=
(
RecyclerView
)
rootView
.
findViewById
(
R
.
id
.
messageRecyclerView
);
if
(
listView
!=
null
)
{
RecyclerView
.
Adapter
adapter
=
listView
.
getAdapter
();
if
(
adapter
!=
null
)
{
RecyclerView
.
Adapter
adapter
=
messageRecyclerView
.
getAdapter
();
if
(
adapter
!=
null
)
adapter
.
unregisterAdapterDataObserver
(
recyclerViewAutoScrollManager
);
}
}
compositeDisposable
.
clear
();
...
...
@@ -551,12 +543,11 @@ public class RoomFragment extends AbstractChatRoomFragment implements
@Override
public
void
updateHistoryState
(
boolean
hasNext
,
boolean
isLoaded
)
{
RecyclerView
listView
=
(
RecyclerView
)
rootView
.
findViewById
(
R
.
id
.
messageRecyclerView
);
if
(
listView
==
null
||
!(
listView
.
getAdapter
()
instanceof
MessageListAdapter
))
{
if
(
messageRecyclerView
==
null
||
!(
messageRecyclerView
.
getAdapter
()
instanceof
MessageListAdapter
))
{
return
;
}
MessageListAdapter
adapter
=
(
MessageListAdapter
)
list
View
.
getAdapter
();
MessageListAdapter
adapter
=
(
MessageListAdapter
)
messageRecycler
View
.
getAdapter
();
if
(
isLoaded
)
{
scrollListener
.
setLoadingDone
();
}
...
...
@@ -608,4 +599,4 @@ public class RoomFragment extends AbstractChatRoomFragment implements
edittingMessage
=
message
;
messageFormManager
.
setEditMessage
(
message
.
getMessage
());
}
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/helper/Avatar.java
View file @
720d4500
...
...
@@ -6,6 +6,8 @@ import android.graphics.Canvas;
import
android.graphics.Typeface
;
import
android.graphics.drawable.BitmapDrawable
;
import
android.graphics.drawable.Drawable
;
import
android.support.graphics.drawable.VectorDrawableCompat
;
import
chat.rocket.android.R
;
import
com.amulyakhare.textdrawable.TextDrawable
;
import
java.io.UnsupportedEncodingException
;
...
...
@@ -91,6 +93,14 @@ public class Avatar {
rocketChatAvatar
.
loadImage
(
getImageUrl
(),
getTextDrawable
(
context
));
}
/**
* render error avatar into RocketChatAvatar.
*/
public
void
errorInto
(
final
RocketChatAvatar
rocketChatAvatar
)
{
final
Context
context
=
rocketChatAvatar
.
getContext
();
rocketChatAvatar
.
loadImage
(
VectorDrawableCompat
.
create
(
context
.
getResources
(),
R
.
drawable
.
ic_error_outline_black_24dp
,
null
));
}
public
Drawable
getTextDrawable
(
Context
context
)
{
if
(
username
==
null
)
{
return
null
;
...
...
app/src/main/java/chat/rocket/android/renderer/MessageRenderer.java
View file @
720d4500
...
...
@@ -44,7 +44,8 @@ public class MessageRenderer extends AbstractRenderer<Message> {
}
if
(
object
.
getSyncState
()
==
SyncState
.
FAILED
)
rocketChatAvatar
.
loadImage
(
VectorDrawableCompat
.
create
(
context
.
getResources
(),
R
.
drawable
.
ic_error_outline_black_24dp
,
null
));
// rocketChatAvatar.loadImage(VectorDrawableCompat.create(context.getResources(), R.drawable.ic_error_outline_black_24dp, null));
userRenderer
.
errorAvatarInto
(
rocketChatAvatar
);
else
if
(
TextUtils
.
isEmpty
(
object
.
getAvatar
()))
userRenderer
.
avatarInto
(
rocketChatAvatar
,
absoluteUrl
);
else
{
...
...
app/src/main/java/chat/rocket/android/renderer/UserRenderer.java
View file @
720d4500
...
...
@@ -32,6 +32,20 @@ public class UserRenderer extends AbstractRenderer<User> {
return
this
;
}
/**
* show Avatar error image
*/
public
UserRenderer
errorAvatarInto
(
RocketChatAvatar
rocketChatAvatar
)
{
if
(!
shouldHandle
(
rocketChatAvatar
))
{
return
this
;
}
if
(!
TextUtils
.
isEmpty
(
object
.
getUsername
()))
{
new
Avatar
(
null
,
object
.
getUsername
()).
errorInto
(
rocketChatAvatar
);
}
return
this
;
}
/**
* show Username in textView
*/
...
...
rocket-chat-android-widgets/src/main/java/chat/rocket/android/widget/RocketChatAvatar.java
View file @
720d4500
...
...
@@ -11,6 +11,7 @@ import android.widget.FrameLayout;
import
com.facebook.drawee.backends.pipeline.Fresco
;
import
com.facebook.drawee.generic.GenericDraweeHierarchy
;
import
com.facebook.drawee.generic.GenericDraweeHierarchyBuilder
;
import
com.facebook.drawee.interfaces.DraweeController
;
import
com.facebook.drawee.view.SimpleDraweeView
;
...
...
@@ -49,8 +50,18 @@ public class RocketChatAvatar extends FrameLayout {
}
public
void
loadImage
(
Drawable
drawable
)
{
// final GenericDraweeHierarchy hierarchy = draweeView.getHierarchy();
// hierarchy.setImage(drawable, 100, true); // Is there a better way?
final
GenericDraweeHierarchy
hierarchy
=
draweeView
.
getHierarchy
();
hierarchy
.
setImage
(
drawable
,
100
,
true
);
// Is there a better way?
hierarchy
.
setPlaceholderImage
(
drawable
);
hierarchy
.
setFailureImage
(
drawable
);
final
DraweeController
controller
=
Fresco
.
newDraweeControllerBuilder
()
.
setAutoPlayAnimations
(
true
)
.
build
();
draweeView
.
setController
(
controller
);
}
public
void
loadImage
(
String
url
,
Drawable
placeholder
)
{
...
...
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