display a file name at the media activity
This commit is contained in:
parent
401569043a
commit
c609072eaf
7 changed files with 33 additions and 4 deletions
|
@ -232,7 +232,7 @@ public class MediaActivity extends SimpleActivity
|
|||
if (file.exists()) {
|
||||
final int dateIndex = cursor.getColumnIndex(MediaStore.Images.Media.DATE_MODIFIED);
|
||||
final long timestamp = cursor.getLong(dateIndex);
|
||||
media.add(new Medium(curPath, (i == 1), timestamp, file.length()));
|
||||
media.add(new Medium(file.getName(), curPath, (i == 1), timestamp, file.length()));
|
||||
} else {
|
||||
invalidFiles.add(file.getAbsolutePath());
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ public class PhotoVideoActivity extends SimpleActivity implements ViewPagerFragm
|
|||
|
||||
final Bundle bundle = new Bundle();
|
||||
final File file = new File(mUri.toString());
|
||||
final Medium medium = new Medium(mUri.toString(), mIsVideo, 0, file.length());
|
||||
final Medium medium = new Medium(file.getName(), mUri.toString(), mIsVideo, 0, file.length());
|
||||
bundle.putSerializable(Constants.MEDIUM, medium);
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
|
|
|
@ -380,7 +380,7 @@ public class ViewPagerActivity extends SimpleActivity
|
|||
|
||||
final int sizeIndex = cursor.getColumnIndex(MediaStore.Images.Media.SIZE);
|
||||
final long size = cursor.getLong(sizeIndex);
|
||||
media.add(new Medium(curPath, i == 1, timestamp, size));
|
||||
media.add(new Medium("", curPath, i == 1, timestamp, size));
|
||||
}
|
||||
} while (cursor.moveToNext());
|
||||
cursor.close();
|
||||
|
|
|
@ -6,19 +6,25 @@ import java.io.Serializable;
|
|||
|
||||
public class Medium implements Serializable, Comparable {
|
||||
private static final long serialVersionUID = -6543139465975455L;
|
||||
private final String mName;
|
||||
private final boolean mIsVideo;
|
||||
private final long mTimestamp;
|
||||
private final long mSize;
|
||||
public static int mSorting;
|
||||
private String mPath;
|
||||
|
||||
public Medium(String path, boolean isVideo, long timestamp, long size) {
|
||||
public Medium(String name, String path, boolean isVideo, long timestamp, long size) {
|
||||
mName = name;
|
||||
mPath = path;
|
||||
mIsVideo = isVideo;
|
||||
mTimestamp = timestamp;
|
||||
mSize = size;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return mName;
|
||||
}
|
||||
|
||||
public void setPath(String path) {
|
||||
mPath = path;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ 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 com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||
import com.bumptech.glide.signature.StringSignature
|
||||
|
@ -35,6 +36,7 @@ class MediaAdapter(private val mContext: Context, private val mMedia: MutableLis
|
|||
|
||||
viewHolder.playOutline.visibility = if (medium.isVideo) View.VISIBLE else View.GONE
|
||||
|
||||
viewHolder.fileName.text = medium.name
|
||||
val path = medium.path
|
||||
val timestampSignature = StringSignature(medium.timestamp.toString())
|
||||
if (medium.isGif) {
|
||||
|
@ -68,5 +70,6 @@ class MediaAdapter(private val mContext: Context, private val mMedia: MutableLis
|
|||
internal class ViewHolder(view: View) {
|
||||
val photoThumbnail: ImageView = view.medium_thumbnail
|
||||
val playOutline: View = view.play_outline
|
||||
val fileName: TextView = view.file_name
|
||||
}
|
||||
}
|
||||
|
|
7
app/src/main/res/drawable/gradient_background.xml
Normal file
7
app/src/main/res/drawable/gradient_background.xml
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<gradient
|
||||
android:angle="90"
|
||||
android:endColor="@android:color/transparent"
|
||||
android:startColor="#BB000000"/>
|
||||
</shape>
|
|
@ -16,4 +16,17 @@
|
|||
android:src="@mipmap/play_outline"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/file_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="@drawable/gradient_background"
|
||||
android:gravity="bottom"
|
||||
android:paddingBottom="@dimen/small_padding"
|
||||
android:paddingLeft="@dimen/small_padding"
|
||||
android:paddingRight="@dimen/small_padding"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="@dimen/details_text_size"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
|
Loading…
Reference in a new issue