2013-12-09 4 views
0

android?의 Universal image Loader로 미리보기 이미지를로드 할 수 있습니까? 나는 Sdcard에서 이미지와 비디오 파일의 썸네일을 얻었고 그리드 뷰에서이 라이브러리를 사용하여이 썸네일을 어떻게 표시할지 모르기 때문에 아무에게도 어떻게 알 수 있는지 말해 주시겠습니까? 사전에Android 용 Universal Image Loader로 미리보기 이미지로드?

protected Integer doInBackground(Integer... params) { 
     // TODO Auto-generated method stub 

     final String[] columns = { MediaStore.Images.Media.DATA, MediaStore.Images.Media._ID };   // Images getting 
     final String orderBy = MediaStore.Images.Media.DATE_TAKEN; 

     imagecursor = mContext.getContentResolver().query(
       MediaStore.Images.Media.EXTERNAL_CONTENT_URI, columns, null, 
       null, orderBy); 
     int image_column_index = imagecursor.getColumnIndex(MediaStore.Images.Media._ID); 
     this.count = imagecursor.getCount(); 
     /*this.count = params[0]; 

     if(count == 0) 
      this.count = imagecursor.getCount(); 
     else if(count >= 12) 

     */ 
     bitList = new ArrayList<Bitmap>(); 
     arrPathList = new ArrayList<String>(); 
     selectedPath = new ArrayList<String>(); 

     for (int i = 0; i < this.count; i++) { 
      imagecursor.moveToPosition(i); 
      int id = imagecursor.getInt(image_column_index); 
      int dataColumnIndex = imagecursor.getColumnIndex(MediaStore.Images.Media.DATA); 

      bitList.add(MediaStore.Images.Thumbnails.getThumbnail(
        mContext.getContentResolver(), id, 
        MediaStore.Images.Thumbnails.MICRO_KIND, null)); 

      arrPathList.add(imagecursor.getString(dataColumnIndex)); 
     } 

     this.durationcount = new ArrayList<String>();             // Video Getting 
     final String[] parameters = { MediaStore.Video.Media.DATA, MediaStore.Video.Media._ID, MediaStore.Video.Media.DURATION , MediaStore.Video.Media.MIME_TYPE}; // Videos getting 
     final String orderBy_v = MediaStore.Video.Media._ID; 

     videocursor = mContext.getContentResolver().query(
       MediaStore.Video.Media.EXTERNAL_CONTENT_URI, parameters, null, 
       null, orderBy_v); 

     int video_column_index = videocursor.getColumnIndex(MediaStore.Video.Media._ID); 
     int video_column_duration = videocursor.getColumnIndexOrThrow(MediaStore.Video.VideoColumns.DURATION);   // for duration of the video 
     totalCount = imagecursor.getCount() + videocursor.getCount();       /// Checking 
     durationcount_a = new String[imagecursor.getCount() + videocursor.getCount()]; 

     for(int i = 0; i < videocursor.getCount(); i ++){ 
      videocursor.moveToPosition(ii); 
      int id_v = videocursor.getInt(video_column_index); 
      int datacolumn_v = videocursor.getColumnIndex(MediaStore.Video.Media.DATA); 
      long duration = videocursor.getInt(video_column_duration);    // getting duration of the every videos 

      String hms = String.format("%02d:%02d:%02d", TimeUnit.MILLISECONDS.toHours(duration), 
        TimeUnit.MILLISECONDS.toMinutes(duration) - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(duration)), 
        TimeUnit.MILLISECONDS.toSeconds(duration) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(duration))); 

      durationcount.add(hms); 
      durationcount_a[(imagecursor.getCount()) + ii] = hms;   
      bitList.add(MediaStore.Video.Thumbnails.getThumbnail(mContext.getContentResolver(), id_v, 
        MediaStore.Video.Thumbnails.MICRO_KIND, null)); 
      arrPathList.add(videocursor.getString(datacolumn_v)); 
     } 
     thumbnailsselection = new boolean[totalCount]; 
     return null; 

    } 

감사 :

는이 코드에서 썸네일을 얻었다.

+0

확인하여 ImageLoader하기 : [안드로이드 - 갤러리에서 여러 사진을 선택합니다 (HTTP : // WWW .jpchnotalkative.com/android-select-multiple-photos-gallery /) –

+0

ur 답장을 보내 주셔서 감사합니다. 사실 저는 ur 블로그를 보았습니다. 정말 멋졌지만 imageLoader.displayImage() 메소드에서 파일 경로를 전달한 곳에서 시도했습니다. 또한 이미지 및 비디오 파일에 대한하지만 그것은 오직 비디오 파일에 대한 이미지 파일에 대한 썸네일을 표시합니다, 나는 두 파일에 대한 축소판을 표시해야합니다 이 lib를 사용하는 방법? – siva

답변

1

U 유니버설 이미지 로더를 사용하여 이미지를로드하려면 미리보기 이미지의 경로 또는 URI를 가져야합니다.

는이 URI를 얻을 참조 : -

Get thumbnail Uri/path of the image stored in sd card + android

내가 또한 프로젝트의 같은 종류의 일을하고 자식 허브에 그것을 주최 한 .. 내가하여 ImageLoader 및 기타없이 하나의 두 가지 버전이 하여 ImageLoader와 함께 .. 지금은 호스팅 만 이전 하나 - :

-

여기

경로 여기 https://github.com/r4jiv007/CustomFilePicker.git

입니다 내가 사용하는 방법은 .. 이미지를로드하기 위해

imageLoader.displayImage("file://" + fileX.getmThumbPath() + "", imageView, options); 

도 몇 번을 조심 썸네일 이미지에 대한이 없습니다! - :

private String getImageThumbnail(int id) { 
     final String thumb_DATA = MediaStore.Images.Thumbnails.DATA; 
     final String thumb_IMAGE_ID = MediaStore.Images.Thumbnails.IMAGE_ID; 
     Uri uri = thumbUri; 
     String[] projection = {thumb_DATA, thumb_IMAGE_ID}; 
     String selection = thumb_IMAGE_ID + "=" + id + " AND " + MediaStore.Images.Thumbnails.KIND + "=" + MediaStore.Images.Thumbnails.MINI_KIND; 
     Cursor thumbCursor = getContentResolver().query(uri, projection, selection, null, null); 

     String thumbPath = null; 
     Bitmap thumbBitmap = null; 
     if (thumbCursor != null && thumbCursor.getCount() > 0) { 
      thumbCursor.moveToFirst(); 
      int thCulumnIndex = thumbCursor.getColumnIndex(thumb_DATA); 

      thumbPath = thumbCursor.getString(thCulumnIndex); 
/* 
      Toast.makeText(getApplicationContext(), 
        thumbPath, 
        Toast.LENGTH_LONG).show();*/ 

      // thumbBitmap = BitmapFactory.decodeFile(thumbPath); 

     } 
     Log.i("ImageMiniKind", thumbPath + ""); 
     return thumbPath; 
    } 

및 유 사용해야합니다 지금 동영상 파일

private String getVideoThumbnail(int id) { 
    final String thumb_DATA = MediaStore.Video.Thumbnails.DATA; 
    final String thumb_VIDEO_ID = MediaStore.Video.Thumbnails.VIDEO_ID; 
    Uri uri = MediaStore.Video.Thumbnails.EXTERNAL_CONTENT_URI; 
    String[] projection = {thumb_DATA, thumb_VIDEO_ID}; 
    String selection = thumb_VIDEO_ID + "=" + id + " AND " + MediaStore.Video.Thumbnails.KIND + "=" + MediaStore.Video.Thumbnails.MINI_KIND; 
    Cursor thumbCursor = getContentResolver().query(uri, projection, selection, null, null); 
    String thumbPath = null; 
    // Bitmap thumbBitmap = null; 
    if (thumbCursor.moveToFirst()) { 

     int thCulumnIndex = thumbCursor.getColumnIndex(thumb_DATA); 

     thumbPath = thumbCursor.getString(thCulumnIndex); 
    } 
    return thumbPath; 
} 

을로드 축소판에 대한

당신이 경로를 통과한다 할 일은 라이브러리

+0

답장을 보내 주셔서 감사합니다, 이미 내가 이미지와 비디오 파일의 경로를 통과했다는 것을 의미하는 ur 메서드에서 작업 했었지만 이미지 파일에 대한 미리보기 이미지 만있어 두 파일에 대한 미리보기 이미지를 얻었으므로이 미리보기 이미지를이 lib를 사용하여로드해야합니다. , 그것이 가능한지 아닌지 알고 싶습니다. 구현 방법을 알려주십시오. – siva

+0

이전에이 라이브러리로 작업 한 적이 있습니까? – r4jiv007

+0

예, universal-image-loader-1.6.1-src.jar lib를 사용했습니다. – siva

관련 문제