Skip to content

Problem with FindUsersActivity - clear() function #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
alexanderpehlivanov opened this issue Mar 8, 2018 · 1 comment
Open

Problem with FindUsersActivity - clear() function #2

alexanderpehlivanov opened this issue Mar 8, 2018 · 1 comment

Comments

@alexanderpehlivanov
Copy link

E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.liveshotapp.liveshot2, PID: 32461
java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid item position 4(offset:4).state:8 android.support.v7.widget.RecyclerView{9ed5bd0 VFED.V... ......I. 0,169-1080,1089 #7f080085 app:id/recyclerView}, adapter:com.liveshotapp.liveshot2.RecyclerViewFollow.FollowAdapter@ee9a7c9, layout:android.support.v7.widget.LinearLayoutManager@911dece, context:com.liveshotapp.liveshot2.FindUsersActivity@8d0e823
at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5817)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5752)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5748)
at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2232)
at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1559)
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1519)
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:614)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep1(RecyclerView.java:3763)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3527)
at android.support.v7.widget.RecyclerView.consumePendingUpdateOperations(RecyclerView.java:1756)
at android.support.v7.widget.RecyclerView$1.run(RecyclerView.java:356)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:920)
at android.view.Choreographer.doCallbacks(Choreographer.java:695)
at android.view.Choreographer.doFrame(Choreographer.java:628)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:906)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7224)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

@BogdanST
Copy link

Alright, I've found that issue too. The way I fixed it, is by adding mAdapter.notifyDataSetChanged(); in the FindUsersActivity file.

The code should look something like this:
mSearch.setOnClickListener(new View.OnClickListener() {
@OverRide
public void onClick(View view) {
//Before searching in database, it requires to clear the data.
clear();
mAdapter.notifyDataSetChanged();
//Searching for user by email
listenForData();
}
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants