public LinkedHashMap<String, String> HTTPGetAsyncTaskTWO() { n = new GetBusiness( new Callback() { @Override public void onComplete() { try { JSONObject jObject = n.get(1000, TimeUnit.MILLISECONDS); Log.i("front_end", "grabbed JSON Object"); // make restaurant list try { if (jObject != null) { business = jObject.getJSONArray(TAG_QUEUES); // has uniqueID and name for (int i = 0; i < business.length(); i++) { JSONObject j = (JSONObject) business.getJSONObject(i); // add key, values of business String business_name = j.getString(TAG_NAME); String business_id = j.getString(TAG_ID); // put key, values to map // TODO: I might have to switch key, value businessMap.put(business_name, business_id); } } } catch (Exception e) { e.printStackTrace(); } } catch (InterruptedException e) { e.printStackTrace(); Log.i("front_end", "interrupt"); } catch (ExecutionException e) { e.printStackTrace(); Log.i("front_end", "Execution"); } catch (TimeoutException e) { e.printStackTrace(); Log.i("front_end", "timeout"); } } @Override public void onFail() { // TODO: what should it do when it fails? } }); // executes asynctask n.execute(); return businessMap; }
public void HTTPGetAsyncTask() { n = new GetBusiness( new Callback() { @Override public void onComplete() { try { JSONObject jObject = n.get(1000, TimeUnit.MILLISECONDS); Log.i("front_end", "grabbed JSON Object"); // make restaurant list try { if (jObject != null) { business = jObject.getJSONArray(TAG_QUEUES); // has uniqueID and name for (int i = 0; i < business.length(); i++) { JSONObject j = (JSONObject) business.getJSONObject(i); // add key, values of business String business_name = j.getString(TAG_NAME); String business_id = j.getString(TAG_ID); // put key, values to map // TODO: I might have to switch key, value businessMap.put(business_id, business_name); } } } catch (Exception e) { e.printStackTrace(); } finally { // do nothing for now Log.d("front_end", businessMap.toString()); // Toast.makeText(getApplicationContext(), "async done", // Toast.LENGTH_SHORT).show(); // Set up necessary tabs. setupTabs(); // Set up initial lists of restaurants. setupRestaurantList(); // setContentView(R.layout.main); mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); } } catch (InterruptedException e) { e.printStackTrace(); Log.i("front_end", "interrupt"); } catch (ExecutionException e) { e.printStackTrace(); Log.i("front_end", "Execution"); } catch (TimeoutException e) { e.printStackTrace(); Log.i("front_end", "timeout"); } } @Override public void onFail() { // TODO: what should it do when it fails? } }); // executes asynctask n.execute(); }