summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRomain Guy <romainguy@android.com>2009-11-08 18:23:36 -0800
committerRomain Guy <romainguy@android.com>2009-11-08 18:25:13 -0800
commit860eccdfd57bc0bc762f3e45147dafc1dfdbb915 (patch)
tree4cc20333fcd6dd5377ecd6836061c2a21018fc78 /src
parent8cfd0d28d1cb57c98f83ad5da8cc77dbaca5914e (diff)
downloadandroid_packages_wallpapers_LivePicker-860eccdfd57bc0bc762f3e45147dafc1dfdbb915.zip
android_packages_wallpapers_LivePicker-860eccdfd57bc0bc762f3e45147dafc1dfdbb915.tar.gz
android_packages_wallpapers_LivePicker-860eccdfd57bc0bc762f3e45147dafc1dfdbb915.tar.bz2
Fix bug where the preview wasn't starting because using an unknown window token.
Diffstat (limited to 'src')
-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);
}