I have a method which take action against map click, when i click on map, method trying to set the state to STATE_SETTLING
but it's throwing IllegalArgumentException
I have checked the state if it's not in STATE_HIDDEN
or STATE_SETTLING
& isHideable
is true
, but it's throwing java.lang.IllegalArgumentException: Illegal state argument: 2
. I have tried to set the state to STATE_EXPANDED
, STATE_HALF_EXPENDED
, those state are working well, but not that i want.
fun onMapClickListener(zonesViewModel: ZonesViewModel){
if(zonesViewModel.merchantInfoBottomLayout!!.state != BottomSheetBehavior.STATE_HIDDEN || zonesViewModel.merchantInfoBottomLayout!!.state != BottomSheetBehavior.STATE_SETTLING){
zonesViewModel.merchantInfoBottomLayout!!.isHideable = true
zonesViewModel.merchantInfoBottomLayout!!.state = BottomSheetBehavior.STATE_SETTLING
}
}
}
Crash logs:
E/AndroidRuntime: FATAL EXCEPTION: main java.lang.IllegalArgumentException: Illegal state argument: 2 at android.support.design.widget.BottomSheetBehavior.startSettlingAnimation(BottomSheetBehavior.java:755) at android.support.design.widget.BottomSheetBehavior.setState(BottomSheetBehavior.java:650) at ......*.MerchantsZoneLocationHandler.onMapClickListener(MerchantsZoneLocationHandler.kt:171) at ......*.ZonesFragment$setupMerchantsComponents$2.onMapClick(ZonesFragment.kt:119) at com.mapbox.mapboxsdk.maps.MapGestureDetector.notifyOnMapClickListeners(MapGestureDetector.java:882) at com.mapbox.mapboxsdk.maps.MapGestureDetector$StandardGestureListener.onSingleTapConfirmed(MapGestureDetector.java:327) at com.mapbox.android.gestures.StandardGestureDetector$1.onSingleTapConfirmed(StandardGestureDetector.java:81) at android.view.GestureDetector$GestureHandler.handleMessage(GestureDetector.java:300) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:165) at android.app.ActivityThread.main(ActivityThread.java:6375) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:802)
Problem is solved, I needed to change my code a little bit, while I was trying to set state to STATE_SETTLING
it's throwing IllegalArgumentException
, I've just changed my code to:
zonesViewModel.merchantInfoBottomLayout!!.state = BottomSheetBehavior.STATE_COLLAPSED
instead of
zonesViewModel.merchantInfoBottomLayout!!.state = BottomSheetBehavior.STATE_SETTLING`