mzelzoghbi/ZGallery

onclick on the populated images in ZGrid crashing app activity

Opened this issue · 8 comments

Image is showing finely in the grid but whenever i click any of the populated images in the grid, the activity crashes showing error

java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.String
java.lang.CharSequence.toString()' on a null object reference
at com.mzelzoghbi.zgallery.activities.ZGridActivity.onClick(ZGridActivity.java:56)
at com.mzelzoghbi.zgallery.adapters.GridImagesAdapter$1.onClick(GridImagesAdapter.java:46)
at android.view.View.performClick(View.java:5721)
at android.view.View$PerformClick.run(View.java:22620)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7409)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

I have used your code to show local images with ZGrid, inside a onclick listener

Hello, same here.
Do you already found the work around?
If by any chance you are decided to switch to another lib, could I know what is it?
Been wondering but still could not find much like with this zgallery.
Thanks in advance.

@agungsus no the problem still exists..

Hi again,
Finally, in my case, I add this in AndroidManifest and it doesn't crash:

    <activity
        android:name="com.mzelzoghbi.zgallery.activities.ZGridActivity"
        android:label="@string/title_activity"
        android:parentActivityName=".MainActivity"
        android:theme="@style/AppTheme.NoActionBar">
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="com.myapp.MainActivity" />
    </activity>

    <activity
        android:name="com.mzelzoghbi.zgallery.activities.ZGalleryActivity"
        android:label="@string/title_activity"
        android:parentActivityName=".MainActivity"
        android:theme="@style/AppTheme.NoActionBar">
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="com.myapp.MainActivity" />
    </activity>

Well, hope it can help. ^^

@agungsus after using i am getting

java.lang.RuntimeException: Unable to start activity ComponentInfo{joy.creative.uimagesaver/com.mzelzoghbi.zgallery.activities.ZGalleryActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.widget.Toolbar.setVisibility(int)' on a null object reference at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3320)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3416) at android.app.ActivityThread.access$1100(ActivityThread.java:230)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1822) at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:7409)
at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void
android.support.v7.widget.Toolbar.setVisibility(int)' on a null object reference at com.mzelzoghbi.zgallery.activities.BaseActivity.onCreate(BaseActivity.java:56)
at android.app.Activity.performCreate(Activity.java:6904) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1136)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3267) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3416) 
at android.app.ActivityThread.access$1100(ActivityThread.java:230)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1822) 
at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:7409)  at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 

@agungsus

can you please describe the style content of

@style/AppTheme.NoActionBar

Hello,
Here is my style:

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>

    <item name="android:textColor">@android:color/black</item>
</style>

<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
Hope it can help, cheers.

no improve.. same happening. with same error. @agungsus

Hmm, not sure about that error, but do you already use 0.3.1 tag?
com.github.mzelzoghbi:ZGallery:0.3.1
If yes, I don't have any other idea.

@agungsus yes it is 0.3.1.. problem still exist😟😔