onBindViewHolder(RecyclerView.ViewHolder holder, int position)但是没有三参的,灵机一动,自己加了个即
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position, @NonNull List payloads) {
if(payloads.isEmpty()){
onBindViewHolder(holder,position);
}else{
mInnerAdapter.onBindViewHolder(holder,position - getHeadersCount(),payloads);
}
}
运行后发现ok了,问题解决。折腾了下午好一会,记录一下。附上HeaderAndFooterWrapper的代码跟mInnerAdapter的代码如下,只看二个适配器中的onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position, @NonNull List payloads)函数就行了:
public class HeaderAndFooterWrapper extends RecyclerView.Adapter{
public static final int BASE_ITEM_TYPE_HEADER = 100000;
public static final int BASE_ITEM_TYPE_FOOTER = 200000;
private SparseArrayCompat mHeaderViews = new SparseArrayCompat<>();
private SparseArrayCompat mFooterViews = new SparseArrayCompat<>();
private RecyclerView.Adapter mInnerAdapter;
public HeaderAndFooterWrapper(RecyclerView.Adapter innerAdapter) {
mInnerAdapter = innerAdapter;
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
if (mHeaderViews.get(viewType) != null){
return new MyViewHolder(mHeaderViews.get(viewType));
}else if (mFooterViews.get(viewType) != null){
return new MyViewHolder(mFooterViews.get(viewType));
}
return mInnerAdapter.onCreateViewHolder(parent,viewType);
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position, @NonNull List payloads) {
if(payloads.isEmpty()){
onBindViewHolder(holder,position);
}else{
mInnerAdapter.onBindViewHolder(holder,position - getHeadersCount(),payloads);
}
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
if (isHeaderViewPos(position))
return;
if (isFooterViewPos(position))
return;
mInnerAdapter.onBindViewHolder(holder,position - getHeadersCount());
}
@Override
public int getItemCount() {
return getHeadersCount() + getFootersCount() + getRealItemCount();
}
@Override
public int getItemViewType(int position) {
if (isHeaderViewPos(position)){
return mHeaderViews.keyAt(position);
}else if (isFooterViewPos(position)){
return mFooterViews.keyAt(position - getHeadersCount() - getRealItemCount());
}
return mInnerAdapter.getItemViewType(position - getHeadersCount());
}
/**
* 获取正常数据的size
* @return
*/
private int getRealItemCount(){
return mInnerAdapter.getItemCount();
}
/**
* 判断是否是Header
* @param position
* @return
*/
private boolean isHeaderViewPos(int position){
return position < getHeadersCount();
}
/**
* 判断是否是Footer
* @param position
* @return
*/
private boolean isFooterViewPos(int position){
return position >= getHeadersCount() + getRealItemCount();
}
public void addHeaderView(View view){
mHeaderViews.put(mHeaderViews.size() + BASE_ITEM_TYPE_HEADER,view);
}
public void addFooterView(View view){
mFooterViews.put(mFooterViews.size() + BASE_ITEM_TYPE_FOOTER,view);
}
private int getHeadersCount(){
return mHeaderViews.size();
}
public int getFootersCount(){
return mFooterViews.size();
}
class MyViewHolder extends RecyclerView.ViewHolder{
public MyViewHolder(View itemView) {
super(itemView);
}
}
/**
* 适配网格布局
* @param recyclerView
*/
@Override
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
mInnerAdapter.onAttachedToRecyclerView(recyclerView);
final RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
if (layoutManager instanceof GridLayoutManager){
final GridLayoutManager gridLayoutManager = (GridLayoutManager) layoutManager;
gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
return isHeaderViewPos(position) || isFooterViewPos(position) ? ((GridLayoutManager) layoutManager).getSpanCount() : 1;
}
});
}
}
@Override
public void onViewAttachedToWindow(RecyclerView.ViewHolder holder) {
mInnerAdapter.onViewAttachedToWindow(holder);
int position = holder.getLayoutPosition();
if (isHeaderViewPos(position)||isFooterViewPos(position)){
ViewGroup.LayoutParams lp = holder.itemView.getLayoutParams();
if (lp != null && lp instanceof StaggeredGridLayoutManager.LayoutParams){
StaggeredGridLayoutManager.LayoutParams p = (StaggeredGridLayoutManager.LayoutParams) lp;
p.setFullSpan(true);
}
}
}
}
用简单的话来定义tcpdump,就是:dump the traffic on a network,根据使用者的定义对网络上的数据包进行截获的包分析工具。 tcpdump可以将网络中传送的数据包的“头”完全截获下来提供分析。它支 持针对网络层、协议、主机、网络或端口的过滤,并提供and、or、not等逻辑语句来帮助你去掉无用的信息。
实用命令实例
默认启动
tcpdump
普通情况下,直
MO= Mobile originate,上行,即用户上发给SP的信息。MT= Mobile Terminate,下行,即SP端下发给用户的信息;
上行:mo提交短信到短信中心下行:mt短信中心向特定的用户转发短信,你的短信是这样的,你所提交的短信,投递的地址是短信中心。短信中心收到你的短信后,存储转发,转发的时候就会根据你填写的接收方号码寻找路由,下发。在彩信领域是一样的道理。下行业务:由SP
import java.util.Arrays;
import java.util.Random;
public class MinKElement {
/**
* 5.最小的K个元素
* I would like to use MaxHeap.
* using QuickSort is also OK
*/
public static void
添加没有默认值:alter table Test add BazaarType char(1)
有默认值的添加列:alter table Test add BazaarType char(1) default(0)
删除没有默认值的列:alter table Test drop COLUMN BazaarType
删除有默认值的列:先删除约束(默认值)alter table Test DRO
Spring Boot 1.2.4已于6.4日发布,repo.spring.io and Maven Central可以下载(推荐使用maven或者gradle构建下载)。
这是一个维护版本,包含了一些修复small number of fixes,建议所有的用户升级。
Spring Boot 1.3的第一个里程碑版本将在几天后发布,包含许多