|
@@ -31,6 +31,7 @@ import android.content.Context;
|
|
|
import android.content.res.Resources;
|
|
|
import android.graphics.Bitmap;
|
|
|
import android.graphics.LinearGradient;
|
|
|
+import android.graphics.Point;
|
|
|
import android.graphics.PorterDuff;
|
|
|
import android.graphics.Shader;
|
|
|
import android.graphics.drawable.Drawable;
|
|
@@ -40,6 +41,7 @@ import android.text.TextUtils;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
|
+import android.view.WindowManager;
|
|
|
import android.widget.Filter;
|
|
|
import android.widget.FrameLayout;
|
|
|
import android.widget.ImageView;
|
|
@@ -54,6 +56,7 @@ import com.elyeproj.loaderviewlibrary.LoaderImageView;
|
|
|
import com.nextcloud.client.account.User;
|
|
|
import com.nextcloud.client.account.UserAccountManager;
|
|
|
import com.nextcloud.client.preferences.AppPreferences;
|
|
|
+import com.owncloud.android.MainApp;
|
|
|
import com.owncloud.android.R;
|
|
|
import com.owncloud.android.datamodel.FileDataStorageManager;
|
|
|
import com.owncloud.android.datamodel.OCFile;
|
|
@@ -368,7 +371,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|
|
asyncTasks,
|
|
|
gridView,
|
|
|
activity,
|
|
|
- gridViewHolder.shimmerThumbnail);
|
|
|
+ gridViewHolder.shimmerThumbnail, preferences);
|
|
|
|
|
|
if (highlightedItem != null && file.getFileId() == highlightedItem.getFileId()) {
|
|
|
gridViewHolder.itemLayout.setBackgroundColor(activity.getResources()
|
|
@@ -614,17 +617,18 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|
|
List<ThumbnailsCacheManager.ThumbnailGenerationTask> asyncTasks,
|
|
|
boolean gridView,
|
|
|
Context context) {
|
|
|
- setThumbnail(file, thumbnailView, user, storageManager, asyncTasks, gridView, context, null);
|
|
|
+ setThumbnail(file, thumbnailView, user, storageManager, asyncTasks, gridView, context, null, null);
|
|
|
}
|
|
|
|
|
|
private static void setThumbnail(OCFile file,
|
|
|
- ImageView thumbnailView,
|
|
|
- User user,
|
|
|
- FileDataStorageManager storageManager,
|
|
|
- List<ThumbnailsCacheManager.ThumbnailGenerationTask> asyncTasks,
|
|
|
- boolean gridView,
|
|
|
- Context context,
|
|
|
- LoaderImageView shimmerThumbnail) {
|
|
|
+ ImageView thumbnailView,
|
|
|
+ User user,
|
|
|
+ FileDataStorageManager storageManager,
|
|
|
+ List<ThumbnailsCacheManager.ThumbnailGenerationTask> asyncTasks,
|
|
|
+ boolean gridView,
|
|
|
+ Context context,
|
|
|
+ LoaderImageView shimmerThumbnail,
|
|
|
+ AppPreferences preferences) {
|
|
|
if (file.isFolder()) {
|
|
|
thumbnailView.setImageDrawable(MimeTypeUtil
|
|
|
.getFolderTypeIcon(file.isSharedWithMe() || file.isSharedWithSharee(),
|
|
@@ -671,7 +675,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|
|
|
|
|
if (shimmerThumbnail != null && shimmerThumbnail.getVisibility() == View.GONE) {
|
|
|
if (gridView) {
|
|
|
- configShimmerGridImageSize(shimmerThumbnail, task.getThumbnailDimension());
|
|
|
+ configShimmerGridImageSize(shimmerThumbnail, preferences.getGridColumns());
|
|
|
}
|
|
|
startShimmer(shimmerThumbnail, thumbnailView);
|
|
|
}
|
|
@@ -721,14 +725,35 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private static void configShimmerGridImageSize(LoaderImageView thumbnailShimmer, int size){
|
|
|
- final int width = FrameLayout.LayoutParams.MATCH_PARENT;
|
|
|
- final int height = size + size/8;
|
|
|
- FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(width, height);
|
|
|
+ private static Point getScreenSize(Context context) throws Exception {
|
|
|
+ final WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
|
|
|
+ if (windowManager != null) {
|
|
|
+ final Point displaySize = new Point();
|
|
|
+ windowManager.getDefaultDisplay().getSize(displaySize);
|
|
|
+ return displaySize;
|
|
|
+ } else {
|
|
|
+ throw new Exception("WindowManager not found");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void configShimmerGridImageSize(LoaderImageView thumbnailShimmer, float gridColumns) {
|
|
|
+ final Resources resources = MainApp.getAppContext().getResources();
|
|
|
FrameLayout.LayoutParams targetLayoutParams = (FrameLayout.LayoutParams) thumbnailShimmer.getLayoutParams();
|
|
|
- params.setMargins(targetLayoutParams.leftMargin, targetLayoutParams.topMargin,
|
|
|
- targetLayoutParams.rightMargin, targetLayoutParams.bottomMargin);
|
|
|
- thumbnailShimmer.setLayoutParams(params);
|
|
|
+
|
|
|
+ try {
|
|
|
+ final Point screenSize = getScreenSize(thumbnailShimmer.getContext());
|
|
|
+ final int marginLeftAndRight = Math.round(targetLayoutParams.leftMargin + targetLayoutParams.rightMargin);
|
|
|
+ final int size = Math.round(screenSize.x / gridColumns - marginLeftAndRight);
|
|
|
+
|
|
|
+ FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(size, size);
|
|
|
+ params.setMargins(targetLayoutParams.leftMargin,
|
|
|
+ targetLayoutParams.topMargin,
|
|
|
+ targetLayoutParams.rightMargin,
|
|
|
+ targetLayoutParams.bottomMargin);
|
|
|
+ thumbnailShimmer.setLayoutParams(params);
|
|
|
+ } catch (Exception exception) {
|
|
|
+ Log_OC.e("ConfigShimmer", exception.getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private static void startShimmer(LoaderImageView thumbnailShimmer, ImageView thumbnailView) {
|