Avoid creating new remote and beamer instances in onCreate()

This commit is contained in:
Maurizio Porrato 2019-02-17 12:29:35 +00:00
父節點 fa41bfd331
當前提交 661ef08e58
共有 1 個文件被更改,包括 10 次插入7 次删除

查看文件

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