Last active
February 13, 2019 12:10
-
-
Save wightwulf1944/0b2754e528d706d40b529fb7a47b2295 to your computer and use it in GitHub Desktop.
adapter bind listener pattern
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RelevantBindListener { | |
public RelevantBindListener() { | |
SampleAdapter adapter = new SampleAdapter(); | |
adapter.setOnLastItemBindListener(this::onAdapterLastItemBind); | |
} | |
private void onAdapterLastItemBind() { | |
// THIS IS CALLED WHEN THE LAST ADAPTER ITEM IS BIND.. BOUND? BINDED?? | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SampleAdapter extends RecyclerView.Adapter { | |
private Runnable onLastItemBindListener; | |
public void setOnLastItemBindListener(Runnable onLastItemBindListener) { | |
this.onLastItemBindListener = onLastItemBindListener; | |
} | |
@Override | |
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { | |
if (position == getItemCount() - 1) { | |
onLastItemBindListener.run(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment