質問編集履歴
3
radioGroup.getCheckedRadioButtonId()をif文の処理に変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -165,13 +165,12 @@
|
|
165
165
|
String productName = enterProductName.getText().toString();
|
166
166
|
String productType = enterProductType.getText().toString();
|
167
167
|
price = Double.parseDouble(enterPrice.getText().toString());
|
168
|
-
|
168
|
+
if (radioGroup.getCheckedRadioButtonId() == R.id.spd_no) {
|
169
|
-
case R.id.spd_no:
|
170
|
-
|
169
|
+
vatRate = 0.0;
|
171
|
-
|
170
|
+
} else {
|
172
|
-
|
171
|
+
spdBool = true;
|
173
|
-
|
172
|
+
vatRate = Double.parseDouble(enterVatRate.getText().toString());
|
174
|
-
|
173
|
+
price = price * vatRate;
|
175
174
|
}
|
176
175
|
String notes = enterNotes.getText().toString();
|
177
176
|
BudgetTrackerSpending budgetTrackerSpending = new BudgetTrackerSpending(date, storeName, productName, productType, price, spdBool, vatRate, notes);
|
2
saveButton.setOnClickListenerの処理をgetCheckedRadioButtonIdに変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -65,7 +65,7 @@
|
|
65
65
|
private static final String PREF_CURRENCY_FILENAME = "CURRENCY_SHARED";
|
66
66
|
private static final String PREF_CURRENCY_VALUE = "currencyValue";
|
67
67
|
BudgetTrackerSpendingViewModel budgetTrackerSpendingViewModel;
|
68
|
-
boolean spdBool;
|
68
|
+
boolean spdBool = false;
|
69
69
|
Double vatRate;
|
70
70
|
Double price;
|
71
71
|
|
@@ -157,51 +157,28 @@
|
|
157
157
|
|
158
158
|
budgetTrackerSpendingViewModel = new ViewModelProvider(requireActivity()).get(BudgetTrackerSpendingViewModel.class);
|
159
159
|
|
160
|
-
|
160
|
+
saveButton.setOnClickListener(new View.OnClickListener() {
|
161
161
|
@Override
|
162
|
-
public void onC
|
162
|
+
public void onClick(View view) {
|
163
|
+
String date = enterDate.getText().toString();
|
164
|
+
String storeName = enterStoreName.getText().toString();
|
165
|
+
String productName = enterProductName.getText().toString();
|
166
|
+
String productType = enterProductType.getText().toString();
|
167
|
+
price = Double.parseDouble(enterPrice.getText().toString());
|
163
|
-
switch (
|
168
|
+
switch (radioGroup.getCheckedRadioButtonId()) {
|
164
169
|
case R.id.spd_no:
|
165
|
-
saveButton.setOnClickListener(new View.OnClickListener() {
|
166
|
-
@Override
|
167
|
-
public void onClick(View view) {
|
168
|
-
String date = enterDate.getText().toString();
|
169
|
-
String storeName = enterStoreName.getText().toString();
|
170
|
-
String productName = enterProductName.getText().toString();
|
171
|
-
String productType = enterProductType.getText().toString();
|
172
|
-
price = Double.parseDouble(enterPrice.getText().toString());
|
173
|
-
spdBool = false;
|
174
|
-
|
170
|
+
vatRate = 0.0;
|
175
|
-
String notes = enterNotes.getText().toString();
|
176
|
-
BudgetTrackerSpending budgetTrackerSpending = new BudgetTrackerSpending(date, storeName, productName, productType, price, spdBool, vatRate, notes);
|
177
|
-
budgetTrackerSpendingViewModel.insert(budgetTrackerSpending);
|
178
|
-
getActivity().finish();
|
179
|
-
}
|
180
|
-
});
|
181
|
-
break;
|
182
171
|
case R.id.spd_yes:
|
183
|
-
saveButton.setOnClickListener(new View.OnClickListener() {
|
184
|
-
@Override
|
185
|
-
public void onClick(View view) {
|
186
|
-
String date = enterDate.getText().toString();
|
187
|
-
String storeName = enterStoreName.getText().toString();
|
188
|
-
String productName = enterProductName.getText().toString();
|
189
|
-
String productType = enterProductType.getText().toString();
|
190
|
-
price = Double.parseDouble(enterPrice.getText().toString());
|
191
|
-
|
172
|
+
spdBool = true;
|
192
|
-
|
173
|
+
vatRate = Double.parseDouble(enterVatRate.getText().toString());
|
193
|
-
|
174
|
+
price = price * vatRate;
|
194
|
-
String notes = enterNotes.getText().toString();
|
195
|
-
BudgetTrackerSpending budgetTrackerSpending = new BudgetTrackerSpending(date, storeName, productName, productType, price, spdBool, vatRate, notes);
|
196
|
-
budgetTrackerSpendingViewModel.insert(budgetTrackerSpending);
|
197
|
-
getActivity().finish();
|
198
|
-
}
|
199
|
-
});
|
200
|
-
break;
|
201
175
|
}
|
176
|
+
String notes = enterNotes.getText().toString();
|
177
|
+
BudgetTrackerSpending budgetTrackerSpending = new BudgetTrackerSpending(date, storeName, productName, productType, price, spdBool, vatRate, notes);
|
178
|
+
budgetTrackerSpendingViewModel.insert(budgetTrackerSpending);
|
179
|
+
getActivity().finish();
|
202
180
|
}
|
203
181
|
});
|
204
|
-
|
205
182
|
|
206
183
|
|
207
184
|
return view;
|
1
radioGroupの中身のメソッドを変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -157,39 +157,53 @@
|
|
157
157
|
|
158
158
|
budgetTrackerSpendingViewModel = new ViewModelProvider(requireActivity()).get(BudgetTrackerSpendingViewModel.class);
|
159
159
|
|
160
|
-
|
160
|
+
radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
|
161
161
|
@Override
|
162
|
+
public void onCheckedChanged(RadioGroup radioGroup, int checkId) {
|
163
|
+
switch (checkId) {
|
164
|
+
case R.id.spd_no:
|
165
|
+
saveButton.setOnClickListener(new View.OnClickListener() {
|
166
|
+
@Override
|
162
|
-
public void onClick(View view) {
|
167
|
+
public void onClick(View view) {
|
163
|
-
String date = enterDate.getText().toString();
|
168
|
+
String date = enterDate.getText().toString();
|
164
|
-
String storeName = enterStoreName.getText().toString();
|
169
|
+
String storeName = enterStoreName.getText().toString();
|
165
|
-
String productName = enterProductName.getText().toString();
|
170
|
+
String productName = enterProductName.getText().toString();
|
166
|
-
String productType = enterProductType.getText().toString();
|
171
|
+
String productType = enterProductType.getText().toString();
|
167
|
-
price = Double.parseDouble(enterPrice.getText().toString());
|
172
|
+
price = Double.parseDouble(enterPrice.getText().toString());
|
168
|
-
|
169
|
-
radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
|
170
|
-
@Override
|
171
|
-
public void onCheckedChanged(RadioGroup radioGroup, int checkId) {
|
172
|
-
switch (checkId) {
|
173
|
-
case R.id.spd_no:
|
174
173
|
spdBool = false;
|
175
174
|
vatRate = 0.0;
|
175
|
+
String notes = enterNotes.getText().toString();
|
176
|
+
BudgetTrackerSpending budgetTrackerSpending = new BudgetTrackerSpending(date, storeName, productName, productType, price, spdBool, vatRate, notes);
|
177
|
+
budgetTrackerSpendingViewModel.insert(budgetTrackerSpending);
|
178
|
+
getActivity().finish();
|
179
|
+
}
|
180
|
+
});
|
176
|
-
|
181
|
+
break;
|
177
|
-
|
182
|
+
case R.id.spd_yes:
|
183
|
+
saveButton.setOnClickListener(new View.OnClickListener() {
|
184
|
+
@Override
|
185
|
+
public void onClick(View view) {
|
186
|
+
String date = enterDate.getText().toString();
|
187
|
+
String storeName = enterStoreName.getText().toString();
|
188
|
+
String productName = enterProductName.getText().toString();
|
189
|
+
String productType = enterProductType.getText().toString();
|
190
|
+
price = Double.parseDouble(enterPrice.getText().toString());
|
178
191
|
spdBool = true;
|
179
192
|
vatRate = Double.parseDouble(enterVatRate.getText().toString());
|
180
193
|
price = price * vatRate;
|
194
|
+
String notes = enterNotes.getText().toString();
|
195
|
+
BudgetTrackerSpending budgetTrackerSpending = new BudgetTrackerSpending(date, storeName, productName, productType, price, spdBool, vatRate, notes);
|
196
|
+
budgetTrackerSpendingViewModel.insert(budgetTrackerSpending);
|
197
|
+
getActivity().finish();
|
198
|
+
}
|
199
|
+
});
|
181
|
-
|
200
|
+
break;
|
182
|
-
|
201
|
+
}
|
183
|
-
}
|
184
|
-
});
|
185
|
-
|
186
|
-
String notes = enterNotes.getText().toString();
|
187
|
-
|
188
|
-
BudgetTrackerSpending budgetTrackerSpending = new BudgetTrackerSpending(date, storeName, productName, productType, price, spdBool, vatRate, notes);
|
189
|
-
budgetTrackerSpendingViewModel.insert(budgetTrackerSpending);
|
190
202
|
}
|
191
203
|
});
|
192
204
|
|
205
|
+
|
206
|
+
|
193
207
|
return view;
|
194
208
|
}
|
195
209
|
}
|