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

java.lang.NullPointerException #65

Open Abdelsattar opened 7 years ago

Abdelsattar commented 7 years ago
                                                                                     java.lang.NullPointerException: Attempt to invoke interface method 'void com.zhihu.matisse.engine.ImageEngine.loadThumbnail(android.content.Context, int, android.graphics.drawable.Drawable, android.widget.ImageView, android.net.Uri)' on a null object reference

Matisse.from(MainActivity.this) .choose(MimeType.allOf()) .countable(true) .maxSelectable(9) .restrictOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) // .thumbnailScale(0.85f) // .imageEngine(new GlideEngine()) .forResult(REQUEST_CODE_CHOOSE);

gejiaheng commented 7 years ago

@Abdelsattar Thanks for reporting this. Can you reproduce this crash and how?

Abdelsattar commented 7 years ago

`@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN) @AfterPermissionGranted(RC_CAMERA_PERM) void pickUpImage() { if (EasyPermissions.hasPermissions(this, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE)) { // Have permission, do the thing! Matisse.from(MainActivity.this) .choose(MimeType.allOf()) .countable(true) .maxSelectable(9) .restrictOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) .thumbnailScale(0.85f) .imageEngine(new GlideEngine()) .forResult(REQUEST_CODE_CHOOSE);

    } else {
        Log.d("Matisse", "Dont have permsion");
        // Ask for one permission
        EasyPermissions.requestPermissions(this, getString(R.string.rationale_camera),
                RC_CAMERA_PERM, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE);
    }

}`

i used it with another activity of permission but after permission granted and the matisse open it crashed

darshandawaibox commented 7 years ago

Facing the same issue. Any update on this? java.lang.NullPointerException: Attempt to invoke interface method 'void com.zhihu.matisse.engine.ImageEngine.loadThumbnail(android.content.Context, int, android.graphics.drawable.Drawable, android.widget.ImageView, android.net.Uri)' on a null object reference at com.zhihu.matisse.internal.ui.widget.PhotoGrid.setImage(PhotoGrid.java:112) at com.zhihu.matisse.internal.ui.widget.PhotoGrid.bindPhoto(PhotoGrid.java:80) at com.zhihu.matisse.internal.ui.adapter.AlbumPhotosAdapter.onBindViewHolder(AlbumPhotosAdapter.java:111) at com.zhihu.matisse.internal.ui.adapter.RecyclerViewCursorAdapter.onBindViewHolder(RecyclerViewCursorAdapter.java:44)

gejiaheng commented 7 years ago

I can't reproduce this crash. @darshandawaibox can you provide more information?

darshandawaibox commented 7 years ago

@gejiaheng I fixed my way around that but now I am not getting the camera option/button as shown in the below screenshot. Also the preview is not working and is there any way I can customise the toolbar? image

gejiaheng commented 7 years ago

@darshandawaibox Let's get this clear:

  1. How do you fix it?
  2. The capture feature is not stable now, but you can try it like this:
    Matisse.from(MainActivity.this)
    ....
    .capture(true)
    .captureStrategy(new CaptureStrategy(true, "com.zhihu.matisse.sample.fileprovider")
    .forResult(REQUEST_CODE);

    And also define a FileProvider and /xml/file_paths_public.xml like the sample does.

  3. What do you mean by the preview is not working? Preview button disabled or image not showing in the preview UI?
  4. Check out https://github.com/zhihu/Matisse/wiki/Theme to know how to customize toolbar.