コード例 #1
1
    // Get IOB and COB only, dont update chart
    public static JSONObject getIOBCOB(Activity a) {

      List<Stats> statList = Stats.updateActiveBarChart(a.getBaseContext());
      JSONObject reply = new JSONObject();

      if (statList.size() > 0) {
        try {
          reply.put("iob", String.format(Locale.ENGLISH, "%.2f", statList.get(0).iob));
          reply.put("cob", String.format(Locale.ENGLISH, "%.2f", statList.get(0).cob));
        } catch (JSONException e) {
          Crashlytics.logException(e);
          e.printStackTrace();
        }
        return reply;
      } else {
        try {
          reply.put("iob", String.format(Locale.ENGLISH, "%.2f", 0.00));
          reply.put("cob", String.format(Locale.ENGLISH, "%.2f", 0.00));
        } catch (JSONException e) {
          Crashlytics.logException(e);
          e.printStackTrace();
        }
        return reply;
      }
    }
コード例 #2
1
  /**
   * Called when the BroadcastReceiver receives an Intent broadcast. Checks to see whether the
   * intent's action is _listClickAction. If it is, the app widget displays a Toast message for the
   * current item.
   */
  @Override
  public void onReceive(Context context, Intent intent) {
    if (intent.getAction().equals(_listClickAction)) {
      // ---Launch video search in the browser---
      String searchText = intent.getStringExtra("search_text");
      String linkScheme1 = intent.getStringExtra("scheme1");
      String linkScheme2 = intent.getStringExtra("scheme2");
      Intent browserIntent = null; // new Intent(_listClickAction);
      try {
        browserIntent =
            new Intent(
                Intent.ACTION_VIEW,
                Uri.parse(linkScheme1 + URLEncoder.encode(searchText, "UTF-8") + linkScheme2));
      } catch (UnsupportedEncodingException e) {
        BugSenseHandler.sendExceptionMessage("Widget4x4Provider", "onReceive", e);
        Crashlytics.setString("Widget4x4Provider", "onReceive");
        Crashlytics.logException(e);

        if (ApplicationContext.DEBUG_MODE) e.printStackTrace();
      }

      browserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
      browserIntent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName());
      context.startActivity(browserIntent);
    } else if (intent.getAction().equals("android.appwidget.action.APPWIDGET_UPDATE")) {
      // ---Update the widget with latest search---
      final AppWidgetManager mgr = AppWidgetManager.getInstance(context);
      onUpdate(context, mgr, appWidgetIds);
    }
    super.onReceive(context, intent);
  }
コード例 #3
1
  private void initUserSelectionMap() {
    try {
      String jsonString = readFromFile(NEWS_CAT_FILE);
      Crashlytics.log(Log.INFO, LOG_TAG, "jsonString - " + jsonString);

      fullJsonMap = JsonHelper.toMap(new JSONObject(jsonString));
      Crashlytics.log(Log.INFO, LOG_TAG, "fullJsonMap - " + fullJsonMap.toString());

      userSelectionMap = getUserFeedMapFromJsonMap(fullJsonMap);
      Crashlytics.log(Log.INFO, LOG_TAG, "UserSelectionMap - " + userSelectionMap.toString());
    } catch (JSONException e) {
      Crashlytics.logException(e);
    }
  }
コード例 #4
0
 private Boolean login(final LoLin1Account acc) {
   ChatServer chatServer;
   chatServer = ChatServer.valueOf(acc.getRealmEnum().name().toUpperCase(Locale.ENGLISH));
   try {
     api =
         new LoLChat(
             LoLin1Application.getInstance().getContext(),
             ConnectivityManager.CONNECTIVITY_ACTION,
             chatServer,
             Boolean.FALSE);
   } catch (IOException e) {
     Crashlytics.logException(e);
     e.printStackTrace(System.err);
     if (!(e instanceof SSLException)) {
       launchBroadcastLoginFailed();
     }
     return Boolean.FALSE;
   }
   Boolean loginSuccess = Boolean.FALSE;
   try {
     loginSuccess = api.login(acc.getUsername(), acc.getPassword());
   } catch (IOException e) {
     Crashlytics.logException(e);
   }
   if (loginSuccess) {
     api.reloadRoster();
     isConnected = Boolean.TRUE;
     return Boolean.TRUE;
   } else {
     isConnected = Boolean.FALSE;
     return Boolean.FALSE;
   }
 }
