(mensagem de log vazia)
@@ -16,10 +16,10 @@ | ||
16 | 16 | */ |
17 | 17 | package jp.ne.motoki.android.fuelchecker; |
18 | 18 | |
19 | +import android.content.Intent; | |
20 | +import android.database.Cursor; | |
19 | 21 | import android.os.Bundle; |
20 | 22 | |
21 | - | |
22 | - | |
23 | 23 | /** |
24 | 24 | * @author kiyoshi.motoki |
25 | 25 | * |
@@ -26,7 +26,9 @@ | ||
26 | 26 | */ |
27 | 27 | public class UpdateActivity extends FuelCheckerActivity { |
28 | 28 | |
29 | - private long originalDatetime = -1; | |
29 | + private static final long NO_DATA = -1; | |
30 | + | |
31 | + private long originalDatetime = NO_DATA; | |
30 | 32 | |
31 | 33 | /** Called when the activity is first created. */ |
32 | 34 | @Override |
@@ -45,4 +47,26 @@ | ||
45 | 47 | adapter.close(); |
46 | 48 | } |
47 | 49 | } |
50 | + | |
51 | + /* (non-Javadoc) | |
52 | + * @see jp.ne.motoki.android.fuelchecker.FuelCheckerActivity#createData() | |
53 | + */ | |
54 | + @Override | |
55 | + protected FuelData createData() { | |
56 | + Intent intent = getIntent(); | |
57 | + originalDatetime = intent.getLongExtra(Utils.EXTRA_DATETIME, NO_DATA); | |
58 | + | |
59 | + if (originalDatetime == NO_DATA) { | |
60 | + throw new IllegalStateException("Intent hasn't content extra."); | |
61 | + } | |
62 | + | |
63 | + FuelDbAdapter adapter = new FuelDbAdapter(this); | |
64 | + try { | |
65 | + adapter.open(); | |
66 | + Cursor cursor = adapter.fetchData(originalDatetime); | |
67 | + return FuelData.Factory.createInstance(cursor); | |
68 | + } finally { | |
69 | + adapter.close(); | |
70 | + } | |
71 | + } | |
48 | 72 | } |
@@ -42,4 +42,12 @@ | ||
42 | 42 | adapter.close(); |
43 | 43 | } |
44 | 44 | } |
45 | + | |
46 | + /* (non-Javadoc) | |
47 | + * @see jp.ne.motoki.android.fuelchecker.FuelCheckerActivity#createData() | |
48 | + */ | |
49 | + @Override | |
50 | + protected FuelData createData() { | |
51 | + return new FuelData(); | |
52 | + } | |
45 | 53 | } |
@@ -17,7 +17,6 @@ | ||
17 | 17 | package jp.ne.motoki.android.fuelchecker; |
18 | 18 | |
19 | 19 | import jp.ne.motoki.android.fuelchecker.DBConstants.Column; |
20 | -import android.app.Activity; | |
21 | 20 | import android.app.AlertDialog; |
22 | 21 | import android.app.ListActivity; |
23 | 22 | import android.content.DialogInterface; |
@@ -137,18 +136,6 @@ | ||
137 | 136 | adapter.close(); |
138 | 137 | } |
139 | 138 | |
140 | - @Override | |
141 | - protected void onActivityResult(int requestCode, int resultCode, Intent data) { | |
142 | - // TODO Auto-generated method stub | |
143 | - switch (requestCode) { | |
144 | - case REQUEST_UPDATE: | |
145 | - Toast.makeText(this, "resultCode = " + (resultCode == Activity.RESULT_CANCELED ? "RESULT_CANCELED" : "Othre"), Toast.LENGTH_LONG).show(); | |
146 | - break; | |
147 | - default: | |
148 | - throw new AssertionError("requestCode = " + requestCode); | |
149 | - } | |
150 | - } | |
151 | - | |
152 | 139 | private void update(long datetime) { |
153 | 140 | Intent intent = new Intent(this, UpdateActivity.class); |
154 | 141 | intent.putExtra(Utils.EXTRA_DATETIME, datetime); |
@@ -50,7 +50,7 @@ | ||
50 | 50 | |
51 | 51 | private final Intent INTENT_CALL_LIST = new Intent(); |
52 | 52 | |
53 | - private FuelData fuelData = new FuelData(); | |
53 | + private FuelData fuelData = null; | |
54 | 54 | |
55 | 55 | private DatePickerDialogPreference datePreference = null; |
56 | 56 | private TimePickerDialogPreference timePreference = null; |
@@ -133,6 +133,8 @@ | ||
133 | 133 | distancePreference = |
134 | 134 | (NumericPickerDialogPreference) findPreference(PREF_KEY_DISTANCE); |
135 | 135 | |
136 | + fuelData = createData(); | |
137 | + | |
136 | 138 | Calendar calendar = fuelData.getDatetime(); |
137 | 139 | datePreference.setValue(calendar); |
138 | 140 | timePreference.setValue(calendar); |
@@ -197,6 +199,8 @@ | ||
197 | 199 | throw new AssertionError("id = " + id); |
198 | 200 | } |
199 | 201 | } |
202 | + | |
203 | + protected abstract FuelData createData(); | |
200 | 204 | |
201 | 205 | protected void onClickButtonRegister() { |
202 | 206 | if (!isValidData()) { |
@@ -1,69 +0,0 @@ | ||
1 | -<?xml version="1.0" encoding="utf-8"?> | |
2 | -<!-- Copyright (C) 2011 kiyoshi.motoki | |
3 | - | |
4 | - This program is free software: you can redistribute it and/or modify | |
5 | - it under the terms of the GNU General Public License as published by | |
6 | - the Free Software Foundation, either version 3 of the License, or | |
7 | - any later version. | |
8 | - | |
9 | - This program is distributed in the hope that it will be useful, | |
10 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | - GNU General Public License for more details. | |
13 | - | |
14 | - You should have received a copy of the GNU General Public License | |
15 | - along with this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | ---> | |
17 | -<resources> | |
18 | - <string name="app_name">燃費チェッカー</string> | |
19 | - | |
20 | - <string name="title_date_and_time">日時</string> | |
21 | - | |
22 | - <string name="title_date">給油日</string> | |
23 | - <string name="summary_date">給油した日付を\nセットしてください。</string> | |
24 | - | |
25 | - <string name="title_time">時間</string> | |
26 | - <string name="summary_time">給油した時間を\nセットしてください。</string> | |
27 | - | |
28 | - <string name="title_fuel_information">給油情報</string> | |
29 | - | |
30 | - <string name="title_quantity">給油量</string> | |
31 | - <string name="summary_quantity">給油量をセットしてください。</string> | |
32 | - <string name="unit_quantity">ℓ</string> | |
33 | - | |
34 | - <string name="title_distance">走行距離</string> | |
35 | - <string name="summary_distance">前回、給油してからの走行距離を\nセットしてください。</string> | |
36 | - <string name="unit_distance">km</string> | |
37 | - | |
38 | - <string name="title_efficiency">燃費</string> | |
39 | - <string name="unit_efficiency">km/ℓ</string> | |
40 | - | |
41 | - <string name="text_button_save">保存</string> | |
42 | - <string name="text_button_update">編集</string> | |
43 | - <string name="text_button_delete">削除</string> | |
44 | - <string name="text_button_cancel">キャンセル</string> | |
45 | - | |
46 | - <string name="title_confirm_dialog">確認</string> | |
47 | - <string name="text_confirm_dialog_insert">以下のデータを登録します。よろしいですか?</string> | |
48 | - <string name="text_confirm_dialog_delete">以下のデータを削除します。よろしいですか?</string> | |
49 | - | |
50 | - <string name="text_complete_registration">登録が完了しました。</string> | |
51 | - <string name="text_registration_failed">同一日時のデータを重複して登録することはできません。</string> | |
52 | - | |
53 | - <string name="title_menu_graph">グラフ</string> | |
54 | - <string name="title_menu_list">リスト</string> | |
55 | - | |
56 | - <string name="message_0_quantity">給油量は0ℓより多くなければなりません。</string> | |
57 | - | |
58 | - <string name="message_no_data">データが登録されていません。</string> | |
59 | - | |
60 | - <string name="title_chart">燃費チェッカー</string> | |
61 | - <string name="key_fuel_efficiency">燃費(km/ℓ)</string> | |
62 | - | |
63 | - <string name="message_no_data">データがありません。</string> | |
64 | - | |
65 | - <string name="text_confirm_connect_market">この機能を使うにはChartExpertが必要です。</string> | |
66 | - <string name="text_button_connect">マーケットを開く</string> | |
67 | - | |
68 | - <string name="text_delete_complete">データを削除しました。</string> | |
69 | -</resources> |
@@ -1,7 +0,0 @@ | ||
1 | -<?xml version="1.0" encoding="utf-8"?> | |
2 | -<resources> | |
3 | - <string-array name="text_button_execute"> | |
4 | - <item>保存</item> | |
5 | - <item>変更</item> | |
6 | - </string-array> | |
7 | -</resources> |
@@ -1,7 +1,5 @@ | ||
1 | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | 2 | <resources> |
3 | 3 | <string-array name="text_button_execute"> |
4 | - <item>save</item> | |
5 | - <item>update</item> | |
6 | 4 | </string-array> |
7 | 5 | </resources> |
@@ -15,58 +15,57 @@ | ||
15 | 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | 16 | --> |
17 | 17 | <resources> |
18 | - <string name="app_name">Fuel Checker</string> | |
18 | + <string name="app_name">燃費チェッカー</string> | |
19 | 19 | |
20 | - <string name="title_date_and_time">Date and Time</string> | |
20 | + <string name="title_date_and_time">日時</string> | |
21 | 21 | |
22 | - <string name="title_date">Date</string> | |
23 | - <string name="summary_date">Please set a date that fueling.</string> | |
22 | + <string name="title_date">給油日</string> | |
23 | + <string name="summary_date">給油した日付を\nセットしてください。</string> | |
24 | 24 | |
25 | - <string name="title_time">Time</string> | |
26 | - <string name="summary_time">Please set a time that fueling.</string> | |
25 | + <string name="title_time">時間</string> | |
26 | + <string name="summary_time">給油した時間を\nセットしてください。</string> | |
27 | 27 | |
28 | - <string name="title_fuel_information">Fuel Information</string> | |
28 | + <string name="title_fuel_information">給油情報</string> | |
29 | 29 | |
30 | - <string name="title_quantity">Quantity</string> | |
31 | - <string name="summary_quantity">Please set a quantity of oil.</string> | |
32 | - <string name="unit_quantity">gal</string> | |
30 | + <string name="title_quantity">給油量</string> | |
31 | + <string name="summary_quantity">給油量をセットしてください。</string> | |
32 | + <string name="unit_quantity">ℓ</string> | |
33 | 33 | |
34 | - <string name="title_distance">Distance</string> | |
35 | - <string name="summary_distance">Please set a distance\n that your car ran\n duaring the previous fueling.</string> | |
36 | - <string name="unit_distance">mi</string> | |
34 | + <string name="title_distance">走行距離</string> | |
35 | + <string name="summary_distance">前回、給油してからの走行距離を\nセットしてください。</string> | |
36 | + <string name="unit_distance">km</string> | |
37 | 37 | |
38 | - <string name="title_efficiency">Fuel Efficiency</string> | |
39 | - <string name="unit_efficiency">mi/gal</string> | |
38 | + <string name="title_efficiency">燃費</string> | |
39 | + <string name="unit_efficiency">km/ℓ</string> | |
40 | 40 | |
41 | 41 | <string name="text_button_ok">OK</string> |
42 | 42 | |
43 | - <string name="text_button_save">Save</string> | |
44 | - <string name="text_button_update">Update</string> | |
45 | - <string name="text_button_delete">Delete</string> | |
46 | - <string name="text_button_cancel">Cancel</string> | |
43 | + <string name="text_button_save">保存</string> | |
44 | + <string name="text_button_update">編集</string> | |
45 | + <string name="text_button_delete">削除</string> | |
46 | + <string name="text_button_cancel">キャンセル</string> | |
47 | 47 | |
48 | - <string name="title_confirm_dialog">Confirm</string> | |
49 | - <string name="text_confirm_dialog_insert">Are you sure to register to below data?</string> | |
50 | - <string name="text_confirm_dialog_delete">Are you sure to delete to below data?</string> | |
51 | - <string name="text_confirm_dialog_body">\t%1$s\t=\t%2$s</string> | |
48 | + <string name="title_confirm_dialog">確認</string> | |
49 | + <string name="text_confirm_dialog_insert">以下のデータを登録します。よろしいですか?</string> | |
50 | + <string name="text_confirm_dialog_delete">以下のデータを削除します。よろしいですか?</string> | |
52 | 51 | |
53 | - <string name="text_complete_registration">Registration is complete.</string> | |
54 | - <string name="text_registration_failed">You cannot register the data at the same date and time.</string> | |
52 | + <string name="text_complete_registration">登録が完了しました。</string> | |
53 | + <string name="text_registration_failed">同一日時のデータを重複して登録することはできません。</string> | |
55 | 54 | |
56 | - <string name="title_menu_graph">Graph</string> | |
57 | - <string name="title_menu_list">List</string> | |
55 | + <string name="title_menu_graph">グラフ</string> | |
56 | + <string name="title_menu_list">リスト</string> | |
58 | 57 | |
58 | + <string name="message_0_quantity">給油量は0ℓより多くなければなりません。</string> | |
59 | 59 | |
60 | - <string name="message_0_quantity">Amount of oil must be greater than 0gal.</string> | |
61 | - <string name="message_no_data">No data registered.</string> | |
60 | + <string name="message_no_data">データが登録されていません。</string> | |
62 | 61 | |
63 | - <string name="title_chart">Fuel-Checker</string> | |
64 | - <string name="key_fuel_efficiency">Fuel efficiency(mi/gal)</string> | |
62 | + <string name="title_chart">燃費チェッカー</string> | |
63 | + <string name="key_fuel_efficiency">燃費(km/ℓ)</string> | |
65 | 64 | |
66 | - <string name="message_no_data">No data.</string> | |
65 | + <string name="message_no_data">データがありません。</string> | |
67 | 66 | |
68 | - <string name="text_confirm_connect_market">To use this feature, you must have ChartExpert.</string> | |
69 | - <string name="text_button_connect">Open Market</string> | |
67 | + <string name="text_confirm_connect_market">この機能を使うにはChartExpertが必要です。</string> | |
68 | + <string name="text_button_connect">マーケットを開く</string> | |
70 | 69 | |
71 | - <string name="text_delete_complete">Removed the data.</string> | |
70 | + <string name="text_delete_complete">データを削除しました。</string> | |
72 | 71 | </resources> |