mirror of
https://github.com/nextcloud/android.git
synced 2024-11-23 13:45:35 +03:00
Parallel thumbnail fetching
Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
parent
a2d2c1a3c7
commit
73bb12f78a
3 changed files with 24 additions and 8 deletions
|
@ -462,19 +462,27 @@ public final class ThumbnailsCacheManager {
|
|||
mAsyncTasks = asyncTasks;
|
||||
}
|
||||
|
||||
public ThumbnailGenerationTask(ImageView imageView, FileDataStorageManager storageManager,
|
||||
User user, List<ThumbnailGenerationTask> asyncTasks,
|
||||
boolean gridViewEnabled)
|
||||
public ThumbnailGenerationTask(ImageView imageView,
|
||||
FileDataStorageManager storageManager,
|
||||
User user,
|
||||
List<ThumbnailGenerationTask> asyncTasks,
|
||||
boolean gridViewEnabled,
|
||||
String imageKey)
|
||||
throws IllegalArgumentException {
|
||||
this(imageView, storageManager, user, asyncTasks);
|
||||
this.gridViewEnabled = gridViewEnabled;
|
||||
mImageKey = imageKey;
|
||||
}
|
||||
|
||||
public GetMethod getGetMethod() {
|
||||
return getMethod;
|
||||
}
|
||||
|
||||
public ThumbnailGenerationTask(FileDataStorageManager storageManager, User user){
|
||||
public String getImageKey() {
|
||||
return mImageKey;
|
||||
}
|
||||
|
||||
public ThumbnailGenerationTask(FileDataStorageManager storageManager, User user) {
|
||||
if (storageManager == null) {
|
||||
throw new IllegalArgumentException("storageManager must not be NULL");
|
||||
}
|
||||
|
|
|
@ -41,7 +41,6 @@ import android.view.MotionEvent;
|
|||
import android.view.ScaleGestureDetector;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
|
|
|
@ -38,6 +38,7 @@ import android.graphics.Point;
|
|||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.PictureDrawable;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.TextUtils;
|
||||
|
@ -896,13 +897,20 @@ public final class DisplayUtils {
|
|||
} else {
|
||||
// generate new thumbnail
|
||||
if (ThumbnailsCacheManager.cancelPotentialThumbnailWork(file, thumbnailView)) {
|
||||
for (ThumbnailsCacheManager.ThumbnailGenerationTask task : asyncTasks) {
|
||||
if (file.getRemoteId() != null && task.getImageKey() != null &&
|
||||
file.getRemoteId().equals(task.getImageKey())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
try {
|
||||
final ThumbnailsCacheManager.ThumbnailGenerationTask task =
|
||||
new ThumbnailsCacheManager.ThumbnailGenerationTask(thumbnailView,
|
||||
storageManager,
|
||||
user,
|
||||
asyncTasks,
|
||||
gridView);
|
||||
gridView,
|
||||
file.getRemoteId());
|
||||
if (thumbnail == null) {
|
||||
Drawable drawable = MimeTypeUtil.getFileTypeIcon(file.getMimeType(),
|
||||
file.getFileName(),
|
||||
|
@ -941,8 +949,9 @@ public final class DisplayUtils {
|
|||
|
||||
thumbnailView.setImageDrawable(asyncDrawable);
|
||||
asyncTasks.add(task);
|
||||
task.execute(new ThumbnailsCacheManager.ThumbnailGenerationTaskObject(file,
|
||||
file.getRemoteId()));
|
||||
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR,
|
||||
new ThumbnailsCacheManager.ThumbnailGenerationTaskObject(file,
|
||||
file.getRemoteId()));
|
||||
} catch (IllegalArgumentException e) {
|
||||
Log_OC.d(TAG, "ThumbnailGenerationTask : " + e.getMessage());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue