EMMA Coverage Report (generated Wed Mar 29 09:10:45 CEST 2017)
[all classes][info.bpace.munchlife]

COVERAGE SUMMARY FOR SOURCE FILE [SettingsActivity.java]

nameclass, %method, %block, %line, %
SettingsActivity.java100% (2/2)100% (4/4)81%  (55/68)88%  (15/17)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class SettingsActivity$1100% (1/1)100% (2/2)70%  (30/43)80%  (8/10)
onPreferenceChange (Preference, Object): boolean 100% (1/1)65%  (24/37)78%  (7/9)
SettingsActivity$1 (SettingsActivity): void 100% (1/1)100% (6/6)100% (1/1)
     
class SettingsActivity100% (1/1)100% (2/2)100% (25/25)100% (7/7)
SettingsActivity (): void 100% (1/1)100% (9/9)100% (2/2)
onCreate (Bundle): void 100% (1/1)100% (16/16)100% (5/5)

1/*
2 * This program is free software: you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation, either version 3 of the License, or
5 * (at your option) any later version.
6 * 
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10 * GNU General Public License for more details.
11 * 
12 * You should have received a copy of the GNU General Public License
13 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
14 */
15 
16package info.bpace.munchlife;
17 
18import android.app.Activity;
19import android.os.Bundle;
20import android.preference.Preference;
21import android.preference.PreferenceActivity;
22import android.preference.Preference.OnPreferenceChangeListener;
23import android.widget.Toast;
24 
25import android.util.Log;
26 
27public class SettingsActivity extends PreferenceActivity
28{
29        OnPreferenceChangeListener levelListener = new OnPreferenceChangeListener()
30        {
31                public boolean onPreferenceChange(Preference pref, Object newValue)
32                {
33                        int value = 0;
34                        try
35                        {
36                                value = Integer.parseInt(newValue.toString());
37                        }
38                        catch(NumberFormatException error)
39                        {
40                                Log.w(MunchLifeActivity.TAG, 
41              "NumberFormatException: " + error.getMessage());
42                        }
43                
44                        if(value > 1 && value <= 100)
45                        {
46                                return true;
47                        }
48                        else
49                        {
50                                Toast.makeText(getApplicationContext(),
51                       R.string.maxlevelError,
52                       Toast.LENGTH_SHORT).show();
53                                return false;
54                        }
55                }
56        };
57        
58        @Override
59        protected void onCreate(Bundle savedInstanceState)
60        {
61                super.onCreate(savedInstanceState);
62                addPreferencesFromResource(R.xml.preferences);
63                Preference levelPreference;
64    levelPreference = getPreferenceScreen().findPreference("maxlevelPref");
65                levelPreference.setOnPreferenceChangeListener(levelListener);
66        }
67}

[all classes][info.bpace.munchlife]
EMMA 2.0.5312 (C) Vladimir Roubtsov