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

The following examples show how to use timber.log.Timber#log() . 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: SearchTEViewHolder.java    From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private void setEnrollmentInfo(List<Trio<String, String, String>> enrollmentsInfo) {
    binding.chipContainer.removeAllViews();

    Context parentContext = binding.chipContainer.getContext();
    for (Trio<String, String, String> enrollmentInfo : enrollmentsInfo) {
        if (binding.getPresenter().getProgram() == null || !binding.getPresenter().getProgram().displayName().equals(enrollmentInfo.val0())) {

            Chip chip = new Chip(parentContext);
            chip.setText(enrollmentInfo.val0());

            int color = ColorUtils.getColorFrom(enrollmentInfo.val1(), ColorUtils.getPrimaryColor(parentContext, ColorUtils.ColorType.PRIMARY_LIGHT));
            int icon;
            if (!isEmpty(enrollmentInfo.val2())) {
                Resources resources = parentContext.getResources();
                String iconName = enrollmentInfo.val2().startsWith("ic_") ? enrollmentInfo.val2() : "ic_" + enrollmentInfo.val2();
                icon = resources.getIdentifier(iconName, "drawable", parentContext.getPackageName());
            } else {
                icon = R.drawable.ic_program_default;
            }

            Drawable iconImage;
            try {
                iconImage = AppCompatResources.getDrawable(parentContext, icon);
                iconImage.mutate();
            } catch (Exception e) {
                Timber.log(1, e);
                iconImage = AppCompatResources.getDrawable(parentContext, R.drawable.ic_program_default);
                iconImage.mutate();
            }

            Drawable bgDrawable = AppCompatResources.getDrawable(parentContext, R.drawable.ic_chip_circle_24);

            Drawable wrappedIcon = DrawableCompat.wrap(iconImage);
            Drawable wrappedBg = DrawableCompat.wrap(bgDrawable);

            LayerDrawable finalDrawable = new LayerDrawable(new Drawable[]{wrappedBg, wrappedIcon});

            finalDrawable.mutate();

            finalDrawable.getDrawable(1).setColorFilter(new PorterDuffColorFilter(ColorUtils.getContrastColor(color), PorterDuff.Mode.SRC_IN));
            finalDrawable.getDrawable(0).setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN));

            chip.setChipIcon(finalDrawable);

            binding.chipContainer.addView(chip);
            binding.chipContainer.invalidate();
        }
    }
}
 
Example 2
Source File: Shell.java    From wirebug with GNU General Public License v3.0 4 votes vote down vote up
private void logCommand(String command, String output, int exitStatus) {
    if (isLoggingEnabled) {
        Timber.log(logPriority, "$?=%d, %s: %s", exitStatus, command, output);
    }
}
 
Example 3
Source File: ImportService.java    From Hentoid with Apache License 2.0 4 votes vote down vote up
private void trace(int priority, List<LogUtil.LogEntry> memoryLog, String s, String... t) {
    s = String.format(s, (Object[]) t);
    Timber.log(priority, s);
    if (null != memoryLog) memoryLog.add(new LogUtil.LogEntry(s));
}
 
Example 4
Source File: API29MigrationService.java    From Hentoid with Apache License 2.0 4 votes vote down vote up
private void trace(int priority, List<LogUtil.LogEntry> memoryLog, String s, String... t) {
    s = String.format(s, (Object[]) t);
    Timber.log(priority, s);
    if (null != memoryLog) memoryLog.add(new LogUtil.LogEntry(s));
}