Android Open Source - android-unittesting Main Presenter






From Project

Back to project page android-unittesting.

License

The source code is released under:

Apache License

If you think the Android project android-unittesting listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.hp.mvp;
/*  w  w w  .  j a  v  a  2 s.c om*/
import com.hp.mvp.data.DataProvider;
import com.hp.mvp.data.ToDo;

import java.util.List;

import javax.inject.Inject;

/**
 * the Presenter object in our MVP model
 */
public class MainPresenter implements ToDoPresenter {

    private List<ToDo> mData;
    private ToDoView mView;

    @Inject
    DataProvider mProvider;


    public MainPresenter(ToDoView view) {
        mView = view;

        MainApplication app = mView.getMainApplication();
        app.getObjectGraph().inject(this);
    }

    @Override
    public void retrieveData() {
        mData = mProvider.findAll();
        mView.bindToDoList(mData);
    }

    @Override
    public void deleteToDo(long id, int position) {

        //Remove from the local database
        mProvider.deleteTask(id);
        mData.remove(position);
        mView.bindToDoList(mData);
    }

    @Override
    public void addToDo(String item) {
        ToDo newItem = new ToDo();
        newItem.setTitle(item);
        newItem.setId(mProvider.getNextId());
        mProvider.addTask(newItem);

        mData.add(newItem);
        mView.bindToDoList(mData);
    }
}




Java Source Code List

com.devfest.dagger.app.DataModule.java
com.devfest.dagger.app.MainActivity.java
com.devfest.dagger.app.MainApplication.java
com.devfest.dagger.app.ToDoAdapter.java
com.devfest.dagger.data.DataProvider.java
com.devfest.dagger.data.SqlLiteProvider.java
com.devfest.dagger.data.ToDo.java
com.hp.mvp.DataModule.java
com.hp.mvp.MainActivity.java
com.hp.mvp.MainApplication.java
com.hp.mvp.MainPresenter.java
com.hp.mvp.ToDoAdapter.java
com.hp.mvp.ToDoPresenter.java
com.hp.mvp.ToDoView.java
com.hp.mvp.data.DataProvider.java
com.hp.mvp.data.SqlLiteProvider.java
com.hp.mvp.data.ToDo.java