asdsolutions-os / duo-navigation-drawer

A flexible, easy to use, unique drawer library for your Android project.
http://psdcompany.nl/
Apache License 2.0
1.1k stars 191 forks source link

Uncaught exception getLeft() #20

Open michalsrutek opened 6 years ago

michalsrutek commented 6 years ago

Hi,

I'm dealing with the following problem: I start an Activity from which I instantiate a fragment that contains DuoDrawerLayout. From within that fragment I try to call another fragment, but I get

UncaughtException: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getLeft()' on a null object reference at nl.psdcompany.duonavigationdrawer.views.DuoDrawerLayout.computeScroll(DuoDrawerLayout.java:284) ....

I am pretty sure that I do this after everything has been initialized. Any ideas?

potalexander commented 6 years ago

It sounds like your content view is empty. Maybe this happens when you switch fragments? Make sure you add a view within the drawer layout with the tag: 'content' or set it directly with the attribute: 'app:content'.

michalsrutek commented 6 years ago

Yes, I'm immediately switing to a other fragment, but I believe only after everything has been initialized. Is there a way to programatically check that? Or maybe a callback for when the DuoDrawerLayout is successfully initialized? ... Or maybe adding a null check somewhere would fix this?

michalsrutek commented 6 years ago

I am still not sure what is the cause... But I was able to get a workaround by calling menuDrawer.getContentView(); in the fragment from which I want to immediately switch to another one. menuDrawer is DuoDrawerLayout. And by the way, I'm using AndroidAnnotations 4.4.0 with this.