harjot-oberai / VectorMaster

Dynamic control over vector drawables!
MIT License
1.59k stars 161 forks source link

Error when trying to find a path in a vector with multiple paths. #9

Closed Conorh97 closed 6 years ago

Conorh97 commented 6 years ago

In my Android application I'm using a for loop to reference different paths in my VectorDrawable. However, every time I call myVector.getPathModelByName(myString), I get the following error:

java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference at com.sdsmdg.harjot.vectormaster.VectorMasterView.getPathModelByName(VectorMasterView.java:337)

I've been messing around with the vector drawable to fix this. I tried just referencing the first path in the drawable in every loop iteration, and that seems to work fine, so there might be a problem looking past the first path. Is this a bug or am I using the class wrong?

harjot-oberai commented 6 years ago

Can you attach the vector you are trying to work on. It will be easier to debug for me.

Conorh97 commented 6 years ago

vector.zip This is the vector I'm working on. I tried adding android:name="" to all paths. This removed the error, but I still can't access the paths I want. I'm trying to access paths with names such as "pRoom101"

harjot-oberai commented 6 years ago

Well, Its a bug from my side, I was comparing names, without checking if a model.getName() returns null. There was actually a PR open for this particular issue itself, but it had been inactive. I have now incorporated the changes myself. Updating the library in a few minutes.

Its really a miracle that no one actually experienced such an issue before 😅

Cheers 🍻

harjot-oberai commented 6 years ago

Please use version 1.1.2 now. It will fix the issue. Reopen this issue if the problem is not resolved.