add directory thumbnails
This commit is contained in:
parent
c2762ab014
commit
90d5d99c08
|
@ -23,4 +23,5 @@ dependencies {
|
|||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
testCompile 'junit:junit:4.12'
|
||||
compile 'com.android.support:appcompat-v7:23.1.1'
|
||||
compile 'com.github.bumptech.glide:glide:3.7.0'
|
||||
}
|
||||
|
|
|
@ -5,15 +5,20 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DirectoryAdapter extends BaseAdapter {
|
||||
private final Context context;
|
||||
private final List<Directory> dirs;
|
||||
private final LayoutInflater inflater;
|
||||
|
||||
public DirectoryAdapter(Context context, List<Directory> dirs) {
|
||||
this.context = context;
|
||||
this.dirs = dirs;
|
||||
this.inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
}
|
||||
|
@ -32,6 +37,7 @@ public class DirectoryAdapter extends BaseAdapter {
|
|||
Directory dir = dirs.get(position);
|
||||
holder.dirName.setText(dir.getName());
|
||||
holder.photoCnt.setText(String.valueOf(dir.getPhotoCnt()));
|
||||
Glide.with(context).load(dir.getThumbnail()).centerCrop().crossFade().into(holder.dirThumbnail);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
@ -54,10 +60,12 @@ public class DirectoryAdapter extends BaseAdapter {
|
|||
static class ViewHolder {
|
||||
TextView dirName;
|
||||
TextView photoCnt;
|
||||
ImageView dirThumbnail;
|
||||
|
||||
public ViewHolder(View view) {
|
||||
dirName = (TextView) view.findViewById(R.id.dir_name);
|
||||
photoCnt = (TextView) view.findViewById(R.id.photo_cnt);
|
||||
dirThumbnail = (ImageView) view.findViewById(R.id.dir_thumbnail);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:background="@android:color/black"
|
||||
android:columnWidth="@dimen/photo_size"
|
||||
android:horizontalSpacing="1dp"
|
||||
android:horizontalSpacing="2dp"
|
||||
android:numColumns="auto_fit"
|
||||
android:stretchMode="columnWidth"
|
||||
android:verticalSpacing="1dp"/>
|
||||
android:verticalSpacing="2dp"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
android:layout_height="match_parent">
|
||||
|
||||
<gallery.simplemobiletools.com.MyImageView
|
||||
android:id="@+id/photo"
|
||||
android:id="@+id/dir_thumbnail"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@android:color/white"/>
|
||||
|
@ -14,7 +14,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="#44444444"
|
||||
android:background="#55000000"
|
||||
android:paddingBottom="4dp"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingRight="8dp"
|
||||
|
|
Loading…
Reference in New Issue