don't try generating an in-progress part thumbnail

Closes #4042
// FREEBIE
This commit is contained in:
Jake McGinty 2015-09-07 11:48:03 -10:00 committed by Moxie Marlinspike
parent 21b7dccf1c
commit 526f6e3058
2 changed files with 10 additions and 3 deletions

View File

@ -159,14 +159,15 @@ public class ThumbnailView extends FrameLayout {
public void setImageResource(@NonNull Slide slide, @Nullable MasterSecret masterSecret) { public void setImageResource(@NonNull Slide slide, @Nullable MasterSecret masterSecret) {
if (Util.equals(slide, this.slide)) { 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; return;
} }
if (!isContextValid()) { if (!isContextValid()) {
Log.w(TAG, "Not loading resource, context is invalid"); Log.w(TAG, "Not loading slide, context is invalid");
return; return;
} }
Log.w(TAG, "loading part with id " + slide.getPart().getPartId() + ", progress " + slide.getTransferProgress());
if (!hideControls && slide.getTransferProgress() == PartDatabase.TRANSFER_PROGRESS_STARTED) { if (!hideControls && slide.getTransferProgress() == PartDatabase.TRANSFER_PROGRESS_STARTED) {
getProgressWheel().spin(); getProgressWheel().spin();
getProgressWheel().setVisibility(VISIBLE); getProgressWheel().setVisibility(VISIBLE);

View File

@ -24,6 +24,7 @@ import android.database.sqlite.SQLiteOpenHelper;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.net.Uri; import android.net.Uri;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import android.util.Pair; import android.util.Pair;
@ -640,17 +641,22 @@ public class PartDatabase extends Database {
} }
@Override @Override
public InputStream call() throws Exception { public @Nullable InputStream call() throws Exception {
final InputStream stream = getDataStream(masterSecret, partId, THUMBNAIL); final InputStream stream = getDataStream(masterSecret, partId, THUMBNAIL);
if (stream != null) { if (stream != null) {
return stream; return stream;
} }
PduPart part = getPart(partId); PduPart part = getPart(partId);
if (part.isInProgress()) {
return null;
}
ThumbnailData data = MediaUtil.generateThumbnail(context, masterSecret, part.getDataUri(), Util.toIsoString(part.getContentType())); ThumbnailData data = MediaUtil.generateThumbnail(context, masterSecret, part.getDataUri(), Util.toIsoString(part.getContentType()));
if (data == null) { if (data == null) {
return null; return null;
} }
updatePartThumbnail(masterSecret, partId, part, data.toDataStream(), data.getAspectRatio()); updatePartThumbnail(masterSecret, partId, part, data.toDataStream(), data.getAspectRatio());
return getDataStream(masterSecret, partId, THUMBNAIL); return getDataStream(masterSecret, partId, THUMBNAIL);