io.nlopez.smartadapters.SmartAdapter Java Examples

The following examples show how to use io.nlopez.smartadapters.SmartAdapter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FragmentRepoList.java    From AndroidStarter with Apache License 2.0 5 votes vote down vote up
@DebugLog
@Override
public void setData(final RepoListMvp.Model poData) {
    ((RepoListMvp.ViewState) viewState).data = poData;

    SmartAdapter.items(poData.repos)
            .map(RepoEntity.class, CellRepo.class)
            .listener(FragmentRepoList.this)
            .into(mRecyclerView);
}
 
Example #2
Source File: ControllerRepoList.java    From AndroidStarterAlt with Apache License 2.0 5 votes vote down vote up
@DebugLog
@Override
public void setData(final RepoListMvp.Model poData) {
    viewState.data = poData;

    SmartAdapter.items(poData.repos)
            .map(RepoEntity.class, CellRepo.class)
            .listener(ControllerRepoList.this)
            .into(mRecyclerView);
}
 
Example #3
Source File: MultiRecyclerViewCustomBuilderActivity.java    From smart-adapters with MIT License 5 votes vote down vote up
private void initView() {
    List mixedList = DataGenerator.generateMix(100);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    SmartAdapter.items(mixedList)
            .map(User.class, UserView.class)
            .map(User.class, UserAltView.class)
            .map(Place.class, PlaceView.class)
            .map(Place.class, PlaceAltView.class)
            .builder(new DefaultBindableLayoutBuilder() {

                @Override
                public Class<? extends BindableLayout> viewType(
                        @NonNull Object item, int position, @NonNull Mapper mapper) {
                    if (item instanceof User) {
                        User user = (User) item;
                        if (user.getFirstName().length() % 2 == 1) {
                            return UserView.class;
                        } else {
                            return UserAltView.class;
                        }
                    } else if (item instanceof Place) {
                        Place place = (Place) item;
                        if (place.getName().length() % 2 == 1) {
                            return PlaceView.class;
                        } else {
                            return PlaceAltView.class;
                        }
                    } else {
                        return super.viewType(item, position, mapper);
                    }
                }

                @Override
                public boolean allowsMultimapping() {
                    return true;
                }
            })
            .into(recyclerView);
}
 
Example #4
Source File: MultiRecyclerViewActivity.java    From smart-adapters with MIT License 5 votes vote down vote up
private void initView() {
    List mixedList = DataGenerator.generateMix(100);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    SmartAdapter.items(mixedList)
            .map(User.class, UserView.class)
            .map(Place.class, PlaceView.class)
            .into(recyclerView);
}
 
Example #5
Source File: SingleRecyclerViewActivity.java    From smart-adapters with MIT License 4 votes vote down vote up
private void initView() {
    List<User> userList = DataGenerator.generateUsers(100);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    SmartAdapter.items(userList).map(User.class, UserView.class).into(recyclerView);
}
 
Example #6
Source File: SingleListViewActivity.java    From smart-adapters with MIT License 4 votes vote down vote up
private void initView() {
    List<User> userList = DataGenerator.generateUsers(100);
    SmartAdapter.items(userList).map(User.class, UserView.class).into(listView);
}
 
Example #7
Source File: MultiListViewActivity.java    From smart-adapters with MIT License 4 votes vote down vote up
private void initView() {
    List mixedList = DataGenerator.generateMix(100);
    SmartAdapter.items(mixedList).map(User.class, UserView.class).map(Place.class, PlaceView.class).into(listView);
}