arimorty / floatingsearchview

A search view that implements a floating search bar also known as persistent search
https://github.com/arimorty/floatingsearchview/blob/master/README.md
Apache License 2.0
3.54k stars 667 forks source link

crash while playing with menu items #11

Closed manjunathc23 closed 8 years ago

manjunathc23 commented 8 years ago

Hey Ari,

Take a look at this crash whenever you can. Crashed on me while playing around with menu item configurations.

java.lang.NullPointerException: Attempt to invoke virtual method 'float android.view.View.getTranslationX()' on a null object reference at com.arlib.floatingsearchview.util.view.MenuView.showIfRoomItems(MenuView.java:422) at com.arlib.floatingsearchview.FloatingSearchView.setSearchFocusedInternal(FloatingSearchView.java:1353) at com.arlib.floatingsearchview.FloatingSearchView.access$1500(FloatingSearchView.java:87) at com.arlib.floatingsearchview.FloatingSearchView$13.onItemSelected(FloatingSearchView.java:1095) at com.arlib.floatingsearchview.suggestions.SearchSuggestionsAdapter$1.onItemClicked(SearchSuggestionsAdapter.java:186) at com.arlib.floatingsearchview.suggestions.SearchSuggestionsAdapter$SearchSuggestionViewHolder$2.onClick(SearchSuggestionsAdapter.java:145) at android.view.View.performClick(View.java:4780)

Thanks! Manju

Pabloku commented 8 years ago

I also detected a problem (crash) when there is not a menu set to the floating search view. So, if you do not set app:floatingSearch_menu in your xml: 1.- crash happens in runtime; 2.- designer do not show the floating search view in Android Studio.

This is the crash log:

FATAL EXCEPTION: main
Process: com.cumberland.tutarifa.develop, PID: 30963
android.content.res.Resources$NotFoundException: Resource ID #0x0
 at android.content.res.Resources.getValue(Resources.java:1266)
 at android.content.res.Resources.loadXmlResourceParser(Resources.java:2649)
 at android.content.res.Resources.getLayout(Resources.java:1082)
 at android.support.v7.view.SupportMenuInflater.inflate(SupportMenuInflater.java:115)
 at com.arlib.floatingsearchview.util.view.MenuView.reset(MenuView.java:177)
 at com.arlib.floatingsearchview.FloatingSearchView$2.onGlobalLayout(FloatingSearchView.java:528)
 at android.view.ViewTreeObserver.dispatchOnGlobalLayout(ViewTreeObserver.java:912)
 at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1881)
 at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1061)
 at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5885)
 at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
 at android.view.Choreographer.doCallbacks(Choreographer.java:580)
 at android.view.Choreographer.doFrame(Choreographer.java:550)
 at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
 at android.os.Handler.handleCallback(Handler.java:739)
 at android.os.Handler.dispatchMessage(Handler.java:95)
 at android.os.Looper.loop(Looper.java:135)
 at android.app.ActivityThread.main(ActivityThread.java:5254)
 at java.lang.reflect.Method.invoke(Native Method)
 at java.lang.reflect.Method.invoke(Method.java:372)
 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

Hope it helps!

arimorty commented 8 years ago

@manjunathc23 thanks for the report, it was an unused line that I forgot to remove that caused the exception. It is now fixed in 1.1.2.

@Pabloku that was fixed in 1.1.1 after it was mentioned in #6, anyway the current version is 1.1.2

Enjoy guys, Ari

Pabloku commented 8 years ago

Thanks!