Git Product home page Git Product logo

easyrecyclerview's Introduction

EasyRecyclerView

中文English

Encapsulate many API about RecyclerView into the library,such as arrayAdapter,pull to refresh,auto load more,no more and error in the end,header&footer.
The library uses a new usage of ViewHolder,decoupling the ViewHolder and Adapter.
Adapter will do less work,adapter only direct the ViewHolder,if you use MVP,you can put adapter into presenter.ViewHolder only show the item,then you can use one ViewHolder for many Adapter.
Part of the code modified from Malinskiy/SuperRecyclerView,make more functions handed by Adapter.

Dependency

compile 'com.jude:easyrecyclerview:4.4.2'

ScreenShot

recycler.gif

Usage

EasyRecyclerView

<com.jude.easyrecyclerview.EasyRecyclerView
  android:id="@+id/recyclerView"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  app:layout_empty="@layout/view_empty"
  app:layout_progress="@layout/view_progress"
  app:layout_error="@layout/view_error"
  app:recyclerClipToPadding="true"
  app:recyclerPadding="8dp"
  app:recyclerPaddingTop="8dp"
  app:recyclerPaddingBottom="8dp"
  app:recyclerPaddingLeft="8dp"
  app:recyclerPaddingRight="8dp"
  app:scrollbarStyle="insideOverlay"//insideOverlay or insideInset or outsideOverlay or outsideInset
  app:scrollbars="none"//none or vertical or horizontal
  />

Attention EasyRecyclerView is not a RecyclerView just contain a RecyclerView.use 'getRecyclerView()' to get the RecyclerView;

EmptyView&LoadingView&ErrorView
xml:

app:layout_empty="@layout/view_empty"
app:layout_progress="@layout/view_progress"
app:layout_error="@layout/view_error"

code:

void setEmptyView(View emptyView)
void setProgressView(View progressView)
void setErrorView(View errorView)

then you can show it by this whenever:

void showEmpty()
void showProgress()  
void showError()  
void showRecycler()

scrollToPosition

void scrollToPosition(int position); // such as scroll to top

control the pullToRefresh

void setRefreshing(boolean isRefreshing);
void setRefreshing(final boolean isRefreshing, final boolean isCallback); //second params is callback immediately

##RecyclerArrayAdapter
there is no relation between RecyclerArrayAdapter and EasyRecyclerView.you can user any Adapter for the EasyRecyclerView,and use the RecyclerArrayAdapter for any RecyclerView.

Data Manage

void add(T object);
void addAll(Collection<? extends T> collection);
void addAll(T ... items);
void insert(T object, int index);
void update(T object, int index);
void remove(T object);
void clear();
void sort(Comparator<? super T> comparator);

Header&Footer

void addHeader(ItemView view)
void addFooter(ItemView view)  

ItemView is not a view but a view creator;

public interface ItemView {
     View onCreateView(ViewGroup parent);
     void onBindView(View itemView);
}

The onCreateView and onBindView correspond the callback in RecyclerView's Adapter,so adapter will call onCreateView once and onBindView more than once;
It recommend that add the ItemView to Adapter after the data is loaded,initialization View in onCreateView and nothing in onBindView.

Header and Footer support LinearLayoutManager,GridLayoutManager,StaggeredGridLayoutManager.
In GridLayoutManager you must add this:

//make adapter obtain a LookUp for LayoutManager,param is maxSpan。
gridLayoutManager.setSpanSizeLookup(adapter.obtainGridSpanSizeLookUp(2));

OnItemClickListener&OnItemLongClickListener

adapter.setOnItemClickListener(new RecyclerArrayAdapter.OnItemClickListener() {
    @Override
    public void onItemClick(int position) {
        //position not contain Header
    }
});

adapter.setOnItemLongClickListener(new RecyclerArrayAdapter.OnItemLongClickListener() {
    @Override
    public boolean onItemLongClick(int position) {
        return true;
    }
});

equal 'itemview.setOnClickListener()' in ViewHolder.
if you set listener after RecyclerView has layout.you should use 'notifyDataSetChange()';

###the API below realized by add a Footer。

LoadMore

void setMore(final int res,OnMoreListener listener);
void setMore(final View view,OnMoreListener listener);

Attention when you add null or the length of data you add is 0 ,it will finish LoadMore and show NoMore;
also you can show NoMore manually adapter.stopMore();

LoadError

void setError(final int res,OnErrorListener listener)
void setError(final View view,OnErrorListener listener)

use adapter.pauseMore() to show Error,when your loading throw an error;
if you add data when showing Error.it will resume to load more;
when the ErrorView display to screen again,it will resume to load more too,and callback the OnLoadMoreListener(retry).
adapter.resumeMore()you can resume to load more manually,it will callback the OnLoadMoreListener immediately.
you can put resumeMore() into the OnClickListener of ErrorView to realize click to retry.

NoMore

void setNoMore(final int res,OnNoMoreListener listener)
void setNoMore(final View view,OnNoMoreListener listener)

when loading is finished(add null or empty or stop manually),it while show in the end.

BaseViewHolder<M>

decoupling the ViewHolder and Adapter,new ViewHolder in Adapter and inflate view in ViewHolder.
Example:

public class PersonViewHolder extends BaseViewHolder<Person> {
    private TextView mTv_name;
    private SimpleDraweeView mImg_face;
    private TextView mTv_sign;


    public PersonViewHolder(ViewGroup parent) {
        super(parent,R.layout.item_person);
        mTv_name = $(R.id.person_name);
        mTv_sign = $(R.id.person_sign);
        mImg_face = $(R.id.person_face);
    }

    @Override
    public void setData(final Person person){
        mTv_name.setText(person.getName());
        mTv_sign.setText(person.getSign());
        mImg_face.setImageURI(Uri.parse(person.getFace()));
    }
}

-----------------------------------------------------------------------

public class PersonAdapter extends RecyclerArrayAdapter<Person> {
    public PersonAdapter(Context context) {
        super(context);
    }

    @Override
    public BaseViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) {
        return new PersonViewHolder(parent);
    }
}

Decoration

Now there are three commonly used decoration provide for you.
DividerDecoration
Usually used in LinearLayoutManager.add divider between items.

DividerDecoration itemDecoration = new DividerDecoration(Color.GRAY, Util.dip2px(this,0.5f), Util.dip2px(this,72),0);//color & height & paddingLeft & paddingRight
itemDecoration.setDrawLastItem(true);//sometimes you don't want draw the divider for the last item,default is true.
itemDecoration.setDrawHeaderFooter(false);//whether draw divider for header and footer,default is false.
recyclerView.addItemDecoration(itemDecoration);

this is the demo:

SpaceDecoration
Usually used in GridLayoutManager and StaggeredGridLayoutManager.add space between items.

SpaceDecoration itemDecoration = new SpaceDecoration((int) Utils.convertDpToPixel(8,this));//params is height
itemDecoration.setPaddingEdgeSide(true);//whether add space for left and right adge.default is true.
itemDecoration.setPaddingStart(true);//whether add top space for the first line item(exclude header).default is true.
itemDecoration.setPaddingHeaderFooter(false);//whether add space for header and footer.default is false.
recyclerView.addItemDecoration(itemDecoration);

this is the demo:

StickHeaderDecoration
Group the items,add a GroupHeaderView for each group.The usage of StickyHeaderAdapter is the same with RecyclerView.Adapter. this part is modified from edubarr/header-decor

StickyHeaderDecoration decoration = new StickyHeaderDecoration(new StickyHeaderAdapter(this));
decoration.setIncludeHeader(false);
recyclerView.addItemDecoration(decoration);

for example:

for detail,see the demo

License

Copyright 2015 Jude

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

easyrecyclerview's People

Contributors

dreambigyoung avatar jude95 avatar ravidsrk avatar tudorgk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

easyrecyclerview's Issues

loadmore重复加载

在loadmoreview显示的时候再上下滑会重复加载,建议加个isloadingmore状态判断加载更多是否回调

请教

有没有可以自定义刷新头部动画的刷新控件啊 推荐一个?

下拉刷新&加载更多重大bug

  当前界面的item个数如果不超过屏幕高度,例如当前界面只有两个item显示,会不断地执行“加载更多”回调,直到当前界面item过数超过屏幕高度,麻烦fix一下,谢谢!

当使用gridlayoutmanager时加载更多显示问题

很感谢分享,使用起来确实很方便。但是在实际使用中发现了点问题,当使用gridlayoutmanager或者staggeredgridlayoutmanager,上拉加载更多的布局有点错乱了。不知道该怎么解决的?

EasyRecyclerView的建议

希望在ViewHolder中添加EasyRecyclerView item的点击事件和子view的点击事件,onClick和LongClick

在执行onRefresh 的时候 Progress不显示

//初始化adapter
mAdapter = new MessageOutboxListAdapter(getThisContext());
mList.setAdapterWithProgress(mAdapter);
mAdapter.setMore(R.layout.recyclerview_item_more, this);
代码如上,在执行onRefresh 的时候 Progress不显示呢?

更新数据

更新数据 必须调用 addAll(list)么?我直接更改list这个数据源的话,列表数量是不会变的,这事怎么回事,已经调用了notify了

滑动冲突

我将一个viewpager塞到header里面,发现滑动的时候老是滑动不过去,手指滑动一点就又退回去了,我重写了viewpager还是没用,求解

EasyRecyclerView databinding 会刷新所有的数据

本人懒癌,觉得还是 android:visibility="@{userInfo.videostatus==1?View.VISIBLE:View.GONE}这样方便,特别一个item里面多个图标显示隐藏。notifyDataSetChanged会刷新所有的数据,导致上面加载的数据会闪,需要增加 新增/删除/更新对应的方法
public final void notifyItemRangeChanged(int positionStart, int itemCount)
public final void notifyItemRangeInserted(int positionStart, int itemCount)
public final void notifyItemRangeRemoved(int positionStart, int itemCount)

Item 动画

recyclerView.getRecyclerView().setItemAnimator(new SlideInOutLeftItemAnimator(recyclerView.getRecyclerView()));
无效果,该如何加?谢谢!

getalldata的位置问题

我getviewtype是根据每一项中的type来判断,所以在adapter里面需要getalldata,但是有个问题

我不知道应该在哪里getalldata才比较合理,我现在是在getviewtype时给list赋值,这样的话,每一次getviewtype的时候都会给list赋值,感觉很不合理,但是我又不明白应该在哪里赋值才比较好

我在adapter外调用了addall,和insertall两个方法,但是如果要在这两个方法里面getalldata的话,就需要重写他们,我设想过在notify时get,但似乎不行

希望大家可以提供一些想法

不足一屏

不足一屏时,能不显示下面的loading view么?

某个item在当前屏幕是否可见

请问,如何判断某个item在当前屏幕是否可见?

像listview的OnScrollListener这样。

    ListView mListView = new ListView(getContext());
    mListView.setOnScrollListener(new AbsListView.OnScrollListener() {
        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {

        }

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {

        }
    });

关于加载loading和数据为空时View显示问题

在EasyRecyclerView的lib中没有指定默认的loading和为空时的View。如果使用者忘记添加避免app:layout_empty="@layout/view_empty"
app:layout_progress="@layout/view_progress"

则会crash,建议在lib中添加默认view。

且:
//生成空白View
mEmpty = (ViewStub) v.findViewById(R.id.empty);
mEmpty.setLayoutResource(mEmptyId);
if (mEmptyId != 0)
mEmptyView = mEmpty.inflate();

有bug。

Item button onclick

我子布局有button,如何响应button,如何传递position?谢谢!

滑动冲突

我将一个viewpager塞到header里面,发现滑动的时候老是滑动不过去,手指滑动一点就又退回去了,我重写了viewpager还是没用,求解
还有,可以自动下拉加载更多么

编辑列表

实现编辑列表功能好麻烦。朱大是用什么优雅的方式实现的。

加载更多问题。

mEasyRvAdapter = new EasyRvAdapter(mContext);
recyclerView.setLayoutManager(new LinearLayoutManager(mContext));
recyclerView.setAdapter(mEasyRvAdapter);
mEasyRvAdapter.addAll(DataServer.getDataFive());
mEasyRvAdapter.setMore(R.layout.view_more, new RecyclerArrayAdapter.OnLoadMoreListener() {
@OverRide
public void onLoadMore() {
Log.d(TAG, "onLoadMore");
new Handler().postDelayed(new Runnable() {
@OverRide
public void run() {
mEasyRvAdapter.addAll(DataServer.getDataMore());
}
}, 2000);
}
});
我直接这样写,应该是可以实现加载更多的那个功能的吧。但是实际,却没有,滑动到底部还是不行,不过我用的是RecyclerView ,不是EasyRecyclerView。
还有就是,我直接clone项目,运行,在CollapsingActivity.java,将EasyRecyclerView 替换为RecyclerView ,第一次加载更的时候,不会显示loading view ,往后的第二,第三次,才有。不过代码还没细看,回家在看看,不知道是我的用法有问题,还是其他的问题。

Add Header for adapter meet a problem

Here is the fragmen of my code:
` List data = new ArrayList<>();
for(int i = 0; i < 20; i ++){
data.add("position:" + i);
}
testAdapter = new testAdapter(this);
testAdapter.addHeader(new RecyclerArrayAdapter.ItemView() {
@OverRide
public View onCreateView(ViewGroup parent) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.adapter_test, null, false);
return view;
}

        @Override
        public void onBindView(View headerView) {
            TextView header = (TextView) headerView.findViewById(R.id.header);
            header.setText("I'M HEADER");
        }
    });

    testAdapter.notifyDataSetChanged();
    testAdapter.addAll(data);
    rcv.setAdapter(testAdapter);
    rcv.setLayoutManager(new LinearLayoutManager(this));` 

Here is the exception caught:
FATAL EXCEPTION: main
Process: com.example.zhang.recyclerviewwithheader, PID: 29336
java.lang.NullPointerException
at android.view.ViewGroup$LayoutParams.(ViewGroup.java:5929)
at android.view.ViewGroup$MarginLayoutParams.(ViewGroup.java:6211)
at android.support.v7.widget.RecyclerView$LayoutParams.(RecyclerView.java:8742)
at android.support.v7.widget.StaggeredGridLayoutManager$LayoutParams.(StaggeredGridLayoutManager.java:2050)
at com.jude.easyrecyclerview.adapter.RecyclerArrayAdapter.createSpViewByType(RecyclerArrayAdapter.java:407)
at com.jude.easyrecyclerview.adapter.RecyclerArrayAdapter.onCreateViewHolder(RecyclerArrayAdapter.java:427)
at com.jude.easyrecyclerview.adapter.RecyclerArrayAdapter.onCreateViewHolder(RecyclerArrayAdapter.java:49)
at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:5288)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4551)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4461)
at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:1962)
at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1371)
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1334)
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:563)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2847)
at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3145)
at android.view.View.layout(View.java:14828)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at com.jude.easyrecyclerview.swipe.SwipeRefreshLayout.onLayout(SwipeRefreshLayout.java:546)
at android.view.View.layout(View.java:14828)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.view.View.layout(View.java:14828)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
at android.view.View.layout(View.java:14828)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.view.View.layout(View.java:14828)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.support.v7.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:435)
at android.view.View.layout(View.java:14828)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.view.View.layout(View.java:14828)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
at android.view.View.layout(View.java:14828)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.view.View.layout(View.java:14828)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2074)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1831)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1087)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5696)
at android.view.Ch

想给RecyclerView增加layout_behavior怎么做

感谢Jude95的作品。
因为需要和toolbar联动处理Toolbar的收缩变化,需要给RecylerView增加layout_behavior, 我尝试直接拷贝代码,在layout_progress_rv中增加,但layout_behavior是给CoordinatorLayout用的,编译会出错
请教使用EasyRecyclerView时怎么实现和CollapsingToolbarLayout的联动?
谢谢

java.lang.IllegalArgumentException: pointerIndex out of range

不知道这个FC是不是Easy RecyclerView造成...

Fatal Exception: java.lang.IllegalArgumentException: pointerIndex out of range
       at android.view.MotionEvent.nativeGetAxisValue(MotionEvent.java)
       at android.view.MotionEvent.getY(MotionEvent.java:1996)
       at android.support.v4.view.MotionEventCompatEclair.getY(Unknown Source)
       at android.support.v4.view.MotionEventCompat$EclairMotionEventVersionImpl.getY(Unknown Source)
       at android.support.v4.view.MotionEventCompat.getY(Unknown Source)
       at com.jude.easyrecyclerview.swipe.SwipeRefreshLayout.onTouchEvent(Unknown Source)
       at android.view.View.dispatchTouchEvent(View.java:7127)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2144)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1905)
       at com.jude.easyrecyclerview.swipe.SwipeRefreshLayout.dispatchTouchEvent(Unknown Source)
       at com.jude.easyrecyclerview.EasyRecyclerView.dispatchTouchEvent(Unknown Source)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2146)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1919)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2146)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1919)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2146)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1919)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2146)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1919)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2146)
       at android.view.ViewGroup.cancelAndClearTouchTargets(ViewGroup.java:2009)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1812)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2176)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1877)
       at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1942)
       at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1380)
       at android.app.Activity.dispatchTouchEvent(Activity.java:2510)
       at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(Unknown Source)
       at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1890)
       at android.view.View.dispatchPointerEvent(View.java:7307)
       at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:3174)
       at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:3119)
       at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:4155)
       at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:4134)
       at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:4226)
       at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:171)
       at android.os.MessageQueue.nativePollOnce(MessageQueue.java)
       at android.os.MessageQueue.next(MessageQueue.java:125)
       at android.os.Looper.loop(Looper.java:124)
       at android.app.ActivityThread.main(ActivityThread.java:4745)
       at java.lang.reflect.Method.invokeNative(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:511)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
       at dalvik.system.NativeStart.main(NativeStart.java)

导入Android Studio后报错

我把代码clone下来导入到Android Studio中就报下面的错,不知道怎么回事啊?

Error:Unable to find method 'org.gradle.api.internal.project.ProjectInternal.getPluginManager()Lorg/gradle/api/internal/plugins/PluginManagerInternal;'.
Possible causes for this unexpected error include:

In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

横向的RecyclerView loadMoreView显示不出来?

谢谢你提供一个这么好用的控件,在正常情况下这个控件简单易用,但是我试了一下在LayoutManager为HORIZONTAL时候loadMoreView显示不出来?是不是我的用法有问题?(通过addFooterView()可以添加显示出来, 但这样无法调用loadMoreListener)

复用问题

对于图片的展示或者viewholder使用GridView中图片也存在复用问题,OnBindViewHolder中处理下会更好

about StaggeredGridLayout

用StaggeredGridLayout模式的时候 滑动速度快 item显示就出问题了 不知道作者有没有试过 还有就是'StaggeredGridLayoutManager.HORIZONTAL'有header的时候也有问题~

addHeader情况下无数据时,showEmpty()

private void update() {
log("update");
if (recyclerView.getAdapter() instanceof RecyclerArrayAdapter) {
if (((RecyclerArrayAdapter) recyclerView.getAdapter()).getCount() == 0){
log("no data:"+((hasProgress&&!isInitialized)?"show progress":"show empty"));
if (hasProgress&&!isInitialized)recyclerView.showProgress();
else recyclerView.showEmpty();
} else{
log("has data");
recyclerView.showRecycler();
}
} else {
if (recyclerView.getAdapter().getItemCount() == 0) {
log("no data:"+((hasProgress&&!isInitialized)?"show progress":"show empty"));
if (hasProgress&&!isInitialized)recyclerView.showProgress();
else recyclerView.showEmpty();
} else{
log("has data");
recyclerView.showRecycler();
}
}
isInitialized = true;//设置Adapter时会有一次onChange。忽略此次。

}

process情况下,getCount()=0, 未考虑header在无数据时也需要显示的场景,导致调用showEmpty(),设置是否需要在无数据时,显示header、footer?

addItemDecoration无效果

recyclerView.addItemDecoration(new RecycleViewDivider(getMyContext(), LinearLayoutManager.VERTICAL, 200, getResources().getColor(R.color.black)));
有距离,但是没有颜色

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.