use the same item for photo and video thumbnails
This commit is contained in:
parent
59307251fc
commit
2fb8fc2dc7
|
@ -8,11 +8,14 @@ import android.widget.BaseAdapter;
|
|||
import android.widget.ImageView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.simplemobiletools.gallery.models.Medium;
|
||||
import com.simplemobiletools.gallery.R;
|
||||
import com.simplemobiletools.gallery.models.Medium;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
public class MediaAdapter extends BaseAdapter {
|
||||
private final Context context;
|
||||
private final List<Medium> media;
|
||||
|
@ -29,17 +32,19 @@ public class MediaAdapter extends BaseAdapter {
|
|||
final Medium medium = media.get(position);
|
||||
ViewHolder holder;
|
||||
if (view == null) {
|
||||
int layout = R.layout.photo_item;
|
||||
if (medium.getIsVideo()) {
|
||||
layout = R.layout.video_item;
|
||||
}
|
||||
view = inflater.inflate(layout, parent, false);
|
||||
view = inflater.inflate(R.layout.video_item, parent, false);
|
||||
holder = new ViewHolder(view);
|
||||
view.setTag(holder);
|
||||
} else {
|
||||
holder = (ViewHolder) view.getTag();
|
||||
}
|
||||
|
||||
if (medium.getIsVideo()) {
|
||||
holder.playOutline.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
holder.playOutline.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
final String path = medium.getPath();
|
||||
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 {
|
||||
ImageView photoThumbnail;
|
||||
@BindView(R.id.medium_thumbnail) ImageView photoThumbnail;
|
||||
@BindView(R.id.play_outline) ImageView playOutline;
|
||||
|
||||
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"?>
|
||||
<RelativeLayout
|
||||
android:id="@+id/video_item_holder"
|
||||
android:id="@+id/media_item_holder"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
@ -17,6 +17,7 @@
|
|||
android:layout_height="@dimen/play_outline_size"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:src="@mipmap/play_outline"/>
|
||||
android:src="@mipmap/play_outline"
|
||||
android:visibility="gone"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
|
Loading…
Reference in New Issue