weiciyuan代码阅读2

这次主要是想知道

weiciyuan代码阅读2_第1张图片

此布局对应的是,timeline_listview_item_layout。

其实这里首页对应的listview的item有四种布局,分别是:

timeline_listview_item_simple_layout

timeline_listview_item_middle_layout

timeline_listview_item_big_pic_layout

timeline_listview_item_layout


而在文件AbstractAppListAdapter中就根据不同的情况生成不同的布局类型(TYPE_MIDDLE、TYPE_NOMAL等等),

然后根据不同的布局类型加载上面不同的timeline_listview_item_xxx_layout

    @Override
    public int getItemViewType(int position) {


        if (position >= bean.size()) {
            return -1;
        }


        if (bean.get(position) == null) {
            return TYPE_MIDDLE;
        }


        if (!showOriStatus) {
            return TYPE_SIMPLE;
        }


        if (SettingUtility.getEnableBigPic()) {
            return TYPE_NORMAL_BIG_PIC;
        } else {
            return TYPE_NORMAL;
        }


    }


图片中的九宫格是如何实现的呢?

来到布局文件timeline_listview_item_layout.xml中可以看到如下:

<span style="white-space:pre">	</span><GridLayout
                android:id="@+id/repost_content__pic_multi"
                android:layout_below="@id/repost_content"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:visibility="gone"
                android:layout_marginLeft="0dp"
                android:layout_marginTop="5dp"
                android:columnCount="3"
                android:rowCount="3"
                android:orientation="horizontal"
                android:useDefaultMargins="false"
                android:clickable="false">

            <org.qii.weiciyuan.support.asyncdrawable.MultiPicturesChildImageView
                    style="@style/listViewMultiImageView"/>

            <org.qii.weiciyuan.support.asyncdrawable.MultiPicturesChildImageView
                    style="@style/listViewMultiImageView"/>

            <org.qii.weiciyuan.support.asyncdrawable.MultiPicturesChildImageView
                    style="@style/listViewMultiImageView"/>

            <org.qii.weiciyuan.support.asyncdrawable.MultiPicturesChildImageView
                    style="@style/listViewMultiImageView"/>

            <org.qii.weiciyuan.support.asyncdrawable.MultiPicturesChildImageView
                    style="@style/listViewMultiImageView"/>

            <org.qii.weiciyuan.support.asyncdrawable.MultiPicturesChildImageView
                    style="@style/listViewMultiImageView"/>

            <org.qii.weiciyuan.support.asyncdrawable.MultiPicturesChildImageView
                    style="@style/listViewMultiImageView"/>

            <org.qii.weiciyuan.support.asyncdrawable.MultiPicturesChildImageView
                    style="@style/listViewMultiImageView"/>

            <org.qii.weiciyuan.support.asyncdrawable.MultiPicturesChildImageView
                    style="@style/listViewMultiImageView"/>

        </GridLayout>
(1)类似的效果我也实现过使用的是GridView(也是很方便);

(2)这里使用的是GridLayout实现;

(3)注意到源码其实还有一个GridLayout,一个是content_pic_multi,一个是repost_content__pic_multi

作者很明显告诉我们,一个是我们发的内容包含了图片,一个是恢复的内容里面包含了图片。

你可能感兴趣的:(weiciyuan代码阅读2)