mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-22 20:48:00 +01:00
use the same item for photo and video thumbnails
This commit is contained in:
parent
59307251fc
commit
2fb8fc2dc7
3 changed files with 17 additions and 24 deletions
|
@ -8,11 +8,14 @@ import android.widget.BaseAdapter;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
|
||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
import com.simplemobiletools.gallery.models.Medium;
|
|
||||||
import com.simplemobiletools.gallery.R;
|
import com.simplemobiletools.gallery.R;
|
||||||
|
import com.simplemobiletools.gallery.models.Medium;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import butterknife.BindView;
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
|
||||||
public class MediaAdapter extends BaseAdapter {
|
public class MediaAdapter extends BaseAdapter {
|
||||||
private final Context context;
|
private final Context context;
|
||||||
private final List<Medium> media;
|
private final List<Medium> media;
|
||||||
|
@ -29,17 +32,19 @@ public class MediaAdapter extends BaseAdapter {
|
||||||
final Medium medium = media.get(position);
|
final Medium medium = media.get(position);
|
||||||
ViewHolder holder;
|
ViewHolder holder;
|
||||||
if (view == null) {
|
if (view == null) {
|
||||||
int layout = R.layout.photo_item;
|
view = inflater.inflate(R.layout.video_item, parent, false);
|
||||||
if (medium.getIsVideo()) {
|
|
||||||
layout = R.layout.video_item;
|
|
||||||
}
|
|
||||||
view = inflater.inflate(layout, parent, false);
|
|
||||||
holder = new ViewHolder(view);
|
holder = new ViewHolder(view);
|
||||||
view.setTag(holder);
|
view.setTag(holder);
|
||||||
} else {
|
} else {
|
||||||
holder = (ViewHolder) view.getTag();
|
holder = (ViewHolder) view.getTag();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (medium.getIsVideo()) {
|
||||||
|
holder.playOutline.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
holder.playOutline.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
final String path = medium.getPath();
|
final String path = medium.getPath();
|
||||||
Glide.with(context).load(path).placeholder(R.color.tmb_background).centerCrop().crossFade().into(holder.photoThumbnail);
|
Glide.with(context).load(path).placeholder(R.color.tmb_background).centerCrop().crossFade().into(holder.photoThumbnail);
|
||||||
|
|
||||||
|
@ -68,10 +73,11 @@ public class MediaAdapter extends BaseAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
static class ViewHolder {
|
static class ViewHolder {
|
||||||
ImageView photoThumbnail;
|
@BindView(R.id.medium_thumbnail) ImageView photoThumbnail;
|
||||||
|
@BindView(R.id.play_outline) ImageView playOutline;
|
||||||
|
|
||||||
public ViewHolder(View view) {
|
public ViewHolder(View view) {
|
||||||
photoThumbnail = (ImageView) view.findViewById(R.id.medium_thumbnail);
|
ButterKnife.bind(this, view);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<FrameLayout
|
|
||||||
android:id="@+id/photo_item_holder"
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:foreground="@drawable/selector">
|
|
||||||
|
|
||||||
<com.simplemobiletools.gallery.MyImageView
|
|
||||||
android:id="@+id/medium_thumbnail"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"/>
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/video_item_holder"
|
android:id="@+id/media_item_holder"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
@ -17,6 +17,7 @@
|
||||||
android:layout_height="@dimen/play_outline_size"
|
android:layout_height="@dimen/play_outline_size"
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentBottom="true"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
android:src="@mipmap/play_outline"/>
|
android:src="@mipmap/play_outline"
|
||||||
|
android:visibility="gone"/>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
Loading…
Reference in a new issue