@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); SyncManager.sync(this); setContentView(R.layout.activity_online_stories); lv = (ListView) findViewById(android.R.id.list); et = (EditText) findViewById(R.id.search); esHelper = new ESHelper(); /* * Populate listview with the stories currently online Cache the stories * currently online */ ArrayList<Story> result = esHelper.getOnlineStories(); boolean connected = InternetDetector.connectedToInternet(getApplicationContext()); while (result == null && connected) { result = esHelper.getOnlineStories(); connected = InternetDetector.connectedToInternet(getApplicationContext()); } if (!connected) { Toast.makeText(getApplicationContext(), "No Internet Connection", Toast.LENGTH_LONG).show(); finish(); } fillData(result); registerForContextMenu(getListView()); }
@Override protected void onResume() { SyncManager.sync(this); super.onResume(); ArrayList<Story> result = esHelper.getOnlineStories(); boolean connected = InternetDetector.connectedToInternet(getApplicationContext()); while (result == null && connected) { result = esHelper.getOnlineStories(); connected = InternetDetector.connectedToInternet(getApplicationContext()); } if (!connected) { Toast.makeText(getApplicationContext(), "No Internet Connection", Toast.LENGTH_LONG).show(); finish(); } /* Re-populate the listview with the online stories */ fillData(result); }