Android项目实战(六十九):Matisse知乎图片选择,切换相册不显示图片的bug
问题现象:
正常显示默认的所有的图片,当点击切换相册的时候,相册的图片是空的
因为项目已经不再维护,故下载源码,import module到项目中
修复步骤:
1、MatisseActivity
private void onAlbumSelected(Album album) { if (album.isAll() && album.isEmpty()) { mContainer.setVisibility(View.GONE); mEmptyView.setVisibility(View.VISIBLE); } else { mContainer.setVisibility(View.VISIBLE); mEmptyView.setVisibility(View.GONE); Fragment fragment = MediaSelectionFragment.newInstance(album); // 修复matisse源码存在的,切换其他相册空白问题 Fragment oldFragment = getSupportFragmentManager().findFragmentByTag(MediaSelectionFragment.class.getSimpleName()); if (oldFragment instanceof MediaSelectionFragment) { MediaSelectionFragment newFragment = (MediaSelectionFragment) oldFragment; newFragment.destroyManagerLoader(); } getSupportFragmentManager() .beginTransaction() .replace(R.id.container, fragment, MediaSelectionFragment.class.getSimpleName()) .commitAllowingStateLoss(); } }
@Override protected void onDestroy() { super.onDestroy(); mAlbumCollection.onDestroy(); mSpec.onCheckedListener = null; mSpec.onSelectedListener = null; }
2、MediaSelectionFragment
public void destroyManagerLoader() { mAlbumMediaCollection.onDestroy(); }
3、AlbumMediaCollection
public void onDestroy() { if (mLoaderManager != null) { mLoaderManager.destroyLoader(LOADER_ID); } mCallbacks = null; mLoaderManager = null; }
作者:听着music睡
出处:http://www.cnblogs.com/xqxacm/
Android交流群:38197636
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。