maurycyw / StaggeredGridView

A modified version of Android's experimental StaggeredGridView. Includes own OnItemClickListener and OnItemLongClickListener, selector, and fixed position restore.

Home Page:https://github.com/maurycyw/StaggeredGridViewDemo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Does "span" option work?

pierrre opened this issue · comments

If I have 3 columns and I set the "span" option to "2", I have this error:

12-21 10:50:35.104: E/AndroidRuntime(9418): FATAL EXCEPTION: main
12-21 10:50:35.104: E/AndroidRuntime(9418): java.lang.ArrayIndexOutOfBoundsException: length=3; index=3
12-21 10:50:35.104: E/AndroidRuntime(9418):     at com.origamilabs.library.views.StaggeredGridView.fillDown(StaggeredGridView.java:1430)
12-21 10:50:35.104: E/AndroidRuntime(9418):     at com.origamilabs.library.views.StaggeredGridView.populate(StaggeredGridView.java:972)
12-21 10:50:35.104: E/AndroidRuntime(9418):     at com.origamilabs.library.views.StaggeredGridView.onLayout(StaggeredGridView.java:918)
12-21 10:50:35.104: E/AndroidRuntime(9418):     at android.view.View.layout(View.java:14003)
12-21 10:50:35.104: E/AndroidRuntime(9418):     at android.view.ViewGroup.layout(ViewGroup.java:4375)
12-21 10:50:35.104: E/AndroidRuntime(9418):     at android.widget.RelativeLayout.onLayout(RelativeLayout.java:985)
12-21 10:50:35.104: E/AndroidRuntime(9418):     at android.view.View.layout(View.java:14003)
12-21 10:50:35.104: E/AndroidRuntime(9418):     at android.view.ViewGroup.layout(ViewGroup.java:4375)
12-21 10:50:35.104: E/AndroidRuntime(9418):     at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
12-21 10:50:35.104: E/AndroidRuntime(9418):     at android.view.View.layout(View.java:14003)
12-21 10:50:35.104: E/AndroidRuntime(9418):     at android.view.ViewGroup.layout(ViewGroup.java:4375)
12-21 10:50:35.104: E/AndroidRuntime(9418):     at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1663)
12-21 10:50:35.104: E/AndroidRuntime(9418):     at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1521)
12-21 10:50:35.104: E/AndroidRuntime(9418):     at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
12-21 10:50:35.104: E/AndroidRuntime(9418):     at android.view.View.layout(View.java:14003)
12-21 10:50:35.104: E/AndroidRuntime(9418):     at android.view.ViewGroup.layout(ViewGroup.java:4375)
12-21 10:50:35.104: E/AndroidRuntime(9418):     at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
12-21 10:50:35.104: E/AndroidRuntime(9418):     at android.view.View.layout(View.java:14003)
12-21 10:50:35.104: E/AndroidRuntime(9418):     at android.view.ViewGroup.layout(ViewGroup.java:4375)
12-21 10:50:35.104: E/AndroidRuntime(9418):     at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1892)
12-21 10:50:35.104: E/AndroidRuntime(9418):     at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1711)
12-21 10:50:35.104: E/AndroidRuntime(9418):     at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:989)
12-21 10:50:35.104: E/AndroidRuntime(9418):     at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4351)
12-21 10:50:35.104: E/AndroidRuntime(9418):     at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
12-21 10:50:35.104: E/AndroidRuntime(9418):     at android.view.Choreographer.doCallbacks(Choreographer.java:562)
12-21 10:50:35.104: E/AndroidRuntime(9418):     at android.view.Choreographer.doFrame(Choreographer.java:532)
12-21 10:50:35.104: E/AndroidRuntime(9418):     at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
12-21 10:50:35.104: E/AndroidRuntime(9418):     at android.os.Handler.handleCallback(Handler.java:725)
12-21 10:50:35.104: E/AndroidRuntime(9418):     at android.os.Handler.dispatchMessage(Handler.java:92)
12-21 10:50:35.104: E/AndroidRuntime(9418):     at android.os.Looper.loop(Looper.java:137)
12-21 10:50:35.104: E/AndroidRuntime(9418):     at android.app.ActivityThread.main(ActivityThread.java:5191)
12-21 10:50:35.104: E/AndroidRuntime(9418):     at java.lang.reflect.Method.invokeNative(Native Method)
12-21 10:50:35.104: E/AndroidRuntime(9418):     at java.lang.reflect.Method.invoke(Method.java:511)
12-21 10:50:35.104: E/AndroidRuntime(9418):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
12-21 10:50:35.104: E/AndroidRuntime(9418):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
12-21 10:50:35.104: E/AndroidRuntime(9418):     at dalvik.system.NativeStart.main(Native Method)

My code:

        if (convertView == null) {
            LayoutInflater layoutInflator = LayoutInflater.from(getContext());
            convertView = layoutInflator.inflate(R.layout.row_staggered_demo,
                    null);
            StaggeredGridView.LayoutParams layoutParams = new StaggeredGridView.LayoutParams(StaggeredGridView.LayoutParams.WRAP_CONTENT);
            layoutParams.span = 2;
            convertView.setLayoutParams(layoutParams);
            holder = new ViewHolder();
            holder.imageView = (ScaleImageView) convertView .findViewById(R.id.imageView1);
            convertView.setTag(holder);
        }

Currently it is not supported :( Feel free to have at it. A span would look kinda funny anyways no? Anyways its an interesting problem so ill try to take a look at it once i have some free time.

The "span" option is used in the Google+ app :-)

Span works fine in the original com.android.ex.widget version of this, however for some reason in this build, the scroller stuffs up the laying out? It works fine until scroll though.