CMPUT301W14T08/GeoChan

Reply to thread, comment and view image in a thread in favourites all crash the app.

Closed this issue · 8 comments

03-28 17:22:46.280: E/FragmentManager(17596): Activity state:
03-28 17:22:46.320: E/AndroidRuntime(17596): FATAL EXCEPTION: main
03-28 17:22:46.320: E/AndroidRuntime(17596): Process: ca.ualberta.cmput301w14t08.geochan, PID: 17596
03-28 17:22:46.320: E/AndroidRuntime(17596): java.lang.IllegalArgumentException: No view found for id 0x7f090000 (ca.ualberta.cmput301w14t08.geochan:id/fragment_container) for fragment PostCommentFragment{64f461a0 #2 id=0x7f090000 repFrag}
03-28 17:22:46.320: E/AndroidRuntime(17596): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:919)
03-28 17:22:46.320: E/AndroidRuntime(17596): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)
03-28 17:22:46.320: E/AndroidRuntime(17596): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
03-28 17:22:46.320: E/AndroidRuntime(17596): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1467)
03-28 17:22:46.320: E/AndroidRuntime(17596): at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:472)
03-28 17:22:46.320: E/AndroidRuntime(17596): at ca.ualberta.cmput301w14t08.geochan.adapters.ThreadViewAdapter$4.onClick(ThreadViewAdapter.java:397)
03-28 17:22:46.320: E/AndroidRuntime(17596): at android.view.View.performClick(View.java:4438)
03-28 17:22:46.320: E/AndroidRuntime(17596): at android.view.View$PerformClick.run(View.java:18422)
03-28 17:22:46.320: E/AndroidRuntime(17596): at android.os.Handler.handleCallback(Handler.java:733)
03-28 17:22:46.320: E/AndroidRuntime(17596): at android.os.Handler.dispatchMessage(Handler.java:95)
03-28 17:22:46.320: E/AndroidRuntime(17596): at android.os.Looper.loop(Looper.java:136)
03-28 17:22:46.320: E/AndroidRuntime(17596): at android.app.ActivityThread.main(ActivityThread.java:5017)
03-28 17:22:46.320: E/AndroidRuntime(17596): at java.lang.reflect.Method.invoke(Native Method)
03-28 17:22:46.320: E/AndroidRuntime(17596): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
03-28 17:22:46.320: E/AndroidRuntime(17596): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)

Error for all is pretty much the same.

ThreadViewFragment assumes it is using the main fragment manager

Lines like this:
getFragmentManager().beginTransaction()
.replace(R.id.fragment_container, fragment, "repFrag").addToBackStack(null)
.commit();
Will fail because the fragment manager in favouries view is the child fragment manager and only knows about the views associated with itself. This code has to be adjusted to detect where it is being called from

This issue is mostly fixed. However, when going into reply and attempting to add image or location crashes. Also, getting directions in a favourited thread crashes.

We're still getting the crash when trying to make a reply from a favourited thread. This is the output from logcat:

04-03 15:15:52.673: E/AndroidRuntime(1917): FATAL EXCEPTION: main
04-03 15:15:52.673: E/AndroidRuntime(1917): java.lang.IllegalStateException: Could not execute method of the activity
04-03 15:15:52.673: E/AndroidRuntime(1917): at android.view.View$1.onClick(View.java:3597)
04-03 15:15:52.673: E/AndroidRuntime(1917): at android.view.View.performClick(View.java:4202)
04-03 15:15:52.673: E/AndroidRuntime(1917): at android.view.View$PerformClick.run(View.java:17340)
04-03 15:15:52.673: E/AndroidRuntime(1917): at android.os.Handler.handleCallback(Handler.java:725)
04-03 15:15:52.673: E/AndroidRuntime(1917): at android.os.Handler.dispatchMessage(Handler.java:92)
04-03 15:15:52.673: E/AndroidRuntime(1917): at android.os.Looper.loop(Looper.java:137)
04-03 15:15:52.673: E/AndroidRuntime(1917): at android.app.ActivityThread.main(ActivityThread.java:5039)
04-03 15:15:52.673: E/AndroidRuntime(1917): at java.lang.reflect.Method.invokeNative(Native Method)
04-03 15:15:52.673: E/AndroidRuntime(1917): at java.lang.reflect.Method.invoke(Method.java:511)
04-03 15:15:52.673: E/AndroidRuntime(1917): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
04-03 15:15:52.673: E/AndroidRuntime(1917): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
04-03 15:15:52.673: E/AndroidRuntime(1917): at dalvik.system.NativeStart.main(Native Method)
04-03 15:15:52.673: E/AndroidRuntime(1917): Caused by: java.lang.reflect.InvocationTargetException
04-03 15:15:52.673: E/AndroidRuntime(1917): at java.lang.reflect.Method.invokeNative(Native Method)
04-03 15:15:52.673: E/AndroidRuntime(1917): at java.lang.reflect.Method.invoke(Method.java:511)
04-03 15:15:52.673: E/AndroidRuntime(1917): at android.view.View$1.onClick(View.java:3592)
04-03 15:15:52.673: E/AndroidRuntime(1917): ... 11 more
04-03 15:15:52.673: E/AndroidRuntime(1917): Caused by: java.lang.NullPointerException
04-03 15:15:52.673: E/AndroidRuntime(1917): at ca.ualberta.cmput301w14t08.geochan.activities.MainActivity.post(MainActivity.java:178)
04-03 15:15:52.673: E/AndroidRuntime(1917): ... 14 more

Crash on editing from favourite threads as well.

The problem as stated above is that our buttons are being defered to methods in MainActivity, which always assume that we're using the support fragment manager. Favourites right now is using the child fragment manager, so on button presses we try to find a fragment using the support fragment manager, it can't find it and returns null, then we try and call the appropriate method on that null fragment. Can we get away from using the child fragment manager for favourites?

Issue solved. We check if the fragment is null in MainActivity. If it is then we get the favourites fragment, then get the child fragment manager from that, then find the appropriate fragment using that manager. It works with posting a reply, rolling it out to the other methods now.

There is still some issue with CustomLocationFragment when making a reply or edit from within a favourited thread.

Location change crashing fixed.