mirror of
https://github.com/nextcloud/android.git
synced 2024-11-29 10:49:04 +03:00
Dispaly thumbnail when file is image
This commit is contained in:
parent
48cd33ae2d
commit
a601a0e06e
1 changed files with 20 additions and 5 deletions
23
src/com/owncloud/android/ui/fragment/FileDetailFragment.java
Normal file → Executable file
23
src/com/owncloud/android/ui/fragment/FileDetailFragment.java
Normal file → Executable file
|
@ -25,6 +25,7 @@ import java.lang.ref.WeakReference;
|
||||||
|
|
||||||
import android.accounts.Account;
|
import android.accounts.Account;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
|
@ -41,6 +42,7 @@ import android.widget.TextView;
|
||||||
import com.owncloud.android.R;
|
import com.owncloud.android.R;
|
||||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||||
import com.owncloud.android.datamodel.OCFile;
|
import com.owncloud.android.datamodel.OCFile;
|
||||||
|
import com.owncloud.android.datamodel.ThumbnailsCacheManager;
|
||||||
import com.owncloud.android.files.FileMenuFilter;
|
import com.owncloud.android.files.FileMenuFilter;
|
||||||
import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder;
|
import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder;
|
||||||
import com.owncloud.android.files.services.FileUploader.FileUploaderBinder;
|
import com.owncloud.android.files.services.FileUploader.FileUploaderBinder;
|
||||||
|
@ -343,7 +345,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
|
||||||
|
|
||||||
// set file details
|
// set file details
|
||||||
setFilename(file.getFileName());
|
setFilename(file.getFileName());
|
||||||
setFiletype(file.getMimetype(), file.getFileName());
|
setFiletype(file);
|
||||||
setFilesize(file.getFileLength());
|
setFilesize(file.getFileLength());
|
||||||
|
|
||||||
setTimeModified(file.getModificationTimestamp());
|
setTimeModified(file.getModificationTimestamp());
|
||||||
|
@ -395,20 +397,33 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the MIME type in view
|
* Updates the MIME type in view
|
||||||
* @param mimetype MIME type to set
|
* @param file : An {@link OCFile}
|
||||||
* @param filename Name of the file, to deduce the icon to use in case the MIME type is not precise enough
|
|
||||||
*/
|
*/
|
||||||
private void setFiletype(String mimetype, String filename) {
|
private void setFiletype(OCFile file) {
|
||||||
|
String mimetype = file.getMimetype();
|
||||||
TextView tv = (TextView) getView().findViewById(R.id.fdType);
|
TextView tv = (TextView) getView().findViewById(R.id.fdType);
|
||||||
if (tv != null) {
|
if (tv != null) {
|
||||||
|
// mimetype MIME type to set
|
||||||
String printableMimetype = DisplayUtils.convertMIMEtoPrettyPrint(mimetype);
|
String printableMimetype = DisplayUtils.convertMIMEtoPrettyPrint(mimetype);
|
||||||
tv.setText(printableMimetype);
|
tv.setText(printableMimetype);
|
||||||
}
|
}
|
||||||
ImageView iv = (ImageView) getView().findViewById(R.id.fdIcon);
|
ImageView iv = (ImageView) getView().findViewById(R.id.fdIcon);
|
||||||
if (iv != null) {
|
if (iv != null) {
|
||||||
|
Bitmap thumbnail = null;
|
||||||
|
if (file.isImage()) {
|
||||||
|
String tagId = String.valueOf(file.getRemoteId());
|
||||||
|
thumbnail = ThumbnailsCacheManager.getBitmapFromDiskCache(tagId);
|
||||||
|
}
|
||||||
|
if (thumbnail != null) {
|
||||||
|
// Display thumbnail
|
||||||
|
iv.setImageBitmap(thumbnail);
|
||||||
|
} else {
|
||||||
|
// Name of the file, to deduce the icon to use in case the MIME type is not precise enough
|
||||||
|
String filename = file.getFileName();
|
||||||
iv.setImageResource(DisplayUtils.getFileTypeIconId(mimetype, filename));
|
iv.setImageResource(DisplayUtils.getFileTypeIconId(mimetype, filename));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the file size in view
|
* Updates the file size in view
|
||||||
|
|
Loading…
Reference in a new issue