ApiDemos Clean up
- Add missing @Override - Remove (some) unused imports - Add some missing headers BUG: 2031807
This commit is contained in:
@@ -20,14 +20,11 @@ import android.appwidget.AppWidgetManager;
|
||||
import android.appwidget.AppWidgetProvider;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.SystemClock;
|
||||
import android.util.Log;
|
||||
import android.widget.RemoteViews;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
// Need the following import to get access to the app resources, since this
|
||||
// class is in a sub-package.
|
||||
import com.example.android.apis.R;
|
||||
@@ -51,6 +48,7 @@ public class ExampleAppWidgetProvider extends AppWidgetProvider {
|
||||
// log tag
|
||||
private static final String TAG = "ExampleAppWidgetProvider";
|
||||
|
||||
@Override
|
||||
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
|
||||
Log.d(TAG, "onUpdate");
|
||||
// For each widget that needs an update, get the text that we should display:
|
||||
@@ -65,6 +63,7 @@ public class ExampleAppWidgetProvider extends AppWidgetProvider {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeleted(Context context, int[] appWidgetIds) {
|
||||
Log.d(TAG, "onDeleted");
|
||||
// When the user deletes the widget, delete the preference associated with it.
|
||||
@@ -74,6 +73,7 @@ public class ExampleAppWidgetProvider extends AppWidgetProvider {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnabled(Context context) {
|
||||
Log.d(TAG, "onEnabled");
|
||||
// When the first widget is created, register for the TIMEZONE_CHANGED and TIME_CHANGED
|
||||
@@ -87,11 +87,11 @@ public class ExampleAppWidgetProvider extends AppWidgetProvider {
|
||||
PackageManager.DONT_KILL_APP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisabled(Context context) {
|
||||
// When the first widget is created, stop listening for the TIMEZONE_CHANGED and
|
||||
// TIME_CHANGED broadcasts.
|
||||
Log.d(TAG, "onDisabled");
|
||||
Class clazz = ExampleBroadcastReceiver.class;
|
||||
PackageManager pm = context.getPackageManager();
|
||||
pm.setComponentEnabledSetting(
|
||||
new ComponentName("com.example.android.apis", ".appwidget.ExampleBroadcastReceiver"),
|
||||
|
||||
@@ -17,21 +17,13 @@
|
||||
package com.example.android.apis.appwidget;
|
||||
|
||||
import android.appwidget.AppWidgetManager;
|
||||
import android.appwidget.AppWidgetProvider;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.SystemClock;
|
||||
import android.util.Log;
|
||||
import android.widget.RemoteViews;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
// Need the following import to get access to the app resources, since this
|
||||
// class is in a sub-package.
|
||||
import com.example.android.apis.R;
|
||||
|
||||
/**
|
||||
* A BroadcastReceiver that listens for updates for the ExampleAppWidgetProvider. This
|
||||
* BroadcastReceiver starts off disabled, and we only enable it when there is a widget
|
||||
@@ -39,6 +31,7 @@ import com.example.android.apis.R;
|
||||
*/
|
||||
public class ExampleBroadcastReceiver extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
Log.d("ExmampleBroadcastReceiver", "intent=" + intent);
|
||||
|
||||
@@ -48,8 +41,8 @@ public class ExampleBroadcastReceiver extends BroadcastReceiver {
|
||||
if (action.equals(Intent.ACTION_TIMEZONE_CHANGED)
|
||||
|| action.equals(Intent.ACTION_TIME_CHANGED)) {
|
||||
AppWidgetManager gm = AppWidgetManager.getInstance(context);
|
||||
ArrayList<Integer> appWidgetIds = new ArrayList();
|
||||
ArrayList<String> texts = new ArrayList();
|
||||
ArrayList<Integer> appWidgetIds = new ArrayList<Integer>();
|
||||
ArrayList<String> texts = new ArrayList<String>();
|
||||
|
||||
ExampleAppWidgetConfigure.loadAllTitlePrefs(context, appWidgetIds, texts);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user