Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IllegalStateException in GridView #1447

Closed
cornzy opened this issue Jan 23, 2016 · 10 comments
Closed

IllegalStateException in GridView #1447

cornzy opened this issue Jan 23, 2016 · 10 comments

Comments

@cornzy
Copy link

cornzy commented Jan 23, 2016

I can reproduce this exception with the following steps:

Goto an folder which is configured for grid-view but is empty
Press back button

On master it seems to be necessary to switch from list to gridview prior to click back.

The calling code is in: ExtendedListFragment:428 (function setFooterEnabled)

************ CAUSE OF ERROR ************

java.lang.IllegalStateException: Cannot add header view to grid -- setAdapter has already been called.
at third_parties.in.srain.cube.GridViewWithHeaderAndFooter.addFooterView(GridViewWithHeaderAndFooter.java:183)
at com.owncloud.android.ui.fragment.ExtendedListFragment.setFooterEnabled(ExtendedListFragment.java:490)
at com.owncloud.android.ui.fragment.ExtendedListFragment.setFooterText(ExtendedListFragment.java:516)
at com.owncloud.android.ui.fragment.OCFileListFragment.updateLayout(OCFileListFragment.java:830)
at com.owncloud.android.ui.fragment.OCFileListFragment.listDirectory(OCFileListFragment.java:805)
at com.owncloud.android.ui.fragment.OCFileListFragment.onBrowseUp(OCFileListFragment.java:528)
at com.owncloud.android.ui.activity.FileDisplayActivity.onBackPressed(FileDisplayActivity.java:901)
at android.app.Activity.onKeyUp(Activity.java:2632)
at android.view.KeyEvent.dispatch(KeyEvent.java:3214)
at android.app.Activity.dispatchKeyEvent(Activity.java:2887)
at android.support.v7.view.WindowCallbackWrapper.dispatchKeyEvent(WindowCallbackWrapper.java:50)
at android.support.v7.app.AppCompatDelegateImplBase$AppCompatWindowCallbackBase.dispatchKeyEvent(AppCompatDelegateImplBase.java:224)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:2610)
at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:4777)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4732)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4271)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4324)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4290)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4416)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4298)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4473)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4271)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4324)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4290)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4298)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4271)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4324)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4290)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4449)
at android.view.ViewRootImpl$ImeInputStage.onFinishedInputEvent(ViewRootImpl.java:4613)
at android.view.inputmethod.InputMethodManager$PendingEvent.run(InputMethodManager.java:2766)
at android.view.inputmethod.InputMethodManager.invokeFinishedInputEventCallback(InputMethodManager.java:2358)
at android.view.inputmethod.InputMethodManager.finishedInputEvent(InputMethodManager.java:2349)
at android.view.inputmethod.InputMethodManager$ImeInputEventSender.onInputEventFinished(InputMethodManager.java:2743)
at android.view.InputEventSender.dispatchInputEventFinished(InputEventSender.java:141)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:143)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:6837)
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:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)

************ DEVICE INFORMATION ***********
Brand: samsung
Device: zerolte
Model: SM-G925F
Id: LMY47X
Product: zeroltexx

************ FIRMWARE ************
SDK: 22
Release: 5.1.1
Incremental: G925FXXS3QOK2

@tobiasKaminsky
Copy link
Contributor

I can solve this by changing:
mGridView.addFooterView(mGridFooterView, null, false);
to be in the if branch two lines above.

https://github.com/owncloud/android/blob/beta/src/com/owncloud/android/ui/fragment/ExtendedListFragment.java#L490

But I do not know if this affects something else?
@AndyScherzinger @przybylski

@AndyScherzinger
Copy link
Contributor

Looking through the code I don't know either. May ask @davivel since he also helped me some time ago with the footer handling when I worked on the Material design changes.

@tobiasKaminsky
Copy link
Contributor

@cornzy is this still valid? I cannot reproduce it.

@cornzy
Copy link
Author

cornzy commented Mar 14, 2016

@tobiasKaminsky is there a newer beta release? Just checked F-Droid but there is no update. With 20160120 I could still reproduce.

@AndyScherzinger
Copy link
Contributor

@cornzy can you give the latest one a try: https://github.com/owncloud/android/blob/beta/apks/owncloud-beta-20160313.apk?raw=true
Unfortunately we are experiencing problems with f-droid for a couple of week now so the latest beta versions haven't made it to the f-droid repo :(

@tobiasKaminsky
Copy link
Contributor

@cornzy Please try again

@cornzy
Copy link
Author

cornzy commented May 1, 2016

Sorry, didn't checked Github Mails too long.
Exception still occurs in latest Beta 20160427. Remember it does not comes when opening the folder but when clicking back button inside the empty folder.

************ CAUSE OF ERROR ************

java.lang.IllegalStateException: Cannot add header view to grid -- setAdapter has already been called.
at third_parties.in.srain.cube.GridViewWithHeaderAndFooter.addFooterView(GridViewWithHeaderAndFooter.java:183)
at com.owncloud.android.ui.fragment.ExtendedListFragment.setFooterEnabled(ExtendedListFragment.java:533)
at com.owncloud.android.ui.fragment.ExtendedListFragment.setFooterText(ExtendedListFragment.java:559)
at com.owncloud.android.ui.fragment.OCFileListFragment.updateLayout(OCFileListFragment.java:855)
at com.owncloud.android.ui.fragment.OCFileListFragment.listDirectory(OCFileListFragment.java:830)
at com.owncloud.android.ui.fragment.OCFileListFragment.onBrowseUp(OCFileListFragment.java:541)
at com.owncloud.android.ui.activity.FileDisplayActivity.onBackPressed(FileDisplayActivity.java:903)
at android.app.Activity.onKeyUp(Activity.java:2712)
at android.view.KeyEvent.dispatch(KeyEvent.java:3273)
at android.app.Activity.dispatchKeyEvent(Activity.java:2982)
at android.support.v7.view.WindowCallbackWrapper.dispatchKeyEvent(WindowCallbackWrapper.java:50)
at android.support.v7.app.AppCompatDelegateImplBase$AppCompatWindowCallbackBase.dispatchKeyEvent(AppCompatDelegateImplBase.java:224)
at android.support.v7.view.WindowCallbackWrapper.dispatchKeyEvent(WindowCallbackWrapper.java:50)
at com.android.internal.policy.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:2697)
at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:5220)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:5173)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4620)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4673)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4639)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4781)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4647)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4838)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4620)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4673)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4639)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4647)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4620)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4673)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4639)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4814)
at android.view.ViewRootImpl$ImeInputStage.onFinishedInputEvent(ViewRootImpl.java:5057)
at android.view.inputmethod.InputMethodManager$PendingEvent.run(InputMethodManager.java:2877)
at android.view.inputmethod.InputMethodManager.invokeFinishedInputEventCallback(InputMethodManager.java:2449)
at android.view.inputmethod.InputMethodManager.finishedInputEvent(InputMethodManager.java:2440)
at android.view.inputmethod.InputMethodManager$ImeInputEventSender.onInputEventFinished(InputMethodManager.java:2854)
at android.view.InputEventSender.dispatchInputEventFinished(InputEventSender.java:141)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:323)
at android.os.Looper.loop(Looper.java:143)
at android.app.ActivityThread.main(ActivityThread.java:7224)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

@tobiasKaminsky
Copy link
Contributor

This is a bug that also happens in master, removing beta.
The important step is to switch to grid view on an empty folder.

@tobiasKaminsky tobiasKaminsky changed the title Beta 20160120: IllegalStateException in GridView IllegalStateException in GridView May 1, 2016
@davivel
Copy link
Contributor

davivel commented Jul 13, 2016

We need to refactor the methods in the call tree from OCFileListFragment.onBrowseUp. It's too complex, and ends calling the method ExtendedListFragment.setFooterEnabled from listDirectory even though it's warned in the method comment that could finish in an exception.

We should hide and show the footerView in the grid without adding it , the view itself should be added before, probably in onCreateView.

@michaelstingl michaelstingl added this to the backlog milestone Apr 10, 2019
@michaelstingl michaelstingl added the p3-medium Normal priority label Apr 10, 2019
@michaelstingl michaelstingl removed this from the backlog milestone Sep 30, 2020
@jesmrec
Copy link
Collaborator

jesmrec commented Apr 21, 2022

Grid view was removed in new architecture. Not reproducible in master either

@jesmrec jesmrec closed this as completed Apr 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants