@@ -74,19 +74,19 @@ protected void onCreate(Bundle savedInstanceState) {
74
74
device_found = mCommunicationHandler .device_found ;
75
75
if (device_found ) {
76
76
Log .d (TAG , "PSLab device found" );
77
+ try {
78
+ mCommunicationHandler .open ();
79
+ connected = mCommunicationHandler .isConnected ();
80
+ if (connected ) {
81
+ Log .d (TAG , "Connection established" );
82
+ }
83
+ } catch (IOException e ) {
84
+ e .printStackTrace ();
85
+ Log .e (TAG , "Error in establishing connection" );
86
+ }
77
87
} else {
78
88
Log .d (TAG , "PSLab device not found" );
79
89
}
80
- try {
81
- mCommunicationHandler .open ();
82
- connected = mCommunicationHandler .isConnected ();
83
- if (connected ) {
84
- Log .d (TAG , "Connection established" );
85
- }
86
- } catch (IOException e ) {
87
- e .printStackTrace ();
88
- Log .e (TAG , "Error in establishing connection" );
89
- }
90
90
91
91
toolbar = (Toolbar ) findViewById (R .id .toolbar );
92
92
setSupportActionBar (toolbar );
@@ -142,17 +142,13 @@ private Fragment getHomeFragment() {
142
142
case 0 :
143
143
return HomeFragment .newInstance (connected , device_found );
144
144
case 1 :
145
- ApplicationsFragment applicationsFragment = new ApplicationsFragment ();
146
- return applicationsFragment ;
145
+ return ApplicationsFragment .newInstance ();
147
146
case 2 :
148
- SavedExperiments savedExperiments = new SavedExperiments ();
149
- return savedExperiments ;
147
+ return SavedExperiments .newInstance ();
150
148
case 3 :
151
- DesignExperiments designExperiments = new DesignExperiments ();
152
- return designExperiments ;
149
+ return DesignExperiments .newInstance ();
153
150
case 4 :
154
- SettingsFragment settingsFragment = new SettingsFragment ();
155
- return settingsFragment ;
151
+ return SettingsFragment .newInstance ();
156
152
default :
157
153
return HomeFragment .newInstance (connected , device_found );
158
154
}
0 commit comments