コード例 #5
0
    // Updates Stats
    public static JSONObject updateChart(Activity a) {

      JSONObject reply = new JSONObject();
      List<Stats> statList = Stats.updateActiveBarChart(a.getBaseContext());

      if (iobcobChart != null || statList != null || statList.size() > 0) {
        // reloads charts with Treatment data
        iobcobChart.setColumnChartData(extendedGraphBuilder.iobcobFutureChart(statList));
        try {
          reply.put("iob", String.format(Locale.ENGLISH, "%.2f", statList.get(0).iob));
          reply.put("cob", String.format(Locale.ENGLISH, "%.2f", statList.get(0).cob));
        } catch (JSONException e) {
          Crashlytics.logException(e);
          e.printStackTrace();
        }
        return reply;
      } else {
        try {
          reply.put("iob", String.format(Locale.ENGLISH, "%.2f", 0.00));
          reply.put("cob", String.format(Locale.ENGLISH, "%.2f", 0.00));
        } catch (JSONException e) {
          Crashlytics.logException(e);
          e.printStackTrace();
        }
        return reply;
      }
    }
コード例 #6
0
    @Override
    protected Integer doInBackground(Void... params) {
      int result = R.string.toast_back_up;

      // Count all non-story files
      for (File f : app_internal) {
        mTotalFiles += countFiles(f);
      }

      // Count all story files
      for (File f : appFiles) {
        mTotalFiles += countFiles(f);
      }

      // Set the maximum possible progress in the progress bar
      publishProgress(mZippedFiles);

      final FileOutputStream fos;
      ZipOutputStream zos = null;

      byte[] buffer = new byte[1024];

      try {
        fos = new FileOutputStream(output);
        zos = new ZipOutputStream(fos);

        // Zip all files
        for (File f : app_internal) {
          zipDir(zos, f, buffer, f.getName());
        }

        for (File f : appFiles) {
          zipDir(zos, f, buffer, f.getName());
        }

      } catch (IOException e) {
        Crashlytics.logException(e);
        result = R.string.error_unknown;
      } finally {
        // Note that ZipOutputStream closes the underlying FileOutputStream
        try {
          if (zos != null) zos.close();
        } catch (IOException e) {
          Crashlytics.logException(e);
          result = R.string.error_unknown;
        }
      }
      return result;
    }
コード例 #7
0
  /** Show dialog with new features for this version */
  public static AlertDialog showWhatsNewDialog(Context context) {
    Resources resources = context.getResources();
    StringBuilder releaseTitle = new StringBuilder(resources.getString(R.string.title_whats_new));
    PackageInfo packageInfo;
    try {
      packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
      releaseTitle.append(" - v").append(packageInfo.versionName);
    } catch (NameNotFoundException e) {
      Crashlytics.logException(e);
      Log.e(LOG_TAG, "Error displaying 'Whats new' dialog");
    }

    return new AlertDialog.Builder(context)
        .setTitle(releaseTitle.toString())
        .setMessage(R.string.whats_new)
        .setPositiveButton(
            R.string.label_dismiss,
            new DialogInterface.OnClickListener() {

              @Override
              public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
              }
            })
        .show();
  }
