From c47112a01e83df38efd4acf9461160933ddd70f4 Mon Sep 17 00:00:00 2001 From: zengfantian <@FTZeng1213> Date: Thu, 15 Aug 2019 12:27:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=97=A0=E7=94=A8=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sample/imagepicker/ImageFileBean.java | 3 + .../imagepicker/ImagePickerActivity.java | 95 ------------------- 2 files changed, 3 insertions(+), 95 deletions(-) diff --git a/apps/zftlive-framework-samples/src/main/java/com/zftlive/android/sample/imagepicker/ImageFileBean.java b/apps/zftlive-framework-samples/src/main/java/com/zftlive/android/sample/imagepicker/ImageFileBean.java index f12d255..37a7d0b 100644 --- a/apps/zftlive-framework-samples/src/main/java/com/zftlive/android/sample/imagepicker/ImageFileBean.java +++ b/apps/zftlive-framework-samples/src/main/java/com/zftlive/android/sample/imagepicker/ImageFileBean.java @@ -41,6 +41,9 @@ public class ImageFileBean extends AdapterModelBean { public String resolution = ""; + /** + * 添加时间 + */ public String addDate = ""; /** diff --git a/apps/zftlive-framework-samples/src/main/java/com/zftlive/android/sample/imagepicker/ImagePickerActivity.java b/apps/zftlive-framework-samples/src/main/java/com/zftlive/android/sample/imagepicker/ImagePickerActivity.java index a3ad979..a0c1d82 100644 --- a/apps/zftlive-framework-samples/src/main/java/com/zftlive/android/sample/imagepicker/ImagePickerActivity.java +++ b/apps/zftlive-framework-samples/src/main/java/com/zftlive/android/sample/imagepicker/ImagePickerActivity.java @@ -21,7 +21,6 @@ package com.zftlive.android.sample.imagepicker; import android.Manifest; import android.annotation.SuppressLint; import android.annotation.TargetApi; -import android.app.Activity; import android.content.Context; import android.content.pm.PackageManager; import android.database.Cursor; @@ -90,9 +89,6 @@ public class ImagePickerActivity extends CommonActivity implements LoaderManager } private void initData(){ -// mMyListViewAdapter.clear(); -// mMyListViewAdapter.addItem(getLoadMedia()); - // 检测读取、写入权限 if (ContextCompat.checkSelfPermission(mActivity, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED && @@ -124,97 +120,6 @@ public class ImagePickerActivity extends CommonActivity implements LoaderManager mActivity.getSupportLoaderManager().initLoader(0, null, this); } - public ArrayList getLoadMedia() { - - ArrayList result = new ArrayList<>(); - - Cursor cursor = this.getContentResolver().query(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, null, null, null, MediaStore.Video.Media.DEFAULT_SORT_ORDER); - try { - for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) { - int id = cursor.getInt(cursor.getColumnIndexOrThrow(MediaStore.Video.Media._ID)); // id - String displayName =cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.TITLE)); - String album = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.ALBUM)); // 专辑 - String artist = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.ARTIST)); // 艺术家 - String title = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DISPLAY_NAME)); // 显示名称 - String mimeType =cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.MIME_TYPE)); - String path = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DATA)); // 路径 - long duration = cursor.getInt(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DURATION)); // 时长 - long size = cursor.getLong(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.SIZE)); // 大小 - String resolution =cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.RESOLUTION)); - - ImageFileBean item = new ImageFileBean(); - item.id = id+""; - item.displayName = displayName; - item.album = album; - item.artist = artist; - item.title = title; - item.mimeType = mimeType; - item.path = path; - item.imageURL = path; - item.duration = duration; - item.size = size; - item.resolution = resolution; - - Logger.d(TAG,"id="+id + " title="+title + " mimeType="+mimeType +" resolution="+resolution+ " path="+path +" duration="+duration + " size="+size); - - result.add(item); - } - } catch (Exception e) { - e.printStackTrace(); - } finally { - cursor.close(); - } - - return result; - } - - public static String[] thumbColumns = { MediaStore.Video.Thumbnails.DATA }; - public static String[] mediaColumns = { MediaStore.Video.Media._ID }; - - public static String getThumbnailPathForLocalFile(Activity context, Uri fileUri) { - - long fileId = getFileId(context, fileUri); - - MediaStore.Video.Thumbnails.getThumbnail(context.getContentResolver(), - fileId, MediaStore.Video.Thumbnails.MICRO_KIND, null); - - Cursor thumbCursor = null; - try { - - thumbCursor = context.managedQuery( - MediaStore.Video.Thumbnails.EXTERNAL_CONTENT_URI, - thumbColumns, MediaStore.Video.Thumbnails.VIDEO_ID + " = " - + fileId, null, null); - - if (thumbCursor.moveToFirst()) { - String thumbPath = thumbCursor.getString(thumbCursor - .getColumnIndex(MediaStore.Video.Thumbnails.DATA)); - - return thumbPath; - } - - } finally { - } - - return ""; - } - - public static long getFileId(Activity context, Uri fileUri) { - - Cursor cursor = context.managedQuery(fileUri, mediaColumns, null, null, - null); - - if (cursor.moveToFirst()) { - int columnIndex = cursor - .getColumnIndexOrThrow(MediaStore.Video.Media._ID); - int id = cursor.getInt(columnIndex); - - return id; - } - - return 0; - } - @TargetApi(Build.VERSION_CODES.HONEYCOMB) @NonNull @Override