summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/Launcher.java
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2015-06-12 21:18:53 -0700
committerSunny Goyal <sunnygoyal@google.com>2015-06-16 10:31:43 -0700
commit383c507c47a5abf3258fc04220f37c366f983a97 (patch)
tree8cdd3e088ce1d185861666fcfbfa280a05dc50b8 /src/com/android/launcher3/Launcher.java
parentc332934e27527107c7f9c50ba6b7af93979b8126 (diff)
downloadandroid_packages_apps_Trebuchet-383c507c47a5abf3258fc04220f37c366f983a97.tar.gz
android_packages_apps_Trebuchet-383c507c47a5abf3258fc04220f37c366f983a97.tar.bz2
android_packages_apps_Trebuchet-383c507c47a5abf3258fc04220f37c366f983a97.zip
Removing ContentObserver in launcher
> Using callback insted of using a content observer > Setting the listener in LauncherAppState to prevent resource leak Change-Id: Id23a4d5c8812e86178997e536226e09ec3740f84
Diffstat (limited to 'src/com/android/launcher3/Launcher.java')
-rw-r--r--src/com/android/launcher3/Launcher.java38
1 files changed, 4 insertions, 34 deletions
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index ce0f304c1..9989abb6d 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -36,7 +36,6 @@ import android.content.ActivityNotFoundException;
import android.content.BroadcastReceiver;
import android.content.ComponentCallbacks2;
import android.content.ComponentName;
-import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
@@ -48,7 +47,6 @@ import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Configuration;
-import android.database.ContentObserver;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Bitmap;
import android.graphics.Canvas;
@@ -241,7 +239,6 @@ public class Launcher extends Activity
private final BroadcastReceiver mCloseSystemDialogsReceiver
= new CloseSystemDialogsIntentReceiver();
- private final ContentObserver mWidgetObserver = new AppWidgetResetObserver();
private LayoutInflater mInflater;
@@ -438,7 +435,6 @@ public class Launcher extends Activity
LauncherAppState.setApplicationContext(getApplicationContext());
LauncherAppState app = LauncherAppState.getInstance();
- LauncherAppState.getLauncherProvider().setLauncherProviderChangeListener(this);
// Load configuration-specific DeviceProfile
mDeviceProfile = getResources().getConfiguration().orientation
@@ -478,8 +474,6 @@ public class Launcher extends Activity
setupViews();
mDeviceProfile.layout(this);
- registerContentObservers();
-
lockAllApps();
mSavedState = savedInstanceState;
@@ -2017,7 +2011,6 @@ public class Launcher extends Activity
TextKeyListener.getInstance().release();
- getContentResolver().unregisterContentObserver(mWidgetObserver);
unregisterReceiver(mCloseSystemDialogsReceiver);
mDragLayer.clearAllResizeFrames();
@@ -2386,16 +2379,6 @@ public class Launcher extends Activity
sFolders.remove(folder.id);
}
- /**
- * Registers various content observers. The current implementation registers
- * only a favorites observer to keep track of the favorites applications.
- */
- private void registerContentObservers() {
- ContentResolver resolver = getContentResolver();
- resolver.registerContentObserver(LauncherProvider.CONTENT_APPWIDGET_RESET_URI,
- true, mWidgetObserver);
- }
-
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN) {
@@ -2452,9 +2435,10 @@ public class Launcher extends Activity
}
/**
- * Re-listen when widgets are reset.
+ * Re-listen when widget host is reset.
*/
- @Thunk void onAppWidgetReset() {
+ @Override
+ public void onAppWidgetHostReset() {
if (mAppWidgetHost != null) {
mAppWidgetHost.startListening();
}
@@ -2939,7 +2923,7 @@ public class Launcher extends Activity
return false;
}
- private boolean startActivitySafely(View v, Intent intent, Object tag) {
+ @Thunk boolean startActivitySafely(View v, Intent intent, Object tag) {
boolean success = false;
if (mIsSafeModeEnabled && !Utilities.isSystemApp(this, intent)) {
Toast.makeText(this, R.string.safemode_shortcut_error, Toast.LENGTH_SHORT).show();
@@ -3562,20 +3546,6 @@ public class Launcher extends Activity
}
/**
- * Receives notifications whenever the appwidgets are reset.
- */
- private class AppWidgetResetObserver extends ContentObserver {
- public AppWidgetResetObserver() {
- super(new Handler());
- }
-
- @Override
- public void onChange(boolean selfChange) {
- onAppWidgetReset();
- }
- }
-
- /**
* If the activity is currently paused, signal that we need to run the passed Runnable
* in onResume.
*