1 |
|
package com.loopback.androidapps.saveapp; |
2 |
|
|
3 |
|
import android.app.Activity; |
4 |
|
import android.app.AlertDialog; |
5 |
|
import android.content.DialogInterface; |
6 |
|
import android.content.Intent; |
7 |
|
import android.os.Bundle; |
8 |
|
import android.util.Log; |
9 |
|
import android.view.View; |
10 |
|
import android.widget.Button; |
11 |
|
import android.widget.ImageButton; |
12 |
|
import android.widget.TextView; |
13 |
|
import android.widget.Toast; |
14 |
|
|
|
|
| 98,4% |
Uncovered Elements: 1 (64) |
Complexity: 10 |
Complexity Density: 0,2 |
|
15 |
|
public class AccountDetailActivity extends Activity implements |
16 |
|
View.OnClickListener { |
17 |
|
|
18 |
|
private TextView txtNameValue, txtPeriodValue, txtBudgetValue, |
19 |
|
txtStartDateValue, txtEndDateValue, txtCurrencyValue,txtAccountSelection; |
20 |
|
private Button btnEditAccount, btnNewAccount; |
21 |
|
private ImageButton btnAccountSelection; |
22 |
|
public boolean isEuropeanCalendar = true; |
23 |
|
public Account account; |
24 |
|
public Currency currency; |
25 |
|
|
26 |
|
private SaveApp saveApp; |
27 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0,25 |
|
28 |
3
|
public void onCreate(Bundle savedInstanceState) {... |
29 |
3
|
Log.i("AD", "Init"); |
30 |
3
|
super.onCreate(savedInstanceState); |
31 |
3
|
setContentView(R.layout.accountdetail); |
32 |
|
|
33 |
3
|
loadActivity(); |
34 |
|
} |
35 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 1 |
Complexity Density: 0,07 |
|
36 |
3
|
public void loadActivity() {... |
37 |
3
|
Log.i("AD", "Loading..."); |
38 |
3
|
saveApp = ((SaveApp)getApplicationContext()); |
39 |
|
|
40 |
3
|
txtNameValue = (TextView) findViewById(R.id.txtNameValue); |
41 |
3
|
txtBudgetValue = (TextView) findViewById(R.id.txtBudgetValue); |
42 |
3
|
txtPeriodValue = (TextView) findViewById(R.id.txtPeriodValue); |
43 |
3
|
txtStartDateValue = (TextView) findViewById(R.id.txtStartDateValue); |
44 |
3
|
txtEndDateValue = (TextView) findViewById(R.id.txtEndDateValue); |
45 |
3
|
txtCurrencyValue = (TextView) findViewById(R.id.txtCurrencyValue); |
46 |
3
|
txtAccountSelection= (TextView) findViewById(R.id.txtAccountSelection); |
47 |
3
|
btnNewAccount = (Button) findViewById(R.id.btnNewAccount); |
48 |
3
|
btnAccountSelection = (ImageButton) findViewById(R.id.btnAccountSelection); |
49 |
3
|
btnEditAccount = (Button) findViewById(R.id.btnEditAccount); |
50 |
|
|
51 |
3
|
btnNewAccount.setOnClickListener(this); |
52 |
3
|
btnAccountSelection.setOnClickListener(this); |
53 |
3
|
btnEditAccount.setOnClickListener(this); |
54 |
|
} |
55 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
56 |
3
|
public void onResume(){... |
57 |
3
|
super.onResume(); |
58 |
3
|
loadAccount(); |
59 |
|
} |
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 1 |
Complexity Density: 0,09 |
|
60 |
3
|
public void loadAccount(){... |
61 |
3
|
Log.i("AD", "Loading Account..."); |
62 |
3
|
account = new Account(saveApp.getAccountId()); |
63 |
3
|
txtAccountSelection.setText(getString(R.string.strAccount) |
64 |
|
+ ": " + saveApp.getAccountDesc()); |
65 |
3
|
txtNameValue.setText(saveApp.getAccountDesc()); |
66 |
3
|
txtBudgetValue.setText(String.valueOf(account.getBudget())); |
67 |
3
|
txtPeriodValue.setText(account.getPeriod()); |
68 |
3
|
txtStartDateValue.setText(account.getStartDate()); |
69 |
3
|
txtEndDateValue.setText(account.getEndDate()); |
70 |
|
|
71 |
3
|
currency= new Currency(saveApp.getCurrencyId()); |
72 |
3
|
txtCurrencyValue.setText(currency.getDescription() + ": "+ saveApp.getCurrencySymbol()); |
73 |
|
|
74 |
3
|
Log.i("AD", "Loaded"); |
75 |
|
} |
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
76 |
1
|
public void onBackPressed() {... |
77 |
1
|
Intent intent = new Intent(this.getApplicationContext(), |
78 |
|
HomeActivity.class); |
79 |
1
|
startActivity(intent); |
80 |
|
} |
|
|
| 95,5% |
Uncovered Elements: 1 (22) |
Complexity: 4 |
Complexity Density: 0,25 |
|
81 |
7
|
public void onClick(View v) {... |
82 |
7
|
if (v == btnEditAccount) { |
83 |
2
|
Log.i("AD", "Edit Account"); |
84 |
2
|
Intent intent = new Intent(this.getApplicationContext(), |
85 |
|
AccountEditActivity.class); |
86 |
2
|
startActivity(intent); |
87 |
5
|
} else if (v == btnAccountSelection) { |
88 |
1
|
final CharSequence[] accounts; |
89 |
1
|
Account account = new Account(); |
90 |
1
|
accounts = account.selectAccounts(); |
91 |
1
|
AlertDialog.Builder builder = new AlertDialog.Builder(this); |
92 |
1
|
builder.setTitle("Chooese Account"); |
93 |
1
|
builder.setItems(accounts, new DialogInterface.OnClickListener() { |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
94 |
1
|
public void onClick(DialogInterface dialog, int _item) {... |
95 |
1
|
saveApp.setAccountId(_item + 1); |
96 |
|
} |
97 |
|
}); |
98 |
1
|
AlertDialog dropdown = builder.create(); |
99 |
1
|
dropdown.show(); |
100 |
1
|
Toast.makeText(this, "More than one account is not allowed in this version", |
101 |
|
Toast.LENGTH_LONG).show(); |
102 |
4
|
} else if (v == btnNewAccount) { |
103 |
4
|
Toast.makeText(this, "More than one account is not allowed in this version", |
104 |
|
Toast.LENGTH_LONG).show(); |
105 |
|
} |
106 |
|
|
107 |
|
} |
108 |
|
|
109 |
|
} |
110 |
|
|