Android Open Source - openpomo Trash Sheet






From Project

Back to project page openpomo.

License

The source code is released under:

GNU General Public License

If you think the Android project openpomo 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

/**
 * This file is part of Pomodroid./*from w ww  .j  a  v  a2 s. com*/
 *
 *   Pomodroid is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   Pomodroid is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with Pomodroid.  If not, see <http://www.gnu.org/licenses/>.
 */
package it.unibz.pomodroid;

import java.util.ArrayList;
import java.util.List;

import it.unibz.pomodroid.exceptions.PomodroidException;
import it.unibz.pomodroid.models.*;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.Menu;

/**
 * Trash Sheet class is an extension of Shared List activity.
 * This class shows to the user which activities are done.
 * <p/>
 * From here we can move an activity into the todo today sheet (and automatically into
 * the activity inventory sheet) or into the activity inventory sheet.
 *
 * @author Daniel Graziotin <d AT danielgraziotin DOT it>
 * @author Thomas Schievenin <thomas.schievenin@stud-inf.unibz.it>
 * @see it.unibz.pomodroid.SharedListActivity
 */
public class TrashSheet extends SharedListActivity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.setResourceLayout(R.layout.trashactivityentry);
        super.setContext(this);
        super.onCreate(savedInstanceState);
    }

    /**
     * Gets the Activities from Activity.getCompleted() and adds them to the local
     * list of activities. It calls populateAdapter to populate the adapter with
     * the new list of activities
     *
     * @throws PomodroidException
     * @see Activity
     */

    @Override
    protected void retrieveActivities() throws PomodroidException {
        try {
            activities = new ArrayList<Activity>();
            List<Activity> retrievedActivities = Activity.getCompleted(this.dbHelper);
            activities.addAll(retrievedActivities);
        } catch (Exception e) {
            throw new PomodroidException(
                    "Error in retrieving Activities from the DB!");
        }
        runOnUiThread(populateAdapter);
    }

    /**
     * This dialog gives the possibility to change the status of each activity
     *
     * @param activity
     */
    @Override
    protected void openActivityDialog(Activity activity) {
        final Activity selectedActivity = activity;
        new AlertDialog.Builder(this).setTitle(R.string.activity_title)
                .setItems(R.array.ais_trash,
                        new DialogInterface.OnClickListener() {
                            public void onClick(
                                    DialogInterface dialoginterface, int i) {
                                try {
                                    switch (i) {
                                        case 0:
                                            selectedActivity.setTodoToday(false);
                                            selectedActivity.setUndone();
                                            selectedActivity.save(dbHelper);
                                            activityAdapter
                                                    .remove(selectedActivity);
                                            break;
                                        case 1:
                                            selectedActivity.setTodoToday(true);
                                            selectedActivity.setUndone();
                                            selectedActivity.save(dbHelper);
                                            activityAdapter
                                                    .remove(selectedActivity);
                                            break;
                                    }
                                } catch (PomodroidException e) {
                                    e.alertUser(getContext());
                                } finally {
                                    dbHelper.commit();
                                }
                            }
                        }).show();
    }

    /**
     * We specify the menu labels and theirs icons
     *
     * @param menu
     * @return true
     */
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        if (super.getUser().isAdvanced()) {
            menu.add(0, R.id.ACTION_EMPTY_LIST, 0, "Empty Trash Can").setIcon(
                    android.R.drawable.ic_menu_delete);
            return true;
        }
        menu.add(0, R.id.ACTION_EMPTY_LIST, 0, "Empty Trash Can").setIcon(
                android.R.drawable.ic_menu_delete);
        menu.add(0, R.id.ACTION_GO_TTS, 0, "Todo Today").setIcon(
                android.R.drawable.ic_menu_day);
        menu.add(0, R.id.ACTION_GO_PREFERENCES, 0, "Preferences").setIcon(
                android.R.drawable.ic_menu_preferences);
        return true;
    }

}




Java Source Code List

it.unibz.pomodroid.About.java
it.unibz.pomodroid.ActivityInventorySheet.java
it.unibz.pomodroid.CleanDatabase.java
it.unibz.pomodroid.EditActivity.java
it.unibz.pomodroid.EditService.java
it.unibz.pomodroid.ListServices.java
it.unibz.pomodroid.PomodoroService.java
it.unibz.pomodroid.Pomodoro.java
it.unibz.pomodroid.Pomodroid.java
it.unibz.pomodroid.Preferences.java
it.unibz.pomodroid.Services.java
it.unibz.pomodroid.SharedActivity.java
it.unibz.pomodroid.SharedListActivity.java
it.unibz.pomodroid.Statistics.java
it.unibz.pomodroid.TabPomodroid.java
it.unibz.pomodroid.TabPreferences.java
it.unibz.pomodroid.TodoTodaySheet.java
it.unibz.pomodroid.TrashSheet.java
it.unibz.pomodroid.exceptions.PomodroidException.java
it.unibz.pomodroid.factories.ActivityFactory.java
it.unibz.pomodroid.models.Activity.java
it.unibz.pomodroid.models.DBHelper.java
it.unibz.pomodroid.models.Event.java
it.unibz.pomodroid.models.Service.java
it.unibz.pomodroid.models.User.java
it.unibz.pomodroid.services.TracTicketFetcher.java
it.unibz.pomodroid.services.XmlRpcClient.java
org.xmlrpc.Test.java
org.xmlrpc.android.Base64Coder.java
org.xmlrpc.android.XMLRPCClient.java
org.xmlrpc.android.XMLRPCException.java
org.xmlrpc.android.XMLRPCFault.java
org.xmlrpc.android.XMLRPCSerializer.java