mirror of
https://github.com/oxen-io/session-android.git
synced 2025-01-11 19:53:39 +00:00
don't try generating an in-progress part thumbnail
Closes #4042 // FREEBIE
This commit is contained in:
parent
21b7dccf1c
commit
526f6e3058
@ -159,14 +159,15 @@ public class ThumbnailView extends FrameLayout {
|
||||
|
||||
public void setImageResource(@NonNull Slide slide, @Nullable MasterSecret masterSecret) {
|
||||
if (Util.equals(slide, this.slide)) {
|
||||
Log.w(TAG, "Not loading resource, slide was identical");
|
||||
Log.w(TAG, "Not re-loading slide " + slide.getPart().getPartId());
|
||||
return;
|
||||
}
|
||||
if (!isContextValid()) {
|
||||
Log.w(TAG, "Not loading resource, context is invalid");
|
||||
Log.w(TAG, "Not loading slide, context is invalid");
|
||||
return;
|
||||
}
|
||||
|
||||
Log.w(TAG, "loading part with id " + slide.getPart().getPartId() + ", progress " + slide.getTransferProgress());
|
||||
if (!hideControls && slide.getTransferProgress() == PartDatabase.TRANSFER_PROGRESS_STARTED) {
|
||||
getProgressWheel().spin();
|
||||
getProgressWheel().setVisibility(VISIBLE);
|
||||
|
@ -24,6 +24,7 @@ import android.database.sqlite.SQLiteOpenHelper;
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.Uri;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
@ -640,17 +641,22 @@ public class PartDatabase extends Database {
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream call() throws Exception {
|
||||
public @Nullable InputStream call() throws Exception {
|
||||
final InputStream stream = getDataStream(masterSecret, partId, THUMBNAIL);
|
||||
if (stream != null) {
|
||||
return stream;
|
||||
}
|
||||
|
||||
PduPart part = getPart(partId);
|
||||
if (part.isInProgress()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ThumbnailData data = MediaUtil.generateThumbnail(context, masterSecret, part.getDataUri(), Util.toIsoString(part.getContentType()));
|
||||
if (data == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
updatePartThumbnail(masterSecret, partId, part, data.toDataStream(), data.getAspectRatio());
|
||||
|
||||
return getDataStream(masterSecret, partId, THUMBNAIL);
|
||||
|
Loading…
x
Reference in New Issue
Block a user