zhihu / Matisse

:fireworks: A well-designed local image and video selector for Android
Apache License 2.0
12.52k stars 2.06k forks source link

空指针异常 #241

Closed Kilnn closed 6 years ago

Kilnn commented 7 years ago
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
    at com.zhihu.matisse.internal.entity.Item.isGif(Item.java:91)
    at com.zhihu.matisse.internal.ui.widget.PhotoGrid.setGifTag(PhotoGrid.java:88)
    at com.zhihu.matisse.internal.ui.widget.PhotoGrid.bindPhoto(PhotoGrid.java:78)
    at com.zhihu.matisse.internal.ui.adapter.AlbumPhotosAdapter.onBindViewHolder(AlbumPhotosAdapter.java:111)
    at com.zhihu.matisse.internal.ui.adapter.RecyclerViewCursorAdapter.onBindViewHolder(RecyclerViewCursorAdapter.java:44)
    at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:6356)
    at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:6389)
    at android.support.v7.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:5335)
    at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5598)
    at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5440)
    at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5436)
    at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2224)
    at android.support.v7.widget.GridLayoutManager.layoutChunk(GridLayoutManager.java:556)
    at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1511)
    at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:595)
    at android.support.v7.widget.GridLayoutManager.onLayoutChildren(GridLayoutManager.java:170)
    at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3583)
    at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3312)
    at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3844)
    at android.view.View.layout(View.java:17942)
    at android.view.ViewGroup.layout(ViewGroup.java:5754)
    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:383)
    at android.widget.FrameLayout.onLayout(FrameLayout.java:321)
    at android.view.View.layout(View.java:17942)
    at android.view.ViewGroup.layout(ViewGroup.java:5754)
    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:383)
    at android.widget.FrameLayout.onLayout(FrameLayout.java:321)
    at android.view.View.layout(View.java:17942)
    at android.view.ViewGroup.layout(ViewGroup.java:5754)
    at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1189)
    at android.view.View.layout(View.java:17942)
    at android.view.ViewGroup.layout(ViewGroup.java:5754)
    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:383)
    at android.widget.FrameLayout.onLayout(FrameLayout.java:321)
    at android.view.View.layout(View.java:17942)
    at android.view.ViewGroup.layout(ViewGroup.java:5754)
    at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1982)
    at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1826)
    at android.widget.LinearLayout.onLayout(LinearLayout.java:1735)
    at android.view.View.layout(View.java:17942)
    at android.view.ViewGroup.layout(ViewGroup.java:5754)
    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:383)
    at android.widget.FrameLayout.onLayout(FrameLayout.java:321)
    at android.view.View.layout(View.java:17942)
    at android.view.ViewGroup.layout(ViewGroup.java:5754)
    at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1982)
    at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1826)
    at android.widget.LinearLayout.onLayout(LinearLayout.java:1735)
    at android.view.View.layout(View.java:17942)
    at android.view.ViewGroup.layout(ViewGroup.java:5754)
    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:383)
    at android.widget.FrameLayout.onLayout(FrameLayout.java:321)
    at com.android.internal.policy.DecorView.onLayout(DecorView.java:747)
    at android.view.View.layout(View.java:17942)
    at android.view.ViewGroup.layout(ViewGroup.java:5754)
    at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2737)
    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2407)
    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1481)
    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7077)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:909)
    at android.view.Choreographer.doCallbacks(Choreographer.java:711)
    at android.view.Choreographer.doFrame(Choreographer.java:646)
    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:895)
    at android.os.Handler.handleCallback(Handler.java:836)
    at android.os.Handler.dispatchMessage(Handler.java:103)
    at android.os.Looper.loop(Looper.java:203)
    at android.app.ActivityThread.main(ActivityThread.java:6412)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1113)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:974)
Amyitis commented 7 years ago

我也遇到这个问题了~跟你一样。 java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference 在Item这个类中90行 public boolean isGif() { return mimeType.equals(MimeType.GIF.toString()); }

qdxxxx commented 7 years ago

+1

cfryan1990 commented 7 years ago

使用ide去生成item的equals和hashCode代码,ide会做判空处理

chet-chen commented 6 years ago

+1

REBOOTERS commented 6 years ago

bug had been fixed.