コード例 #1
0
  /**
   * this method checks if the service can precache media files based on the user preference and the
   * type of network connection currently held
   *
   * @param type
   * @return
   */
  private boolean canDownload(int precacheOptionIndex) {
    boolean ok = false;
    if (precacheOptionIndex > -1 && ConstantUtil.PRECACHE_WIFI_ONLY_IDX == precacheOptionIndex) {

      ok = StatusUtil.hasDataConnection(this, true);
    } else {
      ok = StatusUtil.hasDataConnection(this, false);
    }
    return ok;
  }
コード例 #2
0
 /**
  * invokes a service call to get the header information for a single survey
  *
  * @param serverBase
  * @param surveyId
  * @return
  */
 private ArrayList<Survey> getSurveyHeader(String serverBase, String surveyId, String deviceId) {
   String response = null;
   ArrayList<Survey> surveys = new ArrayList<Survey>();
   try {
     response =
         HttpUtil.httpGet(
             serverBase
                 + SURVEY_HEADER_SERVICE_PATH
                 + surveyId
                 + "&devicePhoneNumber="
                 + StatusUtil.getPhoneNumber(this)
                 + (deviceId != null
                     ? (DEV_ID_PARAM + URLEncoder.encode(deviceId, "UTF-8"))
                     : ""));
     if (response != null) {
       StringTokenizer strTok = new StringTokenizer(response, "\n");
       while (strTok.hasMoreTokens()) {
         String currentLine = strTok.nextToken();
         String[] touple = currentLine.split(",");
         if (touple.length < 4) {
           Log.e(TAG, "Survey list response is in an unrecognized format");
         } else {
           Survey temp = new Survey();
           temp.setId(touple[0]);
           temp.setName(touple[1]);
           temp.setLanguage(touple[2]);
           temp.setVersion(Double.parseDouble(touple[3]));
           temp.setType(ConstantUtil.FILE_SURVEY_LOCATION_TYPE);
           surveys.add(temp);
         }
       }
     }
   } catch (HttpException e) {
     Log.e(TAG, "Server returned an unexpected response", e);
     PersistentUncaughtExceptionHandler.recordException(e);
   } catch (Exception e) {
     Log.e(TAG, "Could not get survey headers", e);
     PersistentUncaughtExceptionHandler.recordException(e);
   }
   return surveys;
 }
コード例 #3
0
 /**
  * this method checks if the service can perform the requested operation. If there is no
  * connectivity, this will return false, otherwise it will return true
  *
  * @param type
  * @return
  */
 private boolean isAbleToRun() {
   return StatusUtil.hasDataConnection(this, false);
 }