I am implementing MVP architecture, code works fine, I wanted your suggestions if I there can be improvements done or in any areas where I am not following the pattern correctly.

It is a simple application using RecyclerViews to list games in a Fragment.

FGames - Fragment which displays the list of Games

public class FGames extends Fragment implements GamesView {

    RecyclerView rvGames;
    private GamesAdapter gamesAdapter;
    private GamesPresenterImpl presenter;
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.games_layout, container, false);
        ButterKnife.bind(this, view);
        presenter = new GamesPresenterImpl(this);
        return view;

    public void onActivityCreated(@Nullable Bundle savedInstanceState) {

    public void initRecyclerView(List<GameEntity> gameEntities) {
        gamesAdapter = new GamesAdapter(getActivity(), gameEntities);
        rvGames.setLayoutManager(new LinearLayoutManager(getActivity()));

Interface - GamesView

  public interface GamesView {

         * Initialise the recycler view to list Games data
         * @param gameEntities
        void initRecyclerView(List<GameEntity> gameEntities);

GamesPresenterImpl - Presenter implementation

    public class GamesPresenterImpl implements GamesPresenter {

    GamesView gamesView;

    public GamesPresenterImpl(GamesView gamesView) {
        this.gamesView = gamesView;

    public void initUi() {

    public List<GameEntity> getGamesData() {
        List<GameEntity> gameEntities = new ArrayList<>();
        int counter = 0;
        for(int i = 0; i<10; i++){
            GameEntity gameEntity = new GameEntity();
            counter ++;
            gameEntity.setName("Test name " + counter);
        return gameEntities;

Interface - GamesPresenter

public interface GamesPresenter {
    void initUi();
  • \$\begingroup\$ Hello, I have the same question, I know this is an older question, but did you find an answer or was this enough for the separation of concerns and tests? Thank you. \$\endgroup\$ – Gabi Radu Aug 6 '18 at 11:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.