qingmei2 / RxImagePicker

:rocket:RxJava2 and RxJava3 external support. Android flexible picture selector, provides the support for theme of Zhihu and WeChat (灵活的Android图片选择器,提供了知乎和微信主题的支持).
MIT License
1.2k stars 155 forks source link

2.2.0版本自定义UI会闪退 #94

Open MrNANMU opened 4 years ago

MrNANMU commented 4 years ago

kotlin.KotlinNullPointerException at com.qingmei2.rximagepicker_extension.ui.adapter.AlbumsAdapter.bindView(AlbumsAdapter.kt:67) at android.widget.CursorAdapter.getView(CursorAdapter.java:289) at android.support.v7.widget.DropDownListView.measureHeightOfChildrenCompat(DropDownListView.java:321) at android.support.v7.widget.ListPopupWindow.buildDropDown(ListPopupWindow.java:1301) at android.support.v7.widget.ListPopupWindow.show(ListPopupWindow.java:647) at com.qingmei2.rximagepicker_extension.ui.widget.AlbumsSpinner$setSelectedTextView$1.onClick(AlbumsSpinner.kt:113) at android.view.View.performClick(View.java:6333) at android.view.View$PerformClick.run(View.java:24985) at android.os.Handler.handleCallback(Handler.java:790) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:192) at android.app.ActivityThread.main(ActivityThread.java:6842) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:886) 定位到是AlbumsAdapter的构造方法中的mPlaceholder为空,导致bindView失败。 `constructor(context: Context, c: Cursor?, autoRequery: Boolean) : super(context, c, autoRequery) {

    val ta = context.theme.obtainStyledAttributes(
            intArrayOf(R.attr.album_thumbnail_placeholder))
    mPlaceholder = ta.getDrawable(0)

//这个是空 ta.recycle() } 我自定义的ConfigBuilder: public class WeShootConfigBuilder {

private SelectionSpec selectionSpec;

public WeShootConfigBuilder(Set<MimeType> mimeTypes,boolean mediaTypeExclusive) {
    selectionSpec = SelectionSpec.Companion.getNewCleanInstance(new Glide4Engine());
    selectionSpec.setMimeTypeSet(mimeTypes);
    selectionSpec.setMediaTypeExclusive(mediaTypeExclusive);
    selectionSpec.setOrientation(SCREEN_ORIENTATION_UNSPECIFIED);
    selectionSpec.setShowSingleMediaType(true);
    selectionSpec.setMaxSelectable(10);
    selectionSpec.setCountable(true);
    selectionSpec.setThemeId(com.qingmei2.rximagepicker_extension_zhihu.R.style.Zhihu_Dracula);
}

public SelectionSpec build(){
    return selectionSpec;
}

}` 使用了知乎主题。 另外希望作者可以在readme中详细写一下如何自定义UI,比如主题需要配置什么,每个属性是什么意思等...我至今都没有摸索出如何自定义,自定义都应该增加什么配置等。这个不是只看Demo就能很快掌握的...(尤其我的项目中的UI还是高度自定义,类似抖音上传时候的那种,图片和视频在两个Fragment中还能滑动切换)