EMMA Coverage Report (generated Thu Mar 09 12:17:56 CET 2017)
[all classes][kdk.android.simplydo]

COVERAGE SUMMARY FOR SOURCE FILE [DeleteInactiveAction.java]

nameclass, %method, %block, %line, %
DeleteInactiveAction.java100% (2/2)100% (7/7)98%  (85/87)96%  (22/23)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class DeleteInactiveAction100% (1/1)100% (5/5)97%  (75/77)95%  (19/20)
deleteInactive (int): void 100% (1/1)90%  (18/20)83%  (5/6)
DeleteInactiveAction (Activity, DataViewer, ListPropertiesAdapter, ItemProper... 100% (1/1)100% (40/40)100% (8/8)
access$000 (DeleteInactiveAction): void 100% (1/1)100% (3/3)100% (1/1)
createDialog (): Dialog 100% (1/1)100% (4/4)100% (1/1)
deleteInactive (): void 100% (1/1)100% (10/10)100% (4/4)
     
class DeleteInactiveAction$1100% (1/1)100% (2/2)100% (10/10)100% (3/3)
DeleteInactiveAction$1 (DeleteInactiveAction): void 100% (1/1)100% (6/6)100% (1/1)
onClick (DialogInterface, int): void 100% (1/1)100% (4/4)100% (2/2)

1/*
2 * Copyright (C) 2013 Keith Kildare
3 * 
4 * This file is part of SimplyDo.
5 * 
6 * SimplyDo is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 * 
11 * SimplyDo is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 * GNU General Public License for more details.
15 * 
16 * You should have received a copy of the GNU General Public License
17 * along with SimplyDo.  If not, see <http://www.gnu.org/licenses/>.
18 * 
19 */
20package kdk.android.simplydo;
21 
22import android.app.Activity;
23import android.app.AlertDialog;
24import android.app.Dialog;
25import android.content.DialogInterface;
26import android.content.SharedPreferences;
27import android.preference.PreferenceManager;
28 
29public class DeleteInactiveAction
30{
31    private Activity activity;
32    private DataViewer dataViewer;
33    private ListPropertiesAdapter listPropertiesAdapter;
34    private ItemPropertiesAdapter itemPropertiesAdapter;
35    
36    private AlertDialog.Builder dialogBuilder;
37 
38    public DeleteInactiveAction(
39            Activity activity, 
40            DataViewer dataViewer,
41            ListPropertiesAdapter listPropertiesAdapter, 
42            ItemPropertiesAdapter itemPropertiesAdapter)
43    {
44        this.activity = activity;
45        this.dataViewer = dataViewer;
46        this.listPropertiesAdapter = listPropertiesAdapter;
47        this.itemPropertiesAdapter = itemPropertiesAdapter;
48        
49        dialogBuilder = new AlertDialog.Builder(this.activity);
50        dialogBuilder.setMessage(R.string.deleteInactiveMessage)
51               .setCancelable(true)
52               .setTitle(R.string.deleteInactiveTitle)
53               .setPositiveButton(R.string.deleteInactivePositive, new DialogInterface.OnClickListener() {
54                   public void onClick(DialogInterface dialog, int id) {
55                       deleteInactive();
56                   }
57               })
58               .setNegativeButton(R.string.deleteInactiveNegative, null);
59    }
60 
61    public void deleteInactive(int dialogId)
62    {
63        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity.getBaseContext());
64        boolean confirmDeleteInactive = prefs.getBoolean("confirmDeleteInactive", true);
65        
66        if(confirmDeleteInactive)
67        {
68            activity.showDialog(dialogId);
69        }
70        else
71        {
72            deleteInactive();
73        }
74    }
75    
76    public Dialog createDialog()
77    {
78        return dialogBuilder.create();
79    }
80    
81    private void deleteInactive()
82    {
83        dataViewer.deleteInactive();
84        itemPropertiesAdapter.notifyDataSetChanged();
85        listPropertiesAdapter.notifyDataSetChanged();
86    }
87}

[all classes][kdk.android.simplydo]
EMMA 2.0.5312 (C) Vladimir Roubtsov