Skip to content

Instantly share code, notes, and snippets.

@Teddy-Schmitz
Created June 18, 2013 07:04
Show Gist options
  • Save Teddy-Schmitz/5803234 to your computer and use it in GitHub Desktop.
Save Teddy-Schmitz/5803234 to your computer and use it in GitHub Desktop.
@Override
public void onDreamingStarted() {
super.onDreamingStarted();
galaxy = (ImageView) findViewById(R.id.galaxyView);
mHandler.postDelayed(pictureChange, PICTURE_CHANGE_TIME);
int rndInt = rand.nextInt(PICTURE_RAND_NUM);
int imgId = imageResIds[rndInt];
String imgName = Integer.toString(imgId);
galaxy.setImageDrawable(getResources().getDrawable(imgId));
}
private Runnable pictureChange = new Runnable() {
@Override
public void run() {
int rndInt = rand.nextInt(PICTURE_RAND_NUM) + 1;
int imgId = imageResIds[rndInt];
String imgName = Integer.toString(imgId);
Drawable[] ids = { galaxy.getDrawable(), getResources().getDrawable(imgId) };
TransitionDrawable mTransition = new TransitionDrawable(ids);
mTransition.setCrossFadeEnabled(true);
mTransition.startTransition(5000);
galaxy.setImageDrawable(mTransition);
mHandler.postDelayed(this, PICTURE_CHANGE_TIME);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment