Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
J
jami-client-android
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
146
Issues
146
List
Boards
Labels
Service Desk
Milestones
Iterations
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Analytics
Analytics
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
savoirfairelinux
jami-client-android
Commits
62f2ebc2
Commit
62f2ebc2
authored
Aug 27, 2020
by
Adrien Béraud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
conversation: avoid race-condition during file transfer
Change-Id: I7a22363e61a0158dc043bce5f5f0175c868b12f1
parent
c2d4ea05
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
21 deletions
+34
-21
ring-android/app/src/main/java/cx/ring/adapters/ConversationAdapter.java
...p/src/main/java/cx/ring/adapters/ConversationAdapter.java
+32
-21
ring-android/app/src/main/java/cx/ring/views/ConversationViewHolder.java
...p/src/main/java/cx/ring/views/ConversationViewHolder.java
+2
-0
No files found.
ring-android/app/src/main/java/cx/ring/adapters/ConversationAdapter.java
View file @
62f2ebc2
...
...
@@ -580,7 +580,8 @@ public class ConversationAdapter extends RecyclerView.Adapter<ConversationViewHo
@NonNull
final
Interaction
interaction
,
int
position
)
{
DataTransfer
file
=
(
DataTransfer
)
interaction
;
File
path
=
presenter
.
getDeviceRuntimeService
().
getConversationPath
(
file
.
getPeerId
(),
file
.
getStoragePath
());
file
.
setSize
(
path
.
length
());
if
(
file
.
isComplete
())
file
.
setSize
(
path
.
length
());
String
timeString
=
timestampToDetailString
(
viewHolder
.
itemView
.
getContext
(),
file
.
getTimestamp
());
viewHolder
.
compositeDisposable
.
add
(
timestampUpdateTimer
.
subscribe
(
t
->
{
...
...
@@ -594,21 +595,8 @@ public class ConversationAdapter extends RecyclerView.Adapter<ConversationViewHo
}
}));
TransferMsgType
type
;
if
(!
file
.
isComplete
())
{
type
=
TransferMsgType
.
FILE
;
}
else
if
(
file
.
isPicture
())
{
type
=
TransferMsgType
.
IMAGE
;
}
else
if
(
file
.
isAudio
())
{
type
=
TransferMsgType
.
AUDIO
;
}
else
if
(
file
.
isVideo
())
{
type
=
TransferMsgType
.
VIDEO
;
}
else
{
type
=
TransferMsgType
.
FILE
;
}
TransferMsgType
type
=
viewHolder
.
type
.
getTransferType
();
viewHolder
.
compositeDisposable
.
clear
();
if
(
hasPermanentTimeString
(
file
,
position
))
{
viewHolder
.
compositeDisposable
.
add
(
timestampUpdateTimer
.
subscribe
(
t
->
{
String
timeSeparationString
=
timestampToDetailString
(
viewHolder
.
itemView
.
getContext
(),
file
.
getTimestamp
());
...
...
@@ -651,6 +639,9 @@ public class ConversationAdapter extends RecyclerView.Adapter<ConversationViewHo
viewHolder
.
mImage
:
(
type
==
TransferMsgType
.
VIDEO
)
?
viewHolder
.
video
:
(
type
==
TransferMsgType
.
AUDIO
)
?
viewHolder
.
mAudioInfoLayout
:
viewHolder
.
mFileInfoLayout
;
if
(
longPressView
==
null
)
{
return
;
}
if
(
type
==
TransferMsgType
.
AUDIO
||
type
==
TransferMsgType
.
FILE
)
{
longPressView
.
getBackground
().
setTintList
(
null
);
}
...
...
@@ -1163,6 +1154,12 @@ public class ConversationAdapter extends RecyclerView.Adapter<ConversationViewHo
SINGLE
;
}
private
enum
TransferMsgType
{
FILE
,
IMAGE
,
AUDIO
,
VIDEO
;
}
public
enum
MessageType
{
INCOMING_FILE
(
R
.
layout
.
item_conv_file_peer
),
INCOMING_IMAGE
(
R
.
layout
.
item_conv_image_peer
),
...
...
@@ -1183,12 +1180,26 @@ public class ConversationAdapter extends RecyclerView.Adapter<ConversationViewHo
MessageType
(
int
l
)
{
layout
=
l
;
}
}
private
enum
TransferMsgType
{
FILE
,
IMAGE
,
AUDIO
,
VIDEO
;
boolean
isFile
()
{
return
this
==
INCOMING_FILE
||
this
==
OUTGOING_FILE
;
}
boolean
isAudio
()
{
return
this
==
INCOMING_AUDIO
||
this
==
OUTGOING_AUDIO
;
}
boolean
isVideo
()
{
return
this
==
INCOMING_VIDEO
||
this
==
OUTGOING_VIDEO
;
}
boolean
isImage
()
{
return
this
==
INCOMING_IMAGE
||
this
==
OUTGOING_IMAGE
;
}
public
TransferMsgType
getTransferType
()
{
return
isFile
()
?
TransferMsgType
.
FILE
:
(
isImage
()
?
TransferMsgType
.
IMAGE
:
(
isAudio
()
?
TransferMsgType
.
AUDIO
:
(
isVideo
()
?
TransferMsgType
.
VIDEO
:
TransferMsgType
.
FILE
)));
}
}
}
ring-android/app/src/main/java/cx/ring/views/ConversationViewHolder.java
View file @
62f2ebc2
...
...
@@ -39,6 +39,7 @@ import cx.ring.utils.UiUpdater;
import
io.reactivex.disposables.CompositeDisposable
;
public
class
ConversationViewHolder
extends
RecyclerView
.
ViewHolder
{
public
ConversationAdapter
.
MessageType
type
;
public
View
mItem
;
public
TextView
mMsgTxt
;
public
TextView
mMsgDetailTxt
;
...
...
@@ -66,6 +67,7 @@ public class ConversationViewHolder extends RecyclerView.ViewHolder {
public
ConversationViewHolder
(
ViewGroup
v
,
ConversationAdapter
.
MessageType
type
)
{
super
(
v
);
this
.
type
=
type
;
if
(
type
==
ConversationAdapter
.
MessageType
.
CONTACT_EVENT
)
{
mMsgTxt
=
v
.
findViewById
(
R
.
id
.
contact_event_txt
);
mMsgDetailTxt
=
v
.
findViewById
(
R
.
id
.
contact_event_details_txt
);
...
...
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