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(