|
@@ -75,8 +75,8 @@ import java.util.List;
|
|
|
|
|
|
public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
|
|
|
|
|
- public static final int HEADER_TYPE = 100;
|
|
|
- public static final int ACTIVITY_TYPE = 101;
|
|
|
+ private static final int HEADER_TYPE = 100;
|
|
|
+ private static final int ACTIVITY_TYPE = 101;
|
|
|
private final ActivityListInterface activityListInterface;
|
|
|
private final int px;
|
|
|
private static final String TAG = ActivityListAdapter.class.getSimpleName();
|
|
@@ -101,7 +101,7 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|
|
String sTime = "";
|
|
|
for (Object o : activityItems) {
|
|
|
Activity activity = (Activity) o;
|
|
|
- String time = null;
|
|
|
+ String time;
|
|
|
if (activity.getDatetime() != null) {
|
|
|
time = DisplayUtils.getRelativeTimestamp(context,
|
|
|
activity.getDatetime().getTime()).toString();
|
|
@@ -182,18 +182,15 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|
|
activityViewHolder.list.setVisibility(View.VISIBLE);
|
|
|
activityViewHolder.list.removeAllViews();
|
|
|
|
|
|
- activityViewHolder.list.post(new Runnable() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- int w = activityViewHolder.list.getMeasuredWidth();
|
|
|
- int elPxSize = px + 20;
|
|
|
- int totalColumnCount = (int) Math.floor(w / elPxSize);
|
|
|
-
|
|
|
- try {
|
|
|
- activityViewHolder.list.setColumnCount(totalColumnCount);
|
|
|
- } catch (IllegalArgumentException e) {
|
|
|
- Log_OC.e(TAG, "error setting column count to " + totalColumnCount);
|
|
|
- }
|
|
|
+ activityViewHolder.list.post(() -> {
|
|
|
+ int w = activityViewHolder.list.getMeasuredWidth();
|
|
|
+ int elPxSize = px + 20;
|
|
|
+ int totalColumnCount = (int) Math.floor(w / elPxSize);
|
|
|
+
|
|
|
+ try {
|
|
|
+ activityViewHolder.list.setColumnCount(totalColumnCount);
|
|
|
+ } catch (IllegalArgumentException e) {
|
|
|
+ Log_OC.e(TAG, "error setting column count to " + totalColumnCount);
|
|
|
}
|
|
|
});
|
|
|
|
|
@@ -231,12 +228,7 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|
|
params.setMargins(10, 10, 10, 10);
|
|
|
ImageView imageView = new ImageView(context);
|
|
|
imageView.setLayoutParams(params);
|
|
|
- imageView.setOnClickListener(new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View v) {
|
|
|
- activityListInterface.onActivityClicked(richObject);
|
|
|
- }
|
|
|
- });
|
|
|
+ imageView.setOnClickListener(v -> activityListInterface.onActivityClicked(richObject));
|
|
|
setBitmap(file, imageView);
|
|
|
|
|
|
return imageView;
|
|
@@ -246,11 +238,19 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|
|
// No Folder
|
|
|
if (!file.isFolder()) {
|
|
|
if ((MimeTypeUtil.isImage(file) || MimeTypeUtil.isVideo(file))) {
|
|
|
- String uri = mClient.getBaseUri() + "" +
|
|
|
- "/index.php/apps/files/api/v1/thumbnail/" +
|
|
|
- px + "/" + px + Uri.encode(file.getRemotePath(), "/");
|
|
|
+ int placeholder;
|
|
|
|
|
|
- Glide.with(context).using(new CustomGlideStreamLoader()).load(uri).into(fileIcon); //Using custom fetcher
|
|
|
+ if (MimeTypeUtil.isImage(file)) {
|
|
|
+ placeholder = R.drawable.file_image;
|
|
|
+ } else {
|
|
|
+ placeholder = R.drawable.file_movie;
|
|
|
+ }
|
|
|
+
|
|
|
+ String uri = mClient.getBaseUri() + "/index.php/apps/files/api/v1/thumbnail/" + px + "/" + px +
|
|
|
+ Uri.encode(file.getRemotePath(), "/");
|
|
|
+
|
|
|
+ Glide.with(context).using(new CustomGlideStreamLoader()).load(uri).placeholder(placeholder)
|
|
|
+ .error(placeholder).into(fileIcon); // using custom fetcher
|
|
|
|
|
|
} else {
|
|
|
fileIcon.setImageDrawable(MimeTypeUtil.getFileTypeIcon(file.getMimetype(), file.getFileName(), null));
|
|
@@ -258,11 +258,8 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|
|
} else {
|
|
|
// Folder
|
|
|
fileIcon.setImageDrawable(
|
|
|
- MimeTypeUtil.getFolderTypeIcon(
|
|
|
- file.isSharedWithMe() || file.isSharedWithSharee(),
|
|
|
- file.isSharedViaLink()
|
|
|
- )
|
|
|
- );
|
|
|
+ MimeTypeUtil.getFolderTypeIcon(file.isSharedWithMe() || file.isSharedWithSharee(),
|
|
|
+ file.isSharedViaLink()));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -278,8 +275,7 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|
|
.placeholder(R.drawable.ic_activity)
|
|
|
.error(R.drawable.ic_activity)
|
|
|
.animate(android.R.anim.fade_in)
|
|
|
- .listener(new SvgSoftwareLayerSetter<Uri>());
|
|
|
-
|
|
|
+ .listener(new SvgSoftwareLayerSetter<>());
|
|
|
|
|
|
Uri uri = Uri.parse(icon);
|
|
|
requestBuilder
|
|
@@ -319,7 +315,7 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|
|
return ssb;
|
|
|
}
|
|
|
|
|
|
- public RichObject searchObjectByName(ArrayList<RichObject> richObjectList, String name) {
|
|
|
+ private RichObject searchObjectByName(ArrayList<RichObject> richObjectList, String name) {
|
|
|
for (RichObject richObject : richObjectList) {
|
|
|
if (richObject.getTag().equalsIgnoreCase(name))
|
|
|
return richObject;
|