bk138 / LibSlideMenu

A sliding menu for Android, as found in the Google+ or Facebook apps.
Apache License 2.0
99 stars 56 forks source link

Crashing on Samsung S3 android build 4.1 #12

Closed yogeshkalwar closed 11 years ago

yogeshkalwar commented 11 years ago

It is crashing on Samsung S3 android build 4.1 ClassCastException: LinearLayout casting to FrameLaout.

I found solution :+1:

  1. private static ViewGroup parent;
  2. Converted all FrameLayout.LayoutParams to LayoutParams
  3. parent = (ViewGroup) act.getWindow().getDecorView();
bk138 commented 11 years ago

This will not work on other phones. Can you provide a backtrace and a real patch? We're on github, aren't we ? ;-)

yogeshkalwar commented 11 years ago

:) I am not familiar with it. As I restricted to myself. Well while using your good library i found that this is the case with activity with no action bar. And treeview for layout shows that in case of Samsung S3 4.1 parent of content is not framelayout its linearlayout and it could be worse if ativity's content layout is not optimal. So to bypass the user mistake i just moved the setLayoutParams() call to respective block as there is no generic LayoutParam (even ViewGroup.MarginLayout will not help). Let me know if I missed anything. It is great helper class..

One more thing. How I can make it to RightSliding?

bk138 commented 11 years ago

Which line is the crash happening? What's your change?

yogeshkalwar commented 11 years ago

When the menu button is added to activity xml's root layout (eg RL or LL) it works charm but when you add into deeper layout or in my case using include tag (as i put the menu in header.xml and using it into all activities) it is causing problem.

some plateform showing parent as framelayout and some Linearlayout.

Well I am trying to simplify my xml and using your lib as it is and will try to find the solution for deeper layout structure.  Your code is crashing on 1.6 due to Sony xperia hack(runtime crash). Is there any way to solve it?    Regards, Yogesh Kalwar Surya Edu@Lab


From: Christian Beier notifications@github.com To: bk138/LibSlideMenu LibSlideMenu@noreply.github.com Cc: yogeshkalwar yogesh.kalwar@gmail.com Sent: Wednesday, 12 December 2012 4:30 PM Subject: Re: [LibSlideMenu] Crashing on Samsung S3 android build 4.1 (#12)

Which line is the crash happening? What's your change? — Reply to this email directly or view it on GitHub.

yogeshkalwar commented 11 years ago

And the code I posted earlier is not working on HTC One V. :(   Regards, Yogesh Kalwar Surya Edu@Lab


From: Yogesh Kalwar yogesh.kalwar@yahoo.in To: bk138/LibSlideMenu reply@reply.github.com Sent: Wednesday, 12 December 2012 5:08 PM Subject: Re: [LibSlideMenu] Crashing on Samsung S3 android build 4.1 (#12)

When the menu button is added to activity xml's root layout (eg RL or LL) it works charm but when you add into deeper layout or in my case using include tag (as i put the menu in header.xml and using it into all activities) it is causing problem.

some plateform showing parent as framelayout and some Linearlayout.

Well I am trying to simplify my xml and using your lib as it is and will try to find the solution for deeper layout structure.  Your code is crashing on 1.6 due to Sony xperia hack(runtime crash). Is there any way to solve it?    Regards, Yogesh Kalwar Surya Edu@Lab


From: Christian Beier notifications@github.com To: bk138/LibSlideMenu LibSlideMenu@noreply.github.com Cc: yogeshkalwar yogesh.kalwar@gmail.com Sent: Wednesday, 12 December 2012 4:30 PM Subject: Re: [LibSlideMenu] Crashing on Samsung S3 android build 4.1 (#12)

Which line is the crash happening? What's your change? — Reply to this email directly or view it on GitHub.

bk138 commented 11 years ago

Please, I need backtraces of the crashes to fix them --> http://developer.android.com/tools/debugging/debugging-projects.html

yogeshkalwar commented 11 years ago

FYI

12-13 14:36:29.010: W/dalvikvm(9326): threadid=1: thread exiting with uncaught exception (group=0x4125a2a0) 12-13 14:36:29.025: E/AndroidRuntime(9326): FATAL EXCEPTION: main 12-13 14:36:29.025: E/AndroidRuntime(9326): java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.widget.FrameLayout 12-13 14:36:29.025: E/AndroidRuntime(9326): at com.coboltforge.slidemenu.SlideMenu.show(SlideMenu.java:315) ...

[SlideMenu.java:315 =>    parent = (FrameLayout) content.getParent();]

12-13 14:36:29.025: E/AndroidRuntime(9326): at com.coboltforge.slidemenu.SlideMenu.show(SlideMenu.java:258) 12-13 14:36:29.025: E/AndroidRuntime(9326): at com.rediff.mail.and.activities.InboxActivity.onKeyDown(InboxActivity.java:2484) 12-13 14:36:29.025: E/AndroidRuntime(9326): at android.view.KeyEvent.dispatch(KeyEvent.java:2705) 12-13 14:36:29.025: E/AndroidRuntime(9326): at android.app.Activity.dispatchKeyEvent(Activity.java:2431) 12-13 14:36:29.025: E/AndroidRuntime(9326): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:2009) 12-13 14:36:29.025: E/AndroidRuntime(9326): at android.view.ViewRootImpl.deliverKeyEventPostIme(ViewRootImpl.java:3813) 12-13 14:36:29.025: E/AndroidRuntime(9326): at android.view.ViewRootImpl.handleImeFinishedEvent(ViewRootImpl.java:3761) 12-13 14:36:29.025: E/AndroidRuntime(9326): at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:2926) 12-13 14:36:29.025: E/AndroidRuntime(9326): at android.os.Handler.dispatchMessage(Handler.java:99) 12-13 14:36:29.025: E/AndroidRuntime(9326): at android.os.Looper.loop(Looper.java:137) 12-13 14:36:29.025: E/AndroidRuntime(9326): at android.app.ActivityThread.main(ActivityThread.java:4898) 12-13 14:36:29.025: E/AndroidRuntime(9326): at java.lang.reflect.Method.invokeNative(Native Method) 12-13 14:36:29.025: E/AndroidRuntime(9326): at java.lang.reflect.Method.invoke(Method.java:511) 12-13 14:36:29.025: E/AndroidRuntime(9326): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006) 12-13 14:36:29.025: E/AndroidRuntime(9326): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773) 12-13 14:36:29.025: E/AndroidRuntime(9326): at dalvik.system.NativeStart.main(Native Method)   Regards, Yogesh Kalwar Surya Edu@Lab


