Java Code Examples for io.nlopez.smartadapters.SmartAdapter

The following examples show how to use io.nlopez.smartadapters.SmartAdapter. These examples are extracted from open source projects. 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 Project: AndroidStarter   Source File: FragmentRepoList.java    License: 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 Project: AndroidStarterAlt   Source File: ControllerRepoList.java    License: 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
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 Project: smart-adapters   Source File: MultiRecyclerViewActivity.java    License: 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 Project: smart-adapters   Source File: SingleRecyclerViewActivity.java    License: 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 Project: smart-adapters   Source File: SingleListViewActivity.java    License: 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 Project: smart-adapters   Source File: MultiListViewActivity.java    License: 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);
}