Android Open Source - android-unittesting Main Activity






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 ww  .  ja  v  a 2 s .  c om*/
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;

import com.hp.mvp.data.ToDo;

import java.util.List;


public class MainActivity extends Activity implements ToDoView {

    private TextView mNewTaskText;
    private ListView mTaskView;

    private ToDoPresenter mPresenter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mTaskView = (ListView) findViewById(R.id.taskList);

        mNewTaskText = (TextView) findViewById(R.id.taskText);

        Button action = (Button) findViewById(R.id.newTask);
        action.setOnClickListener(this.handleNewTaskEvent);

        mPresenter = new MainPresenter(this);

        mPresenter.retrieveData();
    }


    private final View.OnClickListener handleNewTaskEvent = new View.OnClickListener() {
        @Override
        public void onClick(final View view) {
            mPresenter.addToDo(mNewTaskText.getText().toString());

            mNewTaskText.setText("");
        }
    };

    public MainApplication getMainApplication(){
        return (MainApplication) getApplication();
    }

    /**
     * Helper method to put the list of items into the ListView
     */
    public void bindToDoList(final List<ToDo> data) {
        final ToDoAdapter adapter = new ToDoAdapter(this, data);
        mTaskView.setAdapter(adapter);

        mTaskView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(final AdapterView<?> parent, final View view, final int position, final long id) {

                final TextView v = (TextView) view;

                final long todoId = (Long) v.getTag();

                mPresenter.deleteToDo(todoId, position);
            }
        });
    }
}




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