コード例 #1
0
  public void display(int itemtype) {
    if (theList != null) {
      Calendar c = Calendar.getInstance();
      String strCurrentTiime =
          "\n(Time of Reading - "
              + c.get(Calendar.HOUR_OF_DAY)
              + " : "
              + c.get(Calendar.MINUTE)
              + ")\n";

      Log.d(TAG, "----------" + theList.getGoaliewins());

      /*
       * feedTitle.setText(myRssFeed.getTitle() + strCurrentTiime);
       *
       *
       *
       * feedDescribtion.setText(myRssFeed.getDescription());
       *
       * feedPubdate.setText(myRssFeed.getPubdate());
       *
       * feedLink.setText(myRssFeed.getLink());
       */
      MyGoalsCustomAdapter adapter0;
      MyPointsCustomAdapter adapter1;
      MyGoalsForAgainstCustomAdapter adapter2;
      MyGoalieWinsCustomAdapter adapter3;
      MyGoalsAgainstAverageCustomAdapter adapter4;
      MySavePercentageCustomAdapter adapter5;
      Context context = getApplicationContext();
      CharSequence text;
      int duration = Toast.LENGTH_SHORT;
      Toast toast;

      switch (itemtype) {
        case (0):
          adapter0 =
              new MyGoalsCustomAdapter(this, R.layout.row_overallleaders, theList.getGoals());
          setListAdapter(adapter0);

          break;

        case (1):
          adapter1 =
              new MyPointsCustomAdapter(this, R.layout.row_overallleaders, theList.getPoints());
          setListAdapter(adapter1);

          break;

        case (2):
          adapter2 =
              new MyGoalsForAgainstCustomAdapter(
                  this, R.layout.row_overallleaders, theList.getGoalsforagainst());
          setListAdapter(adapter2);

          break;

        case (3):
          adapter3 =
              new MyGoalieWinsCustomAdapter(
                  this, R.layout.row_overallleaders, theList.getGoaliewins());
          setListAdapter(adapter3);

          break;

        case (4):
          adapter4 =
              new MyGoalsAgainstAverageCustomAdapter(
                  this, R.layout.row_overallleaders, theList.getGoalsagainstaverage());
          setListAdapter(adapter4);

          break;

        case (5):
          adapter5 =
              new MySavePercentageCustomAdapter(
                  this, R.layout.row_overallleaders, theList.getSavepercentage());
          setListAdapter(adapter5);

          break;

        default:
          adapter0 =
              new MyGoalsCustomAdapter(this, R.layout.row_overallleaders, theList.getGoals());

          break;
      }
    }
    /*
     * if (theList != null) { MyCustomAdapterResults adapterResults = new
     * MyCustomAdapterResults( this, R.layout.row_schedule_results,
     * theList); setListAdapter(adapterResults); }
     */

  }
コード例 #2
0
  private void read() throws IOException {

    try {

      String theUrl = "http://www.cbc.ca/data/statsfeed/plist/overallleaders.json";

      ConnectivityManager conMan =
          (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
      // mobile

      State mobile = conMan.getNetworkInfo(0).getState();

      // wifi

      State wifi = conMan.getNetworkInfo(1).getState();

      if ((mobile == NetworkInfo.State.CONNECTED || mobile == NetworkInfo.State.CONNECTING)
          || (wifi == NetworkInfo.State.CONNECTED || wifi == NetworkInfo.State.CONNECTING)) {

        theUrl = "http://www.cbc.ca/data/statsfeed/plist/overallleaders.json";
        HNICOverallLeadersReader hnicoverallleadersreader = new HNICOverallLeadersReader();

        theList = hnicoverallleadersreader.readOverallLeaders(theUrl);

        goals = theList.getGoals();

        points = theList.getPoints();

        goalsforagainst = theList.getGoalsforagainst();

        goaliewins = theList.getGoaliewins();

        goalsagainstaverage = theList.getGoalsagainstaverage();

        savepercentage = theList.getSavepercentage();

      } else {

        theUrl = "overallleaders.json";
        HNICOverallLeadersReader hnicoverallleadersreader = new HNICOverallLeadersReader();

        try {
          theList = hnicoverallleadersreader.readOverallLeadersFromCache(theUrl);
        } catch (Exception ex) {
          Log.e(
              TAG,
              "-------------------the trouble with paradise is that there is trouble in paradise"
                  + ex.toString());
        }

        Log.d(
            TAG,
            "---------------------------------------------read overallleaders.json from cache");
      }

    } catch (Exception e) {
      Log.d(TAG, "------Whoa!! There was an exception--------------" + e.toString());
    } finally {

    }
  }