-
-
Save DevAhamed/16d4e516ccf1fdfbc595005753c9397d to your computer and use it in GitHub Desktop.
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 CarAdapter extends RecyclerAdapter { | |
private DataListManager<CarModel> dataManager; | |
public CarAdapter() { | |
this.dataManager = new DataListManager<>(this); | |
addDataManager(dataManager); | |
registerBinder(new CarBinder()); | |
} | |
public void addData(List<CarModel> dataList) { | |
dataManager.addAll(dataList); | |
} | |
} |
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
class CarBinder extends ItemBinder<CarModel, CarBinder.CarViewHolder> { | |
@Override public CarViewHolder create(LayoutInflater inflater, ViewGroup parent) { | |
return new CarViewHolder(inflater.inflate(R.layout.item_car, parent, false)); | |
} | |
@Override public boolean canBindData(Object item) { | |
return item instanceof CarModel; | |
} | |
@Override public void bind(CarViewHolder holder, CarModel item) { | |
// Bind the data here | |
} | |
static class CarViewHolder extends BaseViewHolder<ItemModel> { | |
// Normal ViewHolder code | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment