1 |
|
package com.loopback.androidapps.saveapp; |
2 |
|
|
3 |
|
import android.app.PendingIntent; |
4 |
|
import android.appwidget.AppWidgetManager; |
5 |
|
import android.appwidget.AppWidgetProvider; |
6 |
|
import android.content.Context; |
7 |
|
import android.content.Intent; |
8 |
|
import android.util.Log; |
9 |
|
import android.widget.RemoteViews; |
10 |
|
import android.widget.Toast; |
11 |
|
|
|
|
| 0% |
Uncovered Elements: 36 (36) |
Complexity: 9 |
Complexity Density: 0,38 |
|
12 |
|
public class WidgetSaveApp extends AppWidgetProvider { |
13 |
|
|
14 |
|
public DBManager dbManager; |
15 |
|
public SaveApp saveApp; |
16 |
|
String account; |
17 |
|
RemoteViews views; |
18 |
|
public static String ACTION_WIDGET_CONFIGURE = "ConfigureWidget"; |
19 |
|
public static String ACTION_WIDGET_RECEIVER = "ActionReceiverWidget"; |
20 |
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 2 |
Complexity Density: 0,18 |
|
21 |
0
|
public void onUpdate(Context context, AppWidgetManager appWidgetManager,... |
22 |
|
int[] appWidgetIds) { |
23 |
0
|
final int N = appWidgetIds.length; |
24 |
|
|
25 |
|
|
26 |
|
|
27 |
0
|
for (int i = 0; i < N; i++) { |
28 |
0
|
int appWidgetId = appWidgetIds[i]; |
29 |
|
|
30 |
|
|
31 |
0
|
Intent intent = new Intent(context, WidgetSaveApp.class); |
32 |
0
|
intent.setAction(ACTION_WIDGET_RECEIVER); |
33 |
0
|
intent.putExtra("msg", "New Movement Added"); |
34 |
0
|
PendingIntent actionPendingIntent = PendingIntent.getBroadcast( |
35 |
|
context, 0, intent, 0); |
36 |
|
|
37 |
|
|
38 |
|
|
39 |
0
|
views = new RemoteViews(context.getPackageName(), R.layout.widget); |
40 |
0
|
views.setOnClickPendingIntent(R.id.btnWidget, actionPendingIntent); |
41 |
|
|
42 |
|
|
43 |
|
|
44 |
0
|
Log.d("WUP", "Painting..." + String.valueOf(i)); |
45 |
0
|
appWidgetManager.updateAppWidget(appWidgetId, views); |
46 |
|
} |
47 |
|
} |
48 |
|
|
|
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 5 |
Complexity Density: 0,42 |
|
49 |
0
|
public void onReceive(Context context, Intent intent) {... |
50 |
|
|
51 |
0
|
final String action = intent.getAction(); |
52 |
0
|
if (AppWidgetManager.ACTION_APPWIDGET_DELETED.equals(action)) { |
53 |
0
|
final int appWidgetId = intent.getExtras().getInt( |
54 |
|
AppWidgetManager.EXTRA_APPWIDGET_ID, |
55 |
|
AppWidgetManager.INVALID_APPWIDGET_ID); |
56 |
0
|
if (appWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID) { |
57 |
0
|
this.onDeleted(context, new int[] { appWidgetId }); |
58 |
|
} |
59 |
|
} else { |
60 |
|
|
61 |
0
|
if (intent.getAction().equals(ACTION_WIDGET_RECEIVER)) { |
62 |
0
|
String msg = "null"; |
63 |
0
|
try { |
64 |
0
|
msg = intent.getStringExtra("msg"); |
65 |
|
} catch (NullPointerException e) { |
66 |
0
|
Log.e("Error", "msg = null"); |
67 |
|
} |
68 |
0
|
Toast.makeText(context, msg + account, Toast.LENGTH_SHORT).show(); |
69 |
|
} |
70 |
|
|
71 |
0
|
super.onReceive(context, intent); |
72 |
|
} |
73 |
|
} |
74 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
75 |
0
|
public void onEnabled(Context context) {... |
76 |
0
|
dbManager.open(); |
77 |
|
} |
78 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
79 |
0
|
public void onDisable(Context context) {... |
80 |
|
|
81 |
|
} |
82 |
|
|
83 |
|
} |