コード例 #8
0
    public void handleLetterPress(
        KeyEvent event, int keyCode, Device.DeviceType mDeviceType, IBinder windowToken) {
      if (event.getKeyCode() == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_UP) {
        // ---Done/Enter button was pressed---
        InputMethodManager keyboard =
            (InputMethodManager)
                ApplicationContext.getInstance().getSystemService(Context.INPUT_METHOD_SERVICE);
        if (keyboard != null) {
          try {
            keyboard.hideSoftInputFromWindow(windowToken, 0);
          } catch (Exception e) {
            BugSenseHandler.sendExceptionMessage(
                "KeyBindings", "KeyEventHandlers.handleLetterPress", e);
            Crashlytics.setString("KeyBindings", "KeyEventHandlers.handleLetterPress");
            Crashlytics.logException(e);

            if (ApplicationContext.DEBUG_MODE) e.printStackTrace();
          }
        }
      } else if (event.getKeyCode() != KeyEvent.KEYCODE_MENU) {
        if (!SearchFragmentTab.ENGLISH_KBD_BACKSPACE) {
          if (mDeviceType == Device.DeviceType.Google_TV) {
            // *---Goog TV custom keys mappings!---
            handleGoogTvKeyPress(event, keyCode);
          } else {
            handleNonGoogTvKeyPress(event, keyCode);
          }
        } else {
          SearchFragmentTab.ENGLISH_KBD_BACKSPACE = false;
        }
      }
    }
コード例 #9
0
    public static void setSuggested_Temp_Basal(JSONObject openAPSSuggest, Context c) {
      try {
        Suggested_Temp_Basal = new TempBasal();
        Notifications.clear(MainActivity.activity); // Clears any open notifications
        if (openAPSSuggest.has("rate")) { // Temp Basal suggested
          Suggested_Temp_Basal.rate = openAPSSuggest.getDouble("rate");
          Suggested_Temp_Basal.ratePercent = openAPSSuggest.getInt("ratePercent");
          Suggested_Temp_Basal.duration = openAPSSuggest.getInt("duration");
          Suggested_Temp_Basal.basal_type = openAPSSuggest.getString("temp");
          Suggested_Temp_Basal.basal_adjustemnt = openAPSSuggest.getString("basal_adjustemnt");

          if (openAPSSuggest
              .getString("openaps_mode")
              .equals("closed")) { // OpenAPS mode is closed, send command direct to pump
            pumpAction.setTempBasal(
                openAPSFragment.getSuggested_Temp_Basal(), MainActivity.activity);
          } else { // Make notification (Wear & Phone)
            Notifications.newTemp(openAPSSuggest, c);
          }
        }
      } catch (Exception e) {
        Crashlytics.logException(e);
        Toast.makeText(
                MainActivity.activity, "Crash in setSuggested_Temp_Basal", Toast.LENGTH_SHORT)
            .show();
      }
      currentOpenAPSSuggest = openAPSSuggest;
      update();
    }
コード例 #10
0
  @UiThread
  void updateUiAdapter(Address address) {
    if (map == null) {
      return;
    }
    try {
      ignoreUpdate = true;
      CameraPosition position =
          new CameraPosition.Builder()
              .target(new LatLng(address.getLatitude(), address.getLongitude()))
              .zoom(currentZoom)
              .build();
      CameraUpdate update = CameraUpdateFactory.newCameraPosition(position);
      map.animateCamera(update);

      autocompleteEndereco.setAdapter(null);
      autocompleteEndereco.setText(street);
      autocompleteEndereco.setAdapter(
          new PlacesAutoCompleteAdapter(
              getActivity(), R.layout.autocomplete_list_item, ExploreFragment.class));
      tvNumero.setText(number);
    } catch (Exception e) {
      Log.e("ZUP", e.getMessage(), e);
      Crashlytics.logException(e);
    }
  }
コード例 #11
0
  @Override
  public void genericAsyncTaskOnSuccess(Object obj) {
    if (PurpleSQ.isLoadingDialogVisible()) {
      PurpleSQ.dismissLoadingDialog();
    }

    mPaymentTask = null;
    if (obj != null && obj instanceof PaymentPayUVo) {
      PaymentPayUVo paymentPayUVo = (PaymentPayUVo) obj;
      PaymentPayUVo.PaymentRequstVo mPaymentRequstVo = paymentPayUVo.getRequest();
      new PayUTask(mActivity, mPaymentRequstVo).execute((Void) null);
    } else if (obj != null && obj instanceof CouponsVo) {
      CouponsVo couponsVo = (CouponsVo) obj;
      updateUiForCoupon(couponsVo);
    } else if (obj != null && obj instanceof TransactionVo) {
      TransactionVo transactionVo = (TransactionVo) obj;
      try {
        mTransactionVo = transactionVo;

        PurpleSQ.showLoadingDialog(PaymentActivity.this);
        mPaymentTask =
            new PaymentTask(authVo.getToken(), couponCode, mTransactionVo, PaymentActivity.this);
        mPaymentTask.execute((Void) null);
      } catch (Exception e) {
        e.printStackTrace();
        Crashlytics.logException(e);
      }
    }
  }
