本文整理汇总了Java中com.ipaulpro.afilechooser.utils.FileUtils.getMimeType方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtils.getMimeType方法的具体用法?Java FileUtils.getMimeType怎么用?Java FileUtils.getMimeType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.ipaulpro.afilechooser.utils.FileUtils
的用法示例。
在下文中一共展示了FileUtils.getMimeType方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: uploadFileToServer
import com.ipaulpro.afilechooser.utils.FileUtils; //导入方法依赖的package包/类
/**
* Uploads a local file to the server.
*
* @param fileToUpload {File} - the file which will be uploaded
*/
public void uploadFileToServer(@NonNull java.io.File fileToUpload) {
// todo: refactor later on when there are class and course folders
String uploadPath = mDataManager.getCurrentStorageContext() + fileToUpload.getName();
SignedUrlRequest signedUrlRequest = new SignedUrlRequest(
SignedUrlRequest.ACTION_OBJECT_PUT, // action
uploadPath,
FileUtils.getMimeType(fileToUpload));
RxUtil.unsubscribe(fileUploadSubscription);
fileUploadSubscription = mDataManager.getFileUrl(signedUrlRequest)
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
signedUrlResponse -> startUploading(fileToUpload, signedUrlResponse),
error -> {
Timber.e(error, "There was an error uploading file from Server.");
sendToView(FileMvpView::showUploadFileError);
});
}
示例2: onActivityResult
import com.ipaulpro.afilechooser.utils.FileUtils; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case REQUEST_CHOOSER:
if (resultCode == RESULT_OK) {
Intent intent = new Intent(this, ShairingActivity.class);
Uri uri = data.getData();
intent.setAction(Intent.ACTION_SEND);
String mimeType = FileUtils.getMimeType(this, uri);
//TODO add google drive and one drive support
if (mimeType != null) {
intent.setType(mimeType);
intent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(intent);
} else {
//EasyTracker.getTracker(this).sendEvent("Event", "data not supported", uri.toString(), null);
Toast.makeText(this, getString(R.string.we_cant_share_this), Toast.LENGTH_LONG).show();
}
}
break;
}
}
示例3: add
import com.ipaulpro.afilechooser.utils.FileUtils; //导入方法依赖的package包/类
/**
* Add data to data set.
*/
public void add(File file) {
if (file == null)
return;
if (file.getName() == null)
return;
if (isGallery) {
String mimeType = FileUtils.getMimeType(file.getFile());
if (mimeType != null)
if (!mimeType.contains("image"))
return; //abort if not images.
}
if (!data.contains(file))
data.add(file);
notifyDataSetChanged();
}
示例4: add
import com.ipaulpro.afilechooser.utils.FileUtils; //导入方法依赖的package包/类
public void add(File file) {
String mimeType = FileUtils.getMimeType(file.getFile());
if (mimeType != null)
if (!mimeType.contains("image"))
return; //abort if not images.
files.add(file);
notifyDataSetChanged();
}
示例5: styleFileView
import com.ipaulpro.afilechooser.utils.FileUtils; //导入方法依赖的package包/类
private void styleFileView(IndexedFile file, View view) {
String mime = FileUtils.getMimeType(file.getExtension());
if (FileUtils.isImageOrVideo(mime)
&& file.getThumbFile().exists()
&& GeneralSettingsManager.isThumbnailsShown()) {
if (file.getThumbnail() == null) {
// there is no thumbnail yet to set. it still has to be created or retrieved.
// so for now show the normal view
styleFiletypeView(file, view);
}
styleThumbView(file, view);
} else {
styleFiletypeView(file, view);
}
ImageView statusImage = (ImageView) view.findViewById(R.id.file_status);
ImageView statusImageBG = (ImageView) view.findViewById(R.id.file_status_background);
View statusBar = view.findViewById(R.id.content_item_status_line);
if (file.isUnlocked()) {
statusImage.clearAnimation();
statusImage.setImageResource(R.drawable.ic_status_unlocked);
statusImageBG.setBackgroundColor(Utils.color(R.color.unlocked));
view.findViewById(R.id.content_item_status_line).setBackgroundColor(Utils.color(R.color.unlocked));
}
else if (file.isLocked()) {
statusImage.clearAnimation();
statusImage.setImageResource(R.drawable.ic_status_locked);
statusImageBG.setBackgroundColor(Utils.color(R.color.locked));
statusBar.setBackgroundColor(Utils.color(R.color.locked));
}
else {
statusImage.setImageResource(R.drawable.ic_status_processing);
statusImageBG.setBackgroundColor(Utils.color(R.color.processing));
statusBar.setBackgroundColor(Utils.color(R.color.processing));
if (view.getContext() != null) {
statusImage.setAnimation(AnimationUtils.loadAnimation(view.getContext(), R.anim.rotate));
}
}
}
示例6: styleFiletypeView
import com.ipaulpro.afilechooser.utils.FileUtils; //导入方法依赖的package包/类
private void styleFiletypeView(final IndexedFile file, final View view) {
View texts = view.findViewById(R.id.content_texts);
ImageView preview = (ImageView) view.findViewById(R.id.file_preview);
TextView nameTV = (TextView) view.findViewById(R.id.content_filename);
TextView extTV = (TextView) view.findViewById(R.id.content_extension);
String ext = file.getExtension();
String mime = FileUtils.getMimeType(ext);
texts.setVisibility(View.VISIBLE);
nameTV.setText(file.getName());
extTV.setText(ext.substring(1).toUpperCase());
FontManager.handleFontTags(texts);
if (mime == null) {
Utils.d("Could not find mimeType for " + ext);
preview.setBackgroundColor(Utils.color(R.color.filetype_text));
preview.setImageResource(R.drawable.ic_filetype_text);
}
else if (FileUtils.isAudio(mime) || ext.contains("3gp")) {
preview.setBackgroundColor(Utils.color(R.color.filetype_audio));
preview.setImageResource(R.drawable.ic_filetype_audio);
}
else if (FileUtils.isVideo(mime)) {
preview.setBackgroundColor(Utils.color(R.color.filetype_video));
preview.setImageResource(R.drawable.ic_filetype_video);
}
else if (FileUtils.isImage(mime)) {
preview.setBackgroundColor(Utils.color(R.color.filetype_image));
preview.setImageResource(R.drawable.ic_filetype_image);
}
else if (ext.contains("pdf")) {
preview.setBackgroundColor(Utils.color(R.color.filetype_pdf));
preview.setImageResource(R.drawable.ic_filetype_pdf);
}
else if (mime.contains("application/")) {
preview.setBackgroundColor(Utils.color(R.color.filetype_compressed));
preview.setImageResource(R.drawable.ic_filetype_compressed);
}
else if (ext.contains("xls")) {
preview.setBackgroundColor(Utils.color(R.color.filetype_excel));
preview.setImageResource(R.drawable.ic_filetype_excel);
}
else if (ext.contains("doc")) {
preview.setBackgroundColor(Utils.color(R.color.filetype_word));
preview.setImageResource(R.drawable.ic_filetype_word);
}
else if (ext.contains("ppt")) {
preview.setBackgroundColor(Utils.color(R.color.filetype_powerpoint));
preview.setImageResource(R.drawable.ic_filetype_powerpoint);
}
else if (ext.contains("htm")) {
preview.setBackgroundColor(Utils.color(R.color.filetype_html));
preview.setImageResource(R.drawable.ic_filetype_html);
}
else {
preview.setBackgroundColor(Utils.color(R.color.filetype_text));
preview.setImageResource(R.drawable.ic_filetype_text);
}
}