rewrite
This commit is contained in:
parent
19d785d1e9
commit
c1e6416c93
1 changed files with 25 additions and 15 deletions
|
@ -40,12 +40,14 @@ public class EasterDream extends DreamService {
|
|||
private SharedPreferences prefs;
|
||||
|
||||
private Drawable wallPaperDrawable = null;
|
||||
private FrameLayout last = null;
|
||||
private FrameLayout rootLayout = null;
|
||||
private FrameLayout lastDreamLayout = null;
|
||||
private boolean enabled = false;
|
||||
public void refresh() {
|
||||
final ImageView mLogo;
|
||||
final BubblesDrawable mBg;
|
||||
final FrameLayout layout = new FrameLayout(this);
|
||||
final FrameLayout dreamLayout = new FrameLayout(this);
|
||||
dreamLayout.setVisibility(View.GONE);
|
||||
|
||||
final DisplayMetrics dm = getResources().getDisplayMetrics();
|
||||
final float dp = dm.density;
|
||||
|
@ -58,7 +60,7 @@ public class EasterDream extends DreamService {
|
|||
mLogo = new ImageView(this);
|
||||
mLogo.setVisibility(View.GONE);
|
||||
mLogo.setImageResource(R.drawable.t_platlogo);
|
||||
layout.addView(mLogo, lp);
|
||||
dreamLayout.addView(mLogo, lp);
|
||||
|
||||
mBg = new BubblesDrawable(this);
|
||||
mBg.setLevel(0);
|
||||
|
@ -66,37 +68,41 @@ public class EasterDream extends DreamService {
|
|||
mBg.padding = 0.5f * dp;
|
||||
mBg.minR = 1 * dp;
|
||||
if (wallPaperDrawable != null) {
|
||||
layout.setBackground(new LayerDrawable(new Drawable[]{wallPaperDrawable, mBg}));
|
||||
dreamLayout.setBackground(new LayerDrawable(new Drawable[]{wallPaperDrawable, mBg}));
|
||||
}
|
||||
else {
|
||||
layout.setBackground(mBg);
|
||||
dreamLayout.setBackground(mBg);
|
||||
}
|
||||
|
||||
mBg.chooseEmojiSet();
|
||||
mLogo.setVisibility(View.VISIBLE);
|
||||
mBg.setLevel(10000);
|
||||
|
||||
if (last == null) setContentView(layout);
|
||||
|
||||
if (lastDreamLayout == null) {
|
||||
dreamLayout.setVisibility(View.VISIBLE);
|
||||
rootLayout.addView(dreamLayout);
|
||||
}
|
||||
else {
|
||||
layout.setAlpha(0f);
|
||||
layout.setVisibility(View.VISIBLE);
|
||||
addContentView(layout, new ViewGroup.LayoutParams(last.getWidth(), last.getHeight()));
|
||||
dreamLayout.setAlpha(0f);
|
||||
dreamLayout.setVisibility(View.VISIBLE);
|
||||
rootLayout.addView(dreamLayout);
|
||||
int animDuration = getResources().getInteger(android.R.integer.config_longAnimTime);
|
||||
animDuration = Math.max(animDuration, 1500);
|
||||
layout.animate().alpha(1f).setDuration(animDuration).setListener(null);
|
||||
last.animate()
|
||||
dreamLayout.animate().alpha(1f).setDuration(animDuration).setListener(null);
|
||||
final FrameLayout lastDreamLayoutFinal = lastDreamLayout;
|
||||
lastDreamLayoutFinal.animate()
|
||||
.alpha(0f)
|
||||
.setDuration(animDuration)
|
||||
.setListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
last.setVisibility(View.GONE);
|
||||
setContentView(layout);
|
||||
layout.setVisibility(View.VISIBLE);
|
||||
lastDreamLayoutFinal.setVisibility(View.GONE);
|
||||
rootLayout.removeView(lastDreamLayoutFinal);
|
||||
}
|
||||
});
|
||||
}
|
||||
last = layout;
|
||||
lastDreamLayout = dreamLayout;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -124,6 +130,10 @@ public class EasterDream extends DreamService {
|
|||
wallPaperDrawable = wallPaperManager.getDrawable();
|
||||
}
|
||||
}
|
||||
|
||||
rootLayout = new FrameLayout(this);
|
||||
setContentView(rootLayout);
|
||||
|
||||
refresh();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue