/** * Persist worker Thread across orientation changes. * * <p>Includes Thread bookkeeping to prevent not leaking Views on orientation changes. */ @Override public Object onRetainNonConfigurationInstance() { if (upgradeTask != null) { upgradeTask.setActivity(null); } return upgradeTask; }
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.home_screen); Object retained = getLastNonConfigurationInstance(); if (retained instanceof UpgradeTask) { Logging.Log(LOG_TAG, "UpgradeTask retained"); upgradeTask = (UpgradeTask) retained; upgradeTask.setActivity(this); } else { // upgradeTask = new UpgradeTask(this); } int[] gradientColors = {0, 0xFF127DD4, 0}; int curOrientation = this.getResources().getConfiguration().orientation; // FIXME separator1 = (ImageView) findViewById(R.id.separator1); separator1.setBackgroundDrawable( new GradientDrawable( curOrientation == Configuration.ORIENTATION_PORTRAIT ? Orientation.RIGHT_LEFT : Orientation.RIGHT_LEFT, gradientColors)); // separator1.setBackground(new GradientDrawable(Orientation.RIGHT_LEFT, gradientColors)); separator2 = (ImageView) findViewById(R.id.separator2); separator2.setBackgroundDrawable( new GradientDrawable( curOrientation == Configuration.ORIENTATION_PORTRAIT ? Orientation.RIGHT_LEFT : Orientation.TOP_BOTTOM, gradientColors)); // separator2.setBackground(new GradientDrawable(Orientation.RIGHT_LEFT, gradientColors)); separator3 = (ImageView) findViewById(R.id.separator3); separator3.setBackgroundDrawable( new GradientDrawable( curOrientation == Configuration.ORIENTATION_PORTRAIT ? Orientation.TOP_BOTTOM : Orientation.TOP_BOTTOM, gradientColors)); // separator3.setBackground(new GradientDrawable(Orientation.TOP_BOTTOM, gradientColors)); searchButton = (ImageButton) findViewById(R.id.HomeSearch); recentButton = (ImageButton) findViewById(R.id.HomeRecent); downloadButton = (ImageButton) findViewById(R.id.HomeDownload); playingButton = (ImageButton) findViewById(R.id.HomePlaying); featuredShowsButton = (ImageButton) findViewById(R.id.HomeFeatured); browseArtistsButton = (ImageButton) findViewById(R.id.HomeBrowse); db = StaticDataStore.getInstance(this); // setImageButtonToToast(); // upgradeTask = new UpgradeTask(this); // upgradeTask.execute(); if (db.needsUpgrade && upgradeTask == null) { // DB needs updating setImageButtonToToast(); upgradeTask = new UpgradeTask(this); upgradeTask.execute(); } else { // DB Up to date, check artist date setImageButtonToFragments(); if (needsArtistFetching() && upgradeTask == null) { upgradeTask = new UpgradeTask(this); upgradeTask.execute(); } } if (db.dbCopied && !Boolean.parseBoolean(db.getPref("splashShown"))) { this.showDialog( this.getResources().getString(R.string.splash_screen), "Welcome to Vibe Vault 4"); db.updatePref("splashShown", "true"); } else if (db.needsUpgrade) { this.showDialog( this.getResources().getString(R.string.splash_screen), "Welcome to Vibe Vault 4"); } }