From: Christian Beier notifications@github.com To: bk138/LibSlideMenu LibSlideMenu@noreply.github.com Cc: yogeshkalwar yogesh.kalwar@gmail.com Sent: Wednesday, 12 December 2012 10:49 PM Subject: Re: [LibSlideMenu] Crashing on Samsung S3 android build 4.1 (#12)

Please, I need backtraces of the ctashes to fix them --> http://developer.android.com/tools/debugging/debugging-projects.html — Reply to this email directly or view it on GitHub.

bk138 commented 11 years ago

This is not the lastest version from master.Can you please check that one out and post a backtrace again?

yogeshkalwar commented 11 years ago

Finally found the solution: When parent of Content is LinearLayout just insert FrameLayout in between Content and parent of it. Working on all. CODE:: .... // add the slide menu to parent try{ parent = (FrameLayout) content.getParent();//Framelayout }catch(ClassCastException e){ LinearLayout parentLL = (LinearLayout) content.getParent(); parent = new FrameLayout(act); parentLL.addView(parent, 0);//add FrameLayout to parent of content parentLL.removeView(content);//remove content from LL parent parent.addView(content);//add content to Framelayout }

bk138 commented 11 years ago

Thanks, incorporated with https://github.com/bk138/LibSlideMenu/commit/1ee89acf586d827d5f4902d1a79dc8a7f9051990. Does this fix it?

yogeshkalwar commented 11 years ago

Yes tested on Samsung Galaxy S3, HTC ONE V, HTC wildfire S, HTC incredible S. Thanks a Lot

bk138 commented 11 years ago

Cool, closing this then.

yogeshkalwar commented 11 years ago

Thanks!

On Fri, Dec 14, 2012 at 8:03 PM, Christian Beier notifications@github.comwrote:

Cool, closing this then.

— Reply to this email directly or view it on GitHubhttps://github.com/bk138/LibSlideMenu/issues/12#issuecomment-11378072.

Regards, Yogesh Kalwar,

PGDST(NCST) BE(COMP) Cell-No :09920824922