コード例 #12
0
 @Background
 void cameraChangeTask() {
   showHideLoading(true);
   try {
     valid = ZupApi.validateCityBoundary(getActivity(), latitude, longitude);
     if (GPSUtils.getFromLocation(getActivity(), latitude, longitude) == null) {
       return;
     }
     Address addr = GPSUtils.getFromLocation(getActivity(), latitude, longitude).get(0);
     showHideLoading(false);
     verifyValid();
     if (addr == null) {
       return;
     }
     street = addr.getThoroughfare();
     if (!TextUtils.isEmpty(addr.getFeatureName())
         && StringUtils.isNumeric(addr.getFeatureName().substring(0, 1))) {
       number = addr.getFeatureName();
     } else {
       number = "";
     }
     updateUiAdapter(addr);
   } catch (Exception e) {
     Log.e("ZUP", e.getMessage(), e);
     Crashlytics.logException(e);
   }
 }
コード例 #13
0
 /**
  * Returns the currency for an account which has been parsed (but not yet saved to the db)
  *
  * <p>This is used when parsing splits to assign the right currencies to the splits
  *
  * @param accountUID GUID of the account
  * @return Currency of the account
  */
 private Currency getCurrencyForAccount(String accountUID) {
   try {
     return mAccountMap.get(accountUID).getCurrency();
   } catch (Exception e) {
     Crashlytics.logException(e);
     return Currency.getInstance(Money.DEFAULT_CURRENCY_CODE);
   }
 }
コード例 #14
0
  public String readFromFile(String fileName, boolean readFromAsset) {
    StringBuilder returnString = new StringBuilder();
    InputStreamReader isr = null;
    BufferedReader input = null;
    FileInputStream fis = null;
    InputStream is = null;
    try {
      File file = new File(context.getCacheDir(), fileName);
      if (readFromAsset) {
        // Reading from Assets
        Crashlytics.log(Log.INFO, LOG_TAG, "Reading from Assets");
        is = context.getAssets().open(fileName);
        isr = new InputStreamReader(is);
      } else {
        // Reading from Internal
        Crashlytics.log(Log.INFO, LOG_TAG, "Reading from Internal");
        fis = new FileInputStream(file);
        isr = new InputStreamReader(fis);
      }

      input = new BufferedReader(isr);
      String line;
      while ((line = input.readLine()) != null) {
        returnString.append(line);
        returnString.append("\n");
      }

      if (readFromAsset) {
        writeToInternalStorage(returnString.toString(), fileName);
      }
    } catch (FileNotFoundException e) {
      Crashlytics.logException(e);
    } catch (Exception e) {
      Crashlytics.logException(e);
    } finally {
      try {
        if (isr != null) isr.close();
        if (fis != null) fis.close();
        if (is != null) is.close();
        if (input != null) input.close();
      } catch (Exception e2) {
        Crashlytics.logException(e2);
      }
    }
    return returnString.toString();
  }
