1 |
|
package com.loopback.androidapps.saveapp; |
2 |
|
|
3 |
|
import java.util.ArrayList; |
4 |
|
|
5 |
|
import android.app.ListActivity; |
6 |
|
import android.content.Context; |
7 |
|
import android.content.DialogInterface; |
8 |
|
import android.content.DialogInterface.OnClickListener; |
9 |
|
import android.content.Intent; |
10 |
|
import android.content.res.Configuration; |
11 |
|
import android.database.Cursor; |
12 |
|
import android.graphics.PixelFormat; |
13 |
|
import android.os.Bundle; |
14 |
|
import android.util.Log; |
15 |
|
import android.view.Display; |
16 |
|
import android.view.View; |
17 |
|
import android.view.WindowManager; |
18 |
|
import android.widget.ListAdapter; |
19 |
|
import android.widget.ListView; |
20 |
|
import android.widget.TextView; |
21 |
|
|
|
|
| 73,5% |
Uncovered Elements: 18 (68) |
Complexity: 12 |
Complexity Density: 0,21 |
|
22 |
|
public class OutlaysListActivity extends ListActivity implements |
23 |
|
OnClickListener { |
24 |
|
|
25 |
|
private DBManager dbManager; |
26 |
|
private ArrayList<Outlay> outlays = new ArrayList<Outlay>(); |
27 |
|
private ListAdapter listAdapter; |
28 |
|
|
29 |
|
private TextView txtAccount, footerDays, footerBudget; |
30 |
|
private boolean landscape = false; |
31 |
|
|
32 |
|
public SaveApp saveApp; |
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0,38 |
|
37 |
0
|
public void onConfigurationChanged(Configuration newConfig) {... |
38 |
0
|
super.onConfigurationChanged(newConfig); |
39 |
|
|
40 |
0
|
Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)) |
41 |
|
.getDefaultDisplay(); |
42 |
0
|
int orientation = display.getOrientation(); |
43 |
0
|
if (orientation == 1 || orientation == 3) { |
44 |
0
|
setContentView(R.layout.outlayslistland); |
45 |
0
|
landscape = true; |
46 |
|
} else |
47 |
0
|
setContentView(R.layout.outlayslist); |
48 |
|
|
49 |
0
|
loadActivity(); |
50 |
|
} |
51 |
|
|
|
|
| 75% |
Uncovered Elements: 3 (12) |
Complexity: 3 |
Complexity Density: 0,3 |
|
52 |
9
|
public void onCreate(Bundle savedInstanceState) {... |
53 |
9
|
super.onCreate(savedInstanceState); |
54 |
9
|
getWindow().setFormat(PixelFormat.RGBA_8888); |
55 |
9
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DITHER); |
56 |
9
|
Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)) |
57 |
|
.getDefaultDisplay(); |
58 |
9
|
int orientation = display.getOrientation(); |
59 |
9
|
if (orientation == 1 || orientation == 3) { |
60 |
0
|
setContentView(R.layout.outlayslistland); |
61 |
0
|
landscape = true; |
62 |
|
} else |
63 |
9
|
setContentView(R.layout.outlayslist); |
64 |
|
|
65 |
9
|
loadActivity(); |
66 |
|
} |
67 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (20) |
Complexity: 1 |
Complexity Density: 0,05 |
|
68 |
9
|
public void loadActivity() {... |
69 |
9
|
Log.i("OLA", "Loading..."); |
70 |
9
|
saveApp = ((SaveApp) getApplicationContext()); |
71 |
9
|
dbManager = saveApp.getDbManager(); |
72 |
|
|
73 |
9
|
txtAccount = (TextView) findViewById(R.id.txtAccount); |
74 |
9
|
txtAccount.setText(getString(R.string.strAccount) + ": " |
75 |
|
+ saveApp.getAccountDesc()); |
76 |
|
|
77 |
|
|
78 |
9
|
Log.i("OLA", "Reading..."); |
79 |
9
|
Cursor cursor = dbManager.select(-1, DBManager.OUTLAY_TABLE_ID); |
80 |
9
|
DBReader dbReader = new DBReader(); |
81 |
9
|
dbReader.readOutlay(cursor); |
82 |
9
|
outlays = dbReader.outlayList; |
83 |
|
|
84 |
|
|
85 |
9
|
Log.i("OLA", "Inflating..."); |
86 |
9
|
listAdapter = new OutlayAdapter(getApplicationContext(), outlays, |
87 |
|
landscape); |
88 |
9
|
this.setListAdapter(listAdapter); |
89 |
|
|
90 |
|
|
91 |
9
|
Log.i("OLA", "Setting Footer..."); |
92 |
9
|
footerBudget = (TextView) findViewById(R.id.txtFooterBudget); |
93 |
9
|
footerDays = (TextView) findViewById(R.id.txtFooterDays); |
94 |
9
|
footerDays.setText(String.valueOf(saveApp.getCurrentDays())); |
95 |
9
|
footerBudget.setText(saveApp.getCurrentBudget() |
96 |
|
+ saveApp.getCurrencySymbol()); |
97 |
9
|
sendTextToWidget(this); |
98 |
9
|
Log.i("OLA", "Set."); |
99 |
|
} |
100 |
|
|
101 |
|
|
102 |
|
|
103 |
|
|
104 |
|
|
105 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0,25 |
|
106 |
4
|
public void onBackPressed() {... |
107 |
4
|
Log.i("OLA", "Back Pressed..."); |
108 |
4
|
Intent intent = new Intent(this.getApplicationContext(), |
109 |
|
HomeActivity.class); |
110 |
4
|
Log.i("OLA", "Starting Activity Home"); |
111 |
4
|
startActivity(intent); |
112 |
|
} |
113 |
|
|
114 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0,11 |
|
115 |
5
|
public void onListItemClick(ListView parent, View v, int _position, long _id) {... |
116 |
5
|
Log.i("OLA", "ListItemClick"); |
117 |
5
|
int id = outlays.get(_position).getId(); |
118 |
|
|
119 |
5
|
Bundle bundle = new Bundle(); |
120 |
5
|
bundle.putInt("Id", id); |
121 |
|
|
122 |
5
|
Log.i("OLA", "ListItemClick"); |
123 |
|
|
124 |
5
|
Intent intent = new Intent(this.getApplicationContext(), |
125 |
|
OutlayDetailActivity.class); |
126 |
5
|
intent.putExtras(bundle); |
127 |
5
|
Log.i("OLA", "Starting Activity Outlay Detail"); |
128 |
5
|
startActivity(intent); |
129 |
|
|
130 |
|
} |
131 |
|
|
132 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
133 |
0
|
public void onClick(View v) {... |
134 |
0
|
Log.d("Selections:", "Click"); |
135 |
|
} |
136 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
137 |
0
|
public void onClick(DialogInterface dialog, int which) {... |
138 |
0
|
Log.d("Selections:", "Click"); |
139 |
|
|
140 |
|
} |
141 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0,33 |
|
142 |
9
|
private void sendTextToWidget(Context context) {... |
143 |
9
|
Intent uiIntent = new Intent(); |
144 |
9
|
uiIntent.putExtra(Constants.INTENT_EXTRA_WIDGET_TEXT,footerBudget.getText()); |
145 |
9
|
context.sendBroadcast(uiIntent); |
146 |
|
} |
147 |
|
|
148 |
|
} |