Example #1
0
 protected Integer doInBackground(String... args) {
   try {
     toSend = new JSONObject();
     toSend.put("KEY_MERCHANT", merchant_name);
     toSend.put("KEY_DIET", diet_name);
     httpConnector = new HttpConnector(toSend, mealURL, "POST", context);
     result = httpConnector.makeConnection();
     if (result == 1) {
       responseString = httpConnector.convertInputStream();
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
   return result;
 }
Example #2
0
    protected void onPostExecute(Integer res) {
      if (httpConnector != null) httpConnector.close();

      if (pDialog.isShowing()) pDialog.dismiss();

      if (res == 2) {
        Toast.makeText(activity, "No Internet Connection", Toast.LENGTH_SHORT).show();
      } else if (res == 1) {
        parseResult(responseString);
        mealItems.clear();
        listView = (ListView) view.findViewById(R.id.listView);
        for (int i = 0; i < itemNames.size(); i++) {
          mealItems.add(new MealDrawerItem(itemNames.get(i), itemPrices.get(i).intValue()));
        }
        mealAdapter = new MealAdapter(activity, mealItems);
        listView.setAdapter(mealAdapter);
        listView.setTextFilterEnabled(true);
        listView.setOnItemClickListener(new DrawerItemClickListener());
        Log.e("tag_check", "After Setting Adapter");
        communicator.setMealAdapter(mealAdapter);
      } else {
        Log.e("TAG", "Failed to fetch data!");
      }
    }