android RecyclerView+瀑布流+刷新+侧滑栏

咳咳!  今天来搞一下子 RecyclerView+瀑布流+刷新+侧滑栏

      s

今天用kotlin来搞的:

1、线性列表、网格列表、瀑布流

2、(线性列表、网格列表、瀑布流) 刷新、加载

3、(线性列表、网格列表、瀑布流) 刷新、加载、侧滑栏(滑动列表关闭所有侧滑栏、保留所有侧滑栏、保证只存在一个侧滑栏)

                                                      show

 

 

刷新加载的功能实现:在v7 recycleListView 基础上使用 SpringView 库来扩展 ( https://github.com/liaoinstan/SpringView  提供了多种刷新样式可选择)

<com.liaoinstan.springview.widget.SpringView
			android:id="@+id/springView"
			android:layout_width="match_parent"
			android:layout_height="match_parent">

		<android.support.v7.widget.RecyclerView
				android:id="@+id/recycleListView"
				android:layout_width="match_parent"
				android:layout_height="wrap_content">
		</android.support.v7.widget.RecyclerView>

</com.liaoinstan.springview.widget.SpringView>

实现局部刷新: ( https://www.jianshu.com/p/de8601f357a9

override fun onBindViewHolder(holder: ViewHolder, position: Int, payloads: 
            MutableList<Any>) {
	super.onBindViewHolder(holder, position, payloads)

	//局部刷新处理
	if(payloads.isEmpty()){
		onBindViewHolder(holder,position)
	}else{
		val name = (payloads[0] as RecycleDataBean).name
		val image = (payloads[0] as RecycleDataBean).image
		(holder as DemoViewHolder).mText!!.text = name
		Glide.with(mContext).load(image!!).apply(mOptions).into(holder.mImage!!)
	}
}

实现侧滑:( https://github.com/Dsiner/SlideLayout )  处理列表滑动是否关闭已经展开的侧滑栏

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
	xmlns:android="http://schemas.android.com/apk/res/android"
	android:layout_width="match_parent"
	android:gravity="center"
	android:layout_height="wrap_content">

	<com.d.lib.slidelayout.SlideLayout
		android:id="@+id/slideLayout"
		android:layout_width="match_parent"
		android:layout_height="wrap_content">

		<!-- 内容view展示 -->
		<RelativeLayout
			android:layout_width="match_parent"
			android:background="@color/colorPrimaryDark"
			android:gravity="center"
			android:layout_height="wrap_content">

			<ImageView
				android:id="@+id/videoImage"
				android:layout_width="match_parent"
				android:layout_height="match_parent"
				android:scaleType="fitXY"/>

			<TextView
				android:id="@+id/nameTextView"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"
				android:layout_margin="30dp"
				android:ellipsize="end"
				android:textColor="#eee"
				android:text=""/>

		</RelativeLayout>

		<!-- Slide view -->
		<LinearLayout
			android:layout_width="wrap_content"
			android:layout_height="match_parent"
			android:orientation="horizontal">

			<TextView
				android:id="@+id/tv_stick"
				android:layout_width="80dp"
				android:layout_height="match_parent"
				android:background="@color/colorYellow"
				android:gravity="center"
				android:text="STICK"
				android:textColor="@color/colorBlack"
				android:textSize="14dp" />

			<TextView
				android:id="@+id/tv_delete"
				android:layout_width="80dp"
				android:layout_height="match_parent"
				android:background="@color/colorBlue"
				android:gravity="center"
				android:text="DELETE"
				android:textColor="@color/colorBlack"
				android:textSize="14dp" />
		</LinearLayout>

	</com.d.lib.slidelayout.SlideLayout>
</RelativeLayout>
RecycleListAdapter{

	................
	
	
	
	private var nowSelectPosition:Int = 0 //记录当前选择的侧滑栏一条,定位处理滑动而不关闭侧滑

	private var mSlideManager:SlideManager?=null

	init {
		mSlideManager = SlideManager()
	}

	
	//侧滑栏的实现
	holder.mSlideLayout!!.setOpen(mEntityList!![position].isOpen!!,false)
	holder.mSlideLayout!!.setOnStateChangeListener(object :SlideLayout.OnStateChangeListener{

		override fun closeAll(layout: SlideLayout?): Boolean {
			//return mSlideManager!!.closeAll(layout) //关闭所有已经展开的侧滑栏
			return false //返回false 不关闭展开的侧滑栏
		}

		override fun onChange(layout: SlideLayout?, isOpen: Boolean) {

			//根据记录侧滑的当前position来处理,只有一条侧滑展开
			if(nowSelectPosition==0){
				nowSelectPosition = position
				mEntityList!![position].isOpen = true
				mSlideManager!!.onChange(layout, isOpen)
			}else{
				nowSelectPosition = 0
				mEntityList!![position].isOpen = false
				mSlideManager!!.onChange(layout, isOpen)
				mSlideManager!!.closeAll(layout)
			}

			//处理成,多条侧滑展开的效果
			//mEntityList!![position].isOpen = true
			//mSlideManager!!.onChange(layout, isOpen)
		}
	})
	
	
	................

}

                                                                             list

demo源码:https://download.csdn.net/download/u010326875/11377210

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

漠天515

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值