コード例 #15
0
ファイル: NSUploader.java プロジェクト: JohanDegraeve/HAPP
  public static void uploadTempBasals(Context c, SharedPreferences prefs) {
    // Will grab the last 20 suggested TempBasals and check they have all been uploaded to NS

    List<TempBasal> tempBasals = TempBasal.latestTempBasals(20);
    JSONArray tempBasalsJSONArray = new JSONArray();
    String url = prefs.getString("nightscout_url", "") + "/treatments/";
    DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mmZ");
    String dateAsISO8601;

    for (TempBasal tempBasal : tempBasals) {
      try {

        JSONObject tempBasalJSON = new JSONObject();
        JSONObject tempBasalIntegration = tools.getJSONO(tempBasal.integration);

        if (!tempBasalIntegration.has("ns_upload_id")) {

          tempBasalJSON.put("happ_id", tempBasal.getId());
          tempBasalJSON.put("enterdBy", "HAPP_APP");
          dateAsISO8601 = df.format(tempBasal.start_time);
          tempBasalJSON.put("created_at", dateAsISO8601);
          tempBasalJSON.put("eventType", "Temp Basal");
          tempBasalJSON.put("duration", tempBasal.duration);

          // if (tempBasal.basal_type.equals("percent")) {                             //Percent is
          // not supported in NS as expected
          //    tempBasalJSON.put("percent", tempBasal.ratePercent);                  //Basal 1U /
          // Hour
          // } else {                                                                  //NS = 50%
          // means * 1.5 ~~ HAPP 50% means * 0.5
          tempBasalJSON.put("absolute", tempBasal.rate);
          // }

          tempBasalsJSONArray.put(tempBasalJSON);
        } else if (tempBasalIntegration.has("ns_temp_basal_stop")) {
          // This Temp Basal has been stopped, insert a record to NS so it knows
          if (tempBasalIntegration.getString("ns_temp_basal_stop").equals("dirty")) {
            tempBasalJSON.put("happ_id", tempBasal.getId());
            tempBasalJSON.put("enterdBy", "HAPP_APP");
            dateAsISO8601 = df.format(tempBasal.endDate());
            tempBasalJSON.put("created_at", dateAsISO8601);
            tempBasalJSON.put("eventType", "Temp Basal");
            // tempBasalJSON.put("happ_note", "temp_basal_stop");

            tempBasalsJSONArray.put(tempBasalJSON);
          }
        }

      } catch (JSONException | NullPointerException e) {
        Crashlytics.logException(e);
      }
    }

    if (tempBasalsJSONArray.length() > 0) {
      jsonPost(tempBasalsJSONArray, url, c);
    }
  }
コード例 #16
0
 private void disconnect() {
   // All the null checks are necessary because this method is run when an account is added
   // from out of the app as well
   try {
     if (mLoginTask != null)
       mLoginTask.get(); // Disconnecting in the middle of a login may be troublesome
   } catch (InterruptedException | ExecutionException e) {
     Crashlytics.logException(e);
   }
   try {
     if (api != null) {
       api.disconnect();
       api = null;
     }
   } catch (SmackException.NotConnectedException e) {
     Crashlytics.logException(e);
   }
   if (mSmackAndroid != null) mSmackAndroid.onDestroy();
   isConnected = Boolean.FALSE;
 }
コード例 #17
0
 @Override
 protected final boolean handleError(Context context, Throwable e) {
   if (e instanceof RetrofitError) {
     EventBusExt.getDefault()
         .post(new VoteError(context.getResources().getString(R.string.network_msg)));
     return true;
   } else {
     EventBusExt.getDefault().post(new VoteError(true, errorString()));
     Crashlytics.logException(e);
     return false;
   }
 }
コード例 #18
0
 @UiThread
 void updateCamera(LatLng latLong) {
   if (map == null) {
     return;
   }
   try {
     CameraPosition p = new CameraPosition.Builder().target(latLong).zoom(16f).build();
     CameraUpdate update = CameraUpdateFactory.newCameraPosition(p);
     map.animateCamera(update);
   } catch (Exception e) {
     Log.e("ZUP", e.getMessage(), e);
     Crashlytics.logException(e);
   }
 }
コード例 #19
0
ファイル: bfk.java プロジェクト: pankajk87/CompSecurity
 {
     try
     {
         ((InputStream) (obj1)).close();
     }
     // Misplaced declaration of an exception variable
     catch (Object obj)
     {
         ((IOException) (obj)).printStackTrace();
         Crashlytics.logException(((Throwable) (obj)));
         return s;
     }
     return s;
 }
