private void updateTableOrderObject(DataSource dataSource) { Thread threadSync = new Thread(DataService.updateOnce); final DataSource tmpSrc = DataService.getDataSource(); try { DataService.setDataSource(dataSource); threadSync.start(); threadSync.join(SYNCDURATION_DELAY); if (threadSync.isAlive()) threadSync.interrupt(); } catch (InterruptedException ex) { Logger.getLogger(WaiterTableActivity.class.getName()).log(Level.SEVERE, null, ex); } catch (IllegalThreadStateException ex) { } finally { DataService.setDataSource(tmpSrc); } }
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.table_menu); DataService.setSyncSpeed(DataSourceListener.DEFAULT_SYNC_SPPED); DataService.setDataSource(tableOrders); DataService.setHandler(handler); if (tableOrders.getTableSize() != 6) updateTableOrderObject(DataService.getDataSource()); WaiterOrdersActivity.dishes = tableOrders.getDishes(); updateBtnColors(true); }