summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomain Guy <romainguy@android.com>2009-11-09 13:46:55 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2009-11-09 13:46:55 -0800
commitfddfe189604108b8874be907fd37e60aaf69d635 (patch)
tree96d7b7b71eed2102914dcf2e12c70c7a2fff0553
parent1bdf0bad71ee978dd10c34df9fcde3de650e6eff (diff)
parent0f88b598f4dbfa8cd90db78aff555b35e440b0cd (diff)
downloadandroid_packages_wallpapers_LivePicker-fddfe189604108b8874be907fd37e60aaf69d635.tar.gz
android_packages_wallpapers_LivePicker-fddfe189604108b8874be907fd37e60aaf69d635.tar.bz2
android_packages_wallpapers_LivePicker-fddfe189604108b8874be907fd37e60aaf69d635.zip
am 0f88b598: am 860eccdf: Fix bug where the preview wasn\'t starting because using an unknown window token.
Merge commit '0f88b598f4dbfa8cd90db78aff555b35e440b0cd' * commit '0f88b598f4dbfa8cd90db78aff555b35e440b0cd': Fix bug where the preview wasn't starting because using an unknown window token.
-rw-r--r--src/com/android/wallpaper/livepicker/LiveWallpaperPreview.java24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/com/android/wallpaper/livepicker/LiveWallpaperPreview.java b/src/com/android/wallpaper/livepicker/LiveWallpaperPreview.java
index 374f5ec..7cd446f 100644
--- a/src/com/android/wallpaper/livepicker/LiveWallpaperPreview.java
+++ b/src/com/android/wallpaper/livepicker/LiveWallpaperPreview.java
@@ -48,6 +48,7 @@ public class LiveWallpaperPreview extends Activity {
private String mSettings;
private String mPackageName;
private Intent mWallpaperIntent;
+ private View mView;
static void showPreview(Activity activity, int code, Intent intent, WallpaperInfo info) {
Intent preview = new Intent(activity, LiveWallpaperPreview.class);
@@ -69,19 +70,17 @@ public class LiveWallpaperPreview extends Activity {
}
setContentView(R.layout.live_wallpaper_preview);
+ mView = findViewById(R.id.configure);
mSettings = extras.getString(EXTRA_LIVE_WALLPAPER_SETTINGS);
mPackageName = extras.getString(EXTRA_LIVE_WALLPAPER_PACKAGE);
if (mSettings == null) {
- findViewById(R.id.configure).setVisibility(View.GONE);
+ mView.setVisibility(View.GONE);
}
mWallpaperManager = WallpaperManager.getInstance(this);
- WallpaperConnection connection = new WallpaperConnection(mWallpaperIntent);
- if (connection.connect()) {
- mWallpaperConnection = connection;
- }
+ mWallpaperConnection = new WallpaperConnection(mWallpaperIntent);
}
public void setLiveWallpaper(View v) {
@@ -129,7 +128,15 @@ public class LiveWallpaperPreview extends Activity {
}
}
}
-
+
+ @Override
+ public void onAttachedToWindow() {
+ super.onAttachedToWindow();
+ if (!mWallpaperConnection.connect()) {
+ mWallpaperConnection = null;
+ }
+ }
+
@Override
public void onDetachedFromWindow() {
super.onDetachedFromWindow();
@@ -180,10 +187,11 @@ public class LiveWallpaperPreview extends Activity {
if (mWallpaperConnection == this) {
mService = IWallpaperService.Stub.asInterface(service);
try {
- final View view = getWindow().getDecorView().getRootView();
+ final View view = mView;
+ final View root = view.getRootView();
mService.attach(this, view.getWindowToken(),
WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA,
- true, view.getWidth(), view.getHeight());
+ true, root.getWidth(), view.getHeight());
} catch (RemoteException e) {
Log.w(LOG_TAG, "Failed attaching wallpaper; clearing", e);
}