コード例 #20
0
  @UiThread
  void verifyValid() {
    try {
      if (!isAdded()) {
        return;
      }
      ((SoliciteActivity) getActivity()).enableNextButton(valid);
      if (!valid && error.getVisibility() != View.VISIBLE) {
        AlphaAnimation anim = new AlphaAnimation(0.0f, 1.0f);
        anim.setDuration(1000);
        anim.setRepeatMode(Animation.REVERSE);
        anim.setAnimationListener(
            new Animation.AnimationListener() {
              @Override
              public void onAnimationStart(Animation animation) {}

              @Override
              public void onAnimationEnd(Animation animation) {
                error.setVisibility(View.VISIBLE);
              }

              @Override
              public void onAnimationRepeat(Animation animation) {}
            });
        error.startAnimation(anim);
      } else if (valid && error.getVisibility() != View.GONE) {
        AlphaAnimation anim = new AlphaAnimation(1.0f, 0.0f);
        anim.setDuration(1000);
        anim.setRepeatMode(Animation.REVERSE);
        anim.setAnimationListener(
            new Animation.AnimationListener() {
              @Override
              public void onAnimationStart(Animation animation) {}

              @Override
              public void onAnimationEnd(Animation animation) {
                error.setVisibility(View.GONE);
              }

              @Override
              public void onAnimationRepeat(Animation animation) {}
            });
        error.startAnimation(anim);
      }
    } catch (Exception e) {
      Log.e("ZUP", e.getMessage(), e);
      Crashlytics.logException(e);
    }
  }
コード例 #21
0
  public void uncaughtException(Thread thread, Throwable exception) {
    Crashlytics.logException(exception);
    Log.e("GPS", "ERROR", exception);
    try {
      Thread.sleep(5000, 0);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
    //        Intent intent = new Intent(myContext, myActivityClass);
    //        myContext.startActivity(intent);
    //        //for restarting the Activity
    //        Process.killProcess(Process.myPid());

    System.exit(0);
  }
コード例 #22
0
 /**
  * Creates a backup of current database contents to the default backup location
  *
  * @return {@code true} if backup was successful, {@code false} otherwise
  */
 public static boolean createBackup() {
   ExportParams params = new ExportParams(ExportFormat.XML);
   try {
     FileOutputStream fileOutputStream = new FileOutputStream(Exporter.buildBackupFile());
     BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(fileOutputStream);
     GZIPOutputStream gzipOutputStream = new GZIPOutputStream(bufferedOutputStream);
     OutputStreamWriter outputStreamWriter = new OutputStreamWriter(gzipOutputStream);
     new GncXmlExporter(params).generateExport(outputStreamWriter);
     outputStreamWriter.close();
     return true;
   } catch (IOException e) {
     Crashlytics.logException(e);
     Log.e("GncXmlExporter", "Error creating backup", e);
     return false;
   }
 }
コード例 #23
0
 @Background
 void geocoderTask(Place place) {
   showHideLoading(true);
   try {
     Address addr = GeoUtils.getFromPlace(place);
     showHideLoading(false);
     if (addr == null) {
       return;
     }
     LatLng latLong = new LatLng(addr.getLatitude(), addr.getLongitude());
     updateCamera(latLong);
   } catch (Exception e) {
     Log.e("ZUP", e.getMessage(), e);
     Crashlytics.logException(e);
   }
 }
コード例 #24
0
ファイル: NSUploader.java プロジェクト: JohanDegraeve/HAPP
  public static void uploadTreatments(Context c, SharedPreferences prefs) {
    // Will grab the last 10 treatments and check they have all been uploaded to NS

    List<Treatments> treatments = Treatments.latestTreatments(10, null);
    JSONArray treatmentsJSONArray = new JSONArray();
    String url = prefs.getString("nightscout_url", "") + "/treatments/";
    DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mmZ");
    String dateAsISO8601;

    for (Treatments treatment : treatments) {
      try {
        JSONObject treatmentJSON = new JSONObject();
        JSONObject treatmentIntegration = tools.getJSONO(treatment.integration);

        if (!treatmentIntegration.has("ns_upload_id")) {

          treatmentJSON.put("happ_id", treatment.getId());
          treatmentJSON.put("enterdBy", "HAPP_APP");
          treatmentJSON.put("display_date", treatment.datetime_display);
          dateAsISO8601 = df.format(treatment.datetime);
          treatmentJSON.put("created_at", dateAsISO8601);

          switch (treatment.type) {
            case "Insulin":
              treatmentJSON.put("insulin", treatment.value);
              treatmentJSON.put("units", tools.bgUnitsFormat(c));
              treatmentJSON.put("eventType", "Bolus");
              break;
            case "Carbs":
              treatmentJSON.put("carbs", treatment.value);
              treatmentJSON.put("eventType", "Carbs");
              break;
            default:
              // no idea what this treatment is, exit
              return;
          }
          treatmentsJSONArray.put(treatmentJSON);
        }
      } catch (JSONException e) {
        Crashlytics.logException(e);
      }
    }

    if (treatmentsJSONArray.length() > 0) {
      jsonPost(treatmentsJSONArray, url, c);
    }
  }
コード例 #25
0
 /**
  * Handles the case when we reach the end of the template numeric slot
  *
  * @param characterString Parsed characters containing split amount
  */
 private void handleEndOfTemplateNumericSlot(String characterString, TransactionType splitType) {
   try {
     BigDecimal amountBigD = GncXmlHelper.parseSplitAmount(characterString);
     Money amount = new Money(amountBigD, getCurrencyForAccount(mSplit.getAccountUID()));
     mSplit.setValue(amount.absolute());
     mSplit.setType(splitType);
     mIgnoreTemplateTransaction = false; // we have successfully parsed an amount
   } catch (NumberFormatException | ParseException e) {
     String msg = "Error parsing template credit split amount " + characterString;
     Log.e(LOG_TAG, msg + "\n" + e.getMessage());
     Crashlytics.log(msg);
     Crashlytics.logException(e);
   } finally {
     if (splitType == TransactionType.CREDIT) mInCreditNumericSlot = false;
     else mInDebitNumericSlot = false;
   }
 }
コード例 #26
0
ファイル: JSONParser.java プロジェクト: pedja1/sql-master
 private void init() {
   try {
     jsonObject = new JSONObject(this.serverResponse.responseData);
     checkErrors();
     if (!serverResponse.isResponseOk()) {
       jsonObject = null;
     }
   } catch (Exception e) {
     if (SettingsManager.DEBUG()) Log.e(LOG_TAG, "JSONUtility " + e.getMessage());
     if (SettingsManager.DEBUG()) Log.e(LOG_TAG, "JSONUtility :: Failed to parse json");
     Crashlytics.setString("response message", serverResponse.responseMessage);
     Crashlytics.setString("response data", serverResponse.responseData);
     Crashlytics.setInt("response code", serverResponse.code);
     Crashlytics.setString("request url", serverResponse.request);
     Crashlytics.logException(e);
   }
 }
コード例 #27
0
  @AfterViews
  void init() {
    try {
      setRetainInstance(true);
      ((SoliciteActivity) getActivity()).exibirBarraInferior(true);
      ((SoliciteActivity) getActivity()).setInfo(R.string.selecione_o_local);
      ((SoliciteActivity) getActivity()).enableNextButton(valid);
      if (checkPlayServices()) {
        ((SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.mapaLocal))
            .getMapAsync(this);
      } else {
        Toast.makeText(
                getActivity(),
                "Necessitamos saber da sua localização. Por favor, autorize nas configurações do seu aparelho.",
                Toast.LENGTH_SHORT)
            .show();
      }

      PlacesAutoCompleteAdapter placesAutoCompleteAdapter =
          new PlacesAutoCompleteAdapter(
              getActivity(), R.layout.autocomplete_list_item, ExploreFragment.class);
      autocompleteEndereco.setTypeface(FontUtils.getRegular(getActivity()));
      autocompleteEndereco.setAdapter(placesAutoCompleteAdapter);
      autocompleteEndereco.setOnItemClickListener(this);
      autocompleteEndereco.setOnEditorActionListener(
          (v, actionId, event) -> {
            boolean handled = false;
            if (actionId == EditorInfo.IME_ACTION_SEARCH) {
              searchTask(v.getText().toString());
              ViewUtils.hideKeyboard(getActivity(), v);
              handled = true;
            }
            return handled;
          });
      tvNumero.setTypeface(FontUtils.getRegular(getActivity()));
      message.setTypeface(FontUtils.getSemibold(getActivity()));
      timerEnderecoTask(latitude, longitude);
      if (file != null && !file.isEmpty()) {
        marcador.setImageBitmap(ImageUtils.getScaled(getActivity(), "reports", file));
      }
    } catch (Exception e) {
      Log.e("ZUP", e.getMessage(), e);
      Crashlytics.logException(e);
    }
  }
コード例 #28
0
    public static void update() {

      if (currentOpenAPSSuggest != null & apsstatus_reason != null) {

        try {
          apsstatus_reason.setText("");
          apsstatus_Action.setText("");
          apsstatus_temp.setText("None");
          apsstatus_deviation.setText("");
          if (currentOpenAPSSuggest.has("deviation"))
            apsstatus_deviation.setText(currentOpenAPSSuggest.getString("deviation"));
          if (currentOpenAPSSuggest.has("openaps_mode"))
            apsstatus_mode.setText(currentOpenAPSSuggest.getString("openaps_mode"));
          if (currentOpenAPSSuggest.has("openaps_loop"))
            apsstatus_loop.setText(currentOpenAPSSuggest.getString("openaps_loop") + "mins");
          if (currentOpenAPSSuggest.has("reason"))
            apsstatus_reason.setText(currentOpenAPSSuggest.getString("reason"));
          if (currentOpenAPSSuggest.has("action"))
            apsstatus_Action.setText(currentOpenAPSSuggest.getString("action"));

          if (currentOpenAPSSuggest.has("rate")) {
            apsstatusAcceptButton.setEnabled(true);
            apsstatusAcceptButton.setTextColor(Color.parseColor("#FFFFFF"));
            if (currentOpenAPSSuggest.getString("basal_adjustemnt").equals("Pump Default")) {
              apsstatus_temp.setText(currentOpenAPSSuggest.getDouble("rate") + "U");
            } else {
              apsstatus_temp.setText(
                  currentOpenAPSSuggest.getDouble("rate")
                      + "U "
                      + currentOpenAPSSuggest.getString("duration")
                      + "mins");
            }
          } else {
            apsstatusAcceptButton.setEnabled(false);
            apsstatusAcceptButton.setTextColor(Color.parseColor("#939393"));
          }
        } catch (Exception e) {
          Crashlytics.logException(e);
          Toast.makeText(
                  MainActivity.activity, "Crash updating OpenAPS Fragment", Toast.LENGTH_SHORT)
              .show();
        }
      }
    }
コード例 #29
0
  /**
   * Writes out the document held in <code>node</code> to <code>outputWriter</code>
   *
   * @param node {@link Node} containing the OFX document structure. Usually the parent node
   * @param outputWriter {@link java.io.Writer} to use in writing the file to stream
   * @param omitXmlDeclaration Flag which causes the XML declaration to be omitted
   */
  private void write(Node node, Writer outputWriter, boolean omitXmlDeclaration) {
    try {
      TransformerFactory transformerFactory = TransformerFactory.newInstance();
      Transformer transformer = transformerFactory.newTransformer();
      DOMSource source = new DOMSource(node);
      StreamResult result = new StreamResult(outputWriter);

      transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
      transformer.setOutputProperty(OutputKeys.INDENT, "yes");
      if (omitXmlDeclaration) {
        transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
      }

      transformer.transform(source, result);
    } catch (TransformerException tfException) {
      Log.e(LOG_TAG, tfException.getMessage());
      Crashlytics.logException(tfException);
    }
  }
コード例 #30
0
  /**
   * Handles the case where another application has selected to open a (.gnucash or .gnca) file with
   * this app
   *
   * @param intent Intent containing the data to be imported
   */
  private void handleOpenFileIntent(Intent intent) {
    // when someone launches the app to view a (.gnucash or .gnca) file
    Uri data = intent.getData();
    if (data != null) {
      GncXmlExporter.createBackup();

      intent.setData(null);
      InputStream accountInputStream = null;
      try {
        accountInputStream = getContentResolver().openInputStream(data);
        new ImportAsyncTask(this).execute(accountInputStream);
      } catch (FileNotFoundException e) {
        Crashlytics.logException(e);
        Log.e(LOG_TAG, "Error opening file for import - " + e.getMessage());
      } finally {
        removeFirstRunFlag();
      }
    }
  }