1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package com.sweetiepiggy.raspberrybusmalaysia; |
21 |
|
|
22 |
|
import android.app.Activity; |
23 |
|
import android.content.Intent; |
24 |
|
import android.content.res.Configuration; |
25 |
|
import android.database.sqlite.SQLiteException; |
26 |
|
import android.net.Uri; |
27 |
|
import android.os.Bundle; |
28 |
|
import android.view.Menu; |
29 |
|
import android.view.MenuInflater; |
30 |
|
import android.view.MenuItem; |
31 |
|
import android.view.View; |
32 |
|
import android.widget.TextView; |
33 |
|
|
|
|
| 95,1% |
Uncovered Elements: 3 (61) |
Complexity: 13 |
Complexity Density: 0,25 |
|
34 |
|
public class RaspberryBusMalaysiaActivity extends Activity |
35 |
|
{ |
36 |
|
private static final String SOURCE_URL = "https://github.com/sweetiepiggy/Raspberry-Bus-Malaysia"; |
37 |
|
|
38 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0,29 |
|
39 |
1
|
@Override... |
40 |
|
public void onCreate(Bundle savedInstanceState) |
41 |
|
{ |
42 |
1
|
super.onCreate(savedInstanceState); |
43 |
|
|
44 |
1
|
init(); |
45 |
1
|
try { |
46 |
|
|
47 |
1
|
DbAdapter dbHelper = new DbAdapter(); |
48 |
1
|
dbHelper.open_readwrite(this); |
49 |
1
|
dbHelper.check_last_update_and_sync(); |
50 |
1
|
dbHelper.close(); |
51 |
|
} catch (SQLiteException e) { |
52 |
|
} |
53 |
|
} |
54 |
|
|
|
|
| 91,7% |
Uncovered Elements: 1 (12) |
Complexity: 2 |
Complexity Density: 0,2 |
|
55 |
1
|
public void init()... |
56 |
|
{ |
57 |
1
|
int content_view = getResources().getConfiguration().orientation == |
58 |
|
Configuration.ORIENTATION_LANDSCAPE ? |
59 |
|
R.layout.main_landscape : R.layout.main; |
60 |
1
|
setContentView(content_view); |
61 |
|
|
62 |
1
|
TextView route = (TextView) findViewById(R.id.route); |
63 |
1
|
route.setOnClickListener(new View.OnClickListener() { |
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
64 |
1
|
public void onClick(View v)... |
65 |
|
{ |
66 |
1
|
Intent intent = new Intent(getApplicationContext(), RouteActivity.class); |
67 |
1
|
startActivity(intent); |
68 |
|
} |
69 |
|
}); |
70 |
|
|
71 |
1
|
TextView submit_trip = (TextView) findViewById(R.id.submit_trip); |
72 |
1
|
submit_trip.setOnClickListener(new View.OnClickListener() { |
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
73 |
1
|
public void onClick(View v)... |
74 |
|
{ |
75 |
1
|
Intent intent = new Intent(getApplicationContext(), SubmitTripActivity.class); |
76 |
1
|
startActivity(intent); |
77 |
|
} |
78 |
|
}); |
79 |
|
|
80 |
1
|
TextView map = (TextView) findViewById(R.id.map); |
81 |
1
|
map.setOnClickListener(new View.OnClickListener() { |
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
|
82 |
1
|
public void onClick(View v)... |
83 |
|
{ |
84 |
1
|
Intent intent = new Intent(getApplicationContext(), RbmMapActivity.class); |
85 |
1
|
Bundle b = new Bundle(); |
86 |
1
|
b.putBoolean("draw_routes", true); |
87 |
1
|
intent.putExtras(b); |
88 |
1
|
startActivity(intent); |
89 |
|
} |
90 |
|
}); |
91 |
|
|
92 |
1
|
TextView complain = (TextView) findViewById(R.id.complain); |
93 |
1
|
complain.setOnClickListener(new View.OnClickListener() { |
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
94 |
1
|
public void onClick(View v)... |
95 |
|
{ |
96 |
1
|
Intent intent = new Intent(getApplicationContext(), ComplainActivity.class); |
97 |
1
|
startActivity(intent); |
98 |
|
} |
99 |
|
}); |
100 |
|
} |
101 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0,33 |
|
102 |
1
|
@Override... |
103 |
|
public boolean onCreateOptionsMenu(Menu menu) { |
104 |
1
|
MenuInflater inflater = getMenuInflater(); |
105 |
1
|
inflater.inflate(R.menu.options_menu, menu); |
106 |
1
|
return true; |
107 |
|
} |
108 |
|
|
|
|
| 90% |
Uncovered Elements: 2 (20) |
Complexity: 4 |
Complexity Density: 0,2 |
|
109 |
3
|
@Override... |
110 |
|
public boolean onOptionsItemSelected(MenuItem item) { |
111 |
3
|
Intent intent; |
112 |
3
|
switch (item.getItemId()) { |
113 |
1
|
case R.id.about: |
114 |
1
|
intent = new Intent(getApplicationContext(), TextViewActivity.class); |
115 |
1
|
Bundle b = new Bundle(); |
116 |
1
|
b.putString("text", getResources().getString(R.string.license)); |
117 |
1
|
intent.putExtras(b); |
118 |
1
|
startActivity(intent); |
119 |
1
|
return true; |
120 |
1
|
case R.id.sync: |
121 |
1
|
SyncTask sync = new SyncTask(this); |
122 |
1
|
sync.execute(); |
123 |
1
|
return true; |
124 |
1
|
case R.id.source: |
125 |
1
|
intent = new Intent(Intent.ACTION_VIEW); |
126 |
1
|
intent.setDataAndType(Uri.parse(SOURCE_URL), "text/html"); |
127 |
1
|
startActivity(Intent.createChooser(intent, null)); |
128 |
1
|
return true; |
129 |
0
|
default: |
130 |
0
|
return super.onOptionsItemSelected(item); |
131 |
|
} |
132 |
|
} |
133 |
|
} |
134 |
|
|