Android项目CJM9之新闻浏览模块的实现

今天看cjm9的代码时候想把模块梳理一下,顺便再熟悉下mvp,rxjava和retrofit的综合运用。我们先看图
这里写图片描述

这里写图片描述
新闻item的具体信息
这里写图片描述
图片item的具体信息
这里写图片描述
大概就是上面那样。

下面开始代码分析:
先看下分包:
这里写图片描述

下面我们看界面的布局文件:
1.fragment_explore.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="@dimen/tab_height"
        android:background="@color/color_primary"
        android:elevation="@dimen/cardview_default_elevation"
        android:gravity="center_vertical"
        android:padding="5dp"
        android:text="@string/explore"
        android:textColor="#ffffff"
        android:textSize="16sp" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="@dimen/tab_height"
        android:background="@color/color_icons"
        android:elevation="@dimen/cardview_default_elevation"
        android:orientation="horizontal">

        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1">

            <net.lucode.hackware.magicindicator.MagicIndicator
                android:id="@+id/magic_indicator"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:focusable="true" />

            <TextView
                android:id="@+id/tv_section"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@color/color_primary_light"
                android:gravity="center_vertical"
                android:padding="5dp"
                android:text="@string/live_exchange"
                android:textColor="@color/color_icons"
                android:textSize="12sp" />

            <ImageView
                android:layout_width="2dp"
                android:layout_height="match_parent"
                android:layout_gravity="end"
                android:alpha="0.3"
                android:scaleType="centerCrop"
                android:src="@drawable/background_shadow" />

        </FrameLayout>


        <ImageView
            android:id="@+id/iv_expandable"
            android:layout_width="@dimen/tab_height"
            android:layout_height="@dimen/tab_height"
            android:layout_weight="0"
            android:background="?selectableItemBackgroundBorderless"
            android:padding="8dp"
            android:scaleType="centerCrop"
            android:src="@drawable/ic_expand_open" />

    </LinearLayout>

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <android.support.v4.view.ViewPager
            android:id="@+id/viewpager"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/color_layout_background" />

        <ScrollView
            android:id="@+id/scroll_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/color_layout_background">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">

                <android.support.v7.widget.RecyclerView
                    android:id="@+id/recyclerview_selected"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:background="@null" />

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="end"
                    android:layout_weight="0"
                    android:orientation="horizontal">

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:padding="5dp"
                        android:text="@string/explore_drag"
                        android:textColor="@color/color_accent"
                        android:textSize="12sp" />

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:padding="5dp"
                        android:text="@string/explore_delete"
                        android:textColor="@color/color_error"
                        android:textSize="12sp" />

                </LinearLayout>

                <ImageView
                    android:layout_width="match_parent"
                    android:layout_height="1dp"
                    android:layout_marginLeft="5dp"
                    android:layout_marginRight="5dp"
                    android:layout_weight="0"
                    android:src="@color/color_divider" />

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="0"
                    android:padding="5dp"
                    android:text="点击添加更多栏目"
                    android:textSize="12sp" />

                <android.support.v7.widget.RecyclerView
                    android:id="@+id/recyclerview_unselected"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:background="@null" />

            </LinearLayout>

        </ScrollView>
    </FrameLayout>


</LinearLayout>

这布局搭建很巧妙,不是通过设置Visible进行小界面的替换,而是通过动画,利用framelayout的特性进行显示和消失的。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值