RiccardoMoro / RMSwitch

A simple and customizable two or three states Switch View
656 stars 81 forks source link

Bug: in sample, crash when pressing home button #5

Closed AndroidDeveloperLB closed 7 years ago

AndroidDeveloperLB commented 7 years ago

This is the log:

11-21 10:10:47.451 4055-4055/com.rm.switchsample E/JavaBinder: !!! FAILED BINDER TRANSACTION !!! (parcel size = 1160672) 11-21 10:10:47.453 4055-4055/com.rm.switchsample E/AndroidRuntime: FATAL EXCEPTION: main Process: com.rm.switchsample, PID: 4055 java.lang.RuntimeException: android.os.TransactionTooLargeException: data parcel size 1160672 bytes at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3755) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6088) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776) Caused by: android.os.TransactionTooLargeException: data parcel size 1160672 bytes at android.os.BinderProxy.transactNative(Native Method) at android.os.BinderProxy.transact(Binder.java:615) at android.app.ActivityManagerProxy.activityStopped(ActivityManagerNative.java:3628) at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3747) at android.os.Handler.handleCallback(Handler.java:751)  at android.os.Handler.dispatchMessage(Handler.java:95)  at android.os.Looper.loop(Looper.java:154)  at android.app.ActivityThread.main(ActivityThread.java:6088)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776) 

RiccardoMoro commented 7 years ago

@AndroidDeveloperLB This crash happened in the sample without modifying it?

Edit:Oh, ok, I needed a nexus 5x to made it crash the same way, it wasn't happening in other devices i own. I'm on it

AndroidDeveloperLB commented 7 years ago

Why does it happen though?

RiccardoMoro commented 7 years ago

Trying to parcel too many bytes while saving switch state (i guess it's all the toggles drawables, a lot of data) I guess i just have not to save the toggle images in the parcel.. But that way, you'll have to set the switch toggles every activity/fragment creation, i guess there's not other way I was warried about that since the beginning

AndroidDeveloperLB commented 7 years ago

Why save the drawables in there? Just save the state (turned off/on).

RiccardoMoro commented 7 years ago

So that a developer do not have to set it every creation (I know, almost everyone do that, so I'm removing it)

AndroidDeveloperLB commented 7 years ago

Set on every creation? But that's how it works. You set it in XML or in code, right in onCreate (or when inflating)...

RiccardoMoro commented 7 years ago

Yes, I know, but it seemed a nice thing for dynamic switch state images (anyway, you're right, I'm removing it right now)

RiccardoMoro commented 7 years ago

Try out with the latest commit, it should be fixed! Thanks for the feedback

AndroidDeveloperLB commented 7 years ago

Thank you. BTW, seeing that you know about switches on Android, can you see why on my tiny library of Material Preferences doesn't show the switches animation : https://github.com/AndroidDeveloperLB/MaterialPreferenceLibrary/issues/22 ?

AndroidDeveloperLB commented 7 years ago

About the commit, for some reason I can't open the project anymore.

RiccardoMoro commented 7 years ago

Ok, i'll check it out What's the problem?

RiccardoMoro commented 7 years ago

I just cloned it and opened with android studio without problems.. have you tried updating the support libraries in your SDK manager? maybe it's that since i've updated the one in this project to the version 25.0.1

AndroidDeveloperLB commented 7 years ago

OK now I cloned it and it works fine.

RiccardoMoro commented 7 years ago

Good! Closing the issue Thanks again for the feedback.

AndroidDeveloperLB commented 7 years ago

Say, does the sample supposed to have a disabled switch? the green one on the right bottom (above the last one) doesn't respond to touch on it.

RiccardoMoro commented 7 years ago

Yes, if you check the MainActivity code, that particular switch has been disabled programmatically

RiccardoMoro commented 7 years ago

(disabled switches also have an alpha to be distinguished from the enabled ones, if you check closely I think it can be seen, it's about 0.6 if I remember right)

AndroidDeveloperLB commented 7 years ago

Oh ok. Maybe you should put some text above it, to indicate that it is disabled.

AndroidDeveloperLB commented 7 years ago

@RiccardoMoro Have you checked the issue ?

RiccardoMoro commented 7 years ago

Nope, I'm busy at work and with conferences this week and the next one, maybe after that I'll take a look