问题现象:
正常显示默认的所有的图片,当点击切换相册的时候,相册的图片是空的
因为项目已经不再维护,故下载源码,import module到项目中
修复步骤:
1、MatisseActivity
代码语言:javascript复制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();
}
}
代码语言:javascript复制@Override
protected void onDestroy() {
super.onDestroy();
mAlbumCollection.onDestroy();
mSpec.onCheckedListener = null;
mSpec.onSelectedListener = null;
}
2、MediaSelectionFragment
代码语言:javascript复制public void destroyManagerLoader() {
mAlbumMediaCollection.onDestroy();
}
3、AlbumMediaCollection
代码语言:javascript复制 public void onDestroy() {
if (mLoaderManager != null) {
mLoaderManager.destroyLoader(LOADER_ID);
}
mCallbacks = null;
mLoaderManager = null;
}