码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • 记录Android 知乎图片选择器Matisse的注意事项


    项目地址:GitHub - zhihu/Matisse: A well-designed local image and video selector for Android:fireworks: A well-designed local image and video selector for Android - GitHub - zhihu/Matisse: A well-designed local image and video selector for Androidhttps://github.com/zhihu/Matisse

    直接依赖:

    1. repositories {
    2. jcenter()
    3. }
    4. dependencies {
    5. implementation 'com.zhihu.android:matisse:$latest_version'
    6. }

    存在问题:默认打开本地图库,全部显示正常,但是切换到其他相册,空白展示;

    目前作者还未修复此问题,可通过以下方式进行修改:

    (1)将源码下载下来;

    (2)使用import module的方式,导入到项目中;

    (3)找到MatisseActivity,onAlbumSelected()方法中:

    1. private void onAlbumSelected(Album album) {
    2. if (album.isAll() && album.isEmpty()) {
    3. mContainer.setVisibility(View.GONE);
    4. mEmptyView.setVisibility(View.VISIBLE);
    5. } else {
    6. mContainer.setVisibility(View.VISIBLE);
    7. mEmptyView.setVisibility(View.GONE);
    8. Fragment fragment = MediaSelectionFragment.newInstance(album);
    9. // 修复matisse源码存在的,切换其他相册空白问题
    10. Fragment oldFragment = getSupportFragmentManager().findFragmentByTag(MediaSelectionFragment.class.getSimpleName());
    11. if (oldFragment instanceof MediaSelectionFragment) {
    12. MediaSelectionFragment newFragment = (MediaSelectionFragment) oldFragment;
    13. newFragment.destroyManagerLoader();
    14. }
    15. getSupportFragmentManager()
    16. .beginTransaction()
    17. .replace(R.id.container, fragment, MediaSelectionFragment.class.getSimpleName())
    18. .commitAllowingStateLoss();
    19. }
    20. }

    (4)在MediaSelectionFragment中添加:

    1. public void destroyManagerLoader() {
    2. mAlbumMediaCollection.onDestroy();
    3. }

    (5)在AlbumCollection添加:

    1. public void onDestroy() {
    2. if (mLoaderManager != null) {
    3. mLoaderManager.destroyLoader(LOADER_ID);
    4. }
    5. mCallbacks = null;
    6. }

    (6)在MatisseActivity onDestroy中调用即可:

    1. @Override
    2. protected void onDestroy() {
    3. super.onDestroy();
    4. mAlbumCollection.onDestroy();
    5. mSpec.onCheckedListener = null;
    6. mSpec.onSelectedListener = null;
    7. }

  • 相关阅读:
    javascript二维数组(18)多个数组按照对应为准相加求和生成新的数组2
    Excel-VBA 快速上手(一、宏、VBA、过程、类型与变量、函数)
    L1-028 判断素数(Lua)
    利用亚马逊 云服务器 EC2 和S3免费套餐搭建私人网盘
    华为三位大佬耗时半年终成MySQL金字塔,面试无忧!
    STL算术生成和集合算法
    CSS属性使用之字体属性和文本属性使用规范标准有那些?
    【GEE】基于GEE进行非监督学习
    栈与队列3——用队列实现栈
    干货|成为优秀软件测试工程师的六大必备能力
  • 原文地址:https://blog.csdn.net/u010231454/article/details/125507625
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号