EMMA Coverage Report (generated Thu Oct 17 06:14:17 PDT 2013)
[all classes][com.example.android.notepad]

COVERAGE SUMMARY FOR SOURCE FILE [TitleEditor.java]

nameclass, %method, %block, %line, %
TitleEditor.java0%   (0/1)0%   (0/6)0%   (0/101)0%   (0/24)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class TitleEditor0%   (0/1)0%   (0/6)0%   (0/101)0%   (0/24)
<static initializer> 0%   (0/1)0%   (0/12)0%   (0/1)
TitleEditor (): void 0%   (0/1)0%   (0/3)0%   (0/1)
onClick (View): void 0%   (0/1)0%   (0/3)0%   (0/2)
onCreate (Bundle): void 0%   (0/1)0%   (0/40)0%   (0/9)
onPause (): void 0%   (0/1)0%   (0/26)0%   (0/6)
onResume (): void 0%   (0/1)0%   (0/17)0%   (0/5)

1/*
2 * Copyright (C) 2007 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 
17package com.example.android.notepad;
18 
19import android.app.Activity;
20import android.content.ContentValues;
21import android.database.Cursor;
22import android.net.Uri;
23import android.os.Bundle;
24import android.view.View;
25import android.widget.Button;
26import android.widget.EditText;
27 
28import com.example.android.notepad.NotePad.NoteColumns;
29 
30/**
31 * An activity that will edit the title of a note. Displays a floating
32 * window with a text field.
33 */
34public class TitleEditor extends Activity implements View.OnClickListener {
35 
36    /**
37     * This is a special intent action that means "edit the title of a note".
38     */
39    public static final String EDIT_TITLE_ACTION = "com.android.notepad.action.EDIT_TITLE";
40 
41    /**
42     * An array of the columns we are interested in.
43     */
44    private static final String[] PROJECTION = new String[] {
45        NoteColumns._ID, // 0
46        NoteColumns.TITLE, // 1
47    };
48    /** Index of the title column */
49    private static final int COLUMN_INDEX_TITLE = 1;
50 
51    /**
52     * Cursor which will provide access to the note whose title we are editing.
53     */
54    private Cursor mCursor;
55 
56    /**
57     * The EditText field from our UI. Keep track of this so we can extract the
58     * text when we are finished.
59     */
60    private EditText mText;
61 
62    /**
63     * The content URI to the note that's being edited.
64     */
65    private Uri mUri;
66 
67    @Override
68    public void onCreate(Bundle savedInstanceState) {
69        super.onCreate(savedInstanceState);
70 
71        setContentView(R.layout.title_editor);
72 
73        // Get the uri of the note whose title we want to edit
74        mUri = getIntent().getData();
75 
76        // Get a cursor to access the note
77        mCursor = managedQuery(mUri, PROJECTION, null, null, null);
78 
79        // Set up click handlers for the text field and button
80        mText = (EditText) this.findViewById(R.id.title);
81        mText.setOnClickListener(this);
82        
83        Button b = (Button) findViewById(R.id.ok);
84        b.setOnClickListener(this);
85    }
86 
87    @Override
88    protected void onResume() {
89        super.onResume();
90 
91        // Initialize the text with the title column from the cursor
92        if (mCursor != null) {
93            mCursor.moveToFirst();
94            mText.setText(mCursor.getString(COLUMN_INDEX_TITLE));
95        }
96    }
97 
98    @Override
99    protected void onPause() {
100        super.onPause();
101 
102        if (mCursor != null) {
103            // Write the title back to the note 
104            ContentValues values = new ContentValues();
105            values.put(NoteColumns.TITLE, mText.getText().toString());
106            getContentResolver().update(mUri, values, null, null);
107        }
108    }
109 
110    @Override
111        public void onClick(View v) {
112        // When the user clicks, just finish this activity.
113        // onPause will be called, and we save our data there.
114        finish();
115    }
116}

[all classes][com.example.android.notepad]
EMMA 2.0.5312 (C) Vladimir Roubtsov