@Override public void onItemClick(AdapterView<?> parent, View v, int position, long id) { mImageResizer.setPauseWork(true); if (position == 0) { Intent intent = new Intent(); intent.setClass(getActivity(), RecorderVideoActivity.class); startActivityForResult(intent, 100); } else { // VideoEntity vEntty=(VideoEntity) parent.getItemAtPosition(position); VideoEntity vEntty = mList.get(position - 1); // 限制大小不能超过10M if (vEntty.size > 1024 * 1024 * 10) { Toast.makeText(getActivity(), "暂不支持大于10M的视频!", Toast.LENGTH_SHORT).show(); return; } Intent intent = getActivity() .getIntent() .putExtra("path", vEntty.filePath) .putExtra("dur", vEntty.duration); getActivity().setResult(Activity.RESULT_OK, intent); getActivity().finish(); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mImageThumbSize = getResources().getDimensionPixelSize(R.dimen.image_thumbnail_size); mImageThumbSpacing = getResources().getDimensionPixelSize(R.dimen.image_thumbnail_spacing); mList = new ArrayList<VideoEntity>(); getVideoFile(); mAdapter = new ImageAdapter(getActivity()); ImageCache.ImageCacheParams cacheParams = new ImageCache.ImageCacheParams(); cacheParams.setMemCacheSizePercent(0.25f); // Set memory cache to 25% of // app memory // The ImageFetcher takes care of loading images into our ImageView // children asynchronously mImageResizer = new ImageResizer(getActivity(), mImageThumbSize); mImageResizer.setLoadingImage(R.drawable.empty_photo); mImageResizer.addImageCache(getActivity().getSupportFragmentManager(), cacheParams); }
@Override public void onDestroy() { super.onDestroy(); mImageResizer.closeCache(); mImageResizer.clearCache(); }
@Override public void onResume() { super.onResume(); mImageResizer.setExitTasksEarly(false); mAdapter.notifyDataSetChanged(); }