Java Code Examples for timber.log.Timber#e()

The following examples show how to use timber.log.Timber#e() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: QrDialogFragment.java    From octoandroid with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void surfaceCreated(SurfaceHolder holder) {

    // Need to check if detector is operational before executing
    // See v9.2 Release notes
    // https://developers.google.com/vision/release-notes
    if (!mBarcodeDetector.isOperational()) {
        toastErrorAndDismiss();
        return;
    }

    try {
        if (ActivityCompat.checkSelfPermission(getActivity(),
                Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
            getNavigator().requestCameraPermission(QrDialogFragment.this);
            return;
        }
        mCameraSource.start(mCameraView.getHolder());
        // Getting RuntimeException: could not find requested camera
        // even though its checked before starting fragment
    } catch (IOException | RuntimeException e) {
        Timber.e(e, null);
        toastErrorAndDismiss();
    }
}
 
Example 2
Source File: HentaiCafeParser.java    From Hentoid with Apache License 2.0 6 votes vote down vote up
private static JSONArray getJSONArrayFromString(String s) {
    @SuppressWarnings("RegExpRedundantEscape")
    Pattern pattern = Pattern.compile(".*\\[\\{ *(.*) *\\}\\].*");
    Matcher matcher = pattern.matcher(s);

    Timber.d("Match found? %s", matcher.find());

    if (matcher.groupCount() > 0) {
        String results = matcher.group(1);
        results = "[{" + results + "}]";
        try {
            return (JSONArray) new JSONTokener(results).nextValue();
        } catch (JSONException e) {
            Timber.e(e, "Couldn't build JSONArray from the provided string");
        }
    }

    return null;
}
 
Example 3
Source File: PlaybackController.java    From jellyfin-androidtv with GNU General Public License v2.0 6 votes vote down vote up
private void handlePlaybackInfoError(Exception exception) {
    Timber.e(exception, "Error getting playback stream info");
    if (exception instanceof PlaybackException) {
        PlaybackException ex = (PlaybackException) exception;
        switch (ex.getErrorCode()) {
            case NotAllowed:
                Utils.showToast(TvApp.getApplication(), TvApp.getApplication().getString(R.string.msg_playback_not_allowed));
                break;
            case NoCompatibleStream:
                Utils.showToast(TvApp.getApplication(), TvApp.getApplication().getString(R.string.msg_playback_incompatible));
                break;
            case RateLimitExceeded:
                Utils.showToast(TvApp.getApplication(), TvApp.getApplication().getString(R.string.msg_playback_restricted));
                break;
        }
    }

}
 
Example 4
Source File: VoiceActivity.java    From africastalking-android with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_voice_dialpad);

    ButterKnife.bind(this);
    callBtn.setEnabled(false);

    try {
        Timber.i("Setting up pjsip....");
        AfricasTalking.initializeVoiceService(this, mRegListener, new Callback<VoiceService>() {
            @Override
            public void onSuccess(VoiceService service) {
                mService = service;
            }

            @Override
            public void onFailure(Throwable throwable) {
                Timber.e(throwable.getMessage());
            }
        });
    } catch (Exception ex) {
        Timber.e(ex.getMessage());
    }

}
 
Example 5
Source File: updateComicDatabase.java    From Easy_xkcd with Apache License 2.0 6 votes vote down vote up
void createNoMediaFile() {
    if (!prefHelper.nomediaCreated()) {
        File sdCard = prefHelper.getOfflinePath();
        File dir = new File(sdCard.getAbsolutePath() + "/easy xkcd/");
        if (!dir.exists()) {
            dir.mkdirs();
        }
        File nomedia = new File(dir, ".nomedia");
        try {
            boolean created = nomedia.createNewFile();
            Timber.d("created .nomedia in external storage: %s", created);
            prefHelper.setNomediaCreated();
        } catch (IOException e) {
            Timber.e(e);
        }
    }
}
 
Example 6
Source File: FieldEntity.java    From ground-android with Apache License 2.0 6 votes vote down vote up
private static Field toField(FieldEntityAndRelations fieldEntityAndRelations) {
  FieldEntity fieldEntity = fieldEntityAndRelations.fieldEntity;
  Field.Builder fieldBuilder =
      Field.newBuilder()
          .setId(fieldEntity.getId())
          .setLabel(fieldEntity.getLabel())
          .setRequired(fieldEntity.isRequired())
          .setType(fieldEntity.getFieldType().toFieldType());

  List<MultipleChoiceEntity> multipleChoiceEntities =
      fieldEntityAndRelations.multipleChoiceEntities;

  if (!multipleChoiceEntities.isEmpty()) {
    if (multipleChoiceEntities.size() > 1) {
      Timber.e("More than 1 multiple choice found for field");
    }

    fieldBuilder.setMultipleChoice(
        MultipleChoiceEntity.toMultipleChoice(
            multipleChoiceEntities.get(0), fieldEntityAndRelations.optionEntities));
  }

  return fieldBuilder.build();
}
 
Example 7
Source File: AirMapConfig.java    From AirMapSDK-Android with Apache License 2.0 5 votes vote down vote up
public static String getAppIdForThirdPartyAPI(String key) {
    try {
        return AirMap.getConfig().getJSONObject(key).getString("app_id");
    } catch (JSONException e) {
        Timber.e("Unable to get app id for third party: " + key);
        return null;
    }
}
 
Example 8
Source File: ResponseJsonConverter.java    From ground-android with Apache License 2.0 5 votes vote down vote up
static Optional<Response> toResponse(Object obj) {
  if (obj instanceof String) {
    return TextResponse.fromString((String) obj);
  } else if (obj instanceof JSONArray) {
    return MultipleChoiceResponse.fromList(toList((JSONArray) obj));
  } else {
    Timber.e("Error parsing JSON in db of " + obj.getClass() + ": " + obj);
    return Optional.empty();
  }
}
 
Example 9
Source File: MP4Encoder.java    From Bitmp4 with Apache License 2.0 5 votes vote down vote up
@Override
protected void onAddFrame(Bitmap bitmap) {
  if (!isStarted) {
    Timber.d(TAG, "already finished. can't add Frame ");
  } else if (bitmap == null) {
    Timber.e(TAG, "Bitmap is null");
  } else {
    int inputBufIndex = videoCodec.dequeueInputBuffer(TIMEOUT_US);
    if (inputBufIndex >= 0) {
      byte[] input = getNV12(bitmap.getWidth(), bitmap.getHeight(), bitmap);
      ByteBuffer inputBuffer = videoCodec.getInputBuffer(inputBufIndex);
      inputBuffer.clear();
      inputBuffer.put(input);
      videoCodec.queueInputBuffer(inputBufIndex, 0, input.length,
          getPresentationTimeUsec(addedFrameCount), 0);
    }
    int audioInputBufferIndex = audioCodec.dequeueInputBuffer(TIMEOUT_US);
    if (audioInputBufferIndex >= -1) {
      ByteBuffer encoderInputBuffer = audioCodec.getInputBuffer(audioInputBufferIndex);
      encoderInputBuffer.clear();
      encoderInputBuffer.put(audioArray);
      audioCodec.queueInputBuffer(audioInputBufferIndex, 0, audioArray.length,
          getPresentationTimeUsec(addedFrameCount), 0);
    }
    addedFrameCount++;
    while (addedFrameCount > encodedFrameCount) {
      encode();
    }
  }
}
 
Example 10
Source File: ProductFragment.java    From openshop.io-android with MIT License 5 votes vote down vote up
private void refreshScreenData(Product product) {
    if (product != null) {
        Analytics.logProductView(product.getRemoteId(), product.getName());

        productNameTv.setText(product.getName());

        // Determine if product is on sale
        double pr = product.getPrice();
        double dis = product.getDiscountPrice();
        if (pr == dis || Math.abs(pr - dis) / Math.max(Math.abs(pr), Math.abs(dis)) < 0.000001) {
            productPriceDiscountTv.setText(product.getDiscountPriceFormatted());
            productPriceDiscountTv.setTextColor(ContextCompat.getColor(getContext(), R.color.textPrimary));
            productPriceTv.setVisibility(View.GONE);
            productPriceDiscountPercentTv.setVisibility(View.GONE);
        } else {
            productPriceDiscountTv.setText(product.getDiscountPriceFormatted());
            productPriceDiscountTv.setTextColor(ContextCompat.getColor(getContext(), R.color.colorAccent));
            productPriceTv.setVisibility(View.VISIBLE);
            productPriceTv.setText(product.getPriceFormatted());
            productPriceTv.setPaintFlags(Paint.STRIKE_THRU_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
            productPriceDiscountPercentTv.setVisibility(View.VISIBLE);
            productPriceDiscountPercentTv.setText(Utils.calculateDiscountPercent(getContext(), pr, dis));
        }
        if (product.getDescription() != null) {
            productInfoTv.setMovementMethod(LinkMovementMethod.getInstance());
            productInfoTv.setText(Utils.safeURLSpanLinks(Html.fromHtml(product.getDescription()), getActivity()));
        }

        setSpinners(product);
    } else {
        MsgUtils.showToast(getActivity(), MsgUtils.TOAST_TYPE_INTERNAL_ERROR, getString(R.string.Internal_error), MsgUtils.ToastLength.LONG);
        Timber.e(new RuntimeException(), "Refresh product screen with null product");
    }
}
 
Example 11
Source File: AboutUtil.java    From IslamicLibraryAndroid with GNU General Public License v3.0 5 votes vote down vote up
public static void ShareAppLink(@NonNull Context c) {
    try {
        Intent shareIntent = new Intent(Intent.ACTION_SEND);
        String appId = c.getPackageName();
        String appName = c.getResources().getString(R.string.app_name);
        String recommendationString = c.getString(R.string.share_app_msg, appName, "https://play.google.com/store/apps/details?id=" + appId);
        shareIntent.setType("text/plain");
        shareIntent.putExtra(Intent.EXTRA_SUBJECT, appName);
        shareIntent.putExtra(Intent.EXTRA_TEXT, recommendationString);
        c.startActivity(Intent.createChooser(shareIntent, "choose one"));
    } catch (Exception e) {
        Timber.e(e);
    }
}
 
Example 12
Source File: FirestoreDataStore.java    From ground-android with Apache License 2.0 5 votes vote down vote up
private Task<?> applyMutationsInternal(ImmutableCollection<Mutation> mutations, User user) {
  WriteBatch batch = db.batch();
  for (Mutation mutation : mutations) {
    try {
      addMutationToBatch(mutation, user, batch);
    } catch (DataStoreException e) {
      Timber.e(e, "Skipping invalid mutation");
    }
  }
  return batch.commit();
}
 
Example 13
Source File: DemoActivity.java    From debugdrawer with Apache License 2.0 5 votes vote down vote up
public void onClick1(View v){
    Timber.d("verbose");
    Timber.i("info");
    Timber.d("debug");
    Timber.w("warning");
    Timber.e("error");
    Timber.wtf("wtf");
}
 
Example 14
Source File: EditObservationFragment.java    From ground-android with Apache License 2.0 5 votes vote down vote up
private void onShowDialog(
    Field field, Optional<Response> currentResponse, Consumer<Optional<Response>> consumer) {
  Cardinality cardinality = field.getMultipleChoice().getCardinality();
  switch (cardinality) {
    case SELECT_MULTIPLE:
      multiSelectDialogFactory.create(field, currentResponse, consumer).show();
      break;
    case SELECT_ONE:
      singleSelectDialogFactory.create(field, currentResponse, consumer).show();
      break;
    default:
      Timber.e("Unknown cardinality: %s", cardinality);
      break;
  }
}
 
Example 15
Source File: SlicerActivity.java    From octoandroid with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void updateFiles() {
    try {
        SlicerPagerAdapter adapter = (SlicerPagerAdapter) getViewPager().getAdapter();
        FilesFragment filesFragment = adapter.getFilesFragment();
        filesFragment.onRefresh();
    } catch (ClassCastException | NullPointerException e) {
        Timber.e(e, null); // Shouldn't happen.
    }
}
 
Example 16
Source File: IOUtils.java    From EFRConnect-android with Apache License 2.0 5 votes vote down vote up
/**
 * Closes the specified stream.
 *
 * @param stream The stream to close.
 */
public static void closeStream(Closeable stream) {
    if (stream != null) {
        try {
            stream.close();
        } catch (IOException e) {
            Timber.e(TAG, "Could not close stream", e);
            Log.e(TAG, "Could not close stream: " + e);
        }
    }
}
 
Example 17
Source File: SearchFragment.java    From marvel with MIT License 4 votes vote down vote up
@Override
public void showServiceError(ApiResponseCodeException throwable) {
    Timber.e(throwable, "Service Error!");

    showRetryMessage(throwable);
}
 
Example 18
Source File: LiquorActivity.java    From Drinks with Apache License 2.0 4 votes vote down vote up
private void errorRetrievingLiquor(Throwable throwable) {
    //TODO handle
    Timber.e(throwable, "Error retrieving liquor");
}
 
Example 19
Source File: OrderDetailFragment.java    From Pharmacy-Android with GNU General Public License v3.0 4 votes vote down vote up
@Override
    public void onDataChange(DataSnapshot dataSnapshot) {
        try {

            Bundle params = new Bundle();
            Order order;
            if (mOrderId != null) {
                order = dataSnapshot.getChildren().iterator().next().getValue(Order.class);

            } else {
                order = dataSnapshot.getValue(Order.class);
            }
            mOrder = order;



            if (order != null) {

                // analytics
                params.putString(FirebaseAnalytics.Param.ITEM_ID, mOrder.getUid());
                params.putString(FirebaseAnalytics.Param.CONTENT_TYPE, Analytics.Param.ORDER_TYPE);
                params.putString(FirebaseAnalytics.Param.VALUE, mOrder.getOrderId());
                params.putString(Analytics.Param.ORDER_STATUS, mOrder.getStatus());
                params.putString(FirebaseAnalytics.Param.PRICE, mOrder.getPrice().toString());
                params.putString(FirebaseAnalytics.Param.SHIPPING, mOrder.getShippingCharge().toString());
                mAnalytics.logEvent(FirebaseAnalytics.Event.VIEW_ITEM, params);


                orderIdTextView.setText(order.getOrderId());

                String orderPrice = getResources().getString(R.string.price, order.getPrice());
                String shippingCharge = getResources().getString(R.string.price, order.getShippingCharge());
                String totalPrice = getResources().getString(R.string.price,
                        order.getPrice() + order.getShippingCharge()
                        );

                orderPriceTextView.setText(orderPrice);
                shippingChargeTextView.setText(shippingCharge);
                totalPriceTextView.setText(totalPrice);

                // seller note
                sellerNoteTextView.setText(order.getSellerNote());

                String url = Utils.getThumbUrl(order.getPrescriptionUrl());

                Glide.with(getActivity())
                        .load(url)
                        .placeholder(ContextCompat.getDrawable(getContext(), R.drawable.ic_pill))
                        .into(prescriptionImageView);


                @Order.Status String status = order.getStatus();

                switch (status) {
                    case Order.Status.PENDING:
                        enableButton(cancelButton);
                        disableButton(confirmButton);
                        break;
                    case Order.Status.ACKNOWLEDGED:
                        enableButton(confirmButton);
                        enableButton(cancelButton);
                        break;
                    default:
                        disableButton(confirmButton);
                        disableButton(cancelButton);
                        break;
                }


                switch (status) {
                    case ACKNOWLEDGED:
                    case PENDING:
//                        statusImageView.setImageResource(R.drawable.status_pending);
                        statusImageView.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.status_pending));
                        break;
                    case COMPLETED:
//                        statusImageView.setImageResource(R.drawable.ok_mark);
                        statusImageView.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ok_mark));
                        break;
                    case CONFIRMED:
//                        statusImageView.setImageResource(R.drawable.delivery_truck);
                        statusImageView.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.delivery_truck));
                        break;
                    case CANCELED:
//                        statusImageView.setImageResource(R.drawable.shopping_cart_cancel);
                        statusImageView.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.shopping_cart_cancel));
                        break;
                }


            }
        } catch (Exception e) {
            Timber.e(e, "Order decode failed");
            Toast.makeText(getActivity(), "Sorry, Unable to fetch order", Toast.LENGTH_SHORT).show();

        }
    }
 
Example 20
Source File: SplashPresenter.java    From Pioneer with Apache License 2.0 4 votes vote down vote up
@Override
protected void onException(Exception exception) {
    Timber.e(exception, "Unable initialize app");
    handleInitializeFinished(false);
}