Skip to content

Commit

Permalink
Improved the icons.
Browse files Browse the repository at this point in the history
  • Loading branch information
octacode committed Jul 7, 2017
1 parent f460066 commit 8a2e4bd
Show file tree
Hide file tree
Showing 13 changed files with 44 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ public void onBindViewHolder(Presenter.ViewHolder viewHolderArgs, Object item) {
setUpDimensions(viewHolder);
if (isDirectory(serverFile))
setDate(serverFile, viewHolder);
else
setSize(serverFile, viewHolder);
// else
// setSize(serverFile, viewHolder);
if (isImage(serverFile)) {
setUpImageIcon(serverFile, viewHolder.mCardView.getMainImageView(), getImageUri(serverFile));
} else {
Expand Down Expand Up @@ -149,7 +149,8 @@ private void setUpDimensions(ViewHolder viewHolder) {
}

private void setUpDrawable(ServerFile serverFile, ViewHolder viewHolder) {
viewHolder.mCardView.setMainImage(ContextCompat.getDrawable(mContext, Mimes.getFileIcon(serverFile)));
viewHolder.mCardView.setMainImageScaleType(ImageView.ScaleType.CENTER_INSIDE);
viewHolder.mCardView.setMainImage(ContextCompat.getDrawable(mContext, Mimes.getTVFileIcon(serverFile)));
}

@Subscribe
Expand Down Expand Up @@ -182,7 +183,7 @@ private void setUpImageIcon(ServerFile file, ImageView fileIconView, String url)
.load(url)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.centerCrop()
.placeholder(Mimes.getFileIcon(file))
.placeholder(Mimes.getTVFileIcon(file))
.into(fileIconView);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import android.support.v17.leanback.widget.ImageCardView;
import android.support.v17.leanback.widget.Presenter;
import android.support.v4.content.ContextCompat;
import android.text.format.Formatter;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
Expand Down Expand Up @@ -67,16 +66,17 @@ public void onBindViewHolder(Presenter.ViewHolder viewHolder, Object item) {
Date d = serverFile.getModificationTime();
SimpleDateFormat dt = new SimpleDateFormat("EEE LLL dd yyyy");
view.mCardView.setContentText(dt.format(d));
} else {
view.mCardView.setContentText(Formatter.formatFileSize(mContext, serverFile.getSize()));
}
// else {
// view.mCardView.setContentText(Formatter.formatFileSize(mContext, serverFile.getSize()));
// }

view.mCardView.setMainImageDimensions(400, 300);

if (isImage(serverFile)) {
setUpImageIcon(serverFile, view.mCardView.getMainImageView());
} else {
view.mCardView.setMainImage(ContextCompat.getDrawable(mContext, Mimes.getFileIcon(serverFile)));
view.mCardView.setMainImage(ContextCompat.getDrawable(mContext, Mimes.getTVFileIcon(serverFile)));
}

}
Expand All @@ -94,7 +94,7 @@ private void setUpImageIcon(ServerFile file, ImageView fileIconView) {
.load(getImageUri(file))
.diskCacheStrategy(DiskCacheStrategy.ALL)
.centerCrop()
.placeholder(Mimes.getFileIcon(file))
.placeholder(Mimes.getTVFileIcon(file))
.into(fileIconView);
}

Expand Down
34 changes: 34 additions & 0 deletions src/main/java/org/amahi/anywhere/util/Mimes.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,40 @@ public static int getFileIcon(ServerFile file) {
}
}

public static int getTVFileIcon(ServerFile file) {
switch (Mimes.match(file.getMime())) {
case Mimes.Type.ARCHIVE:
return R.drawable.tv_ic_archive;

case Mimes.Type.AUDIO:
return R.drawable.tv_ic_audio;

case Mimes.Type.CODE:
return R.drawable.tv_ic_code;

case Mimes.Type.DOCUMENT:
return R.drawable.tv_ic_document;

case Mimes.Type.DIRECTORY:
return R.drawable.tv_ic_folder;

case Mimes.Type.IMAGE:
return R.drawable.tv_ic_images;

case Mimes.Type.PRESENTATION:
return R.drawable.tv_ic_presentation;

case Mimes.Type.SPREADSHEET:
return R.drawable.tv_ic_spreadsheet;

case Mimes.Type.VIDEO:
return R.drawable.tv_ic_video;

default:
return R.drawable.tv_ic_generic;
}
}

public static final class Type {
public static final int UNDEFINED = 0;
public static final int ARCHIVE = 1;
Expand Down
Binary file added src/main/res/drawable-hdpi/tv_ic_archive.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/res/drawable-hdpi/tv_ic_audio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/res/drawable-hdpi/tv_ic_code.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/res/drawable-hdpi/tv_ic_document.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/res/drawable-hdpi/tv_ic_folder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/res/drawable-hdpi/tv_ic_generic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/res/drawable-hdpi/tv_ic_images.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/res/drawable-hdpi/tv_ic_presentation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/res/drawable-hdpi/tv_ic_spreadsheet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/res/drawable-hdpi/tv_ic_video.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8a2e4bd

Please sign in to comment.