Avoid creating new remote and beamer instances in onCreate()

This commit is contained in:
Maurizio Porrato 2019-02-17 12:29:35 +00:00
parent fa41bfd331
commit 661ef08e58
1 changed files with 10 additions and 7 deletions

View File

@ -44,14 +44,17 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); setContentView(R.layout.activity_main);
remote = new RoboVac11sRemote(); if (remote == null)
remote = new RoboVac11sRemote();
beamer = new AndroidIRBeamer(this); if (beamer == null) {
if (!beamer.isAvailable()) { beamer = new AndroidIRBeamer(this);
Toast.makeText(this.getApplicationContext(), if (!beamer.isAvailable()) {
"No IR beamer found: entering debug mode", Toast.makeText(this.getApplicationContext(),
Toast.LENGTH_LONG).show(); "No IR beamer found: entering debug mode",
beamer = new DebugIRBeamer(this); Toast.LENGTH_LONG).show();
beamer = new DebugIRBeamer(this);
}
} }
findViewById(R.id.schedule).setEnabled( findViewById(R.id.schedule).